Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:13

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 // 
0029 // ------------------------------------------------------------
0030 //        GEANT 4  include file implementation
0031 // ------------------------------------------------------------
0032 //
0033 // Class description:
0034 //
0035 // G4Transportation is a process responsible for the transportation of 
0036 // a particle, i.e. the geometrical propagation encountering the 
0037 // geometrical sub-volumes of the detectors.
0038 // It is also tasked with part of updating the "safety".
0039 
0040 // =======================================================================
0041 // Created:  19 March 1997, J. Apostolakis
0042 // =======================================================================
0043 #ifndef G4Transportation_hh
0044 #define G4Transportation_hh 1
0045 
0046 #include "G4VProcess.hh"
0047 
0048 #include "G4Track.hh"
0049 #include "G4Step.hh"
0050 #include "G4ParticleChangeForTransport.hh"
0051 
0052 class G4Navigator;
0053 class G4PropagatorInField;
0054 class G4SafetyHelper; 
0055 class G4TransportationLogger;
0056 
0057 class G4Transportation : public G4VProcess 
0058 {
0059   // Concrete class that does the geometrical transport 
0060 
0061   public:  // with description
0062 
0063      G4Transportation( G4int verbosityLevel= 1, const G4String& aName = "Transportation");
0064      ~G4Transportation(); 
0065 
0066      G4double      AlongStepGetPhysicalInteractionLength(
0067                              const G4Track& track,
0068                                    G4double  previousStepSize,
0069                                    G4double  currentMinimumStep, 
0070                                    G4double& currentSafety,
0071                                    G4GPILSelection* selection
0072                             ); // override;
0073 
0074      G4VParticleChange* AlongStepDoIt(
0075                              const G4Track& track,
0076                              const G4Step& stepData
0077                             ); // override; 
0078 
0079      G4VParticleChange* PostStepDoIt(
0080                              const G4Track& track,
0081                              const G4Step&  stepData
0082                             ); // override;    
0083        // Responsible for the relocation
0084 
0085      G4double PostStepGetPhysicalInteractionLength(
0086                              const G4Track& ,
0087                              G4double   previousStepSize,
0088                              G4ForceCondition* pForceCond
0089                             ); // override;                            
0090        // Forces the PostStepDoIt action to be called, 
0091        // but does not limit the step
0092 
0093      inline G4bool FieldExertedForce() { return fFieldExertedForce; }
0094    
0095      G4PropagatorInField* GetPropagatorInField();
0096      void SetPropagatorInField( G4PropagatorInField* pFieldPropagator);
0097        // Access/set the assistant class that Propagate in a Field
0098 
0099      inline G4double GetThresholdWarningEnergy() const; 
0100      inline G4double GetThresholdImportantEnergy() const; 
0101      inline G4int GetThresholdTrials() const; 
0102 
0103      inline void SetThresholdWarningEnergy( G4double newEnWarn ); 
0104      inline void SetThresholdImportantEnergy( G4double newEnImp ); 
0105      inline void SetThresholdTrials(G4int newMaxTrials ); 
0106      // Get/Set parameters for killing loopers: 
0107      //   Above 'important' energy a 'looping' particle in field will 
0108      //   *NOT* be abandoned, except after fThresholdTrials attempts.
0109      // Below Warning energy, no verbosity for looping particles is issued
0110 
0111      void SetHighLooperThresholds(); // Shortcut method - old values (meant for HEP)   
0112      void SetLowLooperThresholds(); // Set low thresholds - for low-E applications
0113      void PushThresholdsToLogger(); // Inform logger of current thresholds
0114      void ReportLooperThresholds(); // Print values of looper thresholds
0115 
0116      inline G4double GetMaxEnergyKilled() const; 
0117      inline G4double GetSumEnergyKilled() const;
0118      inline void ResetKilledStatistics( G4int report = 1);      
0119      // Statistics for tracks killed (currently due to looping in field)
0120 
0121      inline void EnableShortStepOptimisation(G4bool optimise=true); 
0122      // Whether short steps < safety will avoid to call Navigator (if field=0)
0123 
0124      static G4bool EnableMagneticMoment(G4bool useMoment=true); 
0125      // Whether to enable particles to be deflected with force due to magnetic moment
0126 
0127      static G4bool EnableGravity(G4bool useGravity=true); 
0128      // Whether to enable particles to be deflected with force due to gravity
0129 
0130      static void   SetSilenceLooperWarnings( G4bool val);
0131      // Do not warn (or throw exception) about 'looping' particles
0132      static G4bool GetSilenceLooperWarnings();
0133    
0134   public: // without description    
0135      static G4bool EnableUseMagneticMoment(G4bool useMoment=true)
0136      { return EnableMagneticMoment(useMoment); }  // Old name - will be deprecated
0137    
0138   public:  // without description
0139 
0140      G4double AtRestGetPhysicalInteractionLength( const G4Track&,
0141                                                   G4ForceCondition*)
0142        { return -1.0; }  // No operation in AtRestGPIL
0143 
0144      G4VParticleChange* AtRestDoIt( const G4Track&, const G4Step& )
0145        { return 0; }     // No operation in AtRestDoIt
0146 
0147      void StartTracking(G4Track* aTrack);
0148        // Reset state for new (potentially resumed) track 
0149 
0150      virtual void ProcessDescription(std::ostream& outFile) const; // override;
0151      void PrintStatistics( std::ostream& outStr) const;
0152    
0153   protected:
0154 
0155      void SetTouchableInformation(const G4TouchableHandle& touchable);
0156 
0157      void ReportMissingLogger(const char * methodName);
0158    
0159   protected:
0160 
0161      G4Navigator* fLinearNavigator;
0162        // The navigator for the 'mass' geometry
0163        // (the real one, that physics occurs in)
0164      G4PropagatorInField* fFieldPropagator;
0165        // The Propagators used to transport the particle
0166 
0167      G4ThreeVector fTransportEndPosition=     G4ThreeVector( 0.0, 0.0, 0.0 );
0168      G4ThreeVector fTransportEndMomentumDir=  G4ThreeVector( 0.0, 0.0, 0.0 );
0169      G4double      fTransportEndKineticEnergy= 0.0;
0170      G4ThreeVector fTransportEndSpin=  G4ThreeVector( 0.0, 0.0, 0.0 );
0171      G4bool        fMomentumChanged=   true;
0172      G4bool        fEndGlobalTimeComputed= false; 
0173      G4double      fCandidateEndGlobalTime= 0.0;
0174        // The particle's state after this Step, Store for DoIt
0175 
0176      G4bool        fAnyFieldExists= false; 
0177    
0178      G4bool fParticleIsLooping = false;
0179      G4bool fNewTrack= true;          // Flag from StartTracking 
0180      G4bool fFirstStepInVolume= true;
0181      G4bool fLastStepInVolume= false;  // Last step - almost same as next flag
0182                                 // (temporary redundancy for checking) 
0183      G4bool fGeometryLimitedStep= true;
0184        // Flag to determine whether a boundary was reached
0185 
0186      G4bool fFieldExertedForce= false; // During current step
0187 
0188      G4TouchableHandle fCurrentTouchableHandle;
0189      
0190      G4ThreeVector fPreviousSftOrigin;
0191      G4double      fPreviousSafety; 
0192        // Remember last safety origin & value.
0193 
0194      G4ParticleChangeForTransport fParticleChange;
0195        // New ParticleChange
0196 
0197      G4double fEndPointDistance;
0198 
0199      // Thresholds for looping particles: 
0200      //
0201      G4double fThreshold_Warning_Energy =   1.0 * CLHEP::keV;  //  Warn above this energy
0202      G4double fThreshold_Important_Energy = 1.0 * CLHEP::MeV;  //  Give a few trial above this E
0203      G4int    fThresholdTrials = 10;       //  Number of trials an important looper survives
0204        // Above 'important' energy a 'looping' particle in field will 
0205        // *NOT* be abandoned, except after fThresholdTrials attempts.
0206      G4int    fAbandonUnstableTrials = 0;  //  Number of trials after which to abandon
0207                                            //   unstable loopers ( 0 = never )
0208      // Counter for steps in which particle reports 'looping',
0209      //  ( Used if it is above 'Important' Energy. )
0210      G4int    fNoLooperTrials= 0; 
0211 
0212      // Statistics for tracks abandoned due to looping - and 'saved' despite looping
0213      //
0214      G4double fSumEnergyKilled= 0.0;
0215      G4double fSumEnerSqKilled= 0.0;   
0216      G4double fMaxEnergyKilled= -1.0;
0217      G4int    fMaxEnergyKilledPDG= 0;
0218      unsigned long fNumLoopersKilled= 0;
0219      G4double fSumEnergyKilled_NonElectron= 0.0;
0220      G4double fSumEnerSqKilled_NonElectron= 0.0;
0221      G4double fMaxEnergyKilled_NonElectron= -1.0;
0222      G4int    fMaxEnergyKilled_NonElecPDG= 0;
0223      unsigned long fNumLoopersKilled_NonElectron= 0;
0224      G4double fSumEnergySaved=  0.0;
0225      G4double fMaxEnergySaved= -1.0;
0226      G4double fSumEnergyUnstableSaved = 0.0;
0227      // Whether to avoid calling G4Navigator for short step ( < safety)
0228      // If using it, the safety estimate for endpoint will likely be smaller.
0229      //
0230      G4bool   fShortStepOptimisation; 
0231 
0232      G4SafetyHelper* fpSafetyHelper;    // To pass it the safety value obtained
0233      G4TransportationLogger* fpLogger;  // Reports issues / raises warnings
0234 
0235   protected:
0236 
0237      static G4bool fUseMagneticMoment;
0238      static G4bool fUseGravity;
0239      static G4bool fSilenceLooperWarnings;  // Flag to *Supress* all 'looper' warnings
0240    
0241 };
0242 
0243 #include "G4Transportation.icc"
0244 
0245 #endif