Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CexmcAngularRange.cc File Reference
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "CexmcAngularRange.hh"
Include dependency graph for CexmcAngularRange.cc:

Go to the source code of this file.

Functions

void GetNormalizedAngularRange (const CexmcAngularRangeList &src, CexmcAngularRangeList &dst)
 
void GetAngularGaps (const CexmcAngularRangeList &src, CexmcAngularRangeList &dst)
 
std::ostream & operator<< (std::ostream &out, const CexmcAngularRange &angularRange)
 
std::ostream & operator<< (std::ostream &out, const CexmcAngularRangeList &angularRanges)
 

Function Documentation

void GetAngularGaps ( const CexmcAngularRangeList src,
CexmcAngularRangeList dst 
)

Definition at line 82 of file CexmcAngularRange.cc.

84 {
85  if ( src.empty() )
86  {
87  dst.push_back( CexmcAngularRange( 1.0, -1.0 , 0 ) );
88  return;
89  }
90 
91  CexmcAngularRangeList normalizedAngularRanges;
92  GetNormalizedAngularRange( src, normalizedAngularRanges );
93 
94  G4int index( 0 );
95  if ( normalizedAngularRanges[ 0 ].top < 1.0 )
96  dst.push_back( CexmcAngularRange(
97  1.0, normalizedAngularRanges[ 0 ].top, index++ ) );
98 
99  for ( CexmcAngularRangeList::iterator
100  k( normalizedAngularRanges.begin() );
101  k != normalizedAngularRanges.end(); ++k )
102  {
103  if ( k + 1 == normalizedAngularRanges.end() )
104  break;
105  dst.push_back( CexmcAngularRange(
106  k->bottom, ( k + 1 )->top, index++ ) );
107  }
108 
109  if ( normalizedAngularRanges.back().bottom > -1.0 )
110  dst.push_back( CexmcAngularRange(
111  normalizedAngularRanges.back().bottom, -1.0, index ) );
112 }
int G4int
Definition: G4Types.hh:78
void GetNormalizedAngularRange(const CexmcAngularRangeList &src, CexmcAngularRangeList &dst)
std::vector< CexmcAngularRange > CexmcAngularRangeList

Here is the call graph for this function:

Here is the caller graph for this function:

void GetNormalizedAngularRange ( const CexmcAngularRangeList src,
CexmcAngularRangeList dst 
)

Definition at line 51 of file CexmcAngularRange.cc.

53 {
54  dst = src;
55  if ( dst.size() < 2 )
56  return;
57 
58  std::sort( dst.begin(), dst.end() );
59 
60  const G4double epsilon( 1E-7 );
61 
62  for ( CexmcAngularRangeList::iterator k( dst.begin() + 1 );
63  k != dst.end(); )
64  {
65  if ( std::fabs( k->top - ( k - 1 )->top ) < epsilon ||
66  k->bottom + epsilon >= ( k - 1 )->bottom )
67  {
68  k = dst.erase( k );
69  continue;
70  }
71  if ( k->top + epsilon >= ( k - 1 )->bottom )
72  {
73  ( k - 1 )->bottom = k->bottom;
74  k = dst.erase( k );
75  continue;
76  }
77  ++k;
78  }
79 }
double G4double
Definition: G4Types.hh:76
double epsilon(double density, double temperature)

Here is the call graph for this function:

Here is the caller graph for this function:

std::ostream& operator<< ( std::ostream &  out,
const CexmcAngularRange angularRange 
)

Definition at line 115 of file CexmcAngularRange.cc.

117 {
118  std::ostream::fmtflags savedFlags( out.flags() );
119  std::streamsize prec( out.precision() );
120 
121  out.precision( 4 );
122  out.flags( std::ios::fixed );
123 
124  out << std::setw( 2 ) << angularRange.index + 1 << " [" << std::setw( 7 ) <<
125  angularRange.top << ", " << std::setw( 7 ) << angularRange.bottom <<
126  ")";
127 
128  out.precision( prec );
129  out.flags( savedFlags );
130 
131  return out;
132 }
static const double prec
Definition: RanecuEngine.cc:58
std::ostream& operator<< ( std::ostream &  out,
const CexmcAngularRangeList angularRanges 
)

Definition at line 135 of file CexmcAngularRange.cc.

137 {
138  out << std::endl;
139  for ( CexmcAngularRangeList::const_iterator k( angularRanges.begin() );
140  k != angularRanges.end(); ++k )
141  {
142  out << " " << *k << std::endl;
143  }
144 
145  return out;
146 }