DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4FastSimShowerModel.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDG4_GEANT4FASTSIMSHOWERMODEL_H
14 #define DDG4_GEANT4FASTSIMSHOWERMODEL_H
15 
16 // Framework include files
18 
19 // Geant4 include files
20 #include <G4FastSimulationPhysics.hh>
21 
22 // C/C++ include files
23 #include <set>
24 #include <vector>
25 #include <memory>
26 
28 class G4FastStep;
29 class G4FastTrack;
30 class G4ParticleDefinition;
31 class G4VFastSimulationModel;
32 
34 namespace dd4hep {
35 
37  namespace sim {
38 
40  class Geant4ShowerModelWrapper;
41 
43 
51  protected:
52  // typedef std::vector<std::pair<std::string, double> > ParticleConfig;
53  typedef std::map<const G4ParticleDefinition*, double> ParticleCut;
54  typedef std::map<std::string, std::string> ParticleConfig;
56 
58  std::string m_regionName { "Region-name-not-specified"};
60  std::vector<std::string> m_applicablePartNames { };
62  bool m_enable { false };
64  double m_stepX0 { 0.1 };
73 
75  std::set<const G4ParticleDefinition*> m_applicableParticles { };
79  G4VFastSimulationModel* m_model { nullptr };
81  Wrapper m_wrapper { nullptr };
82 
83  protected:
86 
88  G4Material* getMaterial(const std::string& name) const;
90  G4ParticleDefinition* getParticleDefinition(const std::string& name) const;
92  G4Region* getRegion(const std::string& nam) const;
94  void addShowerModel(G4Region* region);
96  void killParticle(G4FastStep& step, double deposit, double step_length = 0e0);
97 
98  public:
100  Geant4FastSimShowerModel(Geant4Context* context, const std::string& nam);
101 
103  virtual ~Geant4FastSimShowerModel();
104 
106  virtual void constructGeo(Geant4DetectorConstructionContext* ctxt) override;
108  virtual void constructField(Geant4DetectorConstructionContext* ctxt) override;
110  virtual void constructSensitives(Geant4DetectorConstructionContext* ctxt) override;
111 
113  virtual bool check_applicability(const G4ParticleDefinition& particle);
115  virtual bool check_trigger(const G4FastTrack& track);
117  virtual void modelShower(const G4FastTrack& track, G4FastStep& step);
118  };
119 
120 
122 
129  template <typename CONCRETE_MODEL>
131 
132  public:
134  CONCRETE_MODEL locals;
135 
136  public:
138  Geant4FSShowerModel(Geant4Context* context, const std::string& nam);
139 
141  virtual ~Geant4FSShowerModel();
142 
144  void initialize();
145 
147  virtual void constructGeo(Geant4DetectorConstructionContext* ctxt) override;
148 
150  virtual void constructField(Geant4DetectorConstructionContext* ctxt) override;
151 
153  virtual void constructSensitives(Geant4DetectorConstructionContext* ctxt) override;
154 
156 
158  virtual bool check_applicability(const G4ParticleDefinition& particle) override;
159 
161 
164  virtual bool check_trigger(const G4FastTrack& track) override;
165 
167  virtual void modelShower(const G4FastTrack& track, G4FastStep& step) override;
168  };
169  } /* End namespace sim */
170 } /* End namespace dd4hep */
171 #endif // DDG4_GEANT4FASTSIMSHOWERMODEL_H
dd4hep::sim::Geant4FastSimShowerModel::modelShower
virtual void modelShower(const G4FastTrack &track, G4FastStep &step)
User callback to model the particle/energy shower.
Definition: Geant4FastSimShowerModel.cpp:226
dd4hep::sim::Geant4FastSimShowerModel::m_eMin
ParticleConfig m_eMin
Property: Set minimum kinetic energy to trigger parametrisation.
Definition: Geant4FastSimShowerModel.h:66
Geant4DetectorConstruction.h
dd4hep::sim::Geant4FastSimShowerModel::m_applicablePartNames
std::vector< std::string > m_applicablePartNames
Property: Particle names for which this parametrization is applicable.
Definition: Geant4FastSimShowerModel.h:60
dd4hep::sim::Geant4FSShowerModel::modelShower
virtual void modelShower(const G4FastTrack &track, G4FastStep &step) override
User callback to model the particle/energy shower.
Definition: Geant4FastSimShowerModel.inl.h:83
dd4hep::sim::Geant4FastSimShowerModel::m_eTriggerNames
ParticleConfig m_eTriggerNames
Property: Set minimal kinetic energy for particles to trigger the model.
Definition: Geant4FastSimShowerModel.h:72
dd4hep::sim::Geant4FastSimShowerModel::m_eTriggerCut
ParticleCut m_eTriggerCut
Particle cut to trigger model simulation indexed by G4ParticleDefinition.
Definition: Geant4FastSimShowerModel.h:77
dd4hep::sim::Geant4FastSimShowerModel::m_stepX0
double m_stepX0
Property: Defines step length.
Definition: Geant4FastSimShowerModel.h:64
dd4hep::sim::Geant4FSShowerModel::locals
CONCRETE_MODEL locals
Local parameter buffer to specialize caches, properties etc.
Definition: Geant4FastSimShowerModel.h:134
dd4hep::sim::Geant4FastSimShowerModel::m_wrapper
Wrapper m_wrapper
Reference to the shower model.
Definition: Geant4FastSimShowerModel.h:81
dd4hep::sim::Geant4FSShowerModel::constructField
virtual void constructField(Geant4DetectorConstructionContext *ctxt) override
Electromagnetic field construction callback. Called at "ConstructSDandField()".
Definition: Geant4FastSimShowerModel.inl.h:59
dd4hep::sim::Geant4FSShowerModel::initialize
void initialize()
Declare optional properties from embedded structure.
Definition: Geant4FastSimShowerModel.inl.h:48
dd4hep::sim::Geant4FastSimShowerModel::constructSensitives
virtual void constructSensitives(Geant4DetectorConstructionContext *ctxt) override
Sensitive detector construction callback. Called at "ConstructSDandField()".
Definition: Geant4FastSimShowerModel.cpp:184
dd4hep::sim::Geant4DetectorConstructionContext
Geant4 detector construction context definition.
Definition: Geant4DetectorConstruction.h:61
dd4hep::sim::Geant4FastSimShowerModel::constructGeo
virtual void constructGeo(Geant4DetectorConstructionContext *ctxt) override
Geometry construction callback. Called at "Construct()".
Definition: Geant4FastSimShowerModel.cpp:171
dd4hep::sim::Geant4FastSimShowerModel::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4FastSimShowerModel)
Define standard assignments and constructors.
dd4hep::sim::Geant4FastSimShowerModel::Geant4FastSimShowerModel
Geant4FastSimShowerModel(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4FastSimShowerModel.cpp:90
dd4hep::sim::Geant4FSShowerModel
Geant4 wrapper for the Geant4 fast simulation shower model.
Definition: Geant4FastSimShowerModel.h:130
dd4hep::sim::Geant4FastSimShowerModel::m_applicableParticles
std::set< const G4ParticleDefinition * > m_applicableParticles
Particle definitions for which this parametrization is applicable.
Definition: Geant4FastSimShowerModel.h:75
dd4hep::sim::Geant4FSShowerModel::Geant4FSShowerModel
Geant4FSShowerModel(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4FastSimShowerModel.inl.h:35
dd4hep::sim::Geant4FSShowerModel::check_trigger
virtual bool check_trigger(const G4FastTrack &track) override
User callback to determine if the shower creation should be triggered.
Definition: Geant4FastSimShowerModel.inl.h:77
dd4hep::sim::Geant4FastSimShowerModel::m_regionName
std::string m_regionName
Property: Region name to which this parametrization should be applied.
Definition: Geant4FastSimShowerModel.h:58
dd4hep::sim::Geant4FastSimShowerModel::check_trigger
virtual bool check_trigger(const G4FastTrack &track)
User callback to determine if the shower creation should be triggered.
Definition: Geant4FastSimShowerModel.cpp:211
dd4hep::sim::Geant4FSShowerModel::check_applicability
virtual bool check_applicability(const G4ParticleDefinition &particle) override
User callback to determine if the model is applicable for the particle type.
Definition: Geant4FastSimShowerModel.inl.h:71
dd4hep::sim::Geant4FSShowerModel::constructSensitives
virtual void constructSensitives(Geant4DetectorConstructionContext *ctxt) override
Sensitive detector construction callback. Called at "ConstructSDandField()".
Definition: Geant4FastSimShowerModel.inl.h:65
dd4hep::sim::Geant4FastSimShowerModel::~Geant4FastSimShowerModel
virtual ~Geant4FastSimShowerModel()
Default destructor.
Definition: Geant4FastSimShowerModel.cpp:105
dd4hep::sim::Geant4FastSimShowerModel::constructField
virtual void constructField(Geant4DetectorConstructionContext *ctxt) override
Electromagnetic field construction callback. Called at "ConstructSDandField()".
Definition: Geant4FastSimShowerModel.cpp:180
dd4hep::sim::Geant4FastSimShowerModel::check_applicability
virtual bool check_applicability(const G4ParticleDefinition &particle)
User callback to determine if the model is applicable for the particle type.
Definition: Geant4FastSimShowerModel.cpp:204
dd4hep::sim::Geant4FastSimShowerModel::Wrapper
Geant4ShowerModelWrapper * Wrapper
Definition: Geant4FastSimShowerModel.h:55
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4FastSimShowerModel::m_eMax
ParticleConfig m_eMax
Property: Set maximum kinetic energy to trigger parametrisation.
Definition: Geant4FastSimShowerModel.h:68
dd4hep::sim::Geant4FastSimShowerModel::getParticleDefinition
G4ParticleDefinition * getParticleDefinition(const std::string &name) const
Access particle definition from string.
Definition: Geant4FastSimShowerModel.cpp:111
dd4hep::sim::Geant4FSShowerModel::constructGeo
virtual void constructGeo(Geant4DetectorConstructionContext *ctxt) override
Geometry construction callback. Called at "Construct()".
Definition: Geant4FastSimShowerModel.inl.h:53
dd4hep::sim::Geant4FastSimShowerModel::getRegion
G4Region * getRegion(const std::string &nam) const
Access the region from the detector description by name.
Definition: Geant4FastSimShowerModel.cpp:134
dd4hep::sim::Geant4ShowerModelWrapper
Geant4 wrapper for the Geant4 fast simulation shower model.
Definition: Geant4FastSimShowerModel.cpp:48
dd4hep::sim::Geant4FastSimShowerModel::addShowerModel
void addShowerModel(G4Region *region)
Add shower model to region's fast simulation manager.
Definition: Geant4FastSimShowerModel.cpp:152
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4FastSimShowerModel::getMaterial
G4Material * getMaterial(const std::string &name) const
Get parametrization material.
Definition: Geant4FastSimShowerModel.cpp:119
dd4hep::sim::Geant4FSShowerModel::~Geant4FSShowerModel
virtual ~Geant4FSShowerModel()
Default destructor.
Definition: Geant4FastSimShowerModel.inl.h:43
dd4hep::sim::Geant4FastSimShowerModel::m_model
G4VFastSimulationModel * m_model
Reference to the G4 fast simulation model.
Definition: Geant4FastSimShowerModel.h:79
dd4hep::sim::Geant4FastSimShowerModel::ParticleCut
std::map< const G4ParticleDefinition *, double > ParticleCut
Definition: Geant4FastSimShowerModel.h:53
dd4hep::sim::Geant4DetectorConstruction
Basic implementation of the Geant4 detector construction action.
Definition: Geant4DetectorConstruction.h:102
dd4hep::sim::Geant4FastSimShowerModel::killParticle
void killParticle(G4FastStep &step, double deposit, double step_length=0e0)
Kill primary particle when creating the shower.
Definition: Geant4FastSimShowerModel.cpp:197
dd4hep::sim::Geant4FastSimShowerModel::m_eKill
ParticleConfig m_eKill
Property: Set maximum kinetic energy for particles to be killed.
Definition: Geant4FastSimShowerModel.h:70
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270
dd4hep::sim::Geant4FastSimShowerModel
Geant4 wrapper for the Geant4 fast simulation shower model.
Definition: Geant4FastSimShowerModel.h:50
dd4hep::sim::Geant4FastSimShowerModel::m_enable
bool m_enable
Property: Parametrisation control: Enable/disable fast simulation.
Definition: Geant4FastSimShowerModel.h:62
dd4hep::sim::Geant4FastSimShowerModel::ParticleConfig
std::map< std::string, std::string > ParticleConfig
Definition: Geant4FastSimShowerModel.h:54