CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
MonopoleTransportation Class Reference

#include <MonopoleTransportation.h>

Inheritance diagram for MonopoleTransportation:

Public Member Functions

G4VParticleChange * AlongStepDoIt (const G4Track &track, const G4Step &stepData) override
 
G4double AlongStepGetPhysicalInteractionLength (const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &currentSafety, G4GPILSelection *selection) override
 
G4VParticleChange * AtRestDoIt (const G4Track &, const G4Step &) override
 
G4double AtRestGetPhysicalInteractionLength (const G4Track &, G4ForceCondition *) override
 
void EnableShortStepOptimisation (G4bool optimise=true)
 
G4double GetMaxEnergyKilled () const
 
G4PropagatorInField * GetPropagatorInField ()
 
G4double GetSumEnergyKilled () const
 
G4double GetThresholdImportantEnergy () const
 
G4int GetThresholdTrials () const
 
G4double GetThresholdWarningEnergy () const
 
 MonopoleTransportation (const Monopole *p, sim::ChordFinderSetter *cfs, G4int verbosityLevel=1)
 
G4VParticleChange * PostStepDoIt (const G4Track &track, const G4Step &stepData) override
 
G4double PostStepGetPhysicalInteractionLength (const G4Track &, G4double previousStepSize, G4ForceCondition *pForceCond) override
 
void ResetKilledStatistics (G4int report=1)
 
void SetPropagatorInField (G4PropagatorInField *pFieldPropagator)
 
void SetThresholdImportantEnergy (G4double newEnImp)
 
void SetThresholdTrials (G4int newMaxTrials)
 
void SetThresholdWarningEnergy (G4double newEnWarn)
 
void StartTracking (G4Track *aTrack) override
 
 ~MonopoleTransportation () override
 

Protected Member Functions

G4bool DoesGlobalFieldExist ()
 

Private Attributes

G4double endpointDistance
 
G4double fCandidateEndGlobalTime
 
sim::ChordFinderSetterfChordFinderSetter
 
G4TouchableHandle fCurrentTouchableHandle
 
G4bool fEndGlobalTimeComputed
 
G4PropagatorInField * fFieldPropagator
 
G4bool fGeometryLimitedStep
 
CMSFieldManagerfieldMgrCMS
 
G4Navigator * fLinearNavigator
 
G4double fMaxEnergyKilled
 
G4bool fMomentumChanged
 
G4int fNoLooperTrials
 
G4ParticleChangeForTransport fParticleChange
 
const MonopolefParticleDef
 
G4bool fParticleIsLooping
 
G4double fPreviousSafety
 
G4ThreeVector fPreviousSftOrigin
 
G4SafetyHelper * fpSafetyHelper
 
G4bool fShortStepOptimisation
 
G4double fSumEnergyKilled
 
G4double fThreshold_Important_Energy
 
G4double fThreshold_Warning_Energy
 
G4int fThresholdTrials
 
G4double fTransportEndKineticEnergy
 
G4ThreeVector fTransportEndMomentumDir
 
G4ThreeVector fTransportEndPosition
 
G4ThreeVector fTransportEndSpin
 

Detailed Description

Definition at line 49 of file MonopoleTransportation.h.

Constructor & Destructor Documentation

MonopoleTransportation::MonopoleTransportation ( const Monopole p,
sim::ChordFinderSetter cfs,
G4int  verbosityLevel = 1 
)

Definition at line 34 of file MonopoleTransportation.cc.

References fCandidateEndGlobalTime, fCurrentTouchableHandle, fEndGlobalTimeComputed, fFieldPropagator, fLinearNavigator, and fpSafetyHelper.

