Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4LocatorChangeRecord Class Reference

#include <G4LocatorChangeRecord.hh>

Public Types

enum  EChangeLocation {
  kInvalidCL = 0 , kUnknownCL = 1 , kInitialisingCL , kIntersectsAF ,
  kIntersectsFB , kNoIntersectAForFB , kRecalculatedB , kInsertingMidPoint ,
  kRecalculatedBagn , kLevelPop
}
 

Public Member Functions

 G4LocatorChangeRecord (EChangeLocation codeLocation, G4int iter, unsigned int count, const G4FieldTrack &fieldTrack)
 
 G4LocatorChangeRecord (const G4LocatorChangeRecord &)=default
 
 G4LocatorChangeRecord (G4LocatorChangeRecord &&)=default
 
EChangeLocation GetLocation () const
 
unsigned int GetCount () const
 
G4int GetIteration () const
 
G4double GetLength () const
 
std::ostream & StreamInfo (std::ostream &os) const
 

Static Public Member Functions

static const char * GetNameChangeLocation (EChangeLocation)
 
static std::ostream & ReportVector (std::ostream &os, const std::string &nameOfRecord, const std::vector< G4LocatorChangeRecord > &lcr)
 
static std::ostream & ReportEndChanges (std::ostream &os, const std::vector< G4LocatorChangeRecord > &startA, const std::vector< G4LocatorChangeRecord > &endB)
 

Static Public Attributes

static const char * fNameChangeLocation []
 

Friends

std::ostream & operator<< (std::ostream &os, const G4LocatorChangeRecord &r)
 
std::ostream & operator<< (std::ostream &os, const std::vector< G4LocatorChangeRecord > &vecR)
 

Detailed Description

Definition at line 41 of file G4LocatorChangeRecord.hh.

Member Enumeration Documentation

◆ EChangeLocation

Enumerator
kInvalidCL 
kUnknownCL 
kInitialisingCL 
kIntersectsAF 
kIntersectsFB 
kNoIntersectAForFB 
kRecalculatedB 
kInsertingMidPoint 
kRecalculatedBagn 
kLevelPop 

Definition at line 45 of file G4LocatorChangeRecord.hh.

Constructor & Destructor Documentation

◆ G4LocatorChangeRecord() [1/3]

G4LocatorChangeRecord::G4LocatorChangeRecord ( EChangeLocation  codeLocation,
G4int  iter,
unsigned int  count,
const G4FieldTrack fieldTrack 
)
inline

Definition at line 54 of file G4LocatorChangeRecord.hh.

58 : fCodeLocation( codeLocation), fIteration(iter), fEventCount(count),
59 fFieldTrack( fieldTrack ) {}

◆ G4LocatorChangeRecord() [2/3]

G4LocatorChangeRecord::G4LocatorChangeRecord ( const G4LocatorChangeRecord )
default

◆ G4LocatorChangeRecord() [3/3]

G4LocatorChangeRecord::G4LocatorChangeRecord ( G4LocatorChangeRecord &&  )
default

Member Function Documentation

◆ GetCount()

unsigned int G4LocatorChangeRecord::GetCount ( ) const
inline

Definition at line 70 of file G4LocatorChangeRecord.hh.

70{ return fEventCount; }

◆ GetIteration()

G4int G4LocatorChangeRecord::GetIteration ( ) const
inline

Definition at line 71 of file G4LocatorChangeRecord.hh.

71{ return fIteration; }

◆ GetLength()

G4double G4LocatorChangeRecord::GetLength ( ) const
inline

Definition at line 72 of file G4LocatorChangeRecord.hh.

72{ return fFieldTrack.GetCurveLength(); }
G4double GetCurveLength() const

Referenced by StreamInfo().

◆ GetLocation()

EChangeLocation G4LocatorChangeRecord::GetLocation ( ) const
inline

Definition at line 69 of file G4LocatorChangeRecord.hh.

69{ return fCodeLocation; }

◆ GetNameChangeLocation()

const char * G4LocatorChangeRecord::GetNameChangeLocation ( EChangeLocation  loc)
static

Definition at line 282 of file G4LocatorChangeRecord.cc.

283{
284 return fNameChangeLocation[loc];
285}
static const char * fNameChangeLocation[]

Referenced by G4LocatorChangeLogger::ReportEndChanges().

◆ ReportEndChanges()

std::ostream & G4LocatorChangeRecord::ReportEndChanges ( std::ostream &  os,
const std::vector< G4LocatorChangeRecord > &  startA,
const std::vector< G4LocatorChangeRecord > &  endB 
)
static

