Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:33

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 /// \brief This class is a slightly modified version of G4Transportation
0028 ///        initially written by John Apostolakis and colleagues (1997)
0029 ///        But it should use the exact same algorithm
0030 //
0031 // Original Author : John Apostolakis
0032 //
0033 // Contact : Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
0034 //
0035 // WARNING : This class is released as a prototype.
0036 // It might strongly evolve or even disapear in the next releases.
0037 //
0038 // -------------------------------------------------------------------
0039 // Author: Mathieu Karamitros
0040 
0041 // The code is developed in the framework of the ESA AO7146
0042 //
0043 // We would be very happy hearing from you, send us your feedback! :)
0044 //
0045 // In order for Geant4-DNA to be maintained and still open-source,
0046 // article citations are crucial. 
0047 // If you use Geant4-DNA chemistry and you publish papers about your software, 
0048 // in addition to the general paper on Geant4-DNA:
0049 //
0050 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
0051 //
0052 // we would be very happy if you could please also cite the following
0053 // reference papers on chemistry:
0054 //
0055 // J. Comput. Phys. 274 (2014) 841-882
0056 // Prog. Nucl. Sci. Tec. 2 (2011) 503-508 
0057 
0058 #ifndef G4ITTransportation_H
0059 #define G4ITTransportation_H
0060 
0061 #include <CLHEP/Units/SystemOfUnits.h>
0062 
0063 #include "G4VITProcess.hh"
0064 #include "G4Track.hh"
0065 #include "G4Step.hh"
0066 #include "G4ParticleChangeForTransport.hh"
0067 
0068 class G4ITNavigator;
0069 //class G4Navigator;
0070 class G4ITSafetyHelper;
0071 class G4PropagatorInField;
0072 
0073 class G4ITTransportation : public G4VITProcess
0074 {
0075   // Concrete class that does the geometrical transport
0076 public:
0077   // with description
0078 
0079   G4ITTransportation(const G4String& aName = "ITTransportation",
0080                      G4int verbosityLevel = 0);
0081   ~G4ITTransportation() override;
0082 
0083   G4ITTransportation(const G4ITTransportation&);
0084 
0085   G4IT_ADD_CLONE(G4VITProcess, G4ITTransportation)
0086 
0087   void BuildPhysicsTable(const G4ParticleDefinition&) override;
0088 
0089   virtual void ComputeStep(const G4Track&,
0090                            const G4Step&,
0091                            const double timeStep,
0092                            double& spaceStep);
0093 
0094   void StartTracking(G4Track* aTrack) override;
0095   // Give to the track a pointer to the transportation state
0096 
0097   G4bool IsStepLimitedByGeometry()
0098   {
0099     return GetState<G4ITTransportationState>()->fGeometryLimitedStep;
0100   }
0101 
0102   //________________________________________________________
0103 public:
0104   // without description
0105 
0106   G4double AtRestGetPhysicalInteractionLength(const G4Track&,
0107                                                       G4ForceCondition*) override
0108   {
0109     return -1.0;
0110   }
0111   // No operation in  AtRestDoIt.
0112 
0113   G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&) override
0114   {
0115     return nullptr;
0116   }
0117   // No operation in  AtRestDoIt.
0118 
0119   G4double AlongStepGetPhysicalInteractionLength(const G4Track& track,
0120                                                          G4double, //   previousStepSize
0121                                                          G4double currentMinimumStep,
0122                                                          G4double& currentSafety,
0123                                                          G4GPILSelection* selection) override;
0124 
0125   G4double PostStepGetPhysicalInteractionLength(const G4Track&, // track
0126                                                         G4double, // previousStepSize
0127                                                         G4ForceCondition* pForceCond) override;
0128 
0129   G4VParticleChange* AlongStepDoIt(const G4Track& track,
0130                                            const G4Step& stepData) override;
0131 
0132   G4VParticleChange* PostStepDoIt(const G4Track& track, const G4Step&) override;
0133 
0134   //________________________________________________________
0135   //    inline virtual G4double GetTransportationTime() ;
0136 
0137   G4PropagatorInField* GetPropagatorInField();
0138   void SetPropagatorInField(G4PropagatorInField* pFieldPropagator);
0139   // Access/set the assistant class that Propagate in a Field.
0140 
0141   inline void SetVerboseLevel(G4int verboseLevel);
0142   inline G4int GetVerboseLevel() const;
0143   // Level of warnings regarding eg energy conservation
0144   // in field integration.
0145 
0146   inline G4double GetThresholdWarningEnergy() const;
0147   inline G4double GetThresholdImportantEnergy() const;
0148   inline G4int GetThresholdTrials() const;
0149 
0150   inline void SetThresholdWarningEnergy(G4double newEnWarn);
0151   inline void SetThresholdImportantEnergy(G4double newEnImp);
0152   inline void SetThresholdTrials(G4int newMaxTrials);
0153 
0154   // Get/Set parameters for killing loopers:
0155   //   Above 'important' energy a 'looping' particle in field will
0156   //   *NOT* be abandoned, except after fThresholdTrials attempts.
0157   // Below Warning energy, no verbosity for looping particles is issued
0158 
0159   inline G4double GetMaxEnergyKilled() const;
0160   inline G4double GetSumEnergyKilled() const;
0161   inline void ResetKilledStatistics(G4int report = 1);
0162   // Statistics for tracks killed (currently due to looping in field)
0163 
0164   inline void EnableShortStepOptimisation(G4bool optimise = true);
0165   // Whether short steps < safety will avoid to call Navigator (if field=0)
0166 
0167 protected:
0168   //________________________________________________________________
0169   // Protected methods
0170   G4bool DoesGlobalFieldExist();
0171   // Checks whether a field exists for the "global" field manager.
0172 
0173   //________________________________________________________________
0174   // Process information
0175   struct G4ITTransportationState : public G4ProcessState
0176   {
0177   public:
0178     G4ITTransportationState();
0179     ~G4ITTransportationState() override;
0180     G4String GetType() override
0181     {
0182       return "G4ITTransportationState";
0183     }
0184 
0185     G4ThreeVector fTransportEndPosition;
0186     G4ThreeVector fTransportEndMomentumDir;
0187     G4double fTransportEndKineticEnergy;
0188     G4ThreeVector fTransportEndSpin;
0189     G4bool fMomentumChanged;
0190     G4bool fEnergyChanged;
0191     G4bool fEndGlobalTimeComputed;
0192     G4double fCandidateEndGlobalTime;
0193     G4bool fParticleIsLooping;
0194     // The particle's state after this Step, Store for DoIt
0195 
0196     G4TouchableHandle fCurrentTouchableHandle;
0197     G4bool fGeometryLimitedStep;
0198     // Flag to determine whether a boundary was reached.
0199 
0200     G4ThreeVector fPreviousSftOrigin;
0201     G4double fPreviousSafety;
0202     // Remember last safety origin & value.
0203 
0204     // Counter for steps in which particle reports 'looping',
0205     //   if it is above 'Important' Energy
0206     G4int fNoLooperTrials;
0207 
0208     // G4bool         fFieldExists;
0209     // Whether a magnetic field exists ...
0210     // A data member for this is problematic: it is useful only if it
0211     // can be initialised and updated -- and a scheme is not yet possible.
0212 
0213     G4double fEndPointDistance;
0214   };
0215 
0216   //________________________________________________________________
0217   // Informations relative to the process only (meaning no information
0218   // relative to the treated particle)
0219   G4ITNavigator* fLinearNavigator;
0220   G4PropagatorInField* fFieldPropagator;
0221   // The Propagators used to transport the particle
0222 
0223   // static const G4TouchableHandle nullTouchableHandle;
0224   // Points to (G4VTouchable*) 0
0225 
0226   G4ParticleChangeForTransport fParticleChange;
0227   // New ParticleChange
0228 
0229   // Thresholds for looping particles:
0230   //
0231   G4double fThreshold_Warning_Energy; //  Warn above this energy
0232   G4double fThreshold_Important_Energy; //  Hesitate above this
0233   G4int fThresholdTrials{10}; //    for this no of trials
0234   // Above 'important' energy a 'looping' particle in field will
0235   //   *NOT* be abandoned, except after fThresholdTrials attempts.
0236   G4double fUnimportant_Energy;
0237   //  Below this energy, no verbosity for looping particles is issued
0238 
0239   // Statistics for tracks abandoned
0240   G4double fSumEnergyKilled{0.0};
0241   G4double fMaxEnergyKilled{0.0};
0242 
0243   // Whether to avoid calling G4Navigator for short step ( < safety)
0244   //   If using it, the safety estimate for endpoint will likely be smaller.
0245   G4bool fShortStepOptimisation{false};
0246 
0247   G4ITSafetyHelper* fpSafetyHelper; // To pass it the safety value obtained
0248 
0249   // Verbosity
0250   G4int fVerboseLevel;
0251   // Verbosity level for warnings
0252   // eg about energy non-conservation in magnetic field.
0253 
0254   void SetInstantiateProcessState(G4bool flag)
0255   {
0256     fInstantiateProcessState = flag;
0257   }
0258 
0259   G4bool InstantiateProcessState()
0260   {
0261     return fInstantiateProcessState;
0262   }
0263 
0264 private:
0265   G4bool fInstantiateProcessState;
0266   G4ITTransportation& operator=(const G4ITTransportation&);
0267 };
0268 
0269 #include "G4ITTransportation.icc"
0270 #endif // G4ITTransportation_H