37  : G4VProcess( G4String("MonopoleTransportation"), fTransportation ),
38  fParticleDef(mpl),
39  fChordFinderSetter(chordFinderSetter),
40  fieldMgrCMS(nullptr),
41  fLinearNavigator(nullptr),
42  fFieldPropagator(nullptr),
43  fParticleIsLooping( false ),
44  fPreviousSftOrigin (0.,0.,0.),
45  fPreviousSafety ( 0.0 ),
48  fThresholdTrials( 10 ),
49  fNoLooperTrials(0),
50  fSumEnergyKilled( 0.0 ), fMaxEnergyKilled( 0.0 ),
51  fShortStepOptimisation(false), // Old default: true (=fast short steps)
52  fpSafetyHelper(nullptr)
53 {
54  verboseLevel = verb;
55 
56  // set Process Sub Type
57  SetProcessSubType(TRANSPORTATION);
58 
59 #ifdef G4MULTITHREADED
60  // Do not finalize the MonopoleTransportation class
61  if (G4Threading::IsMasterThread())
62  {
63  return;
64  }
65 #endif
66 
67  G4TransportationManager* transportMgr =
68  G4TransportationManager::GetTransportationManager();
69 
70  fLinearNavigator = transportMgr->GetNavigatorForTracking() ;
71 
72  fFieldPropagator = transportMgr->GetPropagatorInField() ;
73  fpSafetyHelper = transportMgr->GetSafetyHelper();
74 
75  // Cannot determine whether a field exists here,
76  // because it would only work if the field manager has informed
77  // about the detector's field before this transportation process
78  // is constructed.
79  // Instead later the method DoesGlobalFieldExist() is called
80 
81  static G4TouchableHandle nullTouchableHandle; // Points to (G4VTouchable*) 0
82  fCurrentTouchableHandle = nullTouchableHandle;
83 
84  fEndGlobalTimeComputed = false;
86 }
const double MeV
G4PropagatorInField * fFieldPropagator
G4TouchableHandle fCurrentTouchableHandle
sim::ChordFinderSetter * fChordFinderSetter
MonopoleTransportation::~MonopoleTransportation ( )
override

Definition at line 90 of file MonopoleTransportation.cc.

References AlongStepGetPhysicalInteractionLength(), and fSumEnergyKilled.

91 {
92  if( (verboseLevel > 0) && (fSumEnergyKilled > 0.0 ) ){
93  /*
94  G4cout << " MonopoleTransportation: Statistics for looping particles "
95  << G4endl;
96  G4cout << " Sum of energy of loopers killed: " << fSumEnergyKilled << G4endl;
97  G4cout << " Max energy of loopers killed: " << fMaxEnergyKilled << G4endl;
98  */
99  }
100 }

Member Function Documentation

G4VParticleChange * MonopoleTransportation::AlongStepDoIt ( const G4Track &  track,
const G4Step &  stepData 
)
override

Definition at line 368 of file MonopoleTransportation.cc.

References fCandidateEndGlobalTime, fEndGlobalTimeComputed, fFieldPropagator, fMaxEnergyKilled, fMomentumChanged, fNoLooperTrials, fParticleChange, fParticleIsLooping, fSumEnergyKilled, fThreshold_Important_Energy, fThreshold_Warning_Energy, fThresholdTrials, fTransportEndKineticEnergy, fTransportEndMomentumDir, fTransportEndPosition, fTransportEndSpin, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, MeV, and PostStepGetPhysicalInteractionLength().

