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

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

#include <G4LocatorChangeLogger.hh>

Inheritance diagram for G4LocatorChangeLogger:

Public Member Functions

 G4LocatorChangeLogger (const std::string &name)
void AddRecord (G4LocatorChangeRecord &&chngRecord)
void AddRecord (const G4LocatorChangeRecord &chngRecord)
void AddRecord (G4LocatorChangeRecord::EChangeLocation codeLocation, G4int iter, unsigned int count, const G4FieldTrack &fieldTrack)
std::ostream & StreamInfo (std::ostream &os) const

Static Public Member Functions

static std::ostream & ReportEndChanges (std::ostream &os, const G4LocatorChangeLogger &startA, const G4LocatorChangeLogger &endB)

Friends

std::ostream & operator<< (std::ostream &os, const G4LocatorChangeLogger &logR)

Detailed Description

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

Definition at line 48 of file G4LocatorChangeLogger.hh.

Constructor & Destructor Documentation

◆ G4LocatorChangeLogger()

G4LocatorChangeLogger::G4LocatorChangeLogger ( const std::string & name)

Constructor.

Definition at line 40 of file G4LocatorChangeLogger.cc.

41 : fName(name)
42{
43}

Referenced by operator<<, and ReportEndChanges().

Member Function Documentation

◆ AddRecord() [1/3]

void G4LocatorChangeLogger::AddRecord ( const G4LocatorChangeRecord & chngRecord)
inline

Definition at line 106 of file G4LocatorChangeLogger.hh.

108{
109 push_back( chngRecord );
110}

◆ AddRecord() [2/3]

void G4LocatorChangeLogger::AddRecord ( G4LocatorChangeRecord && chngRecord)
inline

Move or add a record.

Definition at line 113 of file G4LocatorChangeLogger.hh.

115{
116 push_back( chngRecord );
117}

◆ AddRecord() [3/3]

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

Create a new record with full information.

Definition at line 97 of file G4LocatorChangeLogger.hh.

101{
102 push_back(G4LocatorChangeRecord(codeLocation, iter, count, fieldTrack));
103}

◆ ReportEndChanges()

std::ostream & G4LocatorChangeLogger::ReportEndChanges ( std::ostream & os,
const G4LocatorChangeLogger & startA,
const G4LocatorChangeLogger & endB )
static

Prints the changes in start, end points in columns. One event per row.

Definition at line 68 of file G4LocatorChangeLogger.cc.

71{
72 using std::setw;
73 G4int prec= 16;
74 const G4bool confirm = true;
75 G4long oldprc = os.precision(prec);
76
77 auto itrecA= startA.cbegin();
78 auto itrecB= endB.cbegin();
79
80 os << "====================================================================="
81 << G4endl;
82 os << " Size of individual change record: startA : " << startA.size()
83 << " endB : " << endB.size() << G4endl;
84 os << "====================================================================="
85 << G4endl;
86
87 os << setw( 7 ) << "Change#" << " "
88 << setw( 4 ) << "Iter" << " "
89 << setw( 20 ) << "CodeLocation" << " "
90 << setw( prec+9 ) << "Length-A (start)" << " "
91 << setw( prec+9 ) << "Length-B (end)" << " "
92 << G4endl;
93 os << "=====================================================================";
94
95 auto eventA = (*itrecA).GetCount();
96 auto eventB = (*itrecB).GetCount();
97
98 G4bool isLastA= false;
99 G4bool isLastB= false;
100
101 G4int maxEvent = std::max( startA[ startA.size() - 1 ].GetCount() ,
102 endB[ endB.size() - 1 ].GetCount() );
103 G4int prevA = -1;
104 G4int prevB = -1;
105
106 G4bool advanceA= false, advanceB= false;
107 do
108 {
109 advanceA= false;
110 advanceB= false;
111
112 if( ((G4int)eventA>prevA) && ((G4int)eventB>prevB) )
113 {
114 auto codeLocA= (*itrecA).GetLocation();
115
116 os << G4endl;
117 os << setw( 7 ) << eventA << " "
118 << setw( 4 ) << (*itrecA).GetIteration() << " "
119 << setw( 3 ) << codeLocA << " "
120 << setw( 15 )
122 << setw( prec+9 ) << (*itrecA).GetLength() << " "
123 << setw( prec+9 ) << (*itrecB).GetLength() << " ";
124 if( confirm )
125 {
126 os << setw( 4 ) << (*itrecB).GetIteration() << " "
127 << setw( 15 ) << (*itrecB).GetLocation();
128 }
129 }
130 else
131 {
132 if ( (G4int)eventA > prevA )
133 {
134 auto codeLocA= (*itrecA).GetLocation();
135 os << G4endl;
136 os << setw( 7 ) << (*itrecA).GetCount() << " "
137 << setw( 4 ) << (*itrecA).GetIteration() << " "
138 << setw( 3 ) << codeLocA << " "
139 << setw( 15 )
141 << setw( prec+9 ) << (*itrecA).GetLength() << " "
142 << setw( prec+9 ) << " " << " ";
143 }
144 else
145 {
146 // assert( (G4int)eventB > prevB );
147 auto codeLocB= (*itrecB).GetLocation();
148
149 os << G4endl;
150 os << setw( 7 ) << eventB << " "
151 << setw( 4 ) << (*itrecB).GetIteration() << " "
152 << setw( 3 ) << codeLocB << " "
153 << setw( 15 )
155 << setw( prec+9 ) << " " << " "
156 << setw( prec+9 ) << (*itrecB).GetLength() << " " ;
157 }
158 }
159
160 prevA= eventA;
161 prevB= eventB;
162
163 auto nextA= itrecA;
164 auto nextB= itrecB;
165
166 G4int nextAct = maxEvent, nextBct = maxEvent;
167 ++nextA;
168 ++nextB;
169 if ( nextA != startA.end() ) { nextAct = (*nextA).GetCount(); }
170 if ( nextB != endB.end() ) { nextBct = (*nextB).GetCount(); }
171
172 isLastA= ( nextA >= startA.end() );
173 isLastB= ( nextB >= endB.end() );
174
175 advanceA= ( nextAct <= nextBct ) && !isLastA;
176 advanceB= ( nextBct <= nextAct ) && !isLastB;
177
178 if( advanceA )
179 {
180 ++itrecA;
181 eventA = isLastA ? maxEvent : (*itrecA).GetCount();
182 }
183
184 if( advanceB )
185 {
186 ++itrecB;
187 eventB = isLastB ? maxEvent : (*itrecB).GetCount();
188 }
189
190 // Checks
191 if( isLastA != ( nextA == startA.end() ) )
192 {
193 os << G4endl;
194 os << " Checking isLastA= " << isLastA
195 << " vs expected : " << ( itrecA == startA.end() );
196 os << " BAD --- ERROR " << G4endl;
197 }
198 if( isLastB != ( nextB == endB.end() ) )
199 {
200 os << G4endl;
201 os << " Checking isLastB= " << isLastB
202 << " vs expected : " << ( itrecB == endB.end() );
203 os << " BAD --- ERROR " << G4endl;
204 }
205 } while ( ! ( isLastA && isLastB ) );
206
207 os << G4endl;
208 os.precision(oldprc);
209 return os;
210}
long G4long
Definition G4Types.hh:87
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
static const char * GetNameChangeLocation(EChangeLocation)

Referenced by G4MultiLevelLocator::EstimateIntersectionPoint().

◆ StreamInfo()

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

Streams object contents to an output stream.

Definition at line 57 of file G4LocatorChangeLogger.cc.

58{
59 G4long oldprc = os.precision(16);
60 G4LocatorChangeRecord::ReportVector( os, this->fName, *this );
61 os.precision(oldprc);
62 return os;
63}
static std::ostream & ReportVector(std::ostream &os, const std::string &nameOfRecord, const std::vector< G4LocatorChangeRecord > &lcr)

Referenced by operator<<.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const G4LocatorChangeLogger & logR )
friend

Streaming operator dumping record.

Definition at line 48 of file G4LocatorChangeLogger.cc.

50{
51 return logger.StreamInfo(os);
52}

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