CMS 3D CMS Logo

MonopoleTransportation.h
Go to the documentation of this file.
1 //
2 // =======================================================================
3 //
4 // Class MonopoleTransportation
5 //
6 // Created: 3 May 2010, J. Apostolakis, B. Bozsogi
7 // G4MonopoleTransportation class for
8 // Geant4 extended example "monopole"
9 //
10 // Adopted for CMSSW by V.Ivanchenko 30 April 2018
11 // from Geant4 global tag geant4-10-04-ref-03
12 //
13 // =======================================================================
14 //
15 // Class description:
16 //
17 // G4MonopoleTransportation is a process responsible for the transportation of
18 // magnetic monopoles, i.e. the geometrical propagation encountering the
19 // geometrical sub-volumes of the detectors.
20 // It is also tasked with part of updating the "safety".
21 // For monopoles, uses a different equation of motion and ignores energy
22 // conservation.
23 //
24 
25 #ifndef SimG4Core_PhysicsLists_MonopoleTransportation_h
26 #define SimG4Core_PhysicsLists_MonopoleTransportation_h 1
27 
28 #include "G4VProcess.hh"
29 #include "G4FieldManager.hh"
30 
31 #include "G4Navigator.hh"
32 #include "G4TransportationManager.hh"
33 #include "G4PropagatorInField.hh"
34 #include "G4Track.hh"
35 #include "G4Step.hh"
36 #include "G4ParticleChangeForTransport.hh"
37 #include "CLHEP/Units/SystemOfUnits.h"
38 
39 #include <memory>
40 
41 class G4SafetyHelper;
42 class Monopole;
43 class CMSFieldManager;
44 
45 class MonopoleTransportation : public G4VProcess {
46 public:
48  ~MonopoleTransportation() override;
49 
50  G4double AlongStepGetPhysicalInteractionLength(const G4Track& track,
51  G4double previousStepSize,
52  G4double currentMinimumStep,
53  G4double& currentSafety,
54  G4GPILSelection* selection) override;
55 
56  G4VParticleChange* AlongStepDoIt(const G4Track& track, const G4Step& stepData) override;
57 
58  G4VParticleChange* PostStepDoIt(const G4Track& track, const G4Step& stepData) override;
59  // Responsible for the relocation.
60 
61  G4double PostStepGetPhysicalInteractionLength(const G4Track&,
62  G4double previousStepSize,
63  G4ForceCondition* pForceCond) override;
64  // Forces the PostStepDoIt action to be called,
65  // but does not limit the step.
66 
67  G4PropagatorInField* GetPropagatorInField();
68  void SetPropagatorInField(G4PropagatorInField* pFieldPropagator);
69  // Access/set the assistant class that Propagate in a Field.
70 
71  inline G4double GetThresholdWarningEnergy() const;
72  inline G4double GetThresholdImportantEnergy() const;
73  inline G4int GetThresholdTrials() const;
74 
75  inline void SetThresholdWarningEnergy(G4double newEnWarn);
76  inline void SetThresholdImportantEnergy(G4double newEnImp);
77  inline void SetThresholdTrials(G4int newMaxTrials);
78 
79  // Get/Set parameters for killing loopers:
80  // Above 'important' energy a 'looping' particle in field will
81  // *NOT* be abandoned, except after fThresholdTrials attempts.
82  // Below Warning energy, no verbosity for looping particles is issued
83 
84  inline G4double GetMaxEnergyKilled() const;
85  inline G4double GetSumEnergyKilled() const;
86  void ResetKilledStatistics(G4int report = 1);
87  // Statistics for tracks killed (currently due to looping in field)
88 
89  inline void EnableShortStepOptimisation(G4bool optimise = true);
90  // Whether short steps < safety will avoid to call Navigator (if field=0)
91 
92  G4double AtRestGetPhysicalInteractionLength(const G4Track&, G4ForceCondition*) override;
93 
94  G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&) override;
95  // No operation in AtRestDoIt.
96 
97  void StartTracking(G4Track* aTrack) override;
98  // Reset state for new (potentially resumed) track
99 
100 protected:
101  G4bool DoesGlobalFieldExist();
102  // Checks whether a field exists for the "global" field manager.
103 
104 private:
106 
108 
109  G4Navigator* fLinearNavigator;
110  G4PropagatorInField* fFieldPropagator;
111  // The Propagators used to transport the particle
112 
113  G4ThreeVector fTransportEndPosition;
116  G4ThreeVector fTransportEndSpin;
118 
121  // The particle's state after this Step, Store for DoIt
122 
124 
125  G4TouchableHandle fCurrentTouchableHandle;
126 
128  // Flag to determine whether a boundary was reached.
129 
130  G4ThreeVector fPreviousSftOrigin;
131  G4double fPreviousSafety;
132  // Remember last safety origin & value.
133 
134  G4ParticleChangeForTransport fParticleChange;
135  // New ParticleChange
136 
138 
139  // Thresholds for looping particles:
140  //
141  G4double fThreshold_Warning_Energy; // Warn above this energy
142  G4double fThreshold_Important_Energy; // Hesitate above this
143  G4int fThresholdTrials; // for this no of trials
144  // Above 'important' energy a 'looping' particle in field will
145  // *NOT* be abandoned, except after fThresholdTrials attempts.
146 
147  // Counter for steps in which particle reports 'looping',
148  // if it is above 'Important' Energy
150  // Statistics for tracks abandoned
153 
154  // Whether to avoid calling G4Navigator for short step ( < safety)
155  // If using it, the safety estimate for endpoint will likely be smaller.
157 
158  G4SafetyHelper* fpSafetyHelper; // To pass it the safety value obtained
159 };
160 
161 inline void MonopoleTransportation::SetPropagatorInField(G4PropagatorInField* pFieldPropagator) {
162  fFieldPropagator = pFieldPropagator;
163 }
164 
165 inline G4PropagatorInField* MonopoleTransportation::GetPropagatorInField() { return fFieldPropagator; }
166 
168  G4TransportationManager* transportMgr = G4TransportationManager::GetTransportationManager();
169  return transportMgr->GetFieldManager()->DoesFieldExist();
170 }
171 
173 
175 
177 
178 inline void MonopoleTransportation::SetThresholdWarningEnergy(G4double newEnWarn) {
179  fThreshold_Warning_Energy = newEnWarn;
180 }
181 
183  fThreshold_Important_Energy = newEnImp;
184 }
185 
186 inline void MonopoleTransportation::SetThresholdTrials(G4int newMaxTrials) { fThresholdTrials = newMaxTrials; }
187 
188 // Get parameters for killing loopers:
189 // Above 'important' energy a 'looping' particle in field will
190 // *NOT* be abandoned, except after fThresholdTrials attempts.
191 // Below Warning energy, no verbosity for looping particles is issued
192 
194 
196 
197 inline void MonopoleTransportation::EnableShortStepOptimisation(G4bool optimiseShortStep) {
198  fShortStepOptimisation = optimiseShortStep;
199 }
200 
201 #endif
G4PropagatorInField * GetPropagatorInField()
void SetThresholdTrials(G4int newMaxTrials)
void StartTracking(G4Track *aTrack) override
selection
main part
Definition: corrVsCorr.py:100
G4double GetThresholdWarningEnergy() const
G4double GetMaxEnergyKilled() const
void ResetKilledStatistics(G4int report=1)
G4double AtRestGetPhysicalInteractionLength(const G4Track &, G4ForceCondition *) override
verbosityLevel
L1 selection andOrL1 = cms.bool( True ), l1Algorithms = cms.vstring("L1_ZeroBias_FirstCollidingBunch"...
G4double GetSumEnergyKilled() const
void SetThresholdWarningEnergy(G4double newEnWarn)
G4double GetThresholdImportantEnergy() const
G4ParticleChangeForTransport fParticleChange
void SetThresholdImportantEnergy(G4double newEnImp)
G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &currentSafety, G4GPILSelection *selection) override
G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double previousStepSize, G4ForceCondition *pForceCond) override
MonopoleTransportation(const Monopole *p, G4int verbosityLevel=1)
G4PropagatorInField * fFieldPropagator
G4VParticleChange * AtRestDoIt(const G4Track &, const G4Step &) override
void SetPropagatorInField(G4PropagatorInField *pFieldPropagator)
G4TouchableHandle fCurrentTouchableHandle
void EnableShortStepOptimisation(G4bool optimise=true)
G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &stepData) override
G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData) override