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

G4LocatorChangeRecord records the changes in an endpoint of a locator. Its key use is in playing these back in case of a problem. More...

#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 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 const char * GetNameChangeLocation (EChangeLocation)

Friends

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

Detailed Description

G4LocatorChangeRecord records the changes in an endpoint of a locator. Its key use is in playing these back in case of a problem.

Definition at line 46 of file G4LocatorChangeRecord.hh.

Member Enumeration Documentation

◆ EChangeLocation

Constructor & Destructor Documentation

◆ G4LocatorChangeRecord() [1/3]

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

Constructor.

Definition at line 47 of file G4LocatorChangeRecord.cc.

52 : fCodeLocation( codeLocation),
53 fIteration(iter),
54 fEventCount(count),
55 fFieldTrack( fieldTrack )
56{
57}

Referenced by G4LocatorChangeRecord(), G4LocatorChangeRecord(), and operator<<.

◆ G4LocatorChangeRecord() [2/3]

G4LocatorChangeRecord::G4LocatorChangeRecord ( const G4LocatorChangeRecord & )
default

Default copy and move constructors.

◆ G4LocatorChangeRecord() [3/3]

G4LocatorChangeRecord::G4LocatorChangeRecord ( G4LocatorChangeRecord && )
default

Member Function Documentation

◆ GetCount()

unsigned int G4LocatorChangeRecord::GetCount ( ) const
inline

Definition at line 76 of file G4LocatorChangeRecord.hh.

76{ return fEventCount; }

◆ GetIteration()

G4int G4LocatorChangeRecord::GetIteration ( ) const
inline

Definition at line 77 of file G4LocatorChangeRecord.hh.

77{ return fIteration; }

◆ GetLength()

G4double G4LocatorChangeRecord::GetLength ( ) const
inline

Definition at line 78 of file G4LocatorChangeRecord.hh.

78{ return fFieldTrack.GetCurveLength(); }

Referenced by StreamInfo().

◆ GetLocation()

EChangeLocation G4LocatorChangeRecord::GetLocation ( ) const
inline

Accessors.

Definition at line 75 of file G4LocatorChangeRecord.hh.

75{ return fCodeLocation; }

◆ GetNameChangeLocation()

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

Definition at line 294 of file G4LocatorChangeRecord.cc.

295{
296 return fNameChangeLocation[loc];
297}

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 112 of file G4LocatorChangeRecord.cc.

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

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 61 of file G4LocatorChangeRecord.cc.

64{
65 using std::setw;
66 G4int prec= 16;
67 if( vecRec.empty() )
68 {
69 os << "Locator Change Record for " << name << " is empty" << G4endl;
70 return os;
71 }
72
73 G4long oldprc = os.precision(prec);
74
75 // std::vector<G4LocatorChangeRecord>::const_iterator
76 auto itRec
77 = std::vector<G4LocatorChangeRecord>::const_iterator(vecRec.cbegin());
78
79 os << setw( 7 ) << "Change#" << " "
80 << setw( 4 ) << "Iter" << " "
81 << std::left
82 << setw( prec+9 ) << "Length" << " "
83 << setw( 15 ) << "Code-Location" << " "
84 << G4endl;
85 os << "====================================================================="
86 << G4endl;
87
88 do
89 {
90 auto locationCode= (*itRec).GetLocation();
91 os << std::internal
92 << setw( 7 ) << (*itRec).GetCount() << " " // Event Count
93 << setw( 4 ) << (*itRec).GetIteration() << " "
94 << std::left
95 << setw( prec+9 ) << (*itRec).GetLength() << " "
96 << setw( 2 ) << locationCode << " " // location enum
97 << setw( 15 ) << fNameChangeLocation[ locationCode ]
98 << std::internal
99 ;
100 os << G4endl;
101 ++itRec;
102
103 } while ( itRec != vecRec.cend() );
104
105 os.precision(oldprc);
106 return os;
107}
const char * name(G4int ptype)

Referenced by operator<<, and G4LocatorChangeLogger::StreamInfo().

◆ StreamInfo()

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

Streams object contents to an output stream.

Definition at line 271 of file G4LocatorChangeRecord.cc.

272{
273 G4long oldprc = os.precision(16);
274 os << " count = " << fEventCount
275 << " iter= " << fIteration
276 << " Location code = " << fCodeLocation
277 << " Length = " << GetLength() << G4endl;
278 os.precision(oldprc);
279 return os;
280}

Referenced by operator<<.

◆ operator<< [1/2]

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

Streaming operators, using StreamInfo().

Definition at line 263 of file G4LocatorChangeRecord.cc.

264{
265 return e.StreamInfo(os);
266}

◆ operator<< [2/2]

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

Definition at line 285 of file G4LocatorChangeRecord.cc.

287{
289 return os;
290}
static std::ostream & ReportVector(std::ostream &os, const std::string &nameOfRecord, const std::vector< G4LocatorChangeRecord > &lcr)

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