Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // 27 // 28 // 28 // 29 // ------------------------------------------- 29 // ------------------------------------------------------------ 30 // GEANT 4 include file implementation 30 // GEANT 4 include file implementation 31 // ------------------------------------------- 31 // ------------------------------------------------------------ 32 // 32 // 33 // Class description: 33 // Class description: 34 // 34 // 35 // G4CoupledTransportation is an optional proc 35 // G4CoupledTransportation is an optional process to transport 36 // a particle, in case of coupled navigation i 36 // a particle, in case of coupled navigation in parallel geometries 37 // i.e. the geometrical propagation will be d 37 // i.e. the geometrical propagation will be done 38 // encountering the geometrical volumes of t 38 // encountering the geometrical volumes of the detectors and 39 // those of parallel geometries (eg for bias 39 // those of parallel geometries (eg for biasing, scoring, fast simulation) 40 // It is tasked with updating the "safety" to 40 // It is tasked with updating the "safety" to reflect the geometrical 41 // distance to the nearest volume, and the t 41 // distance to the nearest volume, and the time of flight of the particle. 42 42 43 // =========================================== 43 // ======================================================================= 44 // Created: 17 May 2006, J. Apostolakis 44 // Created: 17 May 2006, J. Apostolakis 45 // =========================================== 45 // ======================================================================= 46 #ifndef G4CoupledTransportation_hh 46 #ifndef G4CoupledTransportation_hh 47 #define G4CoupledTransportation_hh 1 47 #define G4CoupledTransportation_hh 1 48 48 49 #include "G4Transportation.hh" << 49 #include "G4VProcess.hh" >> 50 >> 51 #include "G4FieldManager.hh" >> 52 >> 53 #include "G4Navigator.hh" >> 54 #include "G4TransportationManager.hh" >> 55 #include "G4PropagatorInField.hh" >> 56 #include "G4PathFinder.hh" 50 57 51 #include "G4Track.hh" 58 #include "G4Track.hh" 52 #include "G4Step.hh" 59 #include "G4Step.hh" >> 60 #include "G4ParticleChangeForTransport.hh" 53 61 54 class G4PathFinder; << 62 class G4SafetyHelper; >> 63 class G4TransportationLogger; 55 64 56 class G4CoupledTransportation : public G4Trans << 65 class G4CoupledTransportation : public G4VProcess 57 { 66 { >> 67 // Concrete class that does the geometrical transport 58 68 59 public: // with description 69 public: // with description 60 70 61 G4CoupledTransportation( G4int verbosityL 71 G4CoupledTransportation( G4int verbosityLevel= 0); 62 ~G4CoupledTransportation(); 72 ~G4CoupledTransportation(); 63 73 64 G4double AlongStepGetPhysicalInterac 74 G4double AlongStepGetPhysicalInteractionLength( 65 const G4Track& tr 75 const G4Track& track, 66 G4double p 76 G4double previousStepSize, 67 G4double c 77 G4double currentMinimumStep, 68 G4double& c 78 G4double& currentSafety, 69 G4GPILSelec 79 G4GPILSelection* selection 70 ); 80 ); 71 81 72 // AlongStepDoIt is implemented by G4Tran << 82 G4VParticleChange* AlongStepDoIt( >> 83 const G4Track& track, >> 84 const G4Step& stepData >> 85 ); 73 86 74 G4VParticleChange* PostStepDoIt( 87 G4VParticleChange* PostStepDoIt( 75 const G4Track& tr 88 const G4Track& track, 76 const G4Step& st 89 const G4Step& stepData 77 ); 90 ); 78 // Responsible for the relocation 91 // Responsible for the relocation 79 92 80 // PostStepGetPhysicalInteractionLength i << 93 G4double PostStepGetPhysicalInteractionLength( 81 // G4Transportation to force PostStepDoIt << 94 const G4Track& , >> 95 G4double previousStepSize, >> 96 G4ForceCondition* pForceCond >> 97 ); >> 98 // Forces the PostStepDoIt action to be called, >> 99 // but does not limit the step 82 100 >> 101 G4PropagatorInField* GetPropagatorInField(); >> 102 void SetPropagatorInField( G4PropagatorInField* pFieldPropagator); >> 103 // Access/set the assistant class that Propagate in a Field >> 104 >> 105 inline G4double GetThresholdWarningEnergy() const; >> 106 inline G4double GetThresholdImportantEnergy() const; >> 107 inline G4int GetThresholdTrials() const; >> 108 >> 109 inline void SetThresholdWarningEnergy( G4double newEnWarn ); >> 110 inline void SetThresholdImportantEnergy( G4double newEnImp ); >> 111 inline void SetThresholdTrials(G4int newMaxTrials ); >> 112 >> 113 void SetHighLooperThresholds(); // Shortcut method - old values (meant for HEP) >> 114 void SetLowLooperThresholds(); // Set low thresholds - for low-E applications >> 115 void PushThresholdsToLogger(); // Inform logger of current thresholds >> 116 void ReportLooperThresholds(); // Print values of looper thresholds >> 117 >> 118 // Get/Set parameters for killing loopers: >> 119 // Above 'important' energy a 'looping' particle in field will >> 120 // *NOT* be abandoned, except after fThresholdTrials attempts. >> 121 // Below Warning energy, no verbosity for looping particles is issued >> 122 >> 123 inline G4double GetMaxEnergyKilled() const; >> 124 inline G4double GetSumEnergyKilled() const; >> 125 inline void ResetKilledStatistics( G4int report = 1); >> 126 // Statistics for tracks killed (currently due to looping in field) >> 127 >> 128 static G4bool EnableMagneticMoment(G4bool useMoment=true); >> 129 // Whether to deflect particles with force due to magnetic moment >> 130 >> 131 static G4bool EnableGravity(G4bool useGravity); >> 132 // Turn on the capability to deflect particles with a gravity field >> 133 >> 134 static void SetSilenceLooperWarnings( G4bool val); >> 135 // Do not warn (or throw exception) about 'looping' particles >> 136 static G4bool GetSilenceLooperWarnings(); >> 137 83 static void SetSignifyStepsInAnyVolume( 138 static void SetSignifyStepsInAnyVolume( G4bool anyVol ) 84 { fSignifyStepInAnyVolume = anyVol; } 139 { fSignifyStepInAnyVolume = anyVol; } 85 static G4bool GetSignifyStepsInAnyVolume( 140 static G4bool GetSignifyStepsInAnyVolume() 86 { return fSignifyStepInAnyVolume; } 141 { return fSignifyStepInAnyVolume; } 87 // Flag in step corresponds to first/last 142 // Flag in step corresponds to first/last step in a volume 'any' 88 // geometry (if this is true) or refers t 143 // geometry (if this is true) or refers to first/last step in mass 89 // geometry only (if false) 144 // geometry only (if false) 90 145 91 // The following methods give access to f 146 // The following methods give access to first/last step in particular 92 // geometry *independent* of the choice o 147 // geometry *independent* of the choice of the 'Signify' flag 93 // 148 // 94 G4bool IsFirstStepInAnyVolume() const { r << 149 G4bool IsFirstStepInAnyVolume() const { return fFirstStepInAnyVolume; } 95 G4bool IsLastStepInAnyVolume() const { re << 150 G4bool IsLastStepInAnyVolume() const { return fAnyGeometryLimitedStep; } 96 G4bool IsFirstStepInMassVolume() const { 151 G4bool IsFirstStepInMassVolume() const { return fFirstStepInMassVolume; } 97 G4bool IsLastStepInMassVolume() const { r 152 G4bool IsLastStepInMassVolume() const { return fMassGeometryLimitedStep; } 98 153 99 public: // without description 154 public: // without description 100 155 101 void StartTracking(G4Track* aTrack); 156 void StartTracking(G4Track* aTrack); 102 void EndTracking(); 157 void EndTracking(); 103 158 104 static G4bool EnableUseMagneticMoment(G4b 159 static G4bool EnableUseMagneticMoment(G4bool useMoment=true) 105 { return EnableMagneticMoment(useMoment) 160 { return EnableMagneticMoment(useMoment); } 106 // Old name ... obsolete 161 // Old name ... obsolete 107 162 >> 163 G4double AtRestGetPhysicalInteractionLength( const G4Track& , >> 164 G4ForceCondition* ) >> 165 { return -1.0; } // No operation in AtRestGPIL >> 166 >> 167 G4VParticleChange* AtRestDoIt( const G4Track&, const G4Step&) >> 168 { return 0; } // No operation in AtRestDoIt >> 169 >> 170 void PrintStatistics( std::ostream& outStr) const; >> 171 108 protected: 172 protected: 109 173 >> 174 G4bool DoesAnyFieldExist(); >> 175 // Check whether any field exists in the geometry >> 176 // - replaces method that checked only whether a field for the world volume >> 177 110 void ReportInexactEnergy(G4double startEn 178 void ReportInexactEnergy(G4double startEnergy, G4double endEnergy); 111 // Issue warning 179 // Issue warning 112 180 113 void ReportMove( G4ThreeVector OldVector, 181 void ReportMove( G4ThreeVector OldVector, G4ThreeVector NewVector, 114 const G4String& Quantity 182 const G4String& Quantity ); 115 183 >> 184 void ReportMissingLogger(const char * methodName); >> 185 116 private: 186 private: 117 187 >> 188 G4Navigator* fMassNavigator; >> 189 // The navigator for the 'mass' geometry >> 190 // (the real one, that physics occurs in) 118 G4PathFinder* fPathFinder; 191 G4PathFinder* fPathFinder; >> 192 G4int fNavigatorId; 119 // The PathFinder used to transport the 193 // The PathFinder used to transport the particle 120 194 >> 195 G4PropagatorInField* fFieldPropagator; >> 196 // Still required in order to find/set the fieldmanager >> 197 >> 198 G4bool fAnyFieldExists; >> 199 // G4bool fStartedNewTrack; // True for first step or restarted tracking >> 200 // until first step's AlongStepGPIL >> 201 >> 202 G4ThreeVector fTransportEndPosition; >> 203 G4ThreeVector fTransportEndMomentumDir; >> 204 G4double fTransportEndKineticEnergy; >> 205 G4ThreeVector fTransportEndSpin; >> 206 G4bool fMomentumChanged; >> 207 // The particle's state after this Step, Store for DoIt >> 208 >> 209 G4bool fEndGlobalTimeComputed; >> 210 G4double fCandidateEndGlobalTime; >> 211 >> 212 G4bool fParticleIsLooping; >> 213 G4bool fNewTrack; >> 214 G4ThreeVector fPreviousSftOrigin; 121 G4double fPreviousMassSafety; 215 G4double fPreviousMassSafety; 122 G4double fPreviousFullSafety; 216 G4double fPreviousFullSafety; 123 217 >> 218 G4TouchableHandle fCurrentTouchableHandle; >> 219 >> 220 // G4bool fFieldExists; >> 221 // Whether a magnetic field exists ... >> 222 // A data member for this is problematic: it is useful only if it >> 223 // can be initialised and updated -- and a scheme is not yet possible. >> 224 124 G4bool fMassGeometryLimitedStep; 225 G4bool fMassGeometryLimitedStep; 125 // Flag to determine whether a 'mass' b 226 // Flag to determine whether a 'mass' boundary was reached. >> 227 G4bool fAnyGeometryLimitedStep; >> 228 // Did any geometry limit the step ? >> 229 >> 230 G4ParticleChangeForTransport fParticleChange; >> 231 // New ParticleChange >> 232 >> 233 G4double fEndpointDistance; >> 234 >> 235 >> 236 // Thresholds for looping particles: >> 237 // >> 238 G4double fThreshold_Warning_Energy = 1.0 * CLHEP::keV; // Warn above this energy >> 239 G4double fThreshold_Important_Energy = 1.0 * CLHEP::MeV; // Give a few trial above this E >> 240 G4int fThresholdTrials = 10; // Number of trials an important looper survives >> 241 // Above 'important' energy a 'looping' particle in field will >> 242 // *NOT* be abandoned, except after fThresholdTrials attempts. >> 243 >> 244 // Counter for steps in which particle reports 'looping', >> 245 // if it is above 'Important' Energy >> 246 // >> 247 G4int fNoLooperTrials=0; >> 248 >> 249 // Statistics for tracks abandoned >> 250 // >> 251 G4double fSumEnergyKilled= 0.0; >> 252 G4double fSumEnerSqKilled= 0.0; >> 253 G4double fMaxEnergyKilled= -1.0; >> 254 G4int fMaxEnergyKilledPDG= 0; >> 255 unsigned long fNumLoopersKilled= 0; >> 256 G4double fSumEnergyKilled_NonElectron= 0.0; >> 257 G4double fSumEnerSqKilled_NonElectron= 0.0; >> 258 G4double fMaxEnergyKilled_NonElectron= -1.0; >> 259 G4int fMaxEnergyKilled_NonElecPDG= 0; >> 260 unsigned long fNumLoopersKilled_NonElectron= 0; >> 261 G4double fSumEnergySaved= 0.0; >> 262 G4double fMaxEnergySaved= -1.0; >> 263 G4double fSumEnergyUnstableSaved = 0.0; >> 264 >> 265 G4SafetyHelper* fpSafetyHelper; // To pass it the safety value obtained >> 266 G4TransportationLogger* fpLogger; // Reports issues / raises warnings >> 267 >> 268 private: >> 269 >> 270 friend class G4Transportation; >> 271 static G4bool fUseMagneticMoment; >> 272 static G4bool fUseGravity; >> 273 static G4bool fSilenceLooperWarnings; // Flag to *Supress* all 'looper' warnings 126 274 127 private: 275 private: 128 276 129 G4bool fFirstStepInMassVolume; 277 G4bool fFirstStepInMassVolume; >> 278 G4bool fFirstStepInAnyVolume; 130 // G4bool fLastStepInMassVolume; => use f 279 // G4bool fLastStepInMassVolume; => use fMassGeometryLimitedStep >> 280 // G4bool fLastStepInAnyVolume; => use fAnyGeometryLimitedStep 131 281 132 static G4bool fSignifyStepInAnyVolume; 282 static G4bool fSignifyStepInAnyVolume; 133 // True: First/Last step in any one of 283 // True: First/Last step in any one of the geometries 134 // False: First/Last step in volume of 284 // False: First/Last step in volume of 'mass' geometry 135 }; 285 }; >> 286 >> 287 #include "G4CoupledTransportation.icc" 136 288 137 #endif 289 #endif 138 290