Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 08:31: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 /// \file G4MonopoleTransportation.hh
0027 /// \brief Definition of the G4MonopoleTransportation class
0028 
0029 // ------------------------------------------------------------
0030 //        GEANT 4  include file implementation
0031 // ------------------------------------------------------------
0032 //
0033 // Class description:
0034 //
0035 // G4MonopoleTransportation is a process responsible for the transportation of
0036 // magnetic monopoles, 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:  3 May 2010, J. Apostolakis, B. Bozsogi
0042 // =======================================================================
0043 
0044 #ifndef G4MonopoleTransportation_hh
0045 #define G4MonopoleTransportation_hh 1
0046 
0047 #include "G4FieldManager.hh"
0048 #include "G4MonopoleFieldSetup.hh"
0049 #include "G4Navigator.hh"
0050 #include "G4ParticleChangeForTransport.hh"
0051 #include "G4PropagatorInField.hh"
0052 #include "G4Step.hh"
0053 #include "G4Track.hh"
0054 #include "G4TransportationManager.hh"
0055 #include "G4VProcess.hh"
0056 
0057 class G4SafetyHelper;
0058 class G4Monopole;
0059 
0060 class G4MonopoleTransportation : public G4VProcess
0061 {
0062     // Concrete class that does the geometrical transport
0063 
0064   public:  // with description
0065     G4MonopoleTransportation(const G4Monopole* p, G4int verbosityLevel = 1);
0066     ~G4MonopoleTransportation();
0067 
0068     virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track,
0069                                                            G4double previousStepSize,
0070                                                            G4double currentMinimumStep,
0071                                                            G4double& currentSafety,
0072                                                            G4GPILSelection* selection);
0073 
0074     virtual G4VParticleChange* AlongStepDoIt(const G4Track& track, const G4Step& stepData);
0075 
0076     virtual G4VParticleChange* PostStepDoIt(const G4Track& track, const G4Step& stepData);
0077     // Responsible for the relocation.
0078 
0079     virtual G4double PostStepGetPhysicalInteractionLength(const G4Track&, G4double previousStepSize,
0080                                                           G4ForceCondition* pForceCond);
0081     // Forces the PostStepDoIt action to be called,
0082     // but does not limit the step.
0083 
0084     G4PropagatorInField* GetPropagatorInField();
0085     void SetPropagatorInField(G4PropagatorInField* pFieldPropagator);
0086     // Access/set the assistant class that Propagate in a Field.
0087 
0088     inline G4double GetThresholdWarningEnergy() const;
0089     inline G4double GetThresholdImportantEnergy() const;
0090     inline G4int GetThresholdTrials() const;
0091 
0092     inline void SetThresholdWarningEnergy(G4double newEnWarn);
0093     inline void SetThresholdImportantEnergy(G4double newEnImp);
0094     inline void SetThresholdTrials(G4int newMaxTrials);
0095 
0096     // Get/Set parameters for killing loopers:
0097     //   Above 'important' energy a 'looping' particle in field will
0098     //   *NOT* be abandoned, except after fThresholdTrials attempts.
0099     // Below Warning energy, no verbosity for looping particles is issued
0100 
0101     inline G4double GetMaxEnergyKilled() const;
0102     inline G4double GetSumEnergyKilled() const;
0103     inline void ResetKilledStatistics(G4int report = 1);
0104     // Statistics for tracks killed (currently due to looping in field)
0105 
0106     inline void EnableShortStepOptimisation(G4bool optimise = true);
0107     // Whether short steps < safety will avoid to call Navigator (if field=0)
0108 
0109   public:  // without description
0110     virtual G4double AtRestGetPhysicalInteractionLength(const G4Track&, G4ForceCondition*)
0111     {
0112       return -1.0;
0113     };
0114     // No operation in  AtRestDoIt.
0115 
0116     virtual G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&) { return 0; };
0117     // No operation in  AtRestDoIt.
0118 
0119     G4double GetZmagFieldValue() const { return fMagSetup->GetZmagFieldValue(); }
0120 
0121     virtual void StartTracking(G4Track* aTrack);
0122     // Reset state for new (potentially resumed) track
0123 
0124   protected:
0125     G4bool DoesGlobalFieldExist();
0126     // Checks whether a field exists for the "global" field manager.
0127 
0128   private:
0129     const G4Monopole* fParticleDef;
0130 
0131     G4MonopoleFieldSetup* fMagSetup;
0132 
0133     G4Navigator* fLinearNavigator;
0134     G4PropagatorInField* fFieldPropagator;
0135     // The Propagators used to transport the particle
0136 
0137     G4ThreeVector fTransportEndPosition;
0138     G4ThreeVector fTransportEndMomentumDir;
0139     G4double fTransportEndKineticEnergy;
0140     G4ThreeVector fTransportEndSpin;
0141     G4bool fMomentumChanged;
0142     //  G4bool               fEnergyChanged;
0143     G4bool fEndGlobalTimeComputed;
0144     G4double fCandidateEndGlobalTime;
0145     // The particle's state after this Step, Store for DoIt
0146 
0147     G4bool fParticleIsLooping;
0148 
0149     G4TouchableHandle fCurrentTouchableHandle;
0150 
0151     G4bool fGeometryLimitedStep;
0152     // Flag to determine whether a boundary was reached.
0153 
0154     G4ThreeVector fPreviousSftOrigin;
0155     G4double fPreviousSafety;
0156     // Remember last safety origin & value.
0157 
0158     G4ParticleChangeForTransport fParticleChange;
0159     // New ParticleChange
0160 
0161     G4double endpointDistance;
0162 
0163     // Thresholds for looping particles:
0164     //
0165     G4double fThreshold_Warning_Energy;  //  Warn above this energy
0166     G4double fThreshold_Important_Energy;  //  Hesitate above this
0167     G4int fThresholdTrials;  //    for this no of trials
0168                              // Above 'important' energy a 'looping' particle in field will
0169                              //   *NOT* be abandoned, except after fThresholdTrials attempts.
0170     // G4double fUnimportant_Energy;
0171     //  Below this energy, no verbosity for looping particles is issued
0172 
0173     // Counter for steps in which particle reports 'looping',
0174     //   if it is above 'Important' Energy
0175     G4int fNoLooperTrials;
0176     // Statistics for tracks abandoned
0177     G4double fSumEnergyKilled;
0178     G4double fMaxEnergyKilled;
0179 
0180     // Whether to avoid calling G4Navigator for short step ( < safety)
0181     //   If using it, the safety estimate for endpoint will likely be smaller.
0182     G4bool fShortStepOptimisation;
0183 
0184     G4SafetyHelper* fpSafetyHelper;  // To pass it the safety value obtained
0185     G4int noCalls;
0186 };
0187 
0188 #include "G4MonopoleTransportation.icc"
0189 
0190 #endif