DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
DD4hepRootPersistency.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>
19 
20 // ROOT include files
21 #include <TFile.h>
22 #include <TTimeStamp.h>
23 #include <memory>
24 
26 
27 using namespace dd4hep;
28 
29 namespace {
31  void load_nominal_alignments(DetElement de) {
32  de.nominal();
33  de.survey();
34  for(const auto& c : de.children())
35  load_nominal_alignments(c.second);
36  }
37 }
38 
41 }
42 
45 }
46 
47 int DD4hepRootPersistency::save(Detector& description, const char* fname, const char* instance) {
48  TFile* f = TFile::Open(fname,"RECREATE");
49  if ( f && !f->IsZombie()) {
50  try {
51  TTimeStamp start;
52  DetectorData::patchRootStreamer(TGeoVolume::Class());
53  DetectorData::patchRootStreamer(TGeoNode::Class());
54  load_nominal_alignments(description.world());
56  persist->m_data = new dd4hep::DetectorData();
57  persist->m_data->adoptData(dynamic_cast<DetectorData&>(description),false);
58  for( const auto& sens : persist->m_data->m_sensitive ) {
59  dd4hep::SensitiveDetector sd = sens.second;
60  dd4hep::Readout ro = sd.readout();
61  if ( ro.isValid() && ro.segmentation().isValid() ) {
62  persist->m_segments[ro].first = ro.idSpec();
63  persist->m_segments[ro].second = ro.segmentation().segmentation();
64  }
65  }
66  if ( persist->volumeManager().isValid() ) {
67  for( const auto& mgr : persist->m_data->m_volManager->managers ) {
68  for( const auto& vol : mgr.second->volumes ) {
69  persist->nominals[vol.second->element] = vol.second->element.nominal();
70  }
71  }
72  printout(ALWAYS,"DD4hepRootPersistency","+++ Saving %ld nominals....",persist->nominals.size());
73  }
74  else {
75  printout(ALWAYS,
76  "DD4hepRootPersistency","+++ No valid Volume manager. No nominals saved.",
77  persist->nominals.size());
78  }
79 
81  int nBytes = persist->Write(instance);
82  f->Close();
83  TTimeStamp stop;
84  printout(ALWAYS,"DD4hepRootPersistency",
85  "+++ Wrote %d Bytes of geometry data '%s' to '%s' [%8.3f seconds].",
86  nBytes, instance, fname, stop.AsDouble()-start.AsDouble());
87  if ( nBytes > 0 ) {
88  printout(ALWAYS,"DD4hepRootPersistency",
89  "+++ Successfully saved geometry data to file.");
90  }
91  delete f;
92  delete persist;
93  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
94  DetectorData::unpatchRootStreamer(TGeoNode::Class());
95  return nBytes;
96  }
97  catch (const std::exception& e) {
98  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
99  DetectorData::unpatchRootStreamer(TGeoNode::Class());
100  except("DD4hepRootPersistency","Exception %s while saving file %s",e.what(), fname);
101  }
102  catch (...) {
103  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
104  DetectorData::unpatchRootStreamer(TGeoNode::Class());
105  except("DD4hepRootPersistency","UNKNOWN exception while saving file %s", fname);
106  }
107  return 0;
108  }
109  printout(ERROR,"DD4hepRootPersistency","+++ Cannot open file '%s'.",fname);
110  return 0;
111 }
112 
113 int DD4hepRootPersistency::load(Detector& description, const char* fname, const char* instance) {
114  DetectorData::patchRootStreamer(TGeoVolume::Class());
115  DetectorData::patchRootStreamer(TGeoNode::Class());
116  TFile* f = TFile::Open(fname);
117  if ( f && !f->IsZombie()) {
118  try {
119  TTimeStamp start;
120  std::unique_ptr<DD4hepRootPersistency> persist((DD4hepRootPersistency*)f->Get(instance));
121  if ( persist.get() ) {
122  DetectorData* source = persist->m_data;
123 #if 0
124  const auto& iddesc = persist->idSpecifications();
125  for( const auto& idd : iddesc ) {
126  IDDescriptor id = idd.second;
127  id.rebuild(id->description);
128  }
129  printout(ALWAYS,"DD4hepRootPersistency",
130  "+++ Fixed %ld IDDescriptor objects.",iddesc.size());
131 #endif
132  for( const auto& sg : persist->m_segments ) {
133  Readout ro = sg.first;
134  IDDescriptor id = sg.second.first;
135  DDSegmentation::Segmentation* seg = sg.second.second;
136  ro.setSegmentation(Segmentation(seg->type(),seg->name(),id.decoder()));
137  delete seg;
138  }
139  printout(ALWAYS,"DD4hepRootPersistency",
140  "+++ Fixed %ld segmentation objects.",persist->m_segments.size());
141  persist->m_segments.clear();
142  if ( persist->volumeManager().isValid() ) {
143  const auto& sdets = persist->volumeManager()->subdetectors;
144  size_t num[3] = {0,0,0};
145  for( const auto& vm : sdets ) {
146  VolumeManager::Object* obj = vm.second.ptr();
147  obj->system = obj->id.field("system");
148  if ( 0 != obj->system ) {
149  printout(ALWAYS,"DD4hepRootPersistency",
150  "+++ Fixed VolumeManager.system for %-24s %6ld volumes %4ld sdets %4ld mgrs.",
151  obj->detector.path().c_str(), obj->volumes.size(),
152  obj->subdetectors.size(), obj->managers.size());
153  num[0] += obj->volumes.size();
154  num[1] += obj->subdetectors.size();
155  num[2] += obj->managers.size();
156  continue;
157  }
158  printout(ALWAYS,"DD4hepRootPersistency",
159  "+++ FAILED to fix VolumeManager.system for '%s: %s'.",
160  obj->detector.path().c_str(), "[No IDDescriptor field 'system']");
161  }
162  printout(ALWAYS,"DD4hepRootPersistency",
163  "+++ Fixed VolumeManager TOTALS %-24s %6ld volumes %4ld sdets %4ld mgrs.","",num[0],num[1],num[2]);
164  printout(ALWAYS,"DD4hepRootPersistency","+++ loaded %ld nominals....",persist->nominals.size());
165  }
166  else {
167  printout(ALWAYS,"DD4hepRootPersistency","+++ Volume manager NOT restored. [Was it ever up when saved?]");
168  }
169  DetectorData* tar_data = dynamic_cast<DetectorData*>(&description);
170  DetectorData* src_data = dynamic_cast<DetectorData*>(source);
171  if( tar_data != nullptr && src_data != nullptr ) {
172  tar_data->adoptData(*src_data,false);
173  TTimeStamp stop;
174  printout(ALWAYS,"DD4hepRootPersistency",
175  "+++ Successfully loaded detector description from file:%s [%8.3f seconds]",
176  fname, stop.AsDouble()-start.AsDouble());
177  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
178  DetectorData::unpatchRootStreamer(TGeoNode::Class());
179  return 1;
180  }
181  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
182  DetectorData::unpatchRootStreamer(TGeoNode::Class());
183  return 0;
184  }
185  printout(ERROR,"DD4hepRootPersistency",
186  "+++ Cannot Cannot load instance '%s' from file '%s'.",
187  instance, fname);
188  f->ls();
189  delete f;
190  }
191  catch (const std::exception& e) {
192  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
193  DetectorData::unpatchRootStreamer(TGeoNode::Class());
194  except("DD4hepRootPersistency","Exception %s while loading file %s",e.what(), fname);
195  }
196  catch (...) {
197  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
198  DetectorData::unpatchRootStreamer(TGeoNode::Class());
199  except("DD4hepRootPersistency","UNKNOWN exception while loading %s", fname);
200  }
201  return 0;
202  }
203  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
204  DetectorData::unpatchRootStreamer(TGeoNode::Class());
205  printout(ERROR,"DD4hepRootPersistency","+++ Cannot open file '%s'.",fname);
206  return 0;
207 }
208 
212 
213 namespace {
214 
215  class PersistencyChecks {
216  public:
217  size_t errors = 0;
218 
220  PersistencyChecks() = default;
221 
222  size_t checkConstant(const std::pair<std::string,Constant>& obj) {
223  if ( obj.first.empty() || obj.second->name.empty() ) {
224  printout(ERROR,"chkConstant","+++ Invalid constant: key error %s <> %s [%s]",
225  obj.first.c_str(), obj.second->GetName(), obj.second->GetTitle());
226  ++errors;
227  return 0;
228  }
229  if ( obj.first != obj.second->GetName() ) {
230  printout(ERROR,"chkConstant","+++ Invalid constant: key error %s <> %s [%s]",
231  obj.first.c_str(), obj.second->GetName(), obj.second->GetTitle());
232  ++errors;
233  return 0;
234  }
235  return 1;
236  }
237 
238  size_t checkProperty(const std::pair<std::string, std::map<std::string,std::string> >& obj) {
239  if ( obj.first.empty() || obj.second.empty() ) {
240  printout(ERROR,"chkProperty","+++ Empty property set: %s",obj.first.c_str());
241  ++errors;
242  return 0;
243  }
244  return 1;
245  }
246 
247  size_t printDetElement(DetElement d) {
248  const DetElement::Children& children = d.children();
249  size_t count = 1;
250  printout(INFO,"chkDetector","+++ %-40s Level:%3d Key:%08X VolID:%016llX",
251  d.name(), d.level(), d.key(), d.volumeID());
252  Alignment ideal = d.nominal();
253  if ( ideal.isValid() ) {
254  const Delta& delta = ideal.delta();
255  printout(INFO,"chkDetector","+++ Ideal: %s Delta:%s--%s--%s",
256  yes_no(ideal.isValid()),
257  delta.hasTranslation() ? "Translation" : " ",
258  delta.hasRotation() ? "Rotation" : " ",
259  delta.hasPivot() ? "Pivot" : " "
260  );
261  //ideal.worldTransformation().Print();
262  }
263  else {
264  printout(INFO,"chkDetector","+++ Ideal: %s",yes_no(ideal.isValid()));
265  }
266  for( const auto& c : children )
267  count += printDetElement(c.second);
268  return count;
269  }
270 
271  size_t checkDetector(DetElement d) {
272  printout(INFO,"chkDetector","+++ Checking Sub-Detector: %-40s Key:%08X VolID:%016llX",
273  d.name(), d.key(), d.volumeID());
274  return printDetElement(d);
275  }
276 
277 
278  size_t checkSensitive(SensitiveDetector d) {
279  printout(INFO,"chkDetector","+++ Checking SensitiveDetector: %-30s %-16s CombineHits:%s ecut:%g Collection:%s",
280  d.name(), ("["+d.type()+"]").c_str(),
281  yes_no(d.combineHits()), d.energyCutoff(), d.hitsCollection().c_str());
282  Readout ro = d.readout();
283  if ( !ro.isValid() ) {
284  printout(ERROR,"chkDetector",
285  "+++ FAILED SensitiveDetector:%s No Readout Stricture attached.",
286  ro.name());
287  ++errors;
288  return 0;
289  }
290  if ( ro.isValid() ) {
291  if ( !checkReadout(ro) ) {
292  return 0;
293  }
294  }
295  return 1;
296  }
297 
298  size_t checkReadout(Readout ro) {
299  size_t ret = 1;
300  printout(INFO,"chkReadOut","+++ Checking Readout: %s Collection No:%ld IDspec:%s",
301  ro.name(), ro.numCollections(), yes_no(ro.idSpec().isValid()));
302  IDDescriptor id = ro.idSpec();
303  if ( id.isValid() ) {
304  if ( !checkIDDescriptor(id) ) ret = 0;
305  }
306  else {
307  printout(ERROR,"chkReadOut",
308  "+++ FAILED Segmentation: %s Found readout without ID descriptor!",
309  ro.name());
310  ++errors;
311  ret = 0;
312  }
313  Segmentation sg = ro.segmentation();
314  if ( sg.isValid() ) {
316  if ( !checkSegmentation(sg) ) {
317  ret = 0;
318  }
319  if ( id.isValid() && seg && id.decoder() != sg.decoder() ) {
320  printout(ERROR,"chkReadOut","+++ FAILED Decoder ERROR:%p != %p",
321  (void*)seg->decoder(), (void*)id.decoder());
322  ++errors;
323  ret = 0;
324  }
325  }
326  return ret;
327  }
328 
329  size_t checkSegmentation(Segmentation sg) {
331  if ( seg ) {
332  size_t ret = 1;
333  printout(INFO,"chkSegment","+++ Checking Segmentation: %-24s [%s] DDSegmentation:%p Decoder:%p",
334  sg.name(), seg->type().c_str(),(void*)seg, seg->decoder());
335  const auto& pars = seg->parameters();
336  for ( const auto& par : pars ) {
337  printout(INFO,"chkSegment","+++ Param:%-24s -> %-16s [%s] opt:%s",
338  par->name().c_str(), par->value().c_str(), par->type().c_str(),
339  yes_no(par->isOptional()));
340 
341  }
342  if ( pars.empty() ) {
343  printout(ERROR,"chkSegment",
344  "+++ FAILED Segmentation: %s Found readout with invalid [EMPTY] ID descriptor!",
345  sg.name());
346  ++errors;
347  ret = 0;
348  }
349  if ( !seg->decoder() ) {
350  printout(ERROR,"chkSegment","+++ FAILED Segmentation: %s NO Decoder!!!",
351  sg.name());
352  ++errors;
353  ret = 0;
354  }
355  return ret;
356  }
357  printout(ERROR,"chkSegment","+++ FAILED Segmentation: %s NO DDSegmentation",
358  sg.name());
359  ++errors;
360  return 0;
361  }
362 
363  size_t checkIDDescriptor(IDDescriptor id) {
364  const IDDescriptor::FieldMap& fields = id.fields();
365  printout(INFO,"chkIDDescript","+++ Checking IDDesc: %s decoder:%p",
366  id->GetName(), (void*)id.decoder());
367  printout(INFO,"chkIDDescript","+++ Specs:%s",id.fieldDescription().c_str());
368  for( const auto& fld : fields )
369  printout(INFO,"chkIDDescript","+++ Field:%-24s -> %016llX %3d %3d [%d,%d]",
370  fld.first.c_str(), fld.second->mask(), fld.second->offset(), fld.second->width(),
371  fld.second->minValue(), fld.second->maxValue());
372  if ( fields.empty() ) {
373  printout(ERROR,"chkIDDescript",
374  "+++ FAILED IDDescriptor: %s Found invalid [EMPTY] ID descriptor!",
375  id.name());
376  ++errors;
377  return 0;
378  }
379  return 1;
380  }
381 
382  size_t checkLimitset(LimitSet ls) {
383  printout(INFO,"chkLimitSet","+++ Checking Limits: %s Num.Limiits:%ld",
384  ls.name(), ls.limits().size());
385  return 1;
386  }
387 
388  size_t checkRegion(Region ls) {
389  printout(INFO,"chkRegion","+++ Checking Limits: %s Num.Limiits:%ld",
390  ls.name(), ls.limits().size());
391  return 1;
392  }
393 
394  size_t checkField(CartesianField fld) {
395  printout(INFO,"chkField","+++ Checking Field: %s",
396  fld.name());
397  return 1;
398  }
399  size_t checkAlignment(DetElement det) {
400  AlignmentCondition::Object* align = det->nominal.ptr();
401  if ( 0 == align ) {
402  printout(ERROR,"chkNominals",
403  "+++ ERROR +++ Detector element with invalid nominal:%s",
404  det.path().c_str());
405  ++errors;
406  }
407  else if ( 0 == align->alignment_data ) {
408  printout(ERROR,"chkNominals",
409  "+++ ERROR +++ Detector element with invalid nominal data:%s",
410  det.path().c_str());
411  ++errors;
412  }
413  else if ( Condition(align).data().ptr() != align->alignment_data ) {
414  printout(ERROR,"chkNominals",
415  "+++ ERROR +++ Detector element with inconsisten nominal data:%s [%p != %p]",
416  det.path().c_str(),Condition(align).data().ptr(),align->alignment_data);
417  ++errors;
418  }
419  else {
420  return 1;
421  }
422  return 0;
423  }
424 
426  size_t checkNominals(VolumeManager mgr) {
427  int count = 0;
428  const auto& sdets = mgr->subdetectors;
429  for( const auto& vm : sdets ) {
430  VolumeManager::Object* obj = vm.second.ptr();
431  for( const auto& iv : obj->volumes ) {
432  VolumeManagerContext* ctx = iv.second;
433  count += checkAlignment(ctx->element);
434  }
435  }
436  return count;
437  }
438  size_t checkDetectorNominals(DetElement d) {
439  int count = 0;
440  Volume v = d.placement().volume();
441  if ( v.isSensitive() ) {
442  count += checkAlignment(d);
443  }
444  for( const auto& child : d.children() )
445  count += checkDetectorNominals(child.second);
446  return count;
447  }
448  };
449 }
450 
453  size_t count = 0;
454  PersistencyChecks checks;
455  for( const auto& obj : object->constants() )
456  count += checks.checkConstant(obj);
457  printout(ALWAYS,"chkProperty","+++ %s Checked %ld Constant objects. Num.Errors: %ld",
458  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
459  return checks.errors;
460 }
461 
464  size_t count = 0;
465  PersistencyChecks checks;
466  for( const auto& obj : object->properties() )
467  count += checks.checkProperty(obj);
468  printout(ALWAYS,"chkProperty","+++ %s Checked %ld Property objects. Num.Errors: %ld",
469  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
470  return checks.errors;
471 }
472 
475  size_t count = 0;
476  printout(ALWAYS,"chkMaterials","+++ Check not implemented. Hence OK.");
477  return count;
478 }
479 
481 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkReadouts() const {
482  size_t count = 0;
483  PersistencyChecks checks;
484  for( const auto& obj : object->readouts() )
485  count += checks.checkReadout(obj.second);
486 
487  if ( object->sensitiveDetectors().size() != object->readouts().size() ) {
488  printout(ERROR,"chkNominals",
489  "+++ Number of sensitive detectors does NOT match number of readouts: %ld != %ld",
490  object->sensitiveDetectors().size(),object->readouts().size());
491  ++checks.errors;
492  }
493  printout(ALWAYS,"chkNominals","+++ %s Checked %ld readout objects. Num.Errors: %ld",
494  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
495  return { count, checks.errors };
496 }
497 
500  size_t count = 0;
501  PersistencyChecks checks;
502  for( const auto& obj : object->fields() )
503  count += checks.checkField(obj.second);
504  printout(ALWAYS,"chkFields","+++ %s Checked %ld Field objects. Num.Errors: %ld",
505  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
506  return checks.errors;
507 }
508 
510 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkRegions() const {
511  size_t count = 0;
512  PersistencyChecks checks;
513  for( const auto& obj : object->regions() )
514  count += checks.checkRegion(obj.second);
515  printout(ALWAYS,"chkRegions","+++ %s Checked %ld Region objects. Num.Errors: %ld",
516  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
517  return { count, checks.errors };
518 }
519 
521 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkIdSpecs() const {
522  size_t count = 0;
523  PersistencyChecks checks;
524  for( const auto& obj : object->idSpecifications() )
525  count += checks.checkIDDescriptor(obj.second);
526  printout(ALWAYS,"chkReadouts","+++ %s Checked %ld Readout objects. Num.Errors: %ld",
527  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
528  return { count, checks.errors };
529 }
530 
532 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkDetectors() const {
533  size_t count = 0;
534  PersistencyChecks checks;
535  for( const auto& obj : object->detectors() )
536  count += checks.checkDetector(obj.second);
537  printout(ALWAYS,"chkDetectors","+++ %s Checked %ld DetElement objects. Num.Errors: %ld",
538  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
539  return { count, checks.errors };
540 }
541 
543 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkSensitives() const {
544  size_t count = 0;
545  PersistencyChecks checks;
546  for( const auto& obj : object->sensitiveDetectors() )
547  count += checks.checkSensitive(obj.second);
548  printout(ALWAYS,"chkSensitives","+++ %s Checked %ld SensitiveDetector objects. Num.Errors: %ld",
549  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
550  return { count, checks.errors };
551 }
552 
554 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkLimitSets() const {
555  PersistencyChecks checks;
556  size_t count = 0;
557  for( const auto& obj : object->limitsets() )
558  count += checks.checkLimitset(obj.second);
559  printout(ALWAYS,"chkSensitives","+++ %s Checked %ld SensitiveDetector objects. Num.Errors: %ld",
560  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
561  return { count, checks.errors };
562 }
563 
565 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkVolManager() const {
566  PersistencyChecks checks;
567  size_t count = checks.checkNominals(object->volumeManager());
568  printout(ALWAYS,"chkNominals","+++ %s Checked %ld VolumeManager contexts. Num.Errors: %ld",
569  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
570  return { count , checks.errors };
571 }
572 
574 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkNominals() const {
575  size_t count = 0;
576  PersistencyChecks checks;
577  const auto& dets = object->sensitiveDetectors();
578  for( const auto& d : dets )
579  count += checks.checkDetectorNominals(object->detector(d.first));
580  printout(ALWAYS,"chkNominals","+++ %s Checked %ld DetElements. Num.Errors: %ld",
581  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
582  return { count, checks.errors };
583 }
584 
586 std::pair<std::size_t, std::size_t> DD4hepRootCheck::checkSegmentations() const {
587  size_t count = 0;
588  PersistencyChecks checks;
589  const auto& dets = object->sensitiveDetectors();
590  for( const auto& d : dets ) {
592  if ( seg.isValid() ) count += checks.checkSegmentation(seg);
593  }
594  printout(ALWAYS,"chkNominals","+++ %s Checked %ld readout segmentations. Num.Errors: %ld",
595  checks.errors==0 ? "PASSED" : "FAILED", count, checks.errors);
596  return { count, checks.errors };
597 }
598 
600  size_t count = 0;
601  PersistencyChecks checks;
602 
603  count += checkMaterials();
604  for( const auto& obj : object->properties() )
605  count += checks.checkProperty(obj);
606  for( const auto& obj : object->constants() )
607  count += checks.checkConstant(obj);
608  for( const auto& obj : object->limitsets() )
609  count += checks.checkLimitset(obj.second);
610  for( const auto& obj : object->fields() )
611  count += checks.checkField(obj.second);
612  for( const auto& obj : object->regions() )
613  count += checks.checkRegion(obj.second);
614  for( const auto& obj : object->idSpecifications() )
615  count += checks.checkIDDescriptor(obj.second);
616  for( const auto& obj : object->detectors() )
617  count += checks.checkDetector(obj.second);
618  for( const auto& obj : object->sensitiveDetectors() )
619  count += checks.checkSensitive(obj.second);
620 
621  count += checkVolManager().first;
622  printout(ALWAYS,"chkAll","+++ Checked %ld objects. Num.Errors:%ld",
623  count, checks.errors);
624  return count;
625 }
dd4hep::DetElement::children
const Children & children() const
Access to the list of children.
Definition: DetElement.cpp:207
DD4hepRootPersistency.h
DD4hepRootPersistency::volumeManager
dd4hep::VolumeManager volumeManager() const
Return handle to the VolumeManager.
Definition: DD4hepRootPersistency.h:65
dd4hep::DetectorData::m_sensitive
ObjectHandleMap m_sensitive
The map of top level sub-detector sensitive detector objects indexed by the detector name.
Definition: DetectorData.h:110
dd4hep::Detector::world
virtual DetElement world() const =0
Return reference to the top-most (world) detector element.
DD4hepRootCheck::checkSegmentations
std::pair< std::size_t, std::size_t > checkSegmentations() const
Call to check segmentations starting from the top level Detector element.
Definition: DD4hepRootPersistency.cpp:586
dd4hep::IDDescriptor::FieldMap
std::vector< std::pair< std::string, const Field * > > FieldMap
Definition: IDDescriptor.h:40
dd4hep::DetElement::key
unsigned int key() const
Access hash key of this detector element (Only valid once geometry is closed!)
Definition: DetElement.cpp:134
DD4hepRootCheck::checkLimitSets
std::pair< std::size_t, std::size_t > checkLimitSets() const
Call to check a limit-set object.
Definition: DD4hepRootPersistency.cpp:554
dd4hep::Detector::detector
virtual DetElement detector(const std::string &name) const =0
Retrieve a subdetector element by its name from the detector description.
v
View * v
Definition: MultiView.cpp:28
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:44
ConditionsInterna.h
dd4hep::exception
void exception(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:69
dd4hep::Detector::detectors
virtual const HandleMap & detectors() const =0
Accessor to the map of sub-detectors.
dd4hep::DetElement::placement
PlacedVolume placement() const
Access to the physical volume of this detector element.
Definition: DetElement.cpp:321
DD4hepRootPersistency::load
static int load(dd4hep::Detector &description, const char *fname, const char *instance="Geometry")
Load an detector description from a ROOT file to memory.
Definition: DD4hepRootPersistency.cpp:113
dd4hep::LimitSet::limits
const std::set< Limit > & limits() const
Accessor to limits container.
Definition: Objects.cpp:464
dd4hep::Readout::setSegmentation
void setSegmentation(const Segmentation &segment) const
Assign segmentation structure to readout.
Definition: Readout.cpp:117
delta
const Delta * delta
Definition: AlignmentsCalculator.cpp:67
DD4hepRootCheck::checkRegions
std::pair< std::size_t, std::size_t > checkRegions() const
Call to check a Region object.
Definition: DD4hepRootPersistency.cpp:510
dd4hep::IDDescriptor
Class implementing the ID encoding of the detector response.
Definition: IDDescriptor.h:37
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:128
DetectorInterna.h
dd4hep::Detector::readouts
virtual const HandleMap & readouts() const =0
Accessor to the map of readout structures.
DD4hepRootCheck::checkReadouts
std::pair< std::size_t, std::size_t > checkReadouts() const
Call to check a Readout object.
Definition: DD4hepRootPersistency.cpp:481
DD4hepRootCheck::checkDetectors
std::pair< std::size_t, std::size_t > checkDetectors() const
Call to check a top level Detector element (subdetector)
Definition: DD4hepRootPersistency.cpp:532
DD4hepRootPersistency
Helper class to support ROOT persistency of Detector objects.
Definition: DD4hepRootPersistency.h:26
DD4hepRootPersistency::save
static int save(dd4hep::Detector &description, const char *fname, const char *instance="Geometry")
Save an existing detector description in memory to a ROOT file.
Definition: DD4hepRootPersistency.cpp:47
DD4hepRootPersistency::DD4hepRootPersistency
DD4hepRootPersistency()
Default constructor.
Definition: DD4hepRootPersistency.cpp:40
dd4hep::Detector::fields
virtual const HandleMap & fields() const =0
Accessor to the map of field entries, which together form the global field.
dd4hep::Delta::hasRotation
bool hasRotation() const
Access flags: Check if the delta operation contains a rotation.
Definition: AlignmentData.h:85
dd4hep::DetElement::volumeID
VolumeID volumeID() const
The cached VolumeID of this subdetector element.
Definition: DetElement.cpp:344
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::Alignment::delta
const Delta & delta() const
Access the delta value of the object.
Definition: Alignments.cpp:63
dd4hep::Region::limits
std::vector< std::string > & limits() const
Access references to user limits.
Definition: Objects.cpp:510
dd4hep::Detector::volumeManager
virtual VolumeManager volumeManager() const =0
Return handle to the VolumeManager.
dd4hep::Delta
Class describing an condition to re-adjust an alignment.
Definition: AlignmentData.h:38
DD4hepRootCheck::checkIdSpecs
std::pair< std::size_t, std::size_t > checkIdSpecs() const
Call to check an ID specification.
Definition: DD4hepRootPersistency.cpp:521
dd4hep::Delta::hasPivot
bool hasPivot() const
Access flags: Check if the delta operation contains a pivot.
Definition: AlignmentData.h:87
dd4hep::DDSegmentation::Segmentation::name
virtual const std::string & name() const
Access the segmentation name.
Definition: Segmentation.h:96
DD4hepRootCheck::checkFields
size_t checkFields() const
Call to theck the DD4hep fields.
Definition: DD4hepRootPersistency.cpp:499
dd4hep::Condition
Main condition object handle.
Definition: Conditions.h:51
dd4hep::DDSegmentation::Segmentation::parameters
virtual Parameters parameters() const
Access to all parameters.
Definition: Segmentation.cpp:121
DD4hepRootCheck::checkVolManager
std::pair< std::size_t, std::size_t > checkVolManager() const
Call to check the volume manager hierarchy.
Definition: DD4hepRootPersistency.cpp:565
dd4hep::Detector::constants
virtual const HandleMap & constants() const =0
Accessor to the map of constants.
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::DetectorData::idSpecifications
const Detector::HandleMap & idSpecifications() const
Accessor to the map of ID specifications.
Definition: DetectorData.h:213
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:370
dd4hep::VolumeManager
Class to support the retrieval of detector elements and volumes given a valid identifier.
Definition: VolumeManager.h:135
DD4hepRootPersistency::~DD4hepRootPersistency
virtual ~DD4hepRootPersistency()
Default destructor.
Definition: DD4hepRootPersistency.cpp:44
dd4hep::Detector::regions
virtual const HandleMap & regions() const =0
Accessor to the map of region settings.
dd4hep::DetectorData::m_volManager
VolumeManager m_volManager
Volume manager reference.
Definition: DetectorData.h:139
DD4hepRootPersistency::m_data
dd4hep::DetectorData * m_data
The main data block.
Definition: DD4hepRootPersistency.h:31
dd4hep::LimitSet
Handle class describing a set of limits as they are used for simulation.
Definition: Objects.h:425
dd4hep::SensitiveDetector::hitsCollection
const std::string & hitsCollection() const
Access the hits collection name.
Definition: DetElement.cpp:447
DD4hepRootCheck::checkAll
size_t checkAll() const
Check all of the above.
Definition: DD4hepRootPersistency.cpp:599
dd4hep::SensitiveDetector::combineHits
bool combineHits() const
Access flag to combine hist.
Definition: DetElement.cpp:471
TNamed
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:37
DD4hepRootPersistency::nominals
std::map< dd4hep::DetElement, dd4hep::AlignmentCondition > nominals
Helper to save alignment conditions from the DetElement nominals.
Definition: DD4hepRootPersistency.h:35
dd4hep::DDSegmentation::Segmentation::decoder
virtual const BitFieldCoder * decoder() const
Access the underlying decoder.
Definition: Segmentation.h:112
dd4hep::Detector::limitsets
virtual const HandleMap & limitsets() const =0
Accessor to the map of limit settings.
dd4hep::Region
Handle class describing a region as used in simulation.
Definition: Objects.h:462
dd4hep::Alignment
Main handle class to hold an alignment object.
Definition: Alignments.h:115
dd4hep::Detector::sensitiveDetectors
virtual const HandleMap & sensitiveDetectors() const =0
Accessor to the map of sub-detectors.
dd4hep::DetElement::nominal
Alignment nominal() const
Access to the constant ideal (nominal) alignment information.
Definition: DetElement.cpp:185
DD4hepRootCheck::checkSensitives
std::pair< std::size_t, std::size_t > checkSensitives() const
Call to check a sensitive detector.
Definition: DD4hepRootPersistency.cpp:543
DD4hepRootCheck::checkNominals
std::pair< std::size_t, std::size_t > checkNominals() const
Call to check the nominal alignments in the DetElement hierarchy.
Definition: DD4hepRootPersistency.cpp:574
dd4hep::Readout::segmentation
Segmentation segmentation() const
Access segmentation structure.
Definition: Readout.cpp:134
dd4hep::DetElement::level
int level() const
Access the hierarchical level of the detector element (Only valid once geometry is closed!...
Definition: DetElement.cpp:146
DD4hepRootCheck::checkMaterials
size_t checkMaterials() const
Call to check a Material object.
Definition: DD4hepRootPersistency.cpp:474
DD4hepRootPersistency::m_segments
std::map< dd4hep::Readout, std::pair< dd4hep::IDDescriptor, dd4hep::DDSegmentation::Segmentation * > > m_segments
Helper since plain segmentations cannot be saved.
Definition: DD4hepRootPersistency.h:33
dd4hep::Delta::hasTranslation
bool hasTranslation() const
Access flags: Check if the delta operation contains a translation.
Definition: AlignmentData.h:83
dd4hep::SensitiveDetector::type
std::string type() const
Access the type of the sensitive detector.
Definition: DetElement.cpp:409
dd4hep::Segmentation::name
const char * name() const
Accessor: Segmentation type.
Definition: Segmentations.cpp:45
SegmentationsInterna.h
dd4hep::Segmentation::segmentation
DDSegmentation::Segmentation * segmentation() const
Access to the base DDSegmentation object. WARNING: Deprecated call!
Definition: Segmentations.cpp:99
dd4hep::DetElement::Children
std::map< std::string, DetElement > Children
Definition: DetElement.h:206
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:153
ObjectsInterna.h
dd4hep::DetectorData::adoptData
void adoptData(DetectorData &source, bool CLR=true)
Adopt all data from source structure.
Definition: DetectorData.cpp:283
dd4hep::Segmentation::decoder
const BitFieldCoder * decoder() const
Access the underlying decoder.
Definition: Segmentations.cpp:104
dd4hep::SensitiveDetector::energyCutoff
double energyCutoff() const
Access energy cut off.
Definition: DetElement.cpp:436
dd4hep::IDDescriptor::rebuild
void rebuild(const std::string &description)
Re-build object in place.
Definition: IDDescriptor.cpp:51
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
det
DetElement::Object * det
Definition: AlignmentsCalculator.cpp:66
dd4hep::SensitiveDetector::readout
Readout readout() const
Access readout structure of the sensitive detector.
Definition: DetElement.cpp:420
dd4hep::DetectorData
Data implementation class of the Detector interface.
Definition: DetectorData.h:38
dd4hep::PlacedVolume::volume
Volume volume() const
Logical volume of this placement.
Definition: Volumes.cpp:468
ClassImp
ClassImp(DD4hepRootPersistency) using namespace dd4hep
dd4hep::Readout::numCollections
size_t numCollections() const
Access number of hit collections.
Definition: Readout.cpp:55
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::Readout
Handle to the implementation of the readout structure of a subdetector.
Definition: Readout.h:38
dd4hep::Segmentation
Handle class supporting generic Segmentations of sensitive detectors.
Definition: Segmentations.h:41
dd4hep::IDDescriptor::decoder
BitFieldCoder * decoder() const
Access the BitFieldCoder object.
Definition: IDDescriptor.cpp:198
dd4hep::Readout::idSpec
IDDescriptor idSpec() const
Access IDDescription structure.
Definition: Readout.cpp:112
AlignmentsInterna.h
dd4hep::Detector::idSpecifications
virtual const HandleMap & idSpecifications() const =0
Accessor to the map of ID specifications.
DD4hepRootCheck::checkProperties
size_t checkProperties() const
Check detector description properties (string defines)
Definition: DD4hepRootPersistency.cpp:463
dd4hep::DDSegmentation::Segmentation
Base class for all segmentations.
Definition: Segmentation.h:75
dd4hep::DetElement::survey
Alignment survey() const
Access to the constant survey alignment information.
Definition: DetElement.cpp:198
Printout.h
DD4hepRootCheck::checkConstants
size_t checkConstants() const
Check the collection of define statements.
Definition: DD4hepRootPersistency.cpp:452
DD4hepRootCheck::object
dd4hep::Detector * object
Reference to the detector model object.
Definition: DD4hepRootPersistency.h:103
dd4hep::Detector::properties
virtual Properties & properties() const =0
Access to properties map.
dd4hep::CartesianField
Base class describing any field with 3D cartesian vectors for the field strength.
Definition: Fields.h:40
dd4hep::DDSegmentation::Segmentation::type
virtual const std::string & type() const
Access the segmentation type.
Definition: Segmentation.h:104