DD4hep  1.38.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 <unordered_map>
35 #include <utility>
36 #include <vector>
37 
38 //#define VOLMGR_HAVE_DEBUG_INFO 1
39 
40 #ifdef VOLMGR_HAVE_DEBUG_INFO
41 namespace dd4hep {
44  namespace sim {
45 
46  class Geant4GeometryInfo::DebugInfo {
47  public:
48  typedef std::vector<const G4VPhysicalVolume*> Geant4PlacementPath;
49  std::map<Geant4PlacementPath, Placement> g4Paths;
50  };
51 
52  } // End namespace sim
53 } // End namespace dd4hep
54 #endif
55 
56 
58 namespace dd4hep {
60  namespace sim {
62  void _print_volumeid(const std::string& tag, const IDDescriptor& iddesc, DDSegmentation::VolumeID volID);
63 
64  } // End namespace sim
65 } // End namespace dd4hep
66 
67 using namespace dd4hep::sim;
68 using namespace dd4hep;
69 
71 using VolIDDescriptor = std::pair<VolumeID,std::vector<std::pair<const BitFieldElement*, VolumeID> > >;
72 
73 namespace {
74 
76 
81  struct Populator {
82 
83  typedef std::vector<const TGeoNode*> Chain;
84  // typedef std::map<VolumeID,Geant4TouchableHandler::Geant4PlacementPath> Registries;
85  typedef std::set<VolumeID> Registries;
86 
88  const Detector& m_detDesc;
90  Registries m_entries;
92  Geant4GeometryInfo& m_geo;
94  long m_debug { 0 };
96  std::unordered_map<TGeoVolume*, bool> m_has_sensitive;
97 
99  Populator(const Detector& description, Geant4GeometryInfo& g, long dbg)
100  : m_detDesc(description), m_geo(g), m_debug(dbg)
101  {
102 #ifdef VOLMGR_HAVE_DEBUG_INFO
103  if ( nullptr == g.g4DebugInfo ) {
104  g.g4DebugInfo = new Geant4GeometryInfo::DebugInfo();
105  }
106 #endif
107  }
109  ~Populator() {
110 #ifdef VOLMGR_HAVE_DEBUG_INFO
111  if ( g.g4DebugInfo ) {
112  delete g.g4DebugInfo;
113  g.g4DebugInfo = nullptr;
114  }
115 #endif
116  }
117 
118 
120  void populate(DetElement e) {
121  const DetElement::Children& children = e.children();
122  m_entries.clear();
123  for( const auto& i : children ) {
124  DetElement de = i.second;
125  PlacedVolume pv = de.placement();
126  if( pv.isValid() ) {
127  Chain chain;
130  m_entries.clear();
131  chain.emplace_back(m_detDesc.world().placement().ptr());
132  scanPhysicalVolume(pv.ptr(), ids, sd, chain);
133  continue;
134  }
135  printout(WARNING, "Geant4VolumeManager",
136  "++ Detector element %s of type %s has no placement.",
137  de.name(), de.type().c_str());
138  }
140  for( const auto& pv : m_geo.g4Placements ) {
141  if( pv.second->IsParameterised() )
142  m_geo.g4Parameterised[pv.second] = pv.first;
143  if( pv.second->IsReplicated() )
144  m_geo.g4Replicated[pv.second] = pv.first;
145  }
146  m_entries.clear();
147  }
148 
151  bool hasSensitiveContent(TGeoVolume* vol) {
152  auto [it, inserted] = m_has_sensitive.emplace(vol, false);
153  if ( !inserted ) return it->second;
154  if ( Volume(vol).isSensitive() ) return it->second = true;
155  for ( Int_t i = 0, n = vol->GetNdaughters(); i < n; ++i ) {
156  TGeoNode* dau = vol->GetNode(i);
157  if ( PlacedVolume(dau).data() && hasSensitiveContent(dau->GetVolume()) )
158  return it->second = true;
159  }
160  return false;
161  }
162 
164  void scanPhysicalVolume(const TGeoNode* node, PlacedVolume::VolIDs& ids, SensitiveDetector& sd, Chain& chain) {
165  PlacedVolume pv = node;
166  Volume vol = pv.volume();
167  const PlacedVolume::VolIDs& pv_ids = pv.volIDs();
168 
169  chain.emplace_back(node);
170  const std::size_t ids_save = ids.size();
171  ids.PlacedVolume::VolIDs::Base::insert(ids.end(), pv_ids.begin(), pv_ids.end());
172  if( vol.isSensitive() ) {
173  sd = vol.sensitiveDetector();
174  if( sd.readout().isValid() ) {
175  add_entry(sd, node, ids, chain);
176  }
177  else {
178  printout(WARNING, "Geant4VolumeManager",
179  "populate: Strange constellation volume %s is sensitive, but has no readout! sd:%p", pv.volume().name(),
180  sd.ptr());
181  }
182  }
183  for( Int_t idau = 0, ndau = node->GetNdaughters(); idau < ndau; ++idau ) {
184  TGeoNode* daughter = node->GetDaughter(idau);
185  PlacedVolume placement(daughter);
186  if( placement.data() && hasSensitiveContent(daughter->GetVolume()) ) {
187  scanPhysicalVolume(daughter, ids, sd, chain);
188  }
189  }
190  ids.resize(ids_save);
191  chain.pop_back();
192  }
193 
194  void add_entry(SensitiveDetector sd, const TGeoNode* n, const PlacedVolume::VolIDs& ids, const Chain& nodes) {
195  Chain control;
196  Volume vol;
197  Readout rdout = sd.readout();
198  IDDescriptor iddesc = rdout.idSpec();
199  VolumeID code = iddesc.encode(ids);
200  PrintLevel print_action = (m_debug&Geant4VolumeManager::PRINT_ACTION) ? ALWAYS : m_geo.printLevel;
201  PrintLevel print_chain = (m_debug&Geant4VolumeManager::PRINT_CHAIN) ? ALWAYS : m_geo.printLevel;
202  PrintLevel print_res = (m_debug&Geant4VolumeManager::PRINT_RESULT) ? ALWAYS : m_geo.printLevel;
203  bool print_nodes = (m_debug&Geant4VolumeManager::PRINT_NODES) ? true : false;
205  Registries::const_iterator i = m_entries.find(code);
206 
207  printout(print_action,"Geant4VolumeManager","+++ Add path:%s vid:%016X",
208  detail::tools::placementPath(nodes, false).c_str(), code);
209 
210  if( i == m_entries.end() ) {
211  path.reserve(nodes.size());
212  for( Chain::const_reverse_iterator k = nodes.rbegin(), kend=nodes.rend(); k != kend; ++k ) {
213  const TGeoNode* node = *(k);
214  auto g4pit = m_geo.g4Placements.find(node);
215  if( g4pit != m_geo.g4Placements.end() ) {
216  G4VPhysicalVolume* phys = g4pit->second;
217  if( phys->IsParameterised() ) {
218  PlacedVolume pv(n);
219  PlacedVolumeExtension* ext = pv.data();
220  if( nullptr == ext->params->field ) {
221  ext->params->field = iddesc.field(ext->volIDs.at(0).first);
222  }
223  }
224  path.emplace_back(phys);
225  printout(print_chain, "Geant4VolumeManager",
226  "+++ Chain: Node OK: %s [%s]", node->GetName(), phys->GetName().c_str());
227  continue;
228  }
229  control.insert(control.begin(),node);
230  vol = Volume(node->GetVolume());
231  auto iVolImp = m_geo.g4VolumeImprints.find(vol);
232  if ( iVolImp != m_geo.g4VolumeImprints.end() ) {
233  for(const auto& imp : iVolImp->second ) {
234  const auto& c = imp.first;
235  if ( c.size() <= control.size() && control == c ) {
236  path.emplace_back(imp.second);
237  printout(print_chain, "Geant4VolumeManager", "+++ Chain: Node OK: %s %s -> %s",
238  node->GetName(), detail::tools::placementPath(c,false).c_str(),
239  imp.second->GetName().c_str());
240  control.clear();
241  break;
242  }
243  }
244  }
245  }
246  if ( control.empty() ) {
247  printout(print_res, "Geant4VolumeManager", "+++ Encoded Volume IDs:%s",
248  detail::tools::toString(iddesc,ids,code).c_str());
249  path.erase(path.begin()+path.size()-1);
250  printout(print_res, "Geant4VolumeManager", "+++ Map %016X to Geant4 Path:%s",
251  (void*)code, Geant4TouchableHandler::placementPath(path).c_str());
252  auto hash = detail::hash64(&path[0], path.size()*sizeof(path[0]));
253  bool missing_hash_path = m_geo.g4Paths.find(hash) == m_geo.g4Paths.end();
254 #ifdef VOLMGR_HAVE_DEBUG_INFO
255  {
256  bool missing_real_path = m_geo.g4DebugInfo->g4Paths.find(path) == m_geo.g4DebugInfo->g4Paths.end();
257  if ( missing_real_path != missing_hash_path ) {
258  if ( !path.empty() )
259  printout(ERROR,"Geant4VolumeManager"," New G4 path: %s", Geant4TouchableHandler::placementPath(path).c_str());
260  if ( !nodes.empty() )
261  printout(ERROR,"Geant4VolumeManager"," TGeo path: %s", detail::tools::placementPath(nodes,false).c_str());
262  printout(ERROR,"Geant4VolumeManager", " Offend.VolIDs: %s", detail::tools::toString(iddesc,ids,code).c_str());
263  }
264  if ( missing_real_path ) {
266  opt.flags.parametrised = path.front()->IsParameterised() ? 1 : 0;
267  opt.flags.replicated = path.front()->IsReplicated() ? 1 : 0;
268  m_geo.g4DebugInfo->g4Paths[path] = { code, opt.value };
269  }
270  }
271 #endif
272  if ( missing_hash_path ) {
274  opt.flags.parametrised = path.front()->IsParameterised() ? 1 : 0;
275  opt.flags.replicated = path.front()->IsReplicated() ? 1 : 0;
276  m_geo.g4Paths[hash] = { code, opt.value };
277  if( m_debug&Geant4VolumeManager::PRINT_VOLIDS ) {
278  std::string idstr = iddesc.str(code);
279  printout(ALWAYS, "Geant4VolumeManager",
280  "+++ Decoded Volume IDs: %016llX -> %s", code, idstr.c_str());
281  }
282  m_entries.emplace(code);
283  return;
284  }
286  if ( !path.empty() && (path.front()->IsParameterised() || path.front()->IsReplicated()) ) {
287  return;
288  }
289  printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Geant4 path!!!! %s %s",
290  " [THIS SHOULD NEVER HAPPEN]", Geant4TouchableHandler::placementPath(path).c_str());
291  goto Err;
292  }
293  printout(INFO, "Geant4VolumeManager", "Control block has still %d entries:%s",
294  int(control.size()), detail::tools::placementPath(control,true).c_str());
295  print_nodes = true;
296  goto Err;
297  }
298  else {
300  if ( !path.empty() && (path.front()->IsParameterised() || path.front()->IsReplicated()) ) {
301  return;
302  }
303  }
304  printout(ERROR, "Geant4VolumeManager", "populate: Severe error: Duplicated Volume entry: 0x%X"
305  " [THIS SHOULD NEVER HAPPEN]", code);
306 
307  Err:
308  if ( i != m_entries.end() )
309  printout( ERROR,"Geant4VolumeManager"," Known G4 path: %s", Geant4TouchableHandler::placementPath(path).c_str() );
310  if ( !path.empty() )
311  printout( ERROR,"Geant4VolumeManager"," New G4 path: %s", Geant4TouchableHandler::placementPath(path).c_str() );
312  if ( !nodes.empty() ) {
313  printout( ERROR,"Geant4VolumeManager"," TGeo path: %s", detail::tools::placementPath(nodes,false).c_str() );
314  if( print_nodes ) {
315  std::string node_path;
316  for( std::size_t in=0; in<nodes.size(); ++in ) {
317  PlacedVolume pv(nodes[in]);
318  node_path += "/";
319  node_path += pv.name();
320  printout( ALWAYS,"Geant4VolumeManager", " TGeo Node[%ld]: %s [%p] Volids: '%s'",
321  in, node_path.c_str(), (void*)nodes[in], pv.volIDs().str().c_str() );
322  }
323  }
324  }
325  printout( ERROR,"Geant4VolumeManager", " Offend.VolIDs: %s", detail::tools::toString(iddesc,ids,code).c_str() );
326  throw std::runtime_error("Failed to populate Geant4 volume manager!");
327  }
328  };
329 }
330 
334  if( info && info->valid ) {
335  if( !info->has_volmgr ) {
336  Populator p(description, *info, debug);
337  printout( ALWAYS, "Geant4VolumeManager", "+++ Populating Geant4 volume manager.");
338  p.populate(description.world());
339  printout( ALWAYS, "Geant4VolumeManager",
340  "+++ Geant4 volume manager populated with %ld sensitive path entries.",
341  info->g4Paths.size() );
342  if( debug&PRINT_ENTRIES ) {
343  int count = 0;
344  VolumeManager volmgr = description.volumeManager();
345  for( auto it=info->g4Paths.begin(); it != info->g4Paths.end(); ++it, ++count ) {
346  VolumeID volid = it->second.volumeID;
347  VolumeManagerContext* context = volmgr.lookupContext(volid);
348  if( context ) {
349  std::string path = context->element.path();
350  PlacedVolume plac = context->volumePlacement();
352  std::string idstr = sens.idSpec().str(volid);
353  printout( ALWAYS, "Geant4VolumeManager", "%8d: %016X %s -> %s",
354  count, volid, path.c_str(), plac.name());
355  printout(ALWAYS, "Geant4VolumeManager", "%8s %16s %s", "", "", idstr.c_str());
356  }
357  else {
358  printout( ERROR, "Geant4VolumeManager",
359  "Missing volume manager entry: volume ID %016X", volid);
360  }
361  }
362  }
363  info->has_volmgr = true;
364  }
365  return;
366  }
367  except("Geant4VolumeManager", "Attempt populate from invalid Geant4 geometry info [Invalid-Info]");
368 }
369 
371 std::vector<const G4VPhysicalVolume*>
372 Geant4VolumeManager::placementPath(const G4VTouchable* touchable, bool exception) const {
373  Geant4TouchableHandler handler(touchable);
374  return handler.placementPath(exception);
375 }
376 
379  if( !isValid() ) {
380  except("Geant4VolumeManager", "Attempt to use invalid Geant4 volume manager [Invalid-Handle]");
381  }
382  else if( !ptr()->valid ) {
383  except("Geant4VolumeManager", "Attempt to use invalid Geant4 geometry info [Invalid-Info]");
384  }
385  return true;
386 }
387 
388 namespace {
389  std::string debug_status(const Geant4VolumeManager* mgr) {
390  char text[256];
391  auto* p = mgr->ptr();
392  if ( p ) {
393  ::snprintf(text, sizeof(text), "==> #path entries: %ld valid: %s has_volmgr: %s",
394  p->g4Paths.size(), yes_no(p->valid), yes_no(p->has_volmgr));
395  return { text };
396  }
397  return { "Invalid handle to Geant4GeometryInfo" };
398  }
399 }
400 
402 VolumeID Geant4VolumeManager::volumeID(const G4VTouchable* touchable) const {
403  Geant4TouchableHandler handler(touchable);
404  std::vector<const G4VPhysicalVolume*> path = handler.placementPath();
405  if( !isValid() ) {
406  printout(INFO, "Geant4VolumeManager", "+++ INVALID Geant4VolumeManager handle.");
407  return NonExisting;
408  }
409  else if( !ptr()->valid ) {
410  printout(INFO, "Geant4VolumeManager", "+++ INVALID Geant4VolumeManager [Not initialized]");
411  return NonExisting;
412  }
413  else if( path.empty() ) {
414  printout(INFO, "Geant4VolumeManager", "+++ EMPTY volume Geant4 Path: %s",
416  return NonExisting;
417  }
418  else {
419  uint64_t hash = detail::hash64(&path[0], sizeof(path[0])*path.size());
420  auto i = ptr()->g4Paths.find(hash);
421  if( i != ptr()->g4Paths.end() ) {
422  const auto& e = (*i).second;
423  VolumeID volid = e.volumeID;
425  if( e.flags == 0 ) {
426  return volid;
427  }
428  const auto& paramterised = ptr()->g4Parameterised;
429  const auto& replicated = ptr()->g4Replicated;
431  for( std::size_t j=0; j < path.size(); ++j ) {
432  const auto* phys = path[j];
433  if( phys->IsParameterised() ) {
434  int copy_no = touchable->GetCopyNumber(j);
435  const auto it = paramterised.find(phys);
436  if( it != paramterised.end() ) {
437  //printout(INFO,"Geant4VolumeManager",
438  // "Copy number: %ld <--> %ld", copy_no, long(phys->GetCopyNo()));
439  const auto* field = (*it).second.data()->params->field;
440  volid |= IDDescriptor::encode(field, copy_no);
441  continue;
442  }
443  except("Geant4VolumeManager",
444  "Error Geant4VolumeManager::volumeID(const G4VTouchable* touchable)");
445  }
446  else if( phys->IsReplicated() ) {
447  int copy_no = touchable->GetCopyNumber(j);
448  const auto it = replicated.find(phys);
449  if( it != replicated.end() ) {
450  const auto* field = (*it).second.data()->params->field;
451  volid |= IDDescriptor::encode(field, copy_no);
452  continue;
453  }
454  except("Geant4VolumeManager",
455  "Error Geant4VolumeManager::volumeID(const G4VTouchable* touchable)");
456  }
457  }
458  return volid;
459  }
460  if( !path[0] ) {
461  printout(INFO, "Geant4VolumeManager", "+++ Bad Geant4 volume path: \'%s\' [invalid path] %s",
462  Geant4TouchableHandler::placementPath(path).c_str(), debug_status(this).c_str());
463  return InvalidPath;
464  }
465  else if( !path[0]->GetLogicalVolume()->GetSensitiveDetector() ) {
466  printout(DEBUG, "Geant4VolumeManager", "+++ Bad Geant4 volume path: \'%s\' [insensitive] %s",
467  Geant4TouchableHandler::placementPath(path).c_str(), debug_status(this).c_str());
468  return Insensitive;
469  }
470  printout(INFO, "Geant4VolumeManager",
471  "+++ Bad Geant4 volume path: \'%s\' [missing entry] %s",
472  Geant4TouchableHandler::placementPath(path).c_str(), debug_status(this).c_str());
473  return NonExisting;
474  }
475  printout(INFO, "Geant4VolumeManager", "+++ Bad Geant4 volume path: \'%s\' %s",
476  Geant4TouchableHandler::placementPath(path).c_str(), yes_no(path.empty()));
477  return NonExisting;
478 }
479 
481 void Geant4VolumeManager::volumeDescriptor(const std::vector<const G4VPhysicalVolume*>& path,
482  VolIDDescriptor& vol_desc) const
483 {
484  vol_desc.second.clear();
485  vol_desc.first = NonExisting;
486  if( !path.empty() && checkValidity() ) {
487  auto hash = detail::hash64(&path[0], sizeof(path[0])*path.size());
488  auto i = ptr()->g4Paths.find(hash);
489  if( i != ptr()->g4Paths.end() ) {
490  VolumeID vid = (*i).second.volumeID;
491  G4LogicalVolume* lvol = path[0]->GetLogicalVolume();
492  if( lvol->GetSensitiveDetector() ) {
493  const auto* node = path[0];
494  const auto& pm = ptr()->g4Placements;
495  for( const auto& ipm : pm ) {
496  if ( ipm.second == node ) {
497  PlacedVolume pv = ipm.first;
499  IDDescriptor dsc = sd.readout().idSpec();
500  vol_desc.first = vid;
501  dsc.decodeFields(vid, vol_desc.second);
502  return;
503  }
504  }
505  }
506  vol_desc.first = Insensitive;
507  return;
508  }
509  if( !path[0] )
510  vol_desc.first = InvalidPath;
511  else if( !path[0]->GetLogicalVolume()->GetSensitiveDetector() )
512  vol_desc.first = Insensitive;
513  else
514  vol_desc.first = NonExisting;
515  }
516 }
517 
519 void Geant4VolumeManager::volumeDescriptor(const G4VTouchable* touchable,
520  VolIDDescriptor& vol_desc) const {
521  volumeDescriptor(placementPath(touchable), vol_desc);
522 }
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:623
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:332
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:402
Geant4AssemblyVolume.h
VolIDDescriptor
std::pair< VolumeID, std::vector< std::pair< const BitFieldElement *, VolumeID > > > VolIDDescriptor
Definition: Geant4VolumeManager.cpp:71
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:372
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:201
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:89
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:378
dd4hep::Volume::sensitiveDetector
Handle< NamedObject > sensitiveDetector() const
Access to the handle to the sensitive detector.
Definition: Volumes.cpp:1316