DD4hep  1.35.0
Detector Description Toolkit for High Energy Physics
Geant4VolumeManager.cpp
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 
14 // Framework include files
15 #include <DD4hep/Printout.h>
16 #include <DD4hep/Volumes.h>
17 #include <DD4hep/DetElement.h>
18 #include <DD4hep/DetectorTools.h>
19 #include <DD4hep/VolumeManager.h>
23 #include <DDG4/Geant4Mapping.h>
24 
25 // Geant4 include files
26 #include <G4VTouchable.hh>
27 #include <G4LogicalVolume.hh>
28 #include <G4VPhysicalVolume.hh>
29 
30 // C/C++ include files
31 #include <set>
32 #include <stdexcept>
33 #include <string>
34 #include <utility>
35 #include <vector>
36 
37 //#define VOLMGR_HAVE_DEBUG_INFO 1
38 
39 #ifdef VOLMGR_HAVE_DEBUG_INFO
40 namespace dd4hep {
43  namespace sim {
44 
45  class Geant4GeometryInfo::DebugInfo {
46  public:
47  typedef std::vector<const G4VPhysicalVolume*> Geant4PlacementPath;
48  std::map<Geant4PlacementPath, Placement> g4Paths;
49  };
50 
51  } // End namespace sim
52 } // End namespace dd4hep
53 #endif
54 
55 
57 namespace dd4hep {
59  namespace sim {
61  void _print_volumeid(const std::string& tag, const IDDescriptor& iddesc, DDSegmentation::VolumeID volID);
62 
63  } // End namespace sim
64 } // End namespace dd4hep
65 
66 using namespace dd4hep::sim;
67 using namespace dd4hep;
68 
70 using VolIDDescriptor = std::pair<VolumeID,std::vector<std::pair<const BitFieldElement*, VolumeID> > >;
71 
72 namespace {
73 
75 
80  struct Populator {
81 
82  typedef std::vector<const TGeoNode*> Chain;
83  // typedef std::map<VolumeID,Geant4TouchableHandler::Geant4PlacementPath> Registries;
84  typedef std::set<VolumeID> Registries;
85 
87  const Detector& m_detDesc;
89  Registries m_entries;
91  Geant4GeometryInfo& m_geo;
93  long m_debug { 0 };
94 
96  Populator(const Detector& description, Geant4GeometryInfo& g, long dbg)
97  : m_detDesc(description), m_geo(g), m_debug(dbg)
98  {
99 #ifdef VOLMGR_HAVE_DEBUG_INFO
100  if ( nullptr == g.g4DebugInfo ) {
101  g.g4DebugInfo = new Geant4GeometryInfo::DebugInfo();
102  }
103 #endif
104  }
106  ~Populator() {
107 #ifdef VOLMGR_HAVE_DEBUG_INFO
108  if ( g.g4DebugInfo ) {
109  delete g.g4DebugInfo;
110  g.g4DebugInfo = nullptr;
111  }
112 #endif
113  }
114 
115 
117  void populate(DetElement e) {
118  const DetElement::Children& children = e.children();
119  m_entries.clear();
120  for( const auto& i : children ) {
121  DetElement de = i.second;
122  PlacedVolume pv = de.placement();
123  if( pv.isValid() ) {
124  Chain chain;
127  m_entries.clear();
128  chain.emplace_back(m_detDesc.world().placement().ptr());
129  scanPhysicalVolume(pv.ptr(), std::move(ids), sd, chain);
130  continue;
131  }
132  printout(WARNING, "Geant4VolumeManager",
133  "++ Detector element %s of type %s has no placement.",
134  de.name(), de.type().c_str());
135  }
137  for( const auto& pv : m_geo.g4Placements ) {
138  if( pv.second->IsParameterised() )
139  m_geo.g4Parameterised[pv.second] = pv.first;
140  if( pv.second->IsReplicated() )
141  m_geo.g4Replicated[pv.second] = pv.first;
142  }
143  m_entries.clear();
144  }
145 
147  void scanPhysicalVolume(const TGeoNode* node, PlacedVolume::VolIDs ids, SensitiveDetector& sd, Chain& chain) {
148  PlacedVolume pv = node;
149  Volume vol = pv.volume();
150  PlacedVolume::VolIDs pv_ids = pv.volIDs();
151 
152  chain.emplace_back(node);
153  ids.PlacedVolume::VolIDs::Base::insert(ids.end(), pv_ids.begin(), pv_ids.end());
154  if( vol.isSensitive() ) {
155  sd = vol.sensitiveDetector();
156  if( sd.readout().isValid() ) {
157  add_entry(sd, node, ids, chain);
158  }
159  else {
160  printout(WARNING, "Geant4VolumeManager",
161  "populate: Strange constellation volume %s is sensitive, but has no readout! sd:%p", pv.volume().name(),
162  sd.ptr());
163  }
164  }
165  for( Int_t idau = 0, ndau = node->GetNdaughters(); idau < ndau; ++idau ) {
166  TGeoNode* daughter = node->GetDaughter(idau);
167  PlacedVolume placement(daughter);
168  if( placement.data() ) {
169  scanPhysicalVolume(daughter, ids, sd, chain);
170  }
171  }
172  chain.pop_back();
173  }
174 
175  void add_entry(SensitiveDetector sd, const TGeoNode* n, const PlacedVolume::VolIDs& ids, const Chain& nodes) {
176  Chain control;
177  Volume vol;
178  Readout rdout = sd.readout();
179  IDDescriptor iddesc = rdout.idSpec();
180  VolumeID code = iddesc.encode(ids);
181  PrintLevel print_action = (m_debug&Geant4VolumeManager::PRINT_ACTION) ? ALWAYS : m_geo.printLevel;
182  PrintLevel print_chain = (m_debug&Geant4VolumeManager::PRINT_CHAIN) ? ALWAYS : m_geo.printLevel;
183  PrintLevel print_res = (m_debug&Geant4VolumeManager::PRINT_RESULT) ? ALWAYS : m_geo.printLevel;
184  bool print_nodes = (m_debug&Geant4VolumeManager::PRINT_NODES) ? true : false;
186  Registries::const_iterator i = m_entries.find(code);
187 
188  printout(print_action,"Geant4VolumeManager","+++ Add path:%s vid:%016X",
189  detail::tools::placementPath(nodes, false).c_str(), code);
190 
191  if( i == m_entries.end() ) {
192  path.reserve(nodes.size());
193  for( Chain::const_reverse_iterator k = nodes.rbegin(), kend=nodes.rend(); k != kend; ++k ) {
194  const TGeoNode* node = *(k);
195  auto g4pit = m_geo.g4Placements.find(node);
196  if( g4pit != m_geo.g4Placements.end() ) {
197  G4VPhysicalVolume* phys = g4pit->second;
198  if( phys->IsParameterised() ) {
199  PlacedVolume pv(n);
200  PlacedVolumeExtension* ext = pv.data();
201  if( nullptr == ext->params->field ) {
202  ext->params->field = iddesc.field(ext->volIDs.at(0).first);
203  }
204  }
205  path.emplace_back(phys);
206  printout(print_chain, "Geant4VolumeManager",
207  "+++ Chain: Node OK: %s [%s]", node->GetName(), phys->GetName().c_str());
208  continue;
209  }
210  control.insert(control.begin(),node);
211  vol = Volume(node->GetVolume());
212  auto iVolImp = m_geo.g4VolumeImprints.find(vol);
213  if ( iVolImp != m_geo.g4VolumeImprints.end() ) {
214  for(const auto& imp : iVolImp->second ) {
215  const auto& c = imp.first;
216  if ( c.size() <= control.size() && control == c ) {
217  path.emplace_back(imp.second);
218  printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s %s -> %s",
219  node->GetName(), detail::tools::placementPath(c,false).c_str(),
220  imp.second->GetName().c_str());
221  control.clear();
222  break;
223  }
224  }
225  }
226  }
227  if ( control.empty() ) {
228  printout(print_res, "Geant4VolumeManager", "+++ Encoded Volume IDs:%s",
229  detail::tools::toString(iddesc,ids,code).c_str());
230  path.erase(path.begin()+path.size()-1);
231  printout(print_res, "Geant4VolumeManager", "+++ Map %016X to Geant4 Path:%s",
232  (void*)code, Geant4TouchableHandler::placementPath(path).c_str());
233  auto hash = detail::hash64(&path[0], path.size()*sizeof(path[0]));
234  bool missing_hash_path = m_geo.g4Paths.find(hash) == m_geo.g4Paths.end();
235 #ifdef VOLMGR_HAVE_DEBUG_INFO
236  {
237  bool missing_real_path = m_geo.g4DebugInfo->g4Paths.find(path) == m_geo.g4DebugInfo->g4Paths.end();
238  if ( missing_real_path != missing_hash_path ) {
239  if ( !path.empty() )
240  printout(ERROR,"Geant4VolumeManager"," New G4 path: %s", Geant4TouchableHandler::placementPath(path).c_str());
241  if ( !nodes.empty() )
242  printout(ERROR,"Geant4VolumeManager"," TGeo path: %s", detail::tools::placementPath(nodes,false).c_str());
243  printout(ERROR,"Geant4VolumeManager", " Offend.VolIDs: %s", detail::tools::toString(iddesc,ids,code).c_str());
244  }
245  if ( missing_real_path ) {
247  opt.flags.parametrised = path.front()->IsParameterised() ? 1 : 0;
248  opt.flags.replicated = path.front()->IsReplicated() ? 1 : 0;
249  m_geo.g4DebugInfo->g4Paths[path] = { code, opt.value };
250  }
251  }
252 #endif
253  if ( missing_hash_path ) {
255  opt.flags.parametrised = path.front()->IsParameterised() ? 1 : 0;
256  opt.flags.replicated = path.front()->IsReplicated() ? 1 : 0;
257  m_geo.g4Paths[hash] = { code, opt.value };
258  if( m_debug&Geant4VolumeManager::PRINT_VOLIDS ) {
259  std::string idstr = iddesc.str(code);
260  printout(ALWAYS, "Geant4VolumeManager",
261  "+++ Decoded Volume IDs: %016llX -> %s", code, idstr.c_str());
262  }
263  m_entries.emplace(code);
264  return;
265  }
267  if ( !path.empty() && (path.front()->IsParameterised() || path.front()->IsReplicated()) ) {
268  return;
269  }
270  printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Geant4 path!!!! %s %s",
271  " [THIS SHOULD NEVER HAPPEN]", Geant4TouchableHandler::placementPath(path).c_str());
272  goto Err;
273  }
274  printout(INFO, "Geant4VolumeManager", "Control block has still %d entries:%s",
275  int(control.size()), detail::tools::placementPath(control,true).c_str());
276  print_nodes = true;
277  goto Err;
278  }
279  else {
281  if ( !path.empty() && (path.front()->IsParameterised() || path.front()->IsReplicated()) ) {
282  return;
283  }
284  }
285  printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Volume entry: 0x%X"
286  " [THIS SHOULD NEVER HAPPEN]", code);
287 
288  Err:
289  if ( i != m_entries.end() )
290  printout( ERROR,"Geant4VolumeManager"," Known G4 path: %s", Geant4TouchableHandler::placementPath(path).c_str() );
291  if ( !path.empty() )
292  printout( ERROR,"Geant4VolumeManager"," New G4 path: %s", Geant4TouchableHandler::placementPath(path).c_str() );
293  if ( !nodes.empty() ) {
294  printout( ERROR,"Geant4VolumeManager"," TGeo path: %s", detail::tools::placementPath(nodes,false).c_str() );
295  if( print_nodes ) {
296  std::string node_path;
297  for( std::size_t in=0; in<nodes.size(); ++in ) {
298  PlacedVolume pv(nodes[in]);
299  node_path += "/";
300  node_path += pv.name();
301  printout( ALWAYS,"Geant4VolumeManager", " TGeo Node[%ld]: %s [%p] Volids: '%s'",
302  in, node_path.c_str(), (void*)nodes[in], pv.volIDs().str().c_str() );
303  }
304  }
305  }
306  printout( ERROR,"Geant4VolumeManager", " Offend.VolIDs: %s", detail::tools::toString(iddesc,ids,code).c_str() );
307  throw std::runtime_error("Failed to populate Geant4 volume manager!");
308  }
309  };
310 }
311 
315  if( info && info->valid ) {
316  if( !info->has_volmgr ) {
317  Populator p(description, *info, debug);
318  printout( ALWAYS, "Geant4VolumeManager", "+++ Populating Geant4 volume manager.");
319  p.populate(description.world());
320  printout( ALWAYS, "Geant4VolumeManager",
321  "+++ Geant4 volume manager populated with %ld sensitive path entries.",
322  info->g4Paths.size() );
323  if( debug&PRINT_ENTRIES ) {
324  int count = 0;
325  VolumeManager volmgr = description.volumeManager();
326  for( auto it=info->g4Paths.begin(); it != info->g4Paths.end(); ++it, ++count ) {
327  VolumeID volid = it->second.volumeID;
328  VolumeManagerContext* context = volmgr.lookupContext(volid);
329  if( context ) {
330  std::string path = context->element.path();
331  PlacedVolume plac = context->volumePlacement();
333  std::string idstr = sens.idSpec().str(volid);
334  printout( ALWAYS, "Geant4VolumeManager", "%8d: %016X %s -> %s",
335  count, volid, path.c_str(), plac.name());
336  printout(ALWAYS, "Geant4VolumeManager", "%8s %16s %s", "", "", idstr.c_str());
337  }
338  else {
339  printout( ERROR, "Geant4VolumeManager",
340  "Missing volume manager entry: volume ID %016X", volid);
341  }
342  }
343  }
344  info->has_volmgr = true;
345  }
346  return;
347  }
348  except("Geant4VolumeManager", "Attempt populate from invalid Geant4 geometry info [Invalid-Info]");
349 }
350 
352 std::vector<const G4VPhysicalVolume*>
353 Geant4VolumeManager::placementPath(const G4VTouchable* touchable, bool exception) const {
354  Geant4TouchableHandler handler(touchable);
355  return handler.placementPath(exception);
356 }
357 
360  if( !isValid() ) {
361  except("Geant4VolumeManager", "Attempt to use invalid Geant4 volume manager [Invalid-Handle]");
362  }
363  else if( !ptr()->valid ) {
364  except("Geant4VolumeManager", "Attempt to use invalid Geant4 geometry info [Invalid-Info]");
365  }
366  return true;
367 }
368 
369 namespace {
370  std::string debug_status(const Geant4VolumeManager* mgr) {
371  char text[256];
372  auto* p = mgr->ptr();
373  if ( p ) {
374  ::snprintf(text, sizeof(text), "==> #path entries: %ld valid: %s has_volmgr: %s",
375  p->g4Paths.size(), yes_no(p->valid), yes_no(p->has_volmgr));
376  return { text };
377  }
378  return { "Invalid handle to Geant4GeometryInfo" };
379  }
380 }
381 
383 VolumeID Geant4VolumeManager::volumeID(const G4VTouchable* touchable) const {
384  Geant4TouchableHandler handler(touchable);
385  std::vector<const G4VPhysicalVolume*> path = handler.placementPath();
386  if( !isValid() ) {
387  printout(INFO, "Geant4VolumeManager", "+++ INVALID Geant4VolumeManager handle.");
388  return NonExisting;
389  }
390  else if( !ptr()->valid ) {
391  printout(INFO, "Geant4VolumeManager", "+++ INVALID Geant4VolumeManager [Not initialized]");
392  return NonExisting;
393  }
394  else if( path.empty() ) {
395  printout(INFO, "Geant4VolumeManager", "+++ EMPTY volume Geant4 Path: %s",
397  return NonExisting;
398  }
399  else {
400  uint64_t hash = detail::hash64(&path[0], sizeof(path[0])*path.size());
401  auto i = ptr()->g4Paths.find(hash);
402  if( i != ptr()->g4Paths.end() ) {
403  const auto& e = (*i).second;
404  VolumeID volid = e.volumeID;
406  if( e.flags == 0 ) {
407  return volid;
408  }
409  const auto& paramterised = ptr()->g4Parameterised;
410  const auto& replicated = ptr()->g4Replicated;
412  for( std::size_t j=0; j < path.size(); ++j ) {
413  const auto* phys = path[j];
414  if( phys->IsParameterised() ) {
415  int copy_no = touchable->GetCopyNumber(j);
416  const auto it = paramterised.find(phys);
417  if( it != paramterised.end() ) {
418  //printout(INFO,"Geant4VolumeManager",
419  // "Copy number: %ld <--> %ld", copy_no, long(phys->GetCopyNo()));
420  const auto* field = (*it).second.data()->params->field;
421  volid |= IDDescriptor::encode(field, copy_no);
422  continue;
423  }
424  except("Geant4VolumeManager",
425  "Error Geant4VolumeManager::volumeID(const G4VTouchable* touchable)");
426  }
427  else if( phys->IsReplicated() ) {
428  int copy_no = touchable->GetCopyNumber(j);
429  const auto it = replicated.find(phys);
430  if( it != replicated.end() ) {
431  const auto* field = (*it).second.data()->params->field;
432  volid |= IDDescriptor::encode(field, copy_no);
433  continue;
434  }
435  except("Geant4VolumeManager",
436  "Error Geant4VolumeManager::volumeID(const G4VTouchable* touchable)");
437  }
438  }
439  return volid;
440  }
441  if( !path[0] ) {
442  printout(INFO, "Geant4VolumeManager", "+++ Bad Geant4 volume path: \'%s\' [invalid path] %s",
443  Geant4TouchableHandler::placementPath(path).c_str(), debug_status(this).c_str());
444  return InvalidPath;
445  }
446  else if( !path[0]->GetLogicalVolume()->GetSensitiveDetector() ) {
447  printout(DEBUG, "Geant4VolumeManager", "+++ Bad Geant4 volume path: \'%s\' [insensitive] %s",
448  Geant4TouchableHandler::placementPath(path).c_str(), debug_status(this).c_str());
449  return Insensitive;
450  }
451  printout(INFO, "Geant4VolumeManager",
452  "+++ Bad Geant4 volume path: \'%s\' [missing entry] %s",
453  Geant4TouchableHandler::placementPath(path).c_str(), debug_status(this).c_str());
454  return NonExisting;
455  }
456  printout(INFO, "Geant4VolumeManager", "+++ Bad Geant4 volume path: \'%s\' %s",
457  Geant4TouchableHandler::placementPath(path).c_str(), yes_no(path.empty()));
458  return NonExisting;
459 }
460 
462 void Geant4VolumeManager::volumeDescriptor(const std::vector<const G4VPhysicalVolume*>& path,
463  VolIDDescriptor& vol_desc) const
464 {
465  vol_desc.second.clear();
466  vol_desc.first = NonExisting;
467  if( !path.empty() && checkValidity() ) {
468  auto hash = detail::hash64(&path[0], sizeof(path[0])*path.size());
469  auto i = ptr()->g4Paths.find(hash);
470  if( i != ptr()->g4Paths.end() ) {
471  VolumeID vid = (*i).second.volumeID;
472  G4LogicalVolume* lvol = path[0]->GetLogicalVolume();
473  if( lvol->GetSensitiveDetector() ) {
474  const auto* node = path[0];
475  const auto& pm = ptr()->g4Placements;
476  for( const auto& ipm : pm ) {
477  if ( ipm.second == node ) {
478  PlacedVolume pv = ipm.first;
480  IDDescriptor dsc = sd.readout().idSpec();
481  vol_desc.first = vid;
482  dsc.decodeFields(vid, vol_desc.second);
483  return;
484  }
485  }
486  }
487  vol_desc.first = Insensitive;
488  return;
489  }
490  if( !path[0] )
491  vol_desc.first = InvalidPath;
492  else if( !path[0]->GetLogicalVolume()->GetSensitiveDetector() )
493  vol_desc.first = Insensitive;
494  else
495  vol_desc.first = NonExisting;
496  }
497 }
498 
500 void Geant4VolumeManager::volumeDescriptor(const G4VTouchable* touchable,
501  VolIDDescriptor& vol_desc) const {
502  volumeDescriptor(placementPath(touchable), vol_desc);
503 }
dd4hep::IDDescriptor::decodeFields
void decodeFields(VolumeID vid, std::vector< std::pair< const BitFieldElement *, VolumeID > > &fields) const
Decode volume IDs and return filled descriptor with all fields.
Definition: IDDescriptor.cpp:164
dd4hep::DetElement::children
const Children & children() const
Access to the list of children.
Definition: DetElement.cpp:207
dd4hep::DetElement::path
const std::string & path() const
Path of the detector element (not necessarily identical to placement path!)
Definition: DetElement.cpp:158
dd4hep::sim::Geant4VolumeManager::Geant4VolumeManager
Geant4VolumeManager()=default
Default constructor.
dd4hep::DDSegmentation::VolumeID
uint64_t VolumeID
Definition: BitFieldCoder.h:26
dd4hep::sim::Geant4GeometryInfo::PlacementFlags
Definition: Geant4GeometryInfo.h:93
dd4hep::SensitiveDetector::idSpec
IDDescriptor idSpec() const
Access IDDescription structure.
Definition: DetElement.cpp:425
dd4hep::sim::Geant4TouchableHandler
Helper class to ease the extraction of information from a G4Touchable object.
Definition: Geant4TouchableHandler.h:44
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::_flags::parametrised
unsigned parametrised
Definition: Geant4GeometryInfo.h:96
dd4hep::Detector::world
virtual DetElement world() const =0
Return reference to the top-most (world) detector element.
dd4hep::sim::Geant4VolumeManager::PRINT_VOLIDS
@ PRINT_VOLIDS
Definition: Geant4VolumeManager.h:78
dd4hep::sim::Geant4VolumeManager::PRINT_CHAIN
@ PRINT_CHAIN
Definition: Geant4VolumeManager.h:75
dd4hep::VolumeManager::lookupContext
VolumeManagerContext * lookupContext(VolumeID volume_id) const
Lookup the context, which belongs to a registered physical volume.
Definition: VolumeManager.cpp:605
Volumes.h
dd4hep::sim::Geant4VolumeManager::Insensitive
constexpr static const VolumeID Insensitive
Definition: Geant4VolumeManager.h:70
dd4hep::sim::Geant4VolumeManager::PRINT_ACTION
@ PRINT_ACTION
Definition: Geant4VolumeManager.h:74
dd4hep::sim::Geant4VolumeManager::NonExisting
constexpr static const VolumeID NonExisting
Definition: Geant4VolumeManager.h:71
Geant4Mapping.h
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:43
dd4hep::PlacedVolumeExtension
Implementation class extending the ROOT placed volume.
Definition: Volumes.h:80
dd4hep::IDDescriptor::field
const BitFieldElement * field(const std::string &field_name) const
Get the field descriptor of one field by name.
Definition: IDDescriptor.cpp:96
dd4hep::info
std::size_t info(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:65
dd4hep::exception
void exception(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:69
dd4hep::DetElement::type
std::string type() const
Access detector type (structure, tracker, calorimeter, etc.).
Definition: DetElement.cpp:97
dd4hep::sim::Geant4VolumeManager::InvalidPath
constexpr static const VolumeID InvalidPath
Definition: Geant4VolumeManager.h:69
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:164
Geant4VolumeManager.h
dd4hep::DetElement::placement
PlacedVolume placement() const
Access to the physical volume of this detector element.
Definition: DetElement.cpp:321
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::flags
struct dd4hep::sim::Geant4GeometryInfo::PlacementFlags::_flags flags
VolumeManagerInterna.h
dd4hep::detail::tools::placementPath
std::string placementPath(DetElement element)
Assemble the placement path from a given detector element to the world volume.
Definition: DetectorTools.cpp:283
dd4hep::debug
std::size_t debug(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:64
dd4hep::sim::Geant4VolumeManager::PRINT_NODES
@ PRINT_NODES
Definition: Geant4VolumeManager.h:77
dd4hep::sim::Geant4TouchableHandler::Geant4PlacementPath
std::vector< const G4VPhysicalVolume * > Geant4PlacementPath
Definition: Geant4TouchableHandler.h:47
dd4hep::IDDescriptor
Class implementing the ID encoding of the detector response.
Definition: IDDescriptor.h:36
dd4hep::VolumeManagerContext::element
DetElement element
Handle to the closest Detector element.
Definition: VolumeManager.h:53
dd4hep::Handle::isValid
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:126
dd4hep::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:82
dd4hep::PlacedVolumeExtension::volIDs
VolIDs volIDs
ID container.
Definition: Volumes.h:128
dd4hep::sim::Geant4VolumeManager::PRINT_ENTRIES
@ PRINT_ENTRIES
Definition: Geant4VolumeManager.h:79
dd4hep::Volume::isSensitive
bool isSensitive() const
Accessor if volume is sensitive (ie. is attached to a sensitive detector)
Definition: Volumes.cpp:1322
dd4hep::VolumeManagerContext::volumePlacement
PlacedVolume volumePlacement() const
Acces the sensitive volume placement.
Definition: VolumeManager.cpp:314
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::sim::Geant4GeometryInfo::g4Paths
std::map< uint64_t, Placement > g4Paths
Definition: Geant4GeometryInfo.h:134
dd4hep::Detector::volumeManager
virtual VolumeManager volumeManager() const =0
Return handle to the VolumeManager.
dd4hep::sim::Geant4GeometryInfo::printLevel
PrintLevel printLevel
Definition: Geant4GeometryInfo.h:139
VolumeManager.h
dd4hep::sim::Geant4VolumeManager::PRINT_RESULT
@ PRINT_RESULT
Definition: Geant4VolumeManager.h:76
dd4hep::sim::Geant4GeometryInfo::g4Parameterised
Geant4GeometryMaps::G4PlacementMap g4Parameterised
Definition: Geant4GeometryInfo.h:118
dd4hep::sim::Geant4VolumeManager::volumeID
VolumeID volumeID(const G4VTouchable *touchable) const
Access CELLID by Geant4 touchable object.
Definition: Geant4VolumeManager.cpp:383
Geant4AssemblyVolume.h
VolIDDescriptor
std::pair< VolumeID, std::vector< std::pair< const BitFieldElement *, VolumeID > > > VolIDDescriptor
Definition: Geant4VolumeManager.cpp:70
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:187
dd4hep::PlacedVolumeExtension::VolIDs
Volume ID container.
Definition: Volumes.h:89
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:371
dd4hep::VolumeManager
Class to support the retrieval of detector elements and volumes given a valid identifier.
Definition: VolumeManager.h:135
dd4hep::sim::Geant4GeometryInfo::g4Placements
Geant4GeometryMaps::PlacementMap g4Placements
Definition: Geant4GeometryInfo.h:115
dd4hep::IDDescriptor::encode
static VolumeID encode(const Field *fld, VolumeID value)
Encode partial volume identifiers to a volumeID.
Definition: IDDescriptor.cpp:148
DetectorTools.h
Geant4TouchableHandler.h
dd4hep::IDDescriptor::str
std::string str(VolumeID vid) const
Decode volume IDs and return string reprensentation for debugging purposes.
Definition: IDDescriptor.cpp:174
dd4hep::sim::Geant4GeometryInfo::g4DebugInfo
DebugInfo * g4DebugInfo
Definition: Geant4GeometryInfo.h:109
dd4hep::sim::Geant4VolumeManager
The Geant4VolumeManager to facilitate optimized lookups of cell IDs from touchables.
Definition: Geant4VolumeManager.h:47
dd4hep::sim::Geant4VolumeManager::placementPath
std::vector< const G4VPhysicalVolume * > placementPath(const G4VTouchable *touchable, bool exception=true) const
Helper: Generate placement path from touchable object.
Definition: Geant4VolumeManager.cpp:353
dd4hep::sim::Geant4GeometryInfo::g4VolumeImprints
Geant4GeometryMaps::VolumeImprintMap g4VolumeImprints
Definition: Geant4GeometryInfo.h:117
dd4hep::sim::IDDescriptor
IDDescriptor IDDescriptor
Definition: LCIOConversions.cpp:69
dd4hep::sim::Geant4GeometryInfo::g4Replicated
Geant4GeometryMaps::G4PlacementMap g4Replicated
Definition: Geant4GeometryInfo.h:119
VolumeID
dd4hep::DDSegmentation::VolumeID VolumeID
Definition: SegmentationDictionary.h:50
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::_flags::replicated
unsigned replicated
Definition: Geant4GeometryInfo.h:97
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: EDM4hepFileReader.cpp:46
dd4hep::DetElement::Children
std::map< std::string, DetElement > Children
Definition: DetElement.h:205
dd4hep::sim::Geant4TouchableHandler::placementPath
static std::string placementPath(const Geant4PlacementPath &path, bool reverse=true)
Assemble Geant4 volume path.
Definition: Geant4TouchableHandler.cpp:58
dd4hep::sim::Geant4GeometryInfo
Concreate class holding the relation information between geant4 objects and dd4hep objects.
Definition: Geant4GeometryInfo.h:91
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:151
DetElement.h
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::PlacedVolumeExtension::VolIDs::str
std::string str() const
String representation for debugging.
Definition: Volumes.cpp:436
dd4hep::SensitiveDetector::readout
Readout readout() const
Access readout structure of the sensitive detector.
Definition: DetElement.cpp:420
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::value
int value
Definition: Geant4GeometryInfo.h:94
dd4hep::detail::tools::toString
std::string toString(const PlacedVolume::VolIDs &ids)
Convert VolumeID to string.
Definition: DetectorTools.cpp:385
dd4hep::PlacedVolume::volume
Volume volume() const
Logical volume of this placement.
Definition: Volumes.cpp:468
dd4hep::PlacedVolume::data
Object * data() const
Check if placement is properly instrumented.
Definition: Volumes.cpp:447
dd4hep::sim::hash
unsigned int hash(unsigned int initialSeed, unsigned int eventNumber, unsigned int runNumber)
calculate hash from initialSeed, eventID and runID
Definition: Geant4EventSeed.h:191
dd4hep::VolumeManagerContext
This structure describes the cached data for one placement held by the volume manager.
Definition: VolumeManager.h:50
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::sim::_print_volumeid
void _print_volumeid(const std::string &tag, const IDDescriptor &id, DDSegmentation::VolumeID volID)
Print volume ID.
Definition: Geant4SensDetAction.cpp:46
dd4hep::PlacedVolumeExtension::Parameterisation::field
const detail::BitFieldElement * field
Bitfield from sensitive detector to encode the volume ID on the fly.
Definition: Volumes.h:266
dd4hep::Readout
Handle to the implementation of the readout structure of a subdetector.
Definition: Readout.h:38
dd4hep::Readout::idSpec
IDDescriptor idSpec() const
Access IDDescription structure.
Definition: Readout.cpp:112
dd4hep::PlacedVolume::volIDs
const PlacedVolumeExtension::VolIDs & volIDs() const
Access to the volume IDs.
Definition: Volumes.cpp:496
valid
unsigned char valid
Definition: AlignmentsCalculator.cpp:69
dd4hep::sim::Geant4VolumeManager::volumeDescriptor
void volumeDescriptor(const std::vector< const G4VPhysicalVolume * > &path, std::pair< VolumeID, std::vector< std::pair< const BitFieldElement *, VolumeID > > > &volume_desc) const
Access fully decoded volume fields by placement path.
dd4hep::PlacedVolumeExtension::params
Parameterisation * params
Reference to the parameterised transformation.
Definition: Volumes.h:126
Printout.h
dd4hep::sim::Geant4VolumeManager::checkValidity
bool checkValidity() const
Check the validity of the information before accessing it.
Definition: Geant4VolumeManager.cpp:359
dd4hep::Volume::sensitiveDetector
Handle< NamedObject > sensitiveDetector() const
Access to the handle to the sensitive detector.
Definition: Volumes.cpp:1316