370 {
371  fParticleChange.Initialize(track) ;
372 
373  // Code for specific process
374  //
375  fParticleChange.ProposePosition(fTransportEndPosition) ;
376  fParticleChange.ProposeMomentumDirection(fTransportEndMomentumDir) ;
378  fParticleChange.SetMomentumChanged(fMomentumChanged) ;
379 
380  fParticleChange.ProposePolarization(fTransportEndSpin);
381 
382  G4double deltaTime = 0.0 ;
383 
384  // Calculate Lab Time of Flight (ONLY if field Equations used it!)
385  // G4double endTime = fCandidateEndGlobalTime;
386  // G4double delta_time = endTime - startTime;
387 
388  G4double startTime = track.GetGlobalTime() ;
389 
391  {
392  // The time was not integrated .. make the best estimate possible
393  //
394  G4double finalVelocity = track.GetVelocity() ;
395  G4double initialVelocity = stepData.GetPreStepPoint()->GetVelocity() ;
396  G4double stepLength = track.GetStepLength() ;
397 
398  deltaTime= 0.0; // in case initialVelocity = 0
399  //const G4DynamicParticle* fpDynamicParticle = track.GetDynamicParticle();
400  if (finalVelocity > 0.0)
401  {
402  G4double meanInverseVelocity ;
403  meanInverseVelocity = 0.5
404  * ( 1.0 / initialVelocity + 1.0 / finalVelocity ) ;
405  deltaTime = stepLength * meanInverseVelocity ;
406  }
407  else if( initialVelocity > 0.0 )
408  {
409  deltaTime = stepLength/initialVelocity ;
410  }
411  fCandidateEndGlobalTime = startTime + deltaTime ;
412  }
413  else
414  {
415  deltaTime = fCandidateEndGlobalTime - startTime ;
416  }
417 
418  fParticleChange.ProposeGlobalTime( fCandidateEndGlobalTime ) ;
419 
420  // Now Correct by Lorentz factor to get "proper" deltaTime
421 
422  G4double restMass = track.GetDynamicParticle()->GetMass() ;
423  G4double deltaProperTime = deltaTime*( restMass/track.GetTotalEnergy() ) ;
424 
425  fParticleChange.ProposeProperTime(track.GetProperTime() + deltaProperTime) ;
426  //fParticleChange. ProposeTrueStepLength( track.GetStepLength() ) ;
427 
428  // If the particle is caught looping or is stuck (in very difficult
429  // boundaries) in a magnetic field (doing many steps)
430  // THEN this kills it ...
431  //
432  if ( fParticleIsLooping )
433  {
434  G4double endEnergy= fTransportEndKineticEnergy;
435 
436  if( (endEnergy < fThreshold_Important_Energy)
438  // Kill the looping particle
439  //
440  fParticleChange.ProposeTrackStatus( fStopAndKill ) ;
441 
442  // 'Bare' statistics
443  fSumEnergyKilled += endEnergy;
444  if( endEnergy > fMaxEnergyKilled) { fMaxEnergyKilled= endEnergy; }
445 
446 #ifdef G4VERBOSE
447  if( (verboseLevel > 1) ||
448  ( endEnergy > fThreshold_Warning_Energy ) ) {
449  G4cout << " MonopoleTransportation is killing track that is looping or stuck "
450  << G4endl
451  << " This track has " << track.GetKineticEnergy() / MeV
452  << " MeV energy." << G4endl;
453  G4cout << " Number of trials = " << fNoLooperTrials
454  << " No of calls to AlongStepDoIt = " << noCalls
455  << G4endl;
456  }
457 #endif
458  fNoLooperTrials=0;
459  }
460  else{
461  fNoLooperTrials ++;
462 #ifdef G4VERBOSE
463  if( (verboseLevel > 2) ){
464  G4cout << " MonopoleTransportation::AlongStepDoIt(): Particle looping - "
465  << " Number of trials = " << fNoLooperTrials
466  << " No of calls to = " << noCalls
467  << G4endl;
468  }
469 #endif
470  }
471  }else{
472  fNoLooperTrials=0;
473  }
474 
475  // Another (sometimes better way) is to use a user-limit maximum Step size
476  // to alleviate this problem ..
477 
478  // Introduce smooth curved trajectories to particle-change
479  //
480  fParticleChange.SetPointerToVectorOfAuxiliaryPoints
481  (fFieldPropagator->GimmeTrajectoryVectorAndForgetIt() );
482 
483  return &fParticleChange ;
484 }
const double MeV
G4ParticleChangeForTransport fParticleChange
G4PropagatorInField * fFieldPropagator
G4double MonopoleTransportation::AlongStepGetPhysicalInteractionLength ( const G4Track &  track,
G4double  previousStepSize,
G4double  currentMinimumStep,
G4double &  currentSafety,
G4GPILSelection *  selection 
)
override

Definition at line 110 of file MonopoleTransportation.cc.

References CMSFieldManager::ConfigureForTrack(), endpointDistance, funct::false, fCandidateEndGlobalTime, fEndGlobalTimeComputed, fFieldPropagator, fGeometryLimitedStep, fieldMgrCMS, fLinearNavigator, fMomentumChanged, fParticleChange, fParticleDef, fParticleIsLooping, fPreviousSafety, fPreviousSftOrigin, fpSafetyHelper, fShortStepOptimisation, fTransportEndKineticEnergy, fTransportEndMomentumDir, fTransportEndPosition, fTransportEndSpin, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, mag(), Monopole::MagneticCharge(), CMSFieldManager::SetMonopoleTracking(), spin(), funct::sqr(), mathSSE::sqrt(), and funct::true.

Referenced by ~MonopoleTransportation().

