Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:24

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DDG4_GEANT4USERLIMITS_H
0014 #define DDG4_GEANT4USERLIMITS_H
0015 
0016 // Framework include files
0017 #include <DD4hep/Objects.h>
0018 
0019 // Geant 4 include files
0020 #include <G4UserLimits.hh>
0021 
0022 // Forward declarations
0023 class G4ParticleDefinition;
0024 
0025 /// Namespace for the AIDA detector description toolkit
0026 namespace dd4hep {
0027 
0028 
0029   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0030   namespace sim {
0031 
0032     /// Helper to dump Geant4 volume hierarchy
0033     /**
0034      *  \author  M.Frank
0035      *  \version 1.0
0036      *  \ingroup DD4HEP_SIMULATION
0037      */
0038     class Geant4UserLimits : public  G4UserLimits {
0039     public:
0040       /// Helper class to one limit type
0041       /**
0042        *  \author  M.Frank
0043        *  \version 1.0
0044        *  \ingroup DD4HEP_SIMULATION
0045        */
0046       struct Handler  {
0047       public:
0048         /// Default value (either from base class or value if Limit.particles='*')
0049         double                defaultValue = 0.0;
0050         /// Handler particle ids for the limit (pdgID)
0051         std::map<const G4ParticleDefinition*, double> particleLimits;
0052       public:
0053         /// Default constructor
0054         Handler() = default;
0055         /// Set the handler value(s)
0056         void set(const std::string& particles, double val);
0057         /// Access value according to track
0058         double value(const G4Track& track) const;
0059       };
0060       /// Handle to the limitset to be applied.
0061       LimitSet  limits;
0062       /// Handler map for MaxStepLength limit
0063       Handler   maxStepLength;
0064       /// Handler map for MaxTrackLength limit
0065       Handler   maxTrackLength;
0066       /// Handler map for MaxTime limit
0067       Handler   maxTime;
0068       /// Handler map for MinEKine limit
0069       Handler   minEKine;
0070       /// Handler map for MinRange limit
0071       Handler   minRange;
0072 
0073     public:
0074       /// Initializing Constructor
0075       Geant4UserLimits(LimitSet limitset);
0076       /// Standard destructor
0077       virtual ~Geant4UserLimits();
0078       /// Update the object
0079       virtual void update(LimitSet limitset);
0080       /// Access the user tracklength for a G4 track object
0081       virtual G4double GetMaxAllowedStep(const G4Track& track)
0082       {  return maxStepLength.value(track);    }
0083       /// Access the user tracklength for a G4 track object
0084       virtual G4double GetUserMaxTrackLength(const G4Track& track)
0085       {  return maxTrackLength.value(track);   }
0086       /// Access the proper time cut for a G4 track object
0087       virtual G4double GetUserMaxTime (const G4Track& track)
0088       {  return maxTime.value(track);          }
0089       /// Access the kinetic energy cut for a G4 track object
0090       virtual G4double GetUserMinEkine(const G4Track& track)
0091       {  return minEKine.value(track);         }
0092       /// Access the range cut for a G4 track object
0093       virtual G4double GetUserMinRange(const G4Track& track)
0094       {  return minRange.value(track);         }
0095       /// Setters may not be called!
0096       virtual void SetMaxAllowedStep(G4double ustepMax);    
0097       virtual void SetUserMaxTrackLength(G4double utrakMax);
0098       virtual void SetUserMaxTime(G4double utimeMax);
0099       virtual void SetUserMinEkine(G4double uekinMin);
0100       virtual void SetUserMinRange(G4double urangMin);
0101       /// Allow for debugging user limits (very verbose)
0102       static bool enable_debug(bool value);
0103     };
0104   }
0105 }
0106 
0107 #endif // DDG4_GEANT4USERLIMITS_H