Definition at line 99 of file G4LocatorChangeRecord.cc.

103{
104 using std::setw;
105 G4int prec= 16;
106 const G4bool confirm = true;
107 G4int oldprc = os.precision(prec);
108
109 std::vector<G4LocatorChangeRecord>::const_iterator itrecA, itrecB;
110 itrecA= startA.begin();
111 itrecB= endB.begin();
112
113 os << "====================================================================="
114 << G4endl;
115 os << " Size of individual change record: startA : " << startA.size()
116 << " endB : " << endB.size() << G4endl;
117 os << "====================================================================="
118 << G4endl;
119
120 os << setw( 7 ) << "Change#" << " "
121 << setw( 4 ) << "Iter" << " "
122 << setw( 20 ) << "CodeLocation" << " "
123 << setw( prec+9 ) << "Length-A (start)" << " "
124 << setw( prec+9 ) << "Length-B (end)" << " "
125 << G4endl;
126 os << "=====================================================================";
127
128
129 auto eventA = (*itrecA).GetCount();
130 auto eventB = (*itrecB).GetCount();
131
132 G4bool isLastA= false;
133 G4bool isLastB= false;
134
135 G4int jA=0, jB=0;
136
137 G4int maxEvent = std::max( startA[ startA.size() - 1 ].GetCount() ,
138 endB[ endB.size() - 1 ].GetCount() );
139 G4int prevA = -1;
140 G4int prevB = -1;
141
142 G4bool advanceA= false, advanceB= false;
143 do
144 {
145 advanceA= false;
146 advanceB= false;
147
148 if( ((G4int)eventA>prevA) && ((G4int)eventB>prevB) )
149 {
150 auto codeLocA= (*itrecA).GetLocation();
151
152 os << G4endl;
153 os << setw( 7 ) << eventA << " "
154 << setw( 4 ) << (*itrecA).GetIteration() << " "
155 << setw( 3 ) << codeLocA << " "
156 << setw( 15 ) << fNameChangeLocation[ codeLocA ] << " "
157 << setw( prec+9 ) << (*itrecA).GetLength() << " "
158 << setw( prec+9 ) << (*itrecB).GetLength() << " ";
159 if( confirm )
160 {
161 os << setw( 4 ) << (*itrecB).GetIteration() << " "
162 << setw( 15 ) << (*itrecB).GetLocation();
163 }
164 }
165 else
166 {
167 if ( (G4int)eventA > prevA )
168 {
169 auto codeLocA = (*itrecA).GetLocation();
170 os << G4endl;
171 os << setw( 7 ) << (*itrecA).GetCount() << " "
172 << setw( 4 ) << (*itrecA).GetIteration() << " "
173 << setw( 3 ) << codeLocA << " "
174 << setw( 15 ) << fNameChangeLocation[ codeLocA ] << " "
175 << setw( prec+9 ) << (*itrecA).GetLength() << " "
176 << setw( prec+9 ) << " " << " ";
177 }
178 else
179 {
180 // assert( (G4int)eventB > prevB );
181 auto codeLocB = (*itrecB).GetLocation();
182
183 os << G4endl;
184 os << setw( 7 ) << eventB << " "
185 << setw( 4 ) << (*itrecB).GetIteration() << " "
186 << setw( 3 ) << codeLocB << " "
187 << setw( 15 ) << fNameChangeLocation[ codeLocB ] << " "
188 << setw( prec+9 ) << " " << " "
189 << setw( prec+9 ) << (*itrecB).GetLength() << " " ;
190 }
191 }
192
193 prevA= eventA;
194 prevB= eventB;
195
196 auto nextA= itrecA;
197 auto nextB= itrecB;
198
199 G4int nextAct = maxEvent, nextBct = maxEvent;
200 ++nextA;
201 ++nextB;
202 if ( nextA != startA.end() ) { nextAct = (*nextA).GetCount(); }
203 if ( nextB != endB.end() ) { nextBct = (*nextB).GetCount(); }
204
205 isLastA= ( nextA >= startA.end() );
206 isLastB= ( nextB >= endB.end() );
207
208 advanceA= ( nextAct <= nextBct ) && !isLastA;
209 advanceB= ( nextBct <= nextAct ) && !isLastB;
210
211 if( advanceA )
212 {
213 ++itrecA;
214 if( !isLastA ) { ++jA; eventA = (*itrecA).GetCount(); }
215 else { eventA = maxEvent; }
216 }
217
218 if( advanceB )
219 {
220 ++itrecB;
221 if( !isLastB ) { ++jB; eventB = (*itrecB).GetCount(); }
222 else { eventB = maxEvent; }
223 }
224
225 // Checks
226 if( isLastA != ( nextA == startA.end() ) )
227 {
228 os << G4endl;
229 os << " Checking isLastA= " << isLastA << " vs expected : "
230 << ( itrecA == startA.end() );
231 os << " BAD --- ERROR " << G4endl;
232 }
233 if( isLastB != ( nextB == endB.end() ) )
234 {
235 os << G4endl;
236 os << " Checking isLastB= " << isLastB << " vs expected : "
237 << ( itrecB == endB.end() );
238 os << " BAD --- ERROR " << G4endl;
239 }
240
241 } while ( ! ( isLastA && isLastB ) );
242
243 os << G4endl;
244 os.precision(oldprc);
245 return os;
246}
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57