115 {
116  // change to monopole equation
118 
119  G4double geometryStepLength, newSafety ;
121 
122  // Initial actions moved to StartTrack()
123  // --------------------------------------
124  // Note: in case another process changes touchable handle
125  // it will be necessary to add here (for all steps)
126  // fCurrentTouchableHandle = aTrack->GetTouchableHandle();
127 
128  // GPILSelection is set to defaule value of CandidateForSelection
129  // It is a return value
130  //
131  *selection = CandidateForSelection ;
132 
133  // Get initial Energy/Momentum of the track
134  //
135  const G4DynamicParticle* pParticle = track.GetDynamicParticle() ;
136  const G4ThreeVector& startMomentumDir = pParticle->GetMomentumDirection() ;
137  G4ThreeVector startPosition = track.GetPosition() ;
138 
139  // The Step Point safety can be limited by other geometries and/or the
140  // assumptions of any process - it's not always the geometrical safety.
141  // We calculate the starting point's isotropic safety here.
142  //
143  G4ThreeVector OriginShift = startPosition - fPreviousSftOrigin ;
144  G4double MagSqShift = OriginShift.mag2() ;
145  if( MagSqShift >= sqr(fPreviousSafety) )
146  {
147  currentSafety = 0.0 ;
148  }
149  else
150  {
151  currentSafety = fPreviousSafety - std::sqrt(MagSqShift) ;
152  }
153 
154  // Is the monopole charged ?
155  //
156  G4double particleMagneticCharge = fParticleDef->MagneticCharge() ;
157  G4double particleElectricCharge = pParticle->GetCharge();
158 
160 
161  // There is no need to locate the current volume. It is Done elsewhere:
162  // On track construction
163  // By the tracking, after all AlongStepDoIts, in "Relocation"
164 
165  // Check whether the particle have an (EM) field force exerting upon it
166  G4bool fieldExertsForce = false ;
167 
168  if(particleMagneticCharge != 0.0 && fieldMgrCMS) {
169  // Message the field Manager, to configure it for this track
171  // Moved here, in order to allow a transition
172  // from a zero-field status (with fieldMgr->(field)0
173  // to a finite field status
174 
175  // If the field manager has no field, there is no field !
176  fieldExertsForce = (fieldMgrCMS->GetDetectorField() != nullptr);
177  }
178 
179  // G4cout << " G4Transport: field exerts force= " << fieldExertsForce
180  // << " fieldMgr= " << fieldMgr << G4endl;
181 
182  // Choose the calculation of the transportation: Field or not
183  //
184  if( !fieldExertsForce )
185  {
186  G4double linearStepLength ;
187  if( fShortStepOptimisation && (currentMinimumStep <= currentSafety) )
188  {
189  // The Step is guaranteed to be taken
190  //
191  geometryStepLength = currentMinimumStep ;
193  }
194  else
195  {
196  // Find whether the straight path intersects a volume
197  //
198  linearStepLength = fLinearNavigator->ComputeStep( startPosition,
199  startMomentumDir,
200  currentMinimumStep,
201  newSafety) ;
202  // Remember last safety origin & value.
203  //
204  fPreviousSftOrigin = startPosition ;
205  fPreviousSafety = newSafety ;
206  // fpSafetyHelper->SetCurrentSafety( newSafety, startPosition);
207 
208  // The safety at the initial point has been re-calculated:
209  //
210  currentSafety = newSafety ;
211 
212  fGeometryLimitedStep= (linearStepLength <= currentMinimumStep);
214  {
215  // The geometry limits the Step size (an intersection was found.)
216  geometryStepLength = linearStepLength ;
217  }
218  else
219  {
220  // The full Step is taken.
221  geometryStepLength = currentMinimumStep ;
222  }
223  }
224  endpointDistance = geometryStepLength ;
225 
226  // Calculate final position
227  //
228  fTransportEndPosition = startPosition+geometryStepLength*startMomentumDir ;
229 
230  // Momentum direction, energy and polarisation are unchanged by transport
231  //
232  fTransportEndMomentumDir = startMomentumDir ;
233  fTransportEndKineticEnergy = track.GetKineticEnergy() ;
234  fTransportEndSpin = track.GetPolarization();
238  }
239  else // A field exerts force
240  {
241  G4double momentumMagnitude = pParticle->GetTotalMomentum() ;
242  G4ThreeVector EndUnitMomentum ;
243  G4double lengthAlongCurve ;
244  G4double restMass = fParticleDef->GetPDGMass() ;
245 
246  G4ChargeState chargeState(particleElectricCharge, // The charge can change (dynamic)
247  fParticleDef->GetPDGSpin(),
248  0, // Magnetic moment: pParticleDef->GetMagneticMoment(),
249  0, // Electric Dipole moment - not in Particle Definition
250  particleMagneticCharge ); // in Mev/c
251 
252  G4EquationOfMotion* equationOfMotion =
253  fFieldPropagator->GetChordFinder()->GetIntegrationDriver()->GetEquationOfMotion();
254 
255  equationOfMotion
256  ->SetChargeMomentumMass( chargeState, // Was particleMagneticCharge - in Mev/c
257  momentumMagnitude, // Was particleElectricCharge
258  restMass ) ;
259  // SetChargeMomentumMass now passes both the electric and magnetic charge - in chargeState
260 
261  G4ThreeVector spin = track.GetPolarization() ;
262  G4FieldTrack aFieldTrack = G4FieldTrack( startPosition,
263  track.GetMomentumDirection(),
264  0.0,
265  track.GetKineticEnergy(),
266  restMass,
267  track.GetVelocity(),
268  track.GetGlobalTime(), // Lab.
269  track.GetProperTime(), // Part.
270  &spin ) ;
271  if( currentMinimumStep > 0 )
272  {
273  // Do the Transport in the field (non recti-linear)
274  //
275  lengthAlongCurve = fFieldPropagator->ComputeStep( aFieldTrack,
276  currentMinimumStep,
277  currentSafety,
278  track.GetVolume() ) ;
279  fGeometryLimitedStep= lengthAlongCurve < currentMinimumStep;
280  if( fGeometryLimitedStep ) {
281  geometryStepLength = lengthAlongCurve ;
282  } else {
283  geometryStepLength = currentMinimumStep ;
284  }
285  }
286  else
287  {
288  geometryStepLength = lengthAlongCurve= 0.0 ;
290  }
291 
292  // Remember last safety origin & value.
293  //
294  fPreviousSftOrigin = startPosition ;
295  fPreviousSafety = currentSafety ;
296  // fpSafetyHelper->SetCurrentSafety( newSafety, startPosition);
297 
298  // Get the End-Position and End-Momentum (Dir-ection)
299  //
300  fTransportEndPosition = aFieldTrack.GetPosition() ;
301 
302  // Momentum: Magnitude and direction can be changed too now ...
303  //
305  fTransportEndMomentumDir = aFieldTrack.GetMomentumDir() ;
306 
307  fTransportEndKineticEnergy = aFieldTrack.GetKineticEnergy() ;
308 
309  fCandidateEndGlobalTime = aFieldTrack.GetLabTimeOfFlight();
310  fEndGlobalTimeComputed = true;
311 
312  fTransportEndSpin = aFieldTrack.GetSpin();
313  fParticleIsLooping = fFieldPropagator->IsParticleLooping() ;
314  endpointDistance = (fTransportEndPosition - startPosition).mag() ;
315  }
316 
317  // If we are asked to go a step length of 0, and we are on a boundary
318  // then a boundary will also limit the step -> we must flag this.
319  //
320  if( currentMinimumStep == 0.0 )
321  {
322  if( currentSafety == 0.0 ) fGeometryLimitedStep = true ;
323  }
324 
325  // Update the safety starting from the end-point,
326  // if it will become negative at the end-point.
327  //
328  if( currentSafety < endpointDistance )
329  {
330  // if( particleMagneticCharge == 0.0 )
331  // G4cout << " Avoiding call to ComputeSafety : charge = 0.0 " << G4endl;
332 
333  if( particleMagneticCharge != 0.0 ) {
334 
335  G4double endSafety =
336  fLinearNavigator->ComputeSafety( fTransportEndPosition) ;
337  currentSafety = endSafety ;
338  fPreviousSftOrigin = fTransportEndPosition ;
339  fPreviousSafety = currentSafety ;
340  fpSafetyHelper->SetCurrentSafety( currentSafety, fTransportEndPosition);
341 
342  // Because the Stepping Manager assumes it is from the start point,
343  // add the StepLength
344  //
345  currentSafety += endpointDistance ;
346 
347 #ifdef G4DEBUG_TRANSPORT
348  G4cout.precision(12) ;
349  G4cout << "***MonopoleTransportation::AlongStepGPIL ** " << G4endl ;
350  G4cout << " Called Navigator->ComputeSafety at " << fTransportEndPosition
351  << " and it returned safety= " << endSafety << G4endl ;
352  G4cout << " Adding endpoint distance " << endpointDistance
353  << " to obtain pseudo-safety= " << currentSafety << G4endl ;
354 #endif
355  }
356  }
357 
358  fParticleChange.ProposeTrueStepLength(geometryStepLength) ;
359 
360  return geometryStepLength ;
361 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
selection
main part
Definition: corrVsCorr.py:98
T sqrt(T t)
Definition: SSEVec.h:18
void ConfigureForTrack(const G4Track *) override
G4ParticleChangeForTransport fParticleChange
G4PropagatorInField * fFieldPropagator
G4double MagneticCharge() const
Definition: Monopole.h:19
Square< F >::type sqr(const F &f)
Definition: Square.h:13
void SetMonopoleTracking(G4bool)
float spin(float ph)
G4VParticleChange* MonopoleTransportation::AtRestDoIt ( const G4Track &  ,
const G4Step &   
)
inlineoverride

Definition at line 115 of file MonopoleTransportation.h.

118  {return nullptr;};
G4double MonopoleTransportation::AtRestGetPhysicalInteractionLength ( const G4Track &  ,
G4ForceCondition *   
)
inlineoverride

Definition at line 109 of file MonopoleTransportation.h.

112  { return -1.0; };
G4bool MonopoleTransportation::DoesGlobalFieldExist ( )
inlineprotected

Definition at line 200 of file MonopoleTransportation.h.

Referenced by StartTracking().

201 {
202  G4TransportationManager* transportMgr;
203  transportMgr= G4TransportationManager::GetTransportationManager();
204 
205  // fFieldExists= transportMgr->GetFieldManager()->DoesFieldExist();
206  // return fFieldExists;
207  return transportMgr->GetFieldManager()->DoesFieldExist();
208 }
void MonopoleTransportation::EnableShortStepOptimisation ( G4bool  optimise = true)
inline

Definition at line 269 of file MonopoleTransportation.h.

270 {
271  fShortStepOptimisation=optimiseShortStep;
272 }
G4double MonopoleTransportation::GetMaxEnergyKilled ( ) const
inline

Definition at line 245 of file MonopoleTransportation.h.

246 {
247  return fMaxEnergyKilled;
248 }
G4PropagatorInField * MonopoleTransportation::GetPropagatorInField ( )
inline

Definition at line 195 of file MonopoleTransportation.h.

196 {
197  return fFieldPropagator;
198 }
G4PropagatorInField * fFieldPropagator
G4double MonopoleTransportation::GetSumEnergyKilled ( ) const
inline

Definition at line 250 of file MonopoleTransportation.h.

251 {
252  return fSumEnergyKilled;
253 }
G4double MonopoleTransportation::GetThresholdImportantEnergy ( ) const
inline

Definition at line 215 of file MonopoleTransportation.h.

216 {
218 }
G4int MonopoleTransportation::GetThresholdTrials ( ) const
inline

Definition at line 220 of file MonopoleTransportation.h.

221 {
222  return fThresholdTrials;
223 }
G4double MonopoleTransportation::GetThresholdWarningEnergy ( ) const
inline

Definition at line 210 of file MonopoleTransportation.h.

211 {
213 }
G4VParticleChange * MonopoleTransportation::PostStepDoIt ( const G4Track &  track,
const G4Step &  stepData 
)
override

Definition at line 503 of file MonopoleTransportation.cc.

References fCurrentTouchableHandle, fGeometryLimitedStep, fieldMgrCMS, fLinearNavigator, fParticleChange, nullptr, CMSFieldManager::SetMonopoleTracking(), and funct::true.

505 {
506  G4TouchableHandle retCurrentTouchable ; // The one to return
507 
508  fParticleChange.ProposeTrackStatus(track.GetTrackStatus()) ;
509 
510  // If the Step was determined by the volume boundary,
511  // logically relocate the particle
512 
514  {
515  // fCurrentTouchable will now become the previous touchable,
516  // and what was the previous will be freed.
517  // (Needed because the preStepPoint can point to the previous touchable)
518 
519  fLinearNavigator->SetGeometricallyLimitedStep() ;
521  LocateGlobalPointAndUpdateTouchableHandle( track.GetPosition(),
522  track.GetMomentumDirection(),
524  true ) ;
525  // Check whether the particle is out of the world volume
526  // If so it has exited and must be killed.
527  //
528  if( fCurrentTouchableHandle->GetVolume() == nullptr )
529  {
530  fParticleChange.ProposeTrackStatus( fStopAndKill ) ;
531  }
532  retCurrentTouchable = fCurrentTouchableHandle ;
533  fParticleChange.SetTouchableHandle( fCurrentTouchableHandle ) ;
534  }
535  else // fGeometryLimitedStep is false
536  {
537  // This serves only to move the Navigator's location
538  //
539  fLinearNavigator->LocateGlobalPointWithinVolume( track.GetPosition() ) ;
540 
541  // The value of the track's current Touchable is retained.
542  // (and it must be correct because we must use it below to
543  // overwrite the (unset) one in particle change)
544  // It must be fCurrentTouchable too ??
545  //
546  fParticleChange.SetTouchableHandle( track.GetTouchableHandle() ) ;
547  retCurrentTouchable = track.GetTouchableHandle() ;
548  } // endif ( fGeometryLimitedStep )
549 
550  const G4VPhysicalVolume* pNewVol = retCurrentTouchable->GetVolume() ;
551  const G4Material* pNewMaterial = nullptr ;
552  const G4VSensitiveDetector* pNewSensitiveDetector = nullptr ;
553 
554  if( pNewVol != nullptr )
555  {
556  pNewMaterial= pNewVol->GetLogicalVolume()->GetMaterial();
557  pNewSensitiveDetector= pNewVol->GetLogicalVolume()->GetSensitiveDetector();
558  }
559 
560  // ( <const_cast> pNewMaterial ) ;
561  // ( <const_cast> pNewSensitiveDetector) ;
562 
563  fParticleChange.SetMaterialInTouchable(
564  (G4Material *) pNewMaterial ) ;
565  fParticleChange.SetSensitiveDetectorInTouchable(
566  (G4VSensitiveDetector *) pNewSensitiveDetector ) ;
567 
568  const G4MaterialCutsCouple* pNewMaterialCutsCouple = nullptr;
569  if( pNewVol != nullptr )
570  {
571  pNewMaterialCutsCouple=pNewVol->GetLogicalVolume()->GetMaterialCutsCouple();
572  }
573 
574  if( pNewVol!=nullptr && pNewMaterialCutsCouple!=nullptr &&
575  pNewMaterialCutsCouple->GetMaterial()!=pNewMaterial )
576  {
577  // for parametrized volume
578  //
579  pNewMaterialCutsCouple =
580  G4ProductionCutsTable::GetProductionCutsTable()
581  ->GetMaterialCutsCouple(pNewMaterial,
582  pNewMaterialCutsCouple->GetProductionCuts());
583  }
584  fParticleChange.SetMaterialCutsCoupleInTouchable( pNewMaterialCutsCouple );
585 
586  // temporarily until Get/Set Material of ParticleChange,
587  // and StepPoint can be made const.
588  // Set the touchable in ParticleChange
589  // this must always be done because the particle change always
590  // uses this value to overwrite the current touchable pointer.
591  //
592  fParticleChange.SetTouchableHandle(retCurrentTouchable) ;
593 
594  // change to normal equation
596 
597  return &fParticleChange ;
598 }
#define nullptr
G4ParticleChangeForTransport fParticleChange
G4TouchableHandle fCurrentTouchableHandle
void SetMonopoleTracking(G4bool)
G4double MonopoleTransportation::PostStepGetPhysicalInteractionLength ( const G4Track &  ,
G4double  previousStepSize,
G4ForceCondition *  pForceCond 
)
override

Definition at line 493 of file MonopoleTransportation.cc.

Referenced by AlongStepDoIt().

496 {
497  *pForceCond = Forced ;
498  return DBL_MAX ; // was kInfinity ; but convention now is DBL_MAX
499 }
void MonopoleTransportation::ResetKilledStatistics ( G4int  report = 1)
inline

Definition at line 255 of file MonopoleTransportation.h.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout, and GeV.

256 {
257  if( report ) {
258  G4cout << " MonopoleTransportation: Statistics for looping particles " << G4endl;
259  G4cout << " Sum of energy of loopers killed: " << fSumEnergyKilled << G4endl;
260  G4cout << " Max energy of loopers killed: " << fMaxEnergyKilled << G4endl;
261  }
262 
263  fSumEnergyKilled= 0;
265 }
const double GeV
Definition: MathUtil.h:16
void MonopoleTransportation::SetPropagatorInField ( G4PropagatorInField *  pFieldPropagator)
inline

Definition at line 190 of file MonopoleTransportation.h.

191 {
192  fFieldPropagator= pFieldPropagator;
193 }
G4PropagatorInField * fFieldPropagator
void MonopoleTransportation::SetThresholdImportantEnergy ( G4double  newEnImp)
inline

Definition at line 230 of file MonopoleTransportation.h.

231 {
232  fThreshold_Important_Energy = newEnImp;
233 }
void MonopoleTransportation::SetThresholdTrials ( G4int  newMaxTrials)
inline

Definition at line 235 of file MonopoleTransportation.h.

236 {
237  fThresholdTrials = newMaxTrials;
238 }
void MonopoleTransportation::SetThresholdWarningEnergy ( G4double  newEnWarn)
inline

Definition at line 225 of file MonopoleTransportation.h.

226 {
227  fThreshold_Warning_Energy= newEnWarn;
228 }
void MonopoleTransportation::StartTracking ( G4Track *  aTrack)
override

Definition at line 607 of file MonopoleTransportation.cc.

References DoesGlobalFieldExist(), fCurrentTouchableHandle, fFieldPropagator, fieldMgrCMS, fNoLooperTrials, fPreviousSafety, and fPreviousSftOrigin.

608 {
609  // initialise pointer
610  if(!fieldMgrCMS) {
611  G4FieldManager* fieldMgr =
612  fFieldPropagator->FindAndSetFieldManager(aTrack->GetVolume());
613  fieldMgrCMS = static_cast<CMSFieldManager*>(fieldMgr);
614  }
615 
616  G4VProcess::StartTracking(aTrack);
617 
618  // The actions here are those that were taken in AlongStepGPIL
619  // when track.GetCurrentStepNumber()==1
620 
621  // reset safety value and center
622  //
623  fPreviousSafety = 0.0 ;
624  fPreviousSftOrigin = G4ThreeVector(0.,0.,0.) ;
625 
626  // reset looping counter -- for motion in field
627  fNoLooperTrials= 0;
628  // Must clear this state .. else it depends on last track's value
629  // --> a better solution would set this from state of suspended track TODO ?
630  // Was if( aTrack->GetCurrentStepNumber()==1 ) { .. }
631 
632  // ChordFinder reset internal state
633  //
634  if( DoesGlobalFieldExist() ) {
635  fFieldPropagator->ClearPropagatorState();
636  // Resets all state of field propagator class (ONLY)
637  // including safety values (in case of overlaps and to wipe for first track).
638 
639  G4ChordFinder* chordF= fFieldPropagator->GetChordFinder();
640  if( chordF ) chordF->ResetStepEstimate();
641  }
642 
643  // Make sure to clear the chord finders of all fields (ie managers)
644  G4FieldManagerStore* fieldMgrStore= G4FieldManagerStore::GetInstance();
645  fieldMgrStore->ClearAllChordFindersState();
646 
647  // Update the current touchable handle (from the track's)
648  //
649  fCurrentTouchableHandle = aTrack->GetTouchableHandle();
650 }
G4PropagatorInField * fFieldPropagator
G4TouchableHandle fCurrentTouchableHandle

Member Data Documentation

G4double MonopoleTransportation::endpointDistance
private

Definition at line 164 of file MonopoleTransportation.h.

Referenced by AlongStepGetPhysicalInteractionLength().

G4double MonopoleTransportation::fCandidateEndGlobalTime
private
sim::ChordFinderSetter* MonopoleTransportation::fChordFinderSetter
private

Definition at line 133 of file MonopoleTransportation.h.

G4TouchableHandle MonopoleTransportation::fCurrentTouchableHandle
private

Definition at line 152 of file MonopoleTransportation.h.

Referenced by MonopoleTransportation(), PostStepDoIt(), and StartTracking().

G4bool MonopoleTransportation::fEndGlobalTimeComputed
private
G4PropagatorInField* MonopoleTransportation::fFieldPropagator
private
G4bool MonopoleTransportation::fGeometryLimitedStep
private
CMSFieldManager* MonopoleTransportation::fieldMgrCMS
private
G4Navigator* MonopoleTransportation::fLinearNavigator
private
G4double MonopoleTransportation::fMaxEnergyKilled
private

Definition at line 179 of file MonopoleTransportation.h.

Referenced by AlongStepDoIt().

G4bool MonopoleTransportation::fMomentumChanged
private
G4int MonopoleTransportation::fNoLooperTrials
private

Definition at line 176 of file MonopoleTransportation.h.

Referenced by AlongStepDoIt(), and StartTracking().

G4ParticleChangeForTransport MonopoleTransportation::fParticleChange
private
const Monopole* MonopoleTransportation::fParticleDef
private

Definition at line 131 of file MonopoleTransportation.h.

Referenced by AlongStepGetPhysicalInteractionLength().

G4bool MonopoleTransportation::fParticleIsLooping
private
G4double MonopoleTransportation::fPreviousSafety
private
G4ThreeVector MonopoleTransportation::fPreviousSftOrigin
private
G4SafetyHelper* MonopoleTransportation::fpSafetyHelper
private
G4bool MonopoleTransportation::fShortStepOptimisation
private

Definition at line 183 of file MonopoleTransportation.h.

Referenced by AlongStepGetPhysicalInteractionLength().

G4double MonopoleTransportation::fSumEnergyKilled
private

Definition at line 178 of file MonopoleTransportation.h.

Referenced by AlongStepDoIt(), and ~MonopoleTransportation().

G4double MonopoleTransportation::fThreshold_Important_Energy
private

Definition at line 169 of file MonopoleTransportation.h.

Referenced by AlongStepDoIt().

G4double MonopoleTransportation::fThreshold_Warning_Energy
private

Definition at line 168 of file MonopoleTransportation.h.

Referenced by AlongStepDoIt().

G4int MonopoleTransportation::fThresholdTrials
private

Definition at line 170 of file MonopoleTransportation.h.

Referenced by AlongStepDoIt().

G4double MonopoleTransportation::fTransportEndKineticEnergy
private
G4ThreeVector MonopoleTransportation::fTransportEndMomentumDir
private
G4ThreeVector MonopoleTransportation::fTransportEndPosition
private
G4ThreeVector MonopoleTransportation::fTransportEndSpin
private