 |
DD4hep
1.37.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
49 std::set<Volume>& visited,
52 const std::vector<std::regex>& matches);
77 #include <TTimeStamp.h>
78 #include <TGeoManager.h>
80 #include <G4PVPlacement.hh>
81 #include <G4VSensitiveDetector.hh>
103 std::set<Volume>& visited,
106 const std::vector<std::regex>& matches)
108 std::size_t count = 0;
111 if ( visited.insert(pv.
volume()).second ) {
112 for(
const auto& match : matches ) {
114 if( std::regex_search(path, sm, match) ) {
115 volumes.insert(pv.
volume());
121 const std::size_t base_len = path.size();
122 for(
int i=0, num = pv->GetNdaughters(); i < num; ++i ) {
125 path += daughter.
name();
126 count += this->
collect_volumes(volumes, visited, daughter, path, matches);
127 path.resize(base_len);
143 except(
"Failed to locate subdetector DetElement %s to manage Geant4 energy deposits.",
det);
147 except(
"Failed to locate sensitive detector %s to manage Geant4 energy deposits.",
det);
149 std::string nam = sd.
name();
150 auto iter = types.find(nam);
151 std::string typ = (iter != types.end()) ? (*iter).second : dflt;
155 std::size_t num_nodes = 0;
157 int flags = std::regex_constants::icase | std::regex_constants::ECMAScript;
158 std::vector<std::regex> expressions;
160 std::regex e(val, (std::regex_constants::syntax_option_type)flags);
161 expressions.emplace_back(e);
163 info(
"%s Starting to scan volume....",
det);
164 std::set<Volume> visited;
173 for(
const auto& vol : volumes ) {
174 G4LogicalVolume* g4vol = g4info->
g4Volumes[vol];
176 except(
"+++ Failed to access G4LogicalVolume for SD %s of type %s", nam.c_str(), typ.c_str());
178 debug(
"%s Assign sensitive detector [%s] to volume: %s.",
179 nam.c_str(), typ.c_str(), vol.name());
183 info(
"%s Handled %ld nodes with %ld sensitive volume type(s). Total of %7.3f seconds.",
184 det, num_nodes, volumes.size(), stop.AsDouble()-start.AsDouble() );
virtual ~Geant4RegexSensitivesConstruction()
Default destructor.
Handle class to hold the information of a sensitive detector.
Handle class holding a placed volume (also called physical volume)
Class to create Geant4 detector geometry from TGeo representation in memory.
PlacedVolume placement() const
Access to the physical volume of this detector element.
Class, which allows all Geant4Action derivatives to access the DDG4 kernel structures.
bool isValid() const
Check the validity of the object held by the handle.
static void increment(T *)
Increment count according to type information.
static Geant4Mapping & instance()
Possibility to define a singleton instance.
const char * name() const
Access the object name (or "" if not supported by the object)
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
void info(const char *fmt,...) const
Support of info messages.
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
Geant4 detector construction context definition.
const std::map< std::string, std::string > & sensitiveDetectorTypes() const
Property access: Names with specialized factories to create G4VSensitiveDetector instances.
std::set< Volume > m_cached_volumes
Handle class describing a detector element.
Detector & description
Reference to geometry object.
Geant4GeometryInfo * ptr() const
Access to the data pointer.
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
virtual SensitiveDetector sensitiveDetector(const std::string &name) const =0
Retrieve a sensitive detector by its name from the detector description.
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
static void decrement(T *)
Decrement count according to type information.
const std::string defaultSensitiveDetectorType() const
Property access: Name of the default factory to create G4VSensitiveDetector instances.
void constructSensitives(Geant4DetectorConstructionContext *ctxt)
Sensitives construction callback. Called at "ConstructSDandField()".
const std::string & placementPath() const
Access to the full path to the placed object.
std::string detector_name
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Geant4Kernel & kernel() const
Access to the kernel object.
Concreate class holding the relation information between geant4 objects and dd4hep objects.
std::size_t collect_volumes(std::set< Volume > &volumes, std::set< Volume > &visited, PlacedVolume pv, std::string &path, const std::vector< std::regex > &matches)
void setSensitiveDetector(G4LogicalVolume *vol, G4VSensitiveDetector *sd)
Helper: Assign sensitive detector to logical volume.
Namespace for the AIDA detector description toolkit.
Volume volume() const
Logical volume of this placement.
void debug(const char *fmt,...) const
Support of debug messages.
Basic implementation of the Geant4 detector construction action.
std::vector< std::string > regex_values
Generic context to extend user, run and event information.
Geant4RegexSensitivesConstruction(Geant4Context *ctxt, const std::string &nam)
Initializing constructor for DDG4.
Geant4Context * context() const
Access the context.
Geant4GeometryMaps::VolumeMap g4Volumes