Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TrajectoryDrawerUtils Namespace Reference

Enumerations

enum  TimesValidity { InvalidTimes , ValidTimes }
 

Functions

void GetPoints (const G4VTrajectory &traj, G4Polyline &trajectoryLine, G4Polymarker &auxiliaryPoints, G4Polymarker &stepPoints)
 
void DrawLineAndPoints (const G4VTrajectory &traj, const G4VisTrajContext &, const G4int &i_mode)
 
void DrawLineAndPoints (const G4VTrajectory &traj, const G4VisTrajContext &)
 
TimesValidity GetPointsAndTimes (const G4VTrajectory &traj, const G4VisTrajContext &context, G4Polyline &trajectoryLine, G4Polymarker &auxiliaryPoints, G4Polymarker &stepPoints, std::vector< G4double > &trajectoryLineTimes, std::vector< G4double > &auxiliaryPointTimes, std::vector< G4double > &stepPointTimes)
 

Enumeration Type Documentation

◆ TimesValidity

Function Documentation

◆ DrawLineAndPoints() [1/2]

void G4TrajectoryDrawerUtils::DrawLineAndPoints ( const G4VTrajectory traj,
const G4VisTrajContext context 
)

Definition at line 375 of file G4TrajectoryDrawerUtils.cc.

376 {
377 // Return if don't need to do anything
378 if (!context.GetDrawLine() && !context.GetDrawAuxPts() && !context.GetDrawStepPts()) return;
379
380 // Get points and times (times are returned only if time-slicing
381 // is requested).
382 G4Polyline trajectoryLine;
383 G4Polymarker stepPoints;
384 G4Polymarker auxiliaryPoints;
385 std::vector<G4double> trajectoryLineTimes;
386 std::vector<G4double> stepPointTimes;
387 std::vector<G4double> auxiliaryPointTimes;
388
390 (traj, context,
391 trajectoryLine, auxiliaryPoints, stepPoints,
392 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
393
394 if (validity == ValidTimes) {
395
396 SliceLine(context.GetTimeSliceInterval(),
397 trajectoryLine, trajectoryLineTimes);
398
399 DrawWithTime(context,
400 trajectoryLine, auxiliaryPoints, stepPoints,
401 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
402
403 } else {
404
405 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
406
407 }
408 }
G4bool GetDrawAuxPts() const
G4double GetTimeSliceInterval() const
G4bool GetDrawLine() const
G4bool GetDrawStepPts() const
TimesValidity GetPointsAndTimes(const G4VTrajectory &traj, const G4VisTrajContext &context, G4Polyline &trajectoryLine, G4Polymarker &auxiliaryPoints, G4Polymarker &stepPoints, std::vector< G4double > &trajectoryLineTimes, std::vector< G4double > &auxiliaryPointTimes, std::vector< G4double > &stepPointTimes)

◆ DrawLineAndPoints() [2/2]

void G4TrajectoryDrawerUtils::DrawLineAndPoints ( const G4VTrajectory traj,
const G4VisTrajContext context,
const G4int i_mode 
)

Definition at line 313 of file G4TrajectoryDrawerUtils.cc.

314 {
315 static G4bool warnedAboutIMode = false;
317 ed << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode
318 << "). Feature will be removed at a future major release.";
319 if (!warnedAboutIMode) {
321 ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, context, i_mode)",
322 "modeling0125", JustWarning, ed);
323 warnedAboutIMode = true;
324 }
325
326 // Extra copy while i_mode is still around
327 G4VisTrajContext myContext(context);
328
329 if (i_mode != 0) {
330 const G4double markerSize = std::abs(i_mode)/1000;
331 G4bool lineRequired (i_mode >= 0);
332 G4bool markersRequired (markerSize > 0.);
333
334 myContext.SetDrawLine(lineRequired);
335 myContext.SetDrawAuxPts(markersRequired);
336 myContext.SetDrawStepPts(markersRequired);
337
338 myContext.SetAuxPtsSize(markerSize);
339 myContext.SetStepPtsSize(markerSize);
340 }
341
342 // Return if don't need to do anything
343 if (!myContext.GetDrawLine() && !myContext.GetDrawAuxPts() && !myContext.GetDrawStepPts()) return;
344
345 // Get points and times (times are returned only if time-slicing
346 // is requested).
347 G4Polyline trajectoryLine;
348 G4Polymarker stepPoints;
349 G4Polymarker auxiliaryPoints;
350 std::vector<G4double> trajectoryLineTimes;
351 std::vector<G4double> stepPointTimes;
352 std::vector<G4double> auxiliaryPointTimes;
353
355 (traj, context,
356 trajectoryLine, auxiliaryPoints, stepPoints,
357 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
358
359 if (validity == ValidTimes) {
360
361 SliceLine(context.GetTimeSliceInterval(),
362 trajectoryLine, trajectoryLineTimes);
363
364 DrawWithTime(context,
365 trajectoryLine, auxiliaryPoints, stepPoints,
366 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
367
368 } else {
369
370 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
371
372 }
373 }
@ JustWarning
double G4double
Definition: G4Types.hh:64
bool G4bool
Definition: G4Types.hh:67
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76

Referenced by G4TrajectoryDrawByAttribute::Draw(), G4TrajectoryDrawByCharge::Draw(), G4TrajectoryDrawByOriginVolume::Draw(), G4TrajectoryDrawByParticleID::Draw(), and G4TrajectoryGenericDrawer::Draw().

◆ GetPoints()

void G4TrajectoryDrawerUtils::GetPoints ( const G4VTrajectory traj,
G4Polyline trajectoryLine,
G4Polymarker auxiliaryPoints,
G4Polymarker stepPoints 
)

◆ GetPointsAndTimes()

TimesValidity G4TrajectoryDrawerUtils::GetPointsAndTimes ( const G4VTrajectory traj,
const G4VisTrajContext context,
G4Polyline trajectoryLine,
G4Polymarker auxiliaryPoints,
G4Polymarker stepPoints,
std::vector< G4double > &  trajectoryLineTimes,
std::vector< G4double > &  auxiliaryPointTimes,
std::vector< G4double > &  stepPointTimes 
)

Definition at line 46 of file G4TrajectoryDrawerUtils.cc.

55 {
56 TimesValidity validity = InvalidTimes;
57 if (context.GetTimeSliceInterval()) validity = ValidTimes;
58
59 // Memory for last trajectory point position for auxiliary point
60 // time interpolation algorithm. There are no auxiliary points
61 // for the first trajectory point, so its initial value is
62 // immaterial.
63 G4ThreeVector lastTrajectoryPointPosition;
64
65 // Keep positions. Don't store unless first or different.
66 std::vector<G4ThreeVector> positions;
67
68 for (G4int iPoint=0; iPoint<traj.GetPointEntries(); iPoint++) {
69
70 G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(iPoint);
71 const G4ThreeVector& trajectoryPointPosition =
72 aTrajectoryPoint->GetPosition();
73
74 // Only store if first or if different
75 if (positions.size() == 0 ||
76 trajectoryPointPosition != positions[positions.size()-1]) {
77
78 // Pre- and Post-Point times from the trajectory point...
79 G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
80 G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
81
82 if (context.GetTimeSliceInterval() && validity == ValidTimes) {
83
84 std::vector<G4AttValue>* trajectoryPointAttValues =
85 aTrajectoryPoint->CreateAttValues();
86 if (!trajectoryPointAttValues) {
87 static G4bool warnedNoAttValues = false;
88 if (!warnedNoAttValues) {
89 G4cout <<
90 "*************************************************************************"
91 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values."
92 "\n*************************************************************************"
93 << G4endl;
94 warnedNoAttValues = true;
95 }
96 validity = InvalidTimes;
97 } else {
98 G4bool foundPreTime = false, foundPostTime = false;
99 for (std::vector<G4AttValue>::iterator i =
100 trajectoryPointAttValues->begin();
101 i != trajectoryPointAttValues->end(); ++i) {
102 if (i->GetName() == "PreT") {
103 trajectoryPointPreTime =
105 foundPreTime = true;
106 }
107 if (i->GetName() == "PostT") {
108 trajectoryPointPostTime =
110 foundPostTime = true;
111 }
112 }
113 if (!foundPreTime || !foundPostTime) {
114 static G4bool warnedTimesNotFound = false;
115 if (!warnedTimesNotFound) {
116 G4cout <<
117 "*************************************************************************"
118 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found."
119 "\n*************************************************************************"
120 << G4endl;
121 warnedTimesNotFound = true;
122 }
123 validity = InvalidTimes;
124 }
125 }
126 }
127
128 const std::vector<G4ThreeVector>* auxiliaries
129 = aTrajectoryPoint->GetAuxiliaryPoints();
130 if (0 != auxiliaries) {
131 for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
132 const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
133 if (positions.size() == 0 ||
134 auxPointPosition != positions[positions.size()-1]) {
135 // Only store if first or if different
136 positions.push_back(trajectoryPointPosition);
137 trajectoryLine.push_back(auxPointPosition);
138 auxiliaryPoints.push_back(auxPointPosition);
139 if (validity == ValidTimes) {
140 // Interpolate time for auxiliary points...
141 G4double s1 =
142 (auxPointPosition - lastTrajectoryPointPosition).mag();
143 G4double s2 =
144 (trajectoryPointPosition - auxPointPosition).mag();
145 G4double t = trajectoryPointPreTime +
146 (trajectoryPointPostTime - trajectoryPointPreTime) *
147 (s1 / (s1 + s2));
148 trajectoryLineTimes.push_back(t);
149 auxiliaryPointTimes.push_back(t);
150 }
151 }
152 }
153 }
154
155 positions.push_back(trajectoryPointPosition);
156 trajectoryLine.push_back(trajectoryPointPosition);
157 stepPoints.push_back(trajectoryPointPosition);
158 if (validity == ValidTimes) {
159 trajectoryLineTimes.push_back(trajectoryPointPostTime);
160 stepPointTimes.push_back(trajectoryPointPostTime);
161 }
162 lastTrajectoryPointPosition = trajectoryPointPosition;
163 }
164 }
165 return validity;
166 }
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
static G4double ConvertToDimensionedDouble(const char *st)
Definition: G4UIcommand.cc:429
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::vector< G4ThreeVector > * GetAuxiliaryPoints() const
virtual const G4ThreeVector GetPosition() const =0
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
virtual int GetPointEntries() const =0

Referenced by DrawLineAndPoints().