Referenced by G4MultiLevelLocator::EstimateIntersectionPoint().

◆ ReportVector()

std::ostream & G4LocatorChangeRecord::ReportVector ( std::ostream &  os,
const std::string &  nameOfRecord,
const std::vector< G4LocatorChangeRecord > &  lcr 
)
static

Definition at line 48 of file G4LocatorChangeRecord.cc.

51{
52 using std::setw;
53 G4int prec= 16;
54 if( vecRec.size() == 0 )
55 {
56 os << "Locator Change Record for " << name << " is empty" << G4endl;
57 return os;
58 }
59
60 G4int oldprc = os.precision(prec);
61
62 // std::vector<G4LocatorChangeRecord>::const_iterator
63 auto itRec
64 = std::vector<G4LocatorChangeRecord>::const_iterator(vecRec.cbegin());
65
66 os << setw( 7 ) << "Change#" << " "
67 << setw( 4 ) << "Iter" << " "
68 << std::left
69 << setw( prec+9 ) << "Length" << " "
70 << setw( 15 ) << "Code-Location" << " "
71 << G4endl;
72 os << "====================================================================="
73 << G4endl;
74
75 do
76 {
77 auto locationCode= (*itRec).GetLocation();
78 os << std::internal
79 << setw( 7 ) << (*itRec).GetCount() << " " // Event Count
80 << setw( 4 ) << (*itRec).GetIteration() << " "
81 << std::left
82 << setw( prec+9 ) << (*itRec).GetLength() << " "
83 << setw( 2 ) << locationCode << " " // location enum
84 << setw( 15 ) << fNameChangeLocation[ locationCode ]
85 << std::internal
86 ;
87 os << G4endl;
88 ++itRec;
89
90 } while ( itRec != vecRec.cend() );
91
92 os.precision(oldprc);
93 return os;
94}
const char * name(G4int ptype)

Referenced by G4LocatorChangeLogger::StreamInfo().

◆ StreamInfo()

std::ostream & G4LocatorChangeRecord::StreamInfo ( std::ostream &  os) const

Definition at line 259 of file G4LocatorChangeRecord.cc.

260{
261 G4int oldprc = os.precision(16);
262 os << " count = " << fEventCount
263 << " iter= " << fIteration
264 << " Location code = " << fCodeLocation
265 << " Length = " << GetLength() << G4endl;
266 os.precision(oldprc);
267 return os;
268}

Friends And Related Function Documentation

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream &  os,
const G4LocatorChangeRecord r 
)
friend

Definition at line 251 of file G4LocatorChangeRecord.cc.

252{
253 return e.StreamInfo(os);
254}

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream &  os,
const std::vector< G4LocatorChangeRecord > &  vecR 
)
friend

Definition at line 273 of file G4LocatorChangeRecord.cc.

275{
277 return os;
278}
static std::ostream & ReportVector(std::ostream &os, const std::string &nameOfRecord, const std::vector< G4LocatorChangeRecord > &lcr)

Member Data Documentation

◆ fNameChangeLocation

const char * G4LocatorChangeRecord::fNameChangeLocation
static
Initial value:
=
{ "Invalid", "Unknown", "Initialising", "IntersectsAF", "IntersectsFB",
"NoIntersections-AForFB", "RecalculatedB",
"InsertingMidPoint", "RecalculatedB-2ndHalf",
"Level Pop" }

Definition at line 51 of file G4LocatorChangeRecord.hh.

Referenced by GetNameChangeLocation(), ReportEndChanges(), and ReportVector().


The documentation for this class was generated from the following files: