|
||||
File indexing completed on 2025-01-18 09:55:23
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 0014 #ifndef DDG4_GEANT4DETECTORCONSTRUCTION_H 0015 #define DDG4_GEANT4DETECTORCONSTRUCTION_H 0016 0017 // Framework include files 0018 #include <DD4hep/DetElement.h> 0019 #include <DDG4/Geant4Action.h> 0020 0021 // Forward declarations 0022 class G4VUserDetectorConstruction; 0023 class G4VSensitiveDetector; 0024 class G4VPhysicalVolume; 0025 class G4LogicalVolume; 0026 class G4UserLimits; 0027 class G4Material; 0028 class G4Element; 0029 class G4VSolid; 0030 class G4Region; 0031 0032 /// Namespace for the AIDA detector description toolkit 0033 namespace dd4hep { 0034 0035 // Forward declarations 0036 class Detector; 0037 0038 /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit 0039 namespace sim { 0040 0041 // Forward declarations 0042 class Geant4Kernel; 0043 class Geant4GeometryInfo; 0044 class Geant4AssemblyVolume; 0045 class Geant4DetectorConstruction; 0046 class Geant4DetectorConstructionContext; 0047 class Geant4DetectorConstructionSequence; 0048 0049 /// Geant4 detector construction context definition. 0050 /** 0051 * Detector construction context to allow the workers a simplified 0052 * access to the object created. 0053 * 0054 * The context is a stack based object. Do not keep a pointer to 0055 * The object scope does not span beyond the actional function call. 0056 * 0057 * \author M.Frank 0058 * \version 1.0 0059 * \ingroup DD4HEP_SIMULATION 0060 */ 0061 class Geant4DetectorConstructionContext { 0062 public: 0063 /// Reference to geometry object 0064 #ifdef __CINT__ 0065 Detector* description; 0066 #else 0067 Detector& description; 0068 #endif 0069 /// Reference to the world after construction 0070 G4VPhysicalVolume* world { nullptr }; 0071 /// The cached geometry information 0072 Geant4GeometryInfo* geometry { nullptr }; 0073 /// G4 User detector initializer 0074 G4VUserDetectorConstruction* detector { nullptr }; 0075 /// Initializing Constructor 0076 Geant4DetectorConstructionContext(Detector& l, G4VUserDetectorConstruction* d) 0077 : description(l), world(0), geometry(0), detector(d) { } 0078 /// Default destructor 0079 ~Geant4DetectorConstructionContext() { } 0080 /// Helper: Assign sensitive detector to logical volume 0081 void setSensitiveDetector(G4LogicalVolume* vol, G4VSensitiveDetector* sd); 0082 }; 0083 0084 /// Basic implementation of the Geant4 detector construction action. 0085 /** 0086 * Concrete implementation of the Geant4 detector construction action. 0087 * The sequences as the object's master dispatches the callbacks for 0088 * the "constructGeo()" method to create a detector geometry and the 0089 * "constructSensitives()" call to create the sensitive detectors 0090 * and the "constructField" to each worker subclassing 0091 * Geant4DetectorConstruction. 0092 * 0093 * Please note: 0094 * constructField() and constructSensitives() are executed in a 0095 * thread-local context. See the Geant4 documentation for details: 0096 * https://twiki.cern.ch/twiki/bin/view/Geant4/QuickMigrationGuideForGeant4V10 0097 * 0098 * \author M.Frank 0099 * \version 1.0 0100 * \ingroup DD4HEP_SIMULATION 0101 */ 0102 class Geant4DetectorConstruction : public Geant4Action { 0103 public: 0104 /// Standard Constructor 0105 Geant4DetectorConstruction(Geant4Context* context, const std::string& nam); 0106 /// Default destructor 0107 virtual ~Geant4DetectorConstruction(); 0108 /// Geometry construction callback. Called at "Construct()" 0109 virtual void constructGeo(Geant4DetectorConstructionContext* ctxt); 0110 /// Electromagnetic field construction callback. Called at "ConstructSDandField()" 0111 virtual void constructField(Geant4DetectorConstructionContext* ctxt); 0112 /// Sensitive detector construction callback. Called at "ConstructSDandField()" 0113 virtual void constructSensitives(Geant4DetectorConstructionContext* ctxt); 0114 /// Create Geant4 sensitive detector object using the factory mechanism 0115 virtual G4VSensitiveDetector* createSensitiveDetector(const std::string& type, 0116 const std::string& name); 0117 }; 0118 0119 /// Concrete basic implementation of the Geant4 detector construction sequencer. 0120 /** 0121 * Concrete implementation of the Geant4 detector construction sequence. 0122 * The sequence dispatches the callbacks for the "Construct()" method to 0123 * create a detector geometry and to dispatch the "ConstructSDandField()" 0124 * calls for each worker. 0125 * 0126 * Please note: 0127 * constructField() and constructSensitives() are executed in a 0128 * thread-local context. See the Geant4 documentation for details: 0129 * https://twiki.cern.ch/twiki/bin/view/Geant4/QuickMigrationGuideForGeant4V10 0130 * 0131 * \author M.Frank 0132 * \version 1.0 0133 * \ingroup DD4HEP_SIMULATION 0134 */ 0135 class Geant4DetectorConstructionSequence : public Geant4Action { 0136 protected: 0137 /// The list of action objects to be called 0138 Actors<Geant4DetectorConstruction> m_actors; 0139 0140 public: 0141 /// Standard Constructor 0142 Geant4DetectorConstructionSequence(Geant4Context* context, const std::string& nam); 0143 /// Default destructor 0144 virtual ~Geant4DetectorConstructionSequence(); 0145 /// Set or update client context 0146 virtual void updateContext(Geant4Context* ctxt); 0147 /// Add an actor responding to all callbacks. Sequence takes ownership. 0148 void adopt(Geant4DetectorConstruction* action); 0149 /// Access an actor by name 0150 Geant4DetectorConstruction* get(const std::string& nam) const; 0151 /// Geometry construction callback. Called at "Construct()" 0152 virtual void constructGeo(Geant4DetectorConstructionContext* ctxt); 0153 /// Electromagnetic field construction callback. Called at "ConstructSDandField()" 0154 virtual void constructField(Geant4DetectorConstructionContext* ctxt); 0155 /// Sensitive detector construction callback. Called at "ConstructSDandField()" 0156 virtual void constructSensitives(Geant4DetectorConstructionContext* ctxt); 0157 0158 #if !defined(__CINT__) 0159 //@{ Accessor to the various geant4 maps after construction 0160 0161 /// Access to the converted materials 0162 const std::map<Material, G4Material*>& materials() const; 0163 /// Access to the converted elements 0164 const std::map<Atom, G4Element*>& elements() const; 0165 /// Access to the converted shapes 0166 const std::map<const TGeoShape*, G4VSolid*>& shapes() const; 0167 /// Access to the converted volumes 0168 const std::map<Volume, G4LogicalVolume*>& volumes() const; 0169 /// Access to the converted placements 0170 const std::map<PlacedVolume, G4VPhysicalVolume*>& placements() const; 0171 /// Access to the converted assemblys 0172 const std::map<PlacedVolume, Geant4AssemblyVolume*>& assemblies() const; 0173 0174 /// Access to the converted limit sets 0175 const std::map<LimitSet, G4UserLimits*>& limits() const; 0176 /// Access to the converted regions 0177 const std::map<Region, G4Region*>& regions() const; 0178 #endif 0179 0180 //@} 0181 }; 0182 0183 } // End namespace sim 0184 } // End namespace dd4hep 0185 0186 #endif // DDG4_GEANT4DETECTORCONSTRUCTION_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |