DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
StandardPlugins.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 #define DD4HEP_MUST_USE_DETECTORIMP_H
17 #include <DD4hep/DetectorImp.h>
18 #include <DD4hep/Memory.h>
19 #include <DD4hep/DD4hepUI.h>
20 #include <DD4hep/Factories.h>
21 #include <DD4hep/Printout.h>
22 #include <DD4hep/DD4hepUnits.h>
23 #include <DD4hep/DetectorTools.h>
24 #include <DD4hep/PluginCreators.h>
25 #include <DD4hep/VolumeProcessor.h>
28 #include <XML/DocumentHandler.h>
29 #include <XML/XMLElements.h>
30 #include <XML/XMLTags.h>
31 
32 // ROOT includes
33 #include <TInterpreter.h>
34 #include <TGeoElement.h>
35 #include <TGeoManager.h>
36 #include <TGeoVolume.h>
37 #include <TSystem.h>
38 #include <TClass.h>
39 #include <TRint.h>
40 #include <TGDMLMatrix.h>
41 
42 // C/C++ include files
43 #include <cerrno>
44 #include <cstdlib>
45 #include <fstream>
46 #include <sstream>
47 
48 using namespace dd4hep;
49 using namespace dd4hep::detail;
50 
51 namespace {
52 
53  struct ProcessorArgs {
54  bool use = false;
55  int start = 0, end = 0, argc = 0, count=0;
56  std::vector<char*> argv;
57  ProcessorArgs(int ac, char** av) {
58  for(int i=0; i<ac; ++i) {
59  if ( 0 == ::strncmp(av[i],"-processor",6) ) {
60  use = true;
61  start = i;
62  }
63  if ( use ) {
64  ++argc; ++count; end = i;
65  if ( 0 == ::strncmp(av[i],"-end-processor",6) ) {
66  argv.emplace_back(av[i]);
67  return;
68  }
69  else if ( 0 == ::strncmp(av[i],"-end-plugin",4) ) { // End of current plugin
70  argv.emplace_back((char*)"-end-processor");
71  return;
72  }
73  else if ( 0 == ::strncmp(av[i],"-plugin",4) ) { // Start of next plugin
74  argv.emplace_back((char*)"-end-processor");
75  return;
76  }
77  argv.emplace_back(av[i]);
78  }
79  }
80  }
81  };
82 }
83 
85 
92 static long dummy_plugin(Detector& , int, char**) {
93  return 1;
94 }
95 DECLARE_APPLY(DD4hep_DummyPlugin,dummy_plugin)
96 
97 
105 static void* create_description_instance(const char* /* name */) {
106  return &Detector::getInstance();
107 }
108 DECLARE_CONSTRUCTOR(Detector_constructor,create_description_instance)
109 
110 
119 static long display(Detector& description, int argc, char** argv) {
120  TGeoManager& mgr = description.manager();
121  int vislevel = 6, visopt = 1;
122  std::string detector = "/world";
123  const char* opt = "ogl";
124  for( int i = 0; i < argc && argv[i]; ++i ) {
125  if ( 0 == ::strncmp("-option",argv[i],4) )
126  opt = argv[++i];
127  else if ( 0 == ::strncmp("-level",argv[i],4) )
128  vislevel = ::atol(argv[++i]);
129  else if ( 0 == ::strncmp("-visopt",argv[i],4) )
130  visopt = ::atol(argv[++i]);
131  else if ( 0 == ::strncmp("-detector",argv[i],4) )
132  detector = argv[++i];
133  else {
134  std::cout <<
135  "Usage: -plugin DD4hep_GeometryDisplay -arg [-arg] \n\n"
136  " Invoke the ROOT geometry display using the factory mechanism. \n\n"
137  " -detector <string> Top level DetElement path. Default: '/world' \n"
138  " -option <string> ROOT Draw option. Default: 'ogl' \n"
139  " -level <number> Visualization level [TGeoManager::SetVisLevel] Default: 4 \n"
140  " -visopt <number> Visualization option [TGeoManager::SetVisOption] Default: 1\n"
141  " -load Only load the geometry. Do not invoke the display \n"
142  " -help Print this help output \n"
143  " Arguments given: " << arguments(argc,argv) << std::endl << std::flush;
144  ::exit(EINVAL);
145  }
146  }
147  mgr.SetVisLevel(vislevel);
148  mgr.SetVisOption(visopt);
149  TGeoVolume* vol = mgr.GetTopVolume();
150  if ( detector != "/world" ) {
151  DetElement elt = detail::tools::findElement(description,detector);
152  if ( !elt.isValid() ) {
153  except("DD4hep_GeometryDisplay","+++ Invalid DetElement path: %s",detector.c_str());
154  }
155  if ( !elt.placement().isValid() ) {
156  except("DD4hep_GeometryDisplay","+++ Invalid DetElement placement: %s",detector.c_str());
157  }
158  vol = elt.placement().volume();
159  }
160  if ( vol ) {
161  vol->Draw(opt);
162  return 1;
163  }
164  return 0;
165 }
166 DECLARE_APPLY(DD4hep_GeometryDisplay,display)
167 
168 
176 static long run_function(Detector&, int argc, char** argv) {
177  std::string lib, func;
178  std::vector<char*> args;
179  for(int i = 0; i < argc && argv[i]; ++i) {
180  if ( 0 == ::strncmp("-library",argv[i],4) )
181  lib = argv[++i];
182  else if ( 0 == ::strncmp("-function",argv[i],4) )
183  func = argv[++i];
184  else
185  args.emplace_back(argv[i]);
186  }
187  if ( lib.empty() || func.empty() ) {
188  std::cout <<
189  "Usage: -plugin DD4hep_Function -arg [-arg] \n\n"
190  " Execute a function without arguments inside a library. \n\n"
191  " -library <string> Library to be loaded \n"
192  " -function <string> name of the entry point to be executed. \n"
193  "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush;
194  ::exit(EINVAL);
195  }
196  Func_t f = gSystem->DynFindSymbol("*",func.c_str());
197  int ret;
198  if ( !f ) {
199  ret = gSystem->Load(lib.c_str());
200  if ( ret != 0 ) {
201  except("DD4hep_Function","+++ Failed to load library: %s",lib.c_str());
202  }
203  f = gSystem->DynFindSymbol("*",func.c_str());
204  if ( !f ) {
205  except("DD4hep_Function","+++ Failed to find function %s in library: %s",
206  func.c_str(),lib.c_str());
207  }
208  }
209  typedef int (*call_t)(int, char**);
210  call_t ff = (call_t)f;
211  ret = (*ff)(args.size(),&args[0]);
212  return ret;
213 }
214 DECLARE_APPLY(DD4hep_Function,run_function)
215 
216 
224 static long run_interpreter(Detector& /* description */, int argc, char** argv) {
225  if ( 0 == gApplication ) {
226  std::pair<int, char**> a(argc,argv);
227  gApplication = new TRint("DD4hepRint", &a.first, a.second);
228  printout(INFO,"DD4hepRint","++ Created ROOT interpreter instance for DD4hepUI.");
229  }
230  for(int i=0; i<argc; ++i) {
231  printout(INFO,"DD4hepRint","Excecute[%d]: %s", i, argv[i]);
232  gInterpreter->ProcessLine(argv[i]);
233  }
234  if ( !gApplication->IsRunning() ) {
235  gApplication->Run();
236  }
237  return 1;
238 }
239 DECLARE_APPLY(DD4hep_Rint,run_interpreter)
240 
241 
253 static long root_ui(Detector& description, int /* argc */, char** /* argv */) {
254  char cmd[256];
255  std::snprintf(cmd, sizeof(cmd),
256  "dd4hep::detail::DD4hepUI* gDD4hepUI = new "
257  "dd4hep::detail::DD4hepUI(*(dd4hep::Detector*)%p);",
258  (void*)&description);
259  gInterpreter->ProcessLine(cmd);
260  printout(ALWAYS,"DD4hepUI",
261  "Use the ROOT interpreter variable gDD4hepUI "
262  "to interact with the detector description.");
263  return 1;
264 }
265 DECLARE_APPLY(DD4hep_InteractiveUI,root_ui)
266 
267 
276 static long root_dump_gdml_tables(Detector& description, int /* argc */, char** /* argv */) {
277  size_t num_tables = 0;
278  size_t num_elements = 0;
279  const TObjArray* c = description.manager().GetListOfGDMLMatrices();
280  TObjArrayIter arr(c);
281  printout(INFO,"Dump_GDMLTables","+++ Dumping known GDML tables from TGeoManager.");
282  for(TObject* i = arr.Next(); i; i=arr.Next()) {
283  TGDMLMatrix* gdmlMat = (TGDMLMatrix*)i;
284  num_elements += (gdmlMat->GetRows()*gdmlMat->GetCols());
285  ++num_tables;
286  gdmlMat->Print();
287  }
288  printout(INFO,"Dump_GDMLTables",
289  "+++ Successfully dumped %ld GDML tables with %ld elements.",
290  num_tables, num_elements);
291  return 1;
292 }
293 DECLARE_APPLY(DD4hep_Dump_GDMLTables,root_dump_gdml_tables)
294 
295 
304 static long root_dump_optical_surfaces(Detector& description, int /* argc */, char** /* argv */) {
305  size_t num_surfaces = 0;
306  printout(ALWAYS,"","");
307  const TObjArray* c = description.manager().GetListOfOpticalSurfaces();
308  TObjArrayIter arr(c);
309  printout(ALWAYS,"Dump_OpticalSurfaces","+++ Dumping known Optical Surfaces from TGeoManager.");
310  for(TObject* i = arr.Next(); i; i=arr.Next()) {
311  TGeoOpticalSurface* optSurt = (TGeoOpticalSurface*)i;
312  ++num_surfaces;
313  optSurt->Print();
314  }
315  printout(ALWAYS,"Dump_OpticalSurfaces",
316  "+++ Successfully dumped %ld Optical surfaces.",num_surfaces);
317  return 1;
318 }
319 DECLARE_APPLY(DD4hep_Dump_OpticalSurfaces,root_dump_optical_surfaces)
320 
321 
330 static long root_dump_skin_surfaces(Detector& description, int /* argc */, char** /* argv */) {
331  size_t num_surfaces = 0;
332  printout(ALWAYS,"","");
333  const TObjArray* c = description.manager().GetListOfSkinSurfaces();
334  TObjArrayIter arr(c);
335  printout(ALWAYS,"Dump_SkinSurfaces","+++ Dumping known Skin Surfaces from TGeoManager.");
336  for(TObject* i = arr.Next(); i; i=arr.Next()) {
337  TGeoSkinSurface* skinSurf = (TGeoSkinSurface*)i;
338  ++num_surfaces;
339  skinSurf->Print();
340  }
341  printout(ALWAYS,"Dump_SkinSurfaces",
342  "+++ Successfully dumped %ld Skin surfaces.",num_surfaces);
343  return 1;
344 }
345 DECLARE_APPLY(DD4hep_Dump_SkinSurfaces,root_dump_skin_surfaces)
346 
347 
356 static long root_dump_border_surfaces(Detector& description, int /* argc */, char** /* argv */) {
357  size_t num_surfaces = 0;
358  printout(ALWAYS,"","");
359  const TObjArray* c = description.manager().GetListOfBorderSurfaces();
360  TObjArrayIter arr(c);
361  printout(ALWAYS,"Dump_BorderSurfaces","+++ Dumping known Border Surfaces from TGeoManager.");
362  for(TObject* i = arr.Next(); i; i=arr.Next()) {
363  TGeoBorderSurface* bordSurt = (TGeoBorderSurface*)i;
364  ++num_surfaces;
365  bordSurt->Print();
366  }
367  printout(ALWAYS,"Dump_BorderSurfaces",
368  "+++ Successfully dumped %ld Border surfaces.",num_surfaces);
369  return 1;
370 }
371 DECLARE_APPLY(DD4hep_Dump_BorderSurfaces,root_dump_border_surfaces)
372 
373 
383 static long root_elements(Detector& description, int argc, char** argv) {
384  using elt_h = xml::Element;
385 
387 
392  struct ElementPrint {
394  ElementPrint() = default;
396  virtual ~ElementPrint() = default;
398  virtual void operator()(TGeoElement* elt) { elt->Print(); }
400  virtual void operator()(TGeoIsotope* iso) { iso->Print(); }
401  };
402 
404 
409  struct ElementPrintXML : public ElementPrint {
411  elt_h root;
413  ElementPrintXML(elt_h r) : root(r) {}
415  virtual ~ElementPrintXML() {}
417  virtual void operator()(TGeoElement* element) {
418  elt_h elt = root.addChild(_U(element));
419  elt.setAttr(_U(Z),element->Z());
420  elt.setAttr(_U(N),element->N());
421  elt.setAttr(_U(formula),element->GetName());
422  elt.setAttr(_U(name),element->GetName());
423  elt_h atom = elt.addChild(_U(atom));
424  atom.setAttr(_U(type),"A");
425  atom.setAttr(_U(unit),"g/mole");
426  atom.setAttr(_U(value),element->A());
427  }
429  virtual void operator()(TGeoIsotope* isotope) {
430  elt_h iso = root.addChild(_U(isotope));
431  iso.setAttr(_U(Z),isotope->GetZ());
432  iso.setAttr(_U(N),isotope->GetN());
433  iso.setAttr(_U(formula),isotope->GetName());
434  iso.setAttr(_U(name),isotope->GetName());
435  elt_h atom = iso.addChild(_U(atom));
436  atom.setAttr(_U(type),"A");
437  atom.setAttr(_U(unit),"g/mole");
438  atom.setAttr(_U(value),isotope->GetA());
439  }
440  };
441 
442  std::string type = "text", output = "";
443  for(int i=0; i<argc; ++i) {
444  if ( argv[i][0] == '-' ) {
445  char c = ::tolower(argv[i][1]);
446  if ( c == 't' && i+1<argc ) type = argv[++i];
447  else if ( c == 'o' && i+1<argc ) output = argv[++i];
448  else {
449  ::printf("DD4hep_ElementTable -opt [-opt] \n"
450  " -type <string> Output format: text or xml \n"
451  " -output <file-name> Output file specifier (xml only) \n"
452  "\n");
453  exit(EINVAL);
454  }
455  }
456  }
457 
458  xml::Document doc(0);
460  xml::Element element(0);
461  if ( type == "xml" ) {
462  const char comment[] = "\n"
463  " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
464  " ++++ Generic detector description in C++ ++++\n"
465  " ++++ dd4hep Detector description generator. ++++\n"
466  " ++++ ++++\n"
467  " ++++ Parser:"
469  " ++++\n"
470  " ++++ ++++\n"
471  " ++++ Table of elements as defined in ROOT: " ROOT_RELEASE " ++++\n"
472  " ++++ ++++\n"
473  " ++++ M.Frank CERN/LHCb ++++\n"
474  " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n ";
475  doc = docH.create("materials", comment);
476  element = doc.root();
477  }
478  dd4hep_ptr<ElementPrint> printer(element
479  ? new ElementPrintXML(element)
480  : new ElementPrint());
481  TGeoElementTable* table = description.manager().GetElementTable();
482  for(Int_t i=0, n=table->GetNelements(); i < n; ++i)
483  (*printer)(table->GetElement(i));
484 
485  for(Int_t i=0, n=table->GetNelements(); i < n; ++i) {
486  TGeoElement* elt = table->GetElement(i);
487  Int_t niso = elt->GetNisotopes();
488  if ( niso > 0 ) {
489  for(Int_t j=0; j < niso; ++j)
490  (*printer)(elt->GetIsotope(j));
491  }
492  }
493  if ( element ) {
495  dH.output(doc, output);
496  }
497  return 1;
498 }
499 DECLARE_APPLY(DD4hep_ElementTable,root_elements)
500 
501 
511 static long root_materials(Detector& description, int argc, char** argv) {
512 
513  using elt_h = xml::Element;
514 
516 
521  struct MaterialPrint {
522  public:
524  Detector& description;
525 
526  public:
528  MaterialPrint(Detector& desc) : description(desc) {}
530  virtual ~MaterialPrint() = default;
532  virtual elt_h print(TGeoMaterial* mat) {
533  const char* st = "Undefined";
534  switch( mat->GetState() ) {
535  case TGeoMaterial::kMatStateSolid: st = "solid"; break;
536  case TGeoMaterial::kMatStateLiquid: st = "liquid"; break;
537  case TGeoMaterial::kMatStateGas: st = "gas"; break;
538  case TGeoMaterial::kMatStateUndefined:
539  default: st = "Undefined"; break;
540  }
541  ::printf("%-32s %-8s\n", mat->GetName(), mat->IsMixture() ? "Mixture" : "Material");
542  ::printf(" Aeff=%7.3f Zeff=%7.4f rho=%8.3f [g/mole] radlen=%8.3g [cm] intlen=%8.3g [cm] index=%3d\n",
543  mat->GetA(), mat->GetZ(), mat->GetDensity(),
544  mat->GetRadLen(), mat->GetIntLen(), mat->GetIndex());
545  ::printf(" Temp=%.3g [Kelvin] Pressure=%.5g [hPa] state=%s\n",
546  mat->GetTemperature(), mat->GetPressure()/dd4hep::pascal/100.0, st);
547  return elt_h(0);
548  }
550  virtual void print(elt_h, TGeoElement* elt, double frac) {
551  ::printf(" %-6s Fraction: %7.3f Z=%3d A=%6.2f N=%3d Neff=%6.2f\n",
552  elt->GetName(), frac, elt->Z(), elt->A(), elt->N(), elt->Neff());
553  }
555  virtual void printProperty(elt_h, TNamed* prop, TGDMLMatrix* matrix) {
556  if ( matrix )
557  ::printf(" Property: %-20s [%ld x %ld] --> %s\n",
558  prop->GetName(), long(matrix->GetRows()), long(matrix->GetCols()), prop->GetTitle());
559  else
560  ::printf(" Property: %-20s [ERROR: NO TABLE!] --> %s\n",
561  prop->GetName(), prop->GetTitle());
562  }
563  virtual void operator()(TGeoMaterial* mat) {
564  Double_t* mix = mat->IsMixture() ? ((TGeoMixture*)mat)->GetWmixt() : 0;
565  elt_h mh = print(mat);
566  for( int n=mat->GetNelements(), i=0; i<n; ++i ) {
567  TGeoElement* elt = mat->GetElement(i);
568  print(mh, elt, mix ? mix[i] : 1);
569  }
570  TListIter mat_iter(&mat->GetProperties());
571  for( TObject* i = mat_iter.Next(); i; i=mat_iter.Next() ) {
572  printProperty(mh, (TNamed*)i, description.manager().GetGDMLMatrix(i->GetTitle()));
573  }
574  }
575  };
577 
582  struct MaterialPrintXML : public MaterialPrint {
583  elt_h root;
584  MaterialPrintXML(elt_h elt, Detector& desc) : MaterialPrint(desc), root(elt) {}
585  virtual ~MaterialPrintXML() {}
586  virtual elt_h print(TGeoMaterial* mat) {
587  elt_h elt = root.addChild(_U(material));
588  elt.setAttr(_U(name),mat->GetName());
589  if ( ::strlen(mat->GetTitle())>0 ) {
590  elt.setAttr(_U(formula),mat->GetTitle());
591  }
592  else if ( mat->GetNelements() == 1 ) {
593  elt.setAttr(_U(formula),mat->GetElement(0)->GetName());
594 #if 0
595  // We do not need this. It shall be computed by TGeo using the Geant4 formula.
596  elt_h RL = elt.addChild(_U(RL));
597  RL.setAttr(_U(type), "X0");
598  RL.setAttr(_U(value), mat->GetRadLen());
599  RL.setAttr(_U(unit), "cm");
600  elt_h NIL = elt.addChild(_U(NIL));
601  NIL.setAttr(_U(type), "lambda");
602  NIL.setAttr(_U(value), mat->GetIntLen());
603  NIL.setAttr(_U(unit), "cm");
604 #endif
605  }
606  elt_h D = elt.addChild(_U(D));
607  D.setAttr(_U(type), "density");
608  D.setAttr(_U(value), mat->GetDensity());
609  D.setAttr(_U(unit), "g/cm3");
610  if ( mat->GetTemperature() != description.stdConditions().temperature ) {
611  elt_h T = elt.addChild(_U(T));
612  T.setAttr(_U(type), "temperature");
613  T.setAttr(_U(value), mat->GetTemperature());
614  T.setAttr(_U(unit), "kelvin");
615  }
616  if ( mat->GetPressure() != description.stdConditions().pressure ) {
617  elt_h P = elt.addChild(_U(P));
618  P.setAttr(_U(type), "pressure");
619  P.setAttr(_U(value), mat->GetPressure());
620  P.setAttr(_U(unit), "pascal");
621  }
622  return elt;
623  }
624  virtual void print(elt_h mat, TGeoElement* element, double frac) {
625  elt_h elt = mat.addChild(_U(composite));
626  elt.setAttr(_U(n),frac);
627  elt.setAttr(_U(ref),element->GetName());
628  }
629  virtual void printProperty(elt_h mat, TNamed* prop, TGDMLMatrix* /* matrix */) {
630  elt_h elt = mat.addChild(_U(property));
631  elt.setAttr(_U(name),prop->GetName());
632  elt.setAttr(_U(ref), prop->GetTitle());
633  }
634  };
635 
636  std::string type = "text", output = "", name = "";
637  for(int i=0; i<argc; ++i) {
638  if ( argv[i][0] == '-' ) {
639  char c = ::tolower(argv[i][1]);
640  if ( c == 't' && i+1<argc ) type = argv[++i];
641  else if ( c == 'n' && i+1<argc ) name = argv[++i];
642  else if ( c == 'o' && i+1<argc ) output = argv[++i];
643  else {
644  ::printf("DD4hep_MaterialTable -opt [-opt] \n"
645  " -type <string> Output format: text or xml \n"
646  " -output <file-name> Output file specifier (xml only) \n"
647  "\n");
648  exit(EINVAL);
649  }
650  }
651  }
652 
653  xml::Document doc(0);
655  xml::Element element(0);
656  if ( type == "xml" ) {
657  const char comment[] = "\n"
658  " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
659  " ++++ Generic detector description in C++ ++++\n"
660  " ++++ dd4hep Detector description generator. ++++\n"
661  " ++++ ++++\n"
662  " ++++ Parser:"
664  " ++++\n"
665  " ++++ ++++\n"
666  " ++++ Table of elements as defined in ROOT: " ROOT_RELEASE " ++++\n"
667  " ++++ ++++\n"
668  " ++++ M.Frank CERN/LHCb ++++\n"
669  " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n ";
670  doc = docH.create("materials", comment);
671  element = doc.root();
672  }
673  dd4hep_ptr<MaterialPrint> printer(element
674  ? new MaterialPrintXML(element, description)
675  : new MaterialPrint(description));
676  TObject* obj = 0;
677  TList* mats = description.manager().GetListOfMaterials();
678  dd4hep_ptr<TIterator> iter(mats->MakeIterator());
679  while( (obj=iter->Next()) != 0 ) {
680  TGeoMaterial* mat = (TGeoMaterial*)obj;
681  if ( name.empty() || name == mat->GetName() )
682  (*printer)(mat);
683  }
684  if ( element ) {
686  dH.output(doc, output);
687  }
688  return 1;
689 }
690 DECLARE_APPLY(DD4hep_MaterialTable,root_materials)
691 
692 
705 static long load_compact(Detector& description, int argc, char** argv) {
706  if ( argc > 0 ) {
708  std::string input = argv[0];
709  if ( argc > 1 ) {
710  type = buildType(argv[1]);
711  printout(INFO,"CompactLoader","+++ Processing compact file: %s with flag %s",
712  input.c_str(), argv[1]);
713  description.fromCompact(input,type);
714  return 1;
715  }
716  printout(INFO,"CompactLoader","+++ Processing compact file: %s",input.c_str());
717  description.fromCompact(input);
718  return 1;
719  }
720  return 0;
721 }
722 DECLARE_APPLY(DD4hep_CompactLoader,load_compact)
723 
724 
739 static long load_xml(Detector& description, int argc, char** argv) {
740  if ( argc > 0 ) {
742  std::string input = argv[0];
743  if ( argc > 1 ) {
744  type = buildType(argv[1]);
745  printout(INFO,"XMLLoader","+++ Processing XML file: %s with flag %s",
746  input.c_str(), argv[1]);
747  description.fromXML(input, type);
748  return 1;
749  }
750  printout(INFO,"XMLLoader","+++ Processing XML file: %s",input.c_str());
751  description.fromXML(input, description.buildType());
752  return 1;
753  }
754  return 0;
755 }
756 DECLARE_APPLY(DD4hep_XMLLoader,load_xml)
757 
758 
773 static long process_xml_doc(Detector& description, int argc, char** argv) {
774  if ( argc > 0 ) {
776  DetectorImp* imp = dynamic_cast<DetectorImp*>(&description);
777  if ( imp ) {
778  xml::XmlElement* h = (xml::XmlElement*)argv[0];
779  xml::Handle_t input(h);
780  if ( input.ptr() ) {
781  if ( argc > 1 ) {
782  type = buildType(argv[1]);
783  printout(INFO,"XMLLoader","+++ Processing XML element: %s with flag %s",
784  input.tag().c_str(), argv[1]);
785  }
786  imp->processXMLElement(input, type);
787  return 1;
788  }
789  except("DD4hepXMLProcessor",
790  "++ The passed reference to the parsed XML document is invalid.");
791  }
792  }
793  return 0;
794 }
795 DECLARE_APPLY(DD4hep_XMLProcessor,process_xml_doc)
796 
797 
805 static long load_volmgr(Detector& description, int, char**) {
806  printout(INFO,"DD4hepVolumeManager","**** running plugin DD4hepVolumeManager ! " );
807  try {
808  DetectorImp* imp = dynamic_cast<DetectorImp*>(&description);
809  if ( imp ) {
810  imp->imp_loadVolumeManager();
811  printout(INFO,"VolumeManager","+++ Volume manager populated and loaded.");
812  return 1;
813  }
814  }
815  catch (const std::exception& e) {
816  except("DD4hep_VolumeManager", "Exception: %s\n %s", e.what(),
817  "dd4hep: while programming VolumeManager. Are your volIDs correct?");
818  }
819  catch (...) {
820  except("DD4hep_VolumeManager",
821  "UNKNOWN exception while programming VolumeManager. Are your volIDs correct?");
822  }
823  return 0;
824 }
825 DECLARE_APPLY(DD4hep_VolumeManager,load_volmgr)
826 DECLARE_APPLY(DD4hepVolumeManager,load_volmgr)
827 
828 
836 static long dump_geometry2root(Detector& description, int argc, char** argv) {
837  if ( argc > 0 ) {
838  std::string output;
839  for(int i = 0; i < argc && argv[i]; ++i) {
840  if ( 0 == ::strncmp("-output",argv[i],4) )
841  output = argv[++i];
842  }
843  if ( output.empty() ) {
844  std::cout <<
845  "Usage: -plugin DD4hep_Geometry2ROOT -arg [-arg] \n\n"
846  " Output DD4hep detector description object to a ROOT file. \n\n"
847  " -output <string> Output file name. \n"
848  "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush;
849  ::exit(EINVAL);
850  }
851  printout(INFO,"Geometry2ROOT","+++ Dump geometry to root file:%s",output.c_str());
852  //description.manager().Export(output.c_str()+1);
853  if ( DD4hepRootPersistency::save(description,output.c_str(),"Geometry") > 1 ) {
854  return 1;
855  }
856  }
857  printout(ERROR,"Geometry2ROOT","+++ No output file name given.");
858  return 0;
859 }
860 DECLARE_APPLY(DD4hep_Geometry2ROOT,dump_geometry2root)
861 
862 
870 static long load_geometryFromroot(Detector& description, int argc, char** argv) {
871  if ( argc > 0 ) {
872  std::string input = argv[0]; // <-- for backwards compatibility
873  for(int i = 0; i < argc && argv[i]; ++i) {
874  if ( 0 == ::strncmp("-input",argv[i],4) )
875  input = argv[++i];
876  }
877  if ( input.empty() ) {
878  std::cout <<
879  "Usage: DD4hep_RootLoader -arg [-arg] \n\n"
880  " Load DD4hep detector description from ROOT file to memory. \n\n"
881  " -input <string> Input file name. \n"
882  "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush;
883  ::exit(EINVAL);
884  }
885  printout(INFO,"DD4hepRootLoader","+++ Read geometry from root file:%s",input.c_str());
886  if ( 1 == DD4hepRootPersistency::load(description,input.c_str(),"Geometry") ) {
887  return 1;
888  }
889  }
890  printout(ERROR,"DD4hep_RootLoader","+++ No input file name given.");
891  return 0;
892 }
893 DECLARE_APPLY(DD4hep_RootLoader,load_geometryFromroot)
894 
895 
903 static long dump_geometry2tgeo(Detector& description, int argc, char** argv) {
904  if ( argc > 0 ) {
905  std::string output( argc == 1 ? argv[0] : "" );
906  printout(INFO,"Geometry2TGeo","+++ output: %d %s", argc, output.c_str());
907  for(int i = 0; i < argc && argv[i]; ++i) {
908  if ( 0 == ::strncmp("-output",argv[i],4) )
909  output = argv[++i];
910  }
911  if ( output.empty() ) {
912  std::cout <<
913  "Usage: -plugin <name> -arg [-arg] \n"
914  " Output TGeo information to a ROOT file. \n\n"
915  " name: factory name DD4hepGeometry2TGeo \n"
916  " -output <string> Output file name. \n"
917  "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush;
918  ::exit(EINVAL);
919  }
920  printout(INFO,"Geometry2TGeo","+++ Dump geometry to root file:%s",output.c_str());
921  if ( description.manager().Export(output.c_str()) > 1 ) {
922  return 1;
923  }
924  }
925  printout(ERROR,"Geometry2TGeo","+++ No output file name given.");
926  return 0;
927 }
928 DECLARE_APPLY(DD4hep_Geometry2TGeo,dump_geometry2tgeo)
929 DECLARE_APPLY(DD4hepGeometry2TGeo,dump_geometry2tgeo)
930 
931 
939 static long check_detectors(Detector& description, int /* argc */, char** /* argv */) {
940  DD4hepRootCheck check(&description);
941  auto ret = check.checkDetectors();
942  return ret.first > 0 && ret.second == 0 ? 1 : 0;
943 }
944 DECLARE_APPLY(DD4hep_CheckDetectors,check_detectors)
945 
946 
954 static long check_sensitives(Detector& description, int /* argc */, char** /* argv */) {
955  DD4hepRootCheck check(&description);
956  auto ret = check.checkSensitives();
957  return ret.first > 0 && ret.second == 0 ? 1 : 0;
958 }
959 DECLARE_APPLY(DD4hep_CheckSensitives,check_sensitives)
960 
961 
969 static long check_segmentations(Detector& description, int /* argc */, char** /* argv */) {
970  DD4hepRootCheck check(&description);
971  auto ret = check.checkSegmentations();
972  return ret.first > 0 && ret.second == 0 ? 1 : 0;
973 }
974 DECLARE_APPLY(DD4hep_CheckSegmentations,check_segmentations)
975 
976 
984 static long check_readouts(Detector& description, int /* argc */, char** /* argv */) {
985  DD4hepRootCheck check(&description);
986  auto ret = check.checkReadouts();
987  return ret.first > 0 && ret.second == 0 ? 1 : 0;
988 }
989 DECLARE_APPLY(DD4hep_CheckReadouts,check_readouts)
990 
991 
999 static long check_idspecs(Detector& description, int /* argc */, char** /* argv */) {
1000  DD4hepRootCheck check(&description);
1001  auto ret = check.checkIdSpecs();
1002  return ret.first > 0 && ret.second == 0 ? 1 : 0;
1003 }
1004 DECLARE_APPLY(DD4hep_CheckIdspecs,check_idspecs)
1005 
1006 
1014 static long check_volumemanager(Detector& description, int /* argc */, char** /* argv */) {
1015  DD4hepRootCheck check(&description);
1016  auto ret = check.checkVolManager();
1017  return ret.first > 0 && ret.second == 0 ? 1 : 0;
1018 }
1019 DECLARE_APPLY(DD4hep_CheckVolumeManager,check_volumemanager)
1020 
1021 
1029 static long check_nominals(Detector& description, int /* argc */, char** /* argv */) {
1030  DD4hepRootCheck check(&description);
1031  auto ret = check.checkNominals();
1032  return ret.first > 0 && ret.second == 0 ? 1 : 0;
1033 }
1034 DECLARE_APPLY(DD4hep_CheckNominals,check_nominals)
1035 
1036 
1044 static long dump_volume_tree(Detector& description, int argc, char** argv) {
1045  struct Actor {
1046  Detector& description;
1047  bool m_printPathes = false;
1048  bool m_printVolIDs = false;
1049  bool m_printShapes = false;
1050  bool m_printPointers = false;
1051  bool m_printPositions = false;
1052  bool m_printVis = false;
1053  bool m_printMaterials = false;
1054  bool m_printSensitivesOnly = false;
1055  long m_printMaxLevel = 999999;
1056  long m_numNodes = 0;
1057  long m_numShapes = 0;
1058  long m_numSensitive = 0;
1059  long m_numMaterial = 0;
1060  long m_numMaterialERR = 0;
1061  bool m_topStat = false;
1062  std::string m_detector;
1063  std::string currTop;
1064  std::map<std::string,long> top_counts;
1065 
1066  Actor(Detector& desc, int ac, char** av) : description(desc) {
1067  m_detector = "/world";
1068  for(int i=0; i<ac; ++i) {
1069  char c = ::tolower(av[i][0]);
1070  char* p = av[i];
1071  if ( c == '-' ) { ++p; c = ::tolower(av[i][1]); }
1072  if ( c == '-' ) { ++p; c = ::tolower(av[i][1]); }
1073  if ( ::strncmp(p,"volume_ids",3) == 0 ) m_printVolIDs = true;
1074  else if ( ::strncmp(p,"level",3) == 0 ) m_printMaxLevel = ::atol(av[++i]);
1075  else if ( ::strncmp(p,"materials",3) == 0 ) m_printMaterials = true;
1076  else if ( ::strncmp(p,"pathes",3) == 0 ) m_printPathes = true;
1077  else if ( ::strncmp(p,"positions",3) == 0 ) m_printPositions = true;
1078  else if ( ::strncmp(p,"pointers",3) == 0 ) m_printPointers = true;
1079  else if ( ::strncmp(p,"shapes",3) == 0 ) m_printShapes = true;
1080  else if ( ::strncmp(p,"sensitive",3) == 0 ) m_printSensitivesOnly = true;
1081  else if ( ::strncmp(p,"topstats",3) == 0 ) m_topStat = true;
1082  else if ( ::strncmp(p,"vis",3) == 0 ) m_printVis = true;
1083  else if ( ::strncmp(p,"detector",3) == 0 ) m_detector = av[++i];
1084  else if ( ::strncmp(p,"help",3) == 0 ) {
1085  std::cout <<
1086  "Usage: -plugin <name> -arg [-arg] \n"
1087  " -detector <string> Top level DetElement path. Default: '/world' \n"
1088  " -pathes Print DetElement pathes \n"
1089  " -level <number> Maximal depth to be explored by the scan \n"
1090  " -positions Print placement positions \n"
1091  " -volume_ids Print placement volume IDs \n"
1092  " -materials Print volume materials \n"
1093  " -pointers Debug: Print pointer values \n"
1094  " -shapes Print shape information \n"
1095  " -vis Print visualisation attribute name(s) if present \n"
1096  " -sensitive Only print information for sensitive volumes \n"
1097  " -topstats Print statistics about top level node \n"
1098  "\tArguments given: " << arguments(ac,av) << std::endl << std::flush;
1099  _exit(0);
1100  }
1101  }
1102  if ( m_printMaxLevel < 999999 )
1103  printout(ALWAYS,"VolumeDump","+++ Maximal print level: %ld",m_printMaxLevel);
1104  if ( !m_detector.empty() )
1105  printout(ALWAYS,"VolumeDump","+++ Subdetector path: %s",m_detector.c_str());
1106  printout(ALWAYS,"VolumeDump","+++ Printing positions: %s",yes_no(m_printPositions));
1107  printout(ALWAYS,"VolumeDump","+++ Printing shapes: %s",yes_no(m_printShapes));
1108  printout(ALWAYS,"VolumeDump","+++ Printing materials: %s",yes_no(m_printMaterials));
1109  printout(ALWAYS,"VolumeDump","+++ Printing volume ids: %s",yes_no(m_printVolIDs));
1110  printout(ALWAYS,"VolumeDump","+++ Printing visattrs: %s",yes_no(m_printVis));
1111  printout(ALWAYS,"VolumeDump","+++ Print only sensitives: %s",yes_no(m_printSensitivesOnly));
1112  }
1113  ~Actor() {
1114  printout(ALWAYS,"VolumeDump",
1115  "+++ Checked %ld physical volume placements. %3ld are sensitive.",
1116  m_numNodes, m_numSensitive);
1117  if ( m_printMaterials ) {
1118  printout(ALWAYS,"VolumeDump",
1119  "+++ Checked %ld materials in volume placements. %3ld are BAD.",
1120  m_numMaterial, m_numMaterialERR);
1121  }
1122  if ( m_printShapes ) {
1123  printout(ALWAYS,"VolumeDump","+++ Checked %ld shapes.", m_numShapes);
1124  }
1125  if ( m_topStat ) {
1126  for(const auto& t : top_counts) {
1127  if ( t.second > 1 )
1128  printout(ALWAYS,"VolumeDump",
1129  "+++ Top node: %-32s %8ld placements.",t.first.c_str(),t.second);
1130  }
1131  }
1132  }
1133 
1134  long dump(std::string prefix, TGeoNode* ideal, TGeoNode* aligned, int level, PlacedVolume::VolIDs volids) {
1135  char fmt[128];
1136  std::stringstream log;
1137  PlacedVolume pv(ideal);
1138  bool sensitive = false;
1139  std::string opt_info, pref = std::move(prefix);
1140 
1141  if ( level >= m_printMaxLevel ) {
1142  return 1;
1143  }
1144  ++m_numNodes;
1145  if ( level == 0 )
1146  currTop = "";
1147  else if ( level == 1 ) {
1148  currTop = ideal->GetVolume()->GetName();
1149  ++top_counts[currTop];
1150  }
1151  else if ( level > 1 ) {
1152  ++top_counts[currTop];
1153  }
1154 
1155  if ( m_printPathes ) {
1156  pref += "/";
1157  pref += aligned->GetName();
1158  }
1160  TGeoVolume* mother = ideal ? ideal->GetMotherVolume() : nullptr;
1161  if ( m_printPositions || m_printVolIDs ) {
1162  if ( m_printPointers ) {
1163  if ( ideal != aligned )
1164  std::snprintf(fmt,sizeof(fmt),"Ideal:%p Aligned:%p ",
1165  (void*)ideal,(void*)aligned);
1166  else
1167  std::snprintf(fmt,sizeof(fmt),"Ideal:%p MotherVol:%p",
1168  (void*)ideal, (void*)mother);
1169  log << fmt;
1170  }
1171  // Top level volume! have no volume ids
1172  if ( m_printVolIDs && ideal && ideal->GetMotherVolume() ) {
1173  PlacedVolume::VolIDs vid = pv.volIDs();
1174  if ( !vid.empty() ) {
1175  sensitive = true;
1176  log << " VolID: ";
1177  volids.insert(volids.end(),vid.begin(),vid.end());
1178  for( const auto& i : volids ) {
1179  std::snprintf(fmt, sizeof(fmt), "%s:%2d ",i.first.c_str(),i.second);
1180  log << fmt;
1181  }
1182  if ( !vid.empty() || pv.volume().isSensitive() ) {
1183  SensitiveDetector sd = pv.volume().sensitiveDetector();
1184  if ( sd.isValid() ) {
1185  IDDescriptor dsc = sd.readout().idSpec();
1186  if ( dsc.isValid() ) {
1187  log << std::hex << " (0x" << std::setfill('0') << std::setw(8)
1188  << dsc.encode(volids)
1189  << std::setfill(' ') << std::dec << ") ";
1190  }
1191  }
1192  }
1193  }
1194  }
1195  opt_info = log.str();
1196  log.str("");
1197  }
1199  if ( m_printVis && pv.volume().visAttributes().isValid() ) {
1200  log << " Vis:" << pv.volume().visAttributes().name();
1201  opt_info += log.str();
1202  log.str("");
1203  }
1204  TGeoVolume* volume = ideal ? ideal->GetVolume() : 0;
1205  if ( !m_printSensitivesOnly || (m_printSensitivesOnly && sensitive) ) {
1206  Volume vol = pv.volume();
1207  char sens = vol.isSensitive() ? 'S' : ' ';
1208  if ( m_printPointers ) {
1209  if ( ideal == aligned ) {
1210  std::snprintf(fmt,sizeof(fmt),"%03d %%s [Ideal:%p Vol:%p MotherVol:%p] %%-%ds %%-16s Vol:%%s shape:%%s \t %c %%s",
1211  level+1,(void*)ideal,(void*)vol, (void*)mother, 2*level+1, sens);
1212  }
1213  else {
1214  std::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s Vol:%%s shape:%%s %c %%s",
1215  level+1,(void*)ideal,(void*)aligned,2*level+1,sens);
1216  }
1217  }
1218  else {
1219  if ( ideal == aligned ) {
1220  std::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds %%-16s Vol:%%s shape:%%s \t %c %%s",
1221  level+1,2*level+1,sens);
1222  }
1223  else {
1224  std::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s Vol:%%s shape:%%s %c %%s",
1225  level+1,(void*)ideal,(void*)aligned,2*level+1,sens);
1226  }
1227  }
1228  const auto* sh = volume ? volume->GetShape() : nullptr;
1229  printout(INFO,"VolumeDump",fmt,pref.c_str(),"",
1230  aligned->GetName(),
1231  vol.name(),
1232  sh ? sh->IsA()->GetName() : "[Invalid Shape]",
1233  opt_info.c_str());
1234  if ( sens == 'S' ) ++m_numSensitive;
1235  }
1236  if ( m_printMaterials ) {
1237  Volume vol = pv.volume();
1238  Material mat = vol.material();
1239  TGeoMaterial* mptr = mat->GetMaterial();
1240  bool ok = mat.A() == mptr->GetA() && mat.Z() == mptr->GetZ();
1241  std::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds Material: %%-16s A:%%6.2f %%6.2f Z:%%6.2f %%6.2f",
1242  level+1,2*level+1);
1243  ++m_numMaterial;
1244  if ( !ok ) ++m_numMaterialERR;
1245  printout(ok ? INFO : ERROR, "VolumeDump", fmt,
1246  " ->", "", mat.name(), mat.A(), mptr->GetA(), mat.Z(), mptr->GetZ());
1247  }
1248  log.str("");
1249  if ( m_printShapes ) {
1250  log << "Shape: " << toStringSolid(pv.volume().solid()) << " \t";
1251  }
1252  if ( m_printPositions ) {
1253  if ( ideal ) {
1254  const double* trans = ideal->GetMatrix()->GetTranslation();
1255  std::snprintf(fmt, sizeof(fmt), "Pos: (%f,%f,%f) ",trans[0],trans[1],trans[2]);
1256  }
1257  else {
1258  std::snprintf(fmt, sizeof(fmt), " <ERROR: INVALID Translation matrix> ");
1259  }
1260  log << fmt << " \t";
1261  }
1262  if ( !log.str().empty() ) {
1263  std::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds %%s",level+1,2*level+1);
1264  printout(INFO, "VolumeDump", fmt, " ->", "", log.str().c_str());
1265  }
1266  for (Int_t idau = 0, ndau = aligned->GetNdaughters(); idau < ndau; ++idau) {
1267  if ( ideal ) {
1268  TGeoNode* ideal_daughter = ideal->GetDaughter(idau);
1269  const char* daughter_name = ideal_daughter->GetName();
1270  TGeoNode* aligned_daughter = volume->GetNode(daughter_name);
1271  dump(pref, ideal_daughter, aligned_daughter, level+1, volids);
1272  }
1273  else {
1274  printout(ERROR,"VolumeDump"," <ERROR: INVALID IDEAL Translation matrix>: %s",aligned->GetName());
1275  }
1276  }
1277  return 1;
1278  }
1280  int operator()() {
1281  PlacedVolume pv;
1282  DetElement top = description.world();
1284 
1285  if ( m_detector != "/world" ) {
1286  top = detail::tools::findElement(description,m_detector);
1287  if ( !top.isValid() ) {
1288  except("VolumeDump","+++ Invalid DetElement path: %s",m_detector.c_str());
1289  }
1290  }
1291  if ( !top.placement().isValid() ) {
1292  except("VolumeDump","+++ Invalid DetElement placement: %s",m_detector.c_str());
1293  }
1294  std::string place = top.placementPath();
1295  detail::tools::placementPath(top, path);
1296  pv = detail::tools::findNode(description.world().placement(),place);
1297  if ( !pv.isValid() ) {
1298  except("VolumeDump","+++ Invalid placement verification for placement:%s",place.c_str());
1299  }
1300  return this->dump("", top.placement().ptr(), pv.ptr(), 0, PlacedVolume::VolIDs());
1301  }
1302  };
1303  Actor actor(description, argc, argv);
1304  return actor();
1305 }
1306 DECLARE_APPLY(DD4hep_VolumeDump,dump_volume_tree)
1307 
1308 // ======================================================================================
1310 
1321 static int detelement_processor(Detector& description, int argc, char** argv) {
1322  bool recursive = true;
1323  ProcessorArgs args(argc, argv);
1324  DetElement det = description.world();
1325  std::unique_ptr<DetectorProcessor>
1326  proc(dd4hep::createProcessor<DetectorProcessor>(description, args.argc, &args.argv[0]));
1327 
1328  for(int i=0; i<argc; ++i) {
1329  if ( i >= args.start && i <= args.end )
1330  continue;
1331  else if ( 0 == ::strncmp(argv[i],"-recursive",4) )
1332  recursive = true;
1333  else if ( 0 == ::strncmp(argv[i],"-no-recursive",7) )
1334  recursive = false;
1335  else if ( 0 == ::strncmp(argv[i],"-detector",4) ) {
1336  std::string path = argv[++i];
1337  det = detail::tools::findElement(description, path);
1338  if ( det.isValid() ) {
1339  continue;
1340  }
1341  except("DetElementProcessor",
1342  "++ The detector element path:%s is not part of this description!",
1343  path.c_str());
1344  }
1345  else {
1346  except("DetElementProcessor","++ Unknown plugin argument: %s",argv[i]);
1347  }
1348  }
1349  return DetectorScanner().scan(*proc, det, 0, recursive) > 0 ? 1 : 0;
1350 }
1351 DECLARE_APPLY(DD4hep_DetElementProcessor,detelement_processor)
1352 
1353 // ======================================================================================
1355 
1366 static int placed_volume_processor(Detector& description, int argc, char** argv) {
1367  bool recursive = true;
1368  PlacedVolume pv = description.world().placement();
1369  ProcessorArgs args(argc, argv);
1370  std::unique_ptr<PlacedVolumeProcessor>
1371  proc(dd4hep::createProcessor<PlacedVolumeProcessor>(description, args.argc, &args.argv[0]));
1372 
1373  std::string path = "/world";
1374  for(int i=0; i<argc; ++i) {
1375  if ( i >= args.start && i <= args.end )
1376  continue;
1377  else if ( 0 == ::strncmp(argv[i],"-recursive",4) )
1378  recursive = true;
1379  else if ( 0 == ::strncmp(argv[i],"--recursive",5) )
1380  recursive = true;
1381  else if ( 0 == ::strncmp(argv[i],"-no-recursive",7) )
1382  recursive = false;
1383  else if ( 0 == ::strncmp(argv[i],"--no-recursive",8) )
1384  recursive = false;
1385  else if ( 0 == ::strncmp(argv[i],"-detector",4) )
1386  path = argv[++i];
1387  else if ( 0 == ::strncmp(argv[i],"--detector",5) )
1388  path = argv[++i];
1389  else
1390  except("PlacedVolumeProcessor","++ Unknown plugin argument: %s",argv[i]);
1391  }
1392  DetElement det = detail::tools::findElement(description, path);
1393  if ( det.isValid() ) {
1394  pv = det.placement();
1395  if ( pv.isValid() ) {
1396  return PlacedVolumeScanner().scanPlacements(*proc, pv, 0, recursive) > 0 ? 1 : 0;
1397  }
1398  except("PlacedVolumeProcessor",
1399  "++ The detector element with path:%s has no valid placement!",
1400  path.c_str());
1401  }
1402  except("PlacedVolumeProcessor",
1403  "++ The detector element path:%s is not part of this description!",
1404  path.c_str());
1405  return 0;
1406 }
1407 DECLARE_APPLY(DD4hep_PlacedVolumeProcessor,placed_volume_processor)
1408 
1409 
1417 template <int flag> long dump_detelement_tree(Detector& description, int argc, char** argv) {
1418  using VolIDs = PlacedVolume::VolIDs;
1420  struct Actor {
1421  Detector& descr;
1422  std::string path { };
1423  DetElement det_world { };
1424  long count = 0;
1425  int have_match = -1;
1426  int analysis_level = 999999;
1427  bool dump_materials = false;
1428  bool dump_shapes = false;
1429  bool dump_positions = false;
1430  bool dump_volids = false;
1431  bool sensitive_only = false;
1432 
1434  Actor(Detector& det) : descr(det) {
1435  det_world = descr.world();
1436  }
1438  ~Actor() {
1439  printout(ALWAYS,"DetectorDump", "+++ Scanned a total of %ld elements.",count);
1440  }
1441  void parse_args(int ac, char** av) {
1442  for(int i=0; i<ac; ++i) {
1443  if ( ::strncmp(av[i],"--sensitive", 5)==0 ) { sensitive_only = true; }
1444  else if ( ::strncmp(av[i], "-sensitive", 5)==0 ) { sensitive_only = true; }
1445  else if ( ::strncmp(av[i], "--no-sensitive", 8)==0 ) { sensitive_only = false; }
1446  else if ( ::strncmp(av[i], "-materials", 4)==0 ) { dump_materials = true; }
1447  else if ( ::strncmp(av[i], "--materials", 5)==0 ) { dump_materials = true; }
1448  else if ( ::strncmp(av[i], "-shapes", 4)==0 ) { dump_shapes = true; }
1449  else if ( ::strncmp(av[i], "--shapes", 5)==0 ) { dump_shapes = true; }
1450  else if ( ::strncmp(av[i], "-positions", 4)==0 ) { dump_positions = true; }
1451  else if ( ::strncmp(av[i], "--positions", 5)==0 ) { dump_positions = true; }
1452  else if ( ::strncmp(av[i], "-no-sensitive", 7)==0 ) { sensitive_only = false; }
1453  else if ( ::strncmp(av[i], "--volids", 5)==0 ) { dump_volids = true; }
1454  else if ( ::strncmp(av[i], "-volids", 5)==0 ) { dump_volids = true; }
1455  else if ( ::strncmp(av[i], "--detector", 5)==0 ) { path = av[++i]; }
1456  else if ( ::strncmp(av[i], "-detector", 5)==0 ) { path = av[++i]; }
1457  else if ( ::strncmp(av[i], "--level", 5)==0 ) { analysis_level = ::atol(av[++i]); }
1458  else if ( ::strncmp(av[i], "-level", 5)==0 ) { analysis_level = ::atol(av[++i]); }
1459  else {
1460  std::cout << " "
1461  << (flag==0 ? "DD4hep_DetectorDump" : "DD4hep_DetectorVolumeDump") << " -arg [-arg] \n\n"
1462  << " Dump " << (flag==0 ? "DetElement" : "Detector volume") << " tree. \n"
1463  << " Configure produced output information using the following options: \n\n"
1464  " --sensitive Process only sensitive volumes. \n"
1465  " -sensitive dto. \n"
1466  " --no-sensitive Invert sensitive only flag. \n"
1467  " -no-sensitive dto. \n"
1468  " --shapes Print shape information. \n"
1469  " -shapes dto. \n"
1470  " --positions Print position information. \n"
1471  " -positions dto. \n"
1472  " --materials Print material information. \n"
1473  " -materials dto. \n"
1474  " --detector <path> Process elements only if <path> is part of the DetElement path.\n"
1475  " -detector <path> dto. \n"
1476  " -level <number> Maximal depth to be explored by the scan \n"
1477  " --level <number> dto. \n"
1478  " -volids Print volume identifiers of placements. \n"
1479  " --volids dto. \n"
1480  "\tArguments given: " << arguments(ac,av) << std::endl << std::flush;
1481  ::exit(EINVAL);
1482  }
1483  }
1484  }
1485  IDDescriptor get_id_descriptor(PlacedVolume pv) {
1486  if ( pv.isValid() ) {
1487  Volume v = pv.volume();
1488  SensitiveDetector sd = v.sensitiveDetector();
1489  if ( sd.isValid() ) {
1490  IDDescriptor dsc = sd.readout().idSpec();
1491  if ( dsc.isValid() ) return dsc;
1492  }
1493  for (Int_t idau = 0, ndau = v->GetNdaughters(); idau < ndau; ++idau) {
1494  IDDescriptor dsc = get_id_descriptor(v->GetNode(idau));
1495  if ( dsc.isValid() ) return dsc;
1496  }
1497  }
1498  return IDDescriptor();
1499  }
1500  void validate_id_descriptor(DetElement de, IDDescriptor& desc) {
1501  desc = (!de.parent() || de.parent() == det_world)
1502  ? IDDescriptor() : get_id_descriptor(de.placement());
1503  }
1504 
1505  long dump(DetElement de, int level, IDDescriptor& id_desc, VolIDs chain) {
1506  char fmt[256];
1507  PlacedVolume place = de.placement();
1508  const DetElement::Children& children = de.children();
1509  bool use_elt = path.empty() || de.path().find(path) != std::string::npos;
1510 
1511  if ( have_match < 0 && use_elt ) {
1512  have_match = level;
1513  }
1514 
1515  use_elt &= ((level-have_match) <= analysis_level);
1516  if ( !place.isValid() ) {
1517  std::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s DetElement with INVALID PLACEMENT!", level+1, 2*level+1);
1518  printout(ERROR,"DetectorDump", fmt, "", de.path().c_str());
1519  use_elt = false;
1520  }
1521 
1522  if ( place.isValid() && de != det_world ) {
1523  chain.insert(chain.end(), place.volIDs().begin(), place.volIDs().end());
1524  }
1525  if ( use_elt ) {
1526  if ( !sensitive_only || 0 != de.volumeID() ) {
1527  char sens = place.isValid() && place.volume().isSensitive() ? 'S' : ' ';
1528  switch( flag ) {
1529  case 0:
1530  ++count;
1531  if ( de.placement() == de.idealPlacement() ) {
1532  std::snprintf(fmt, sizeof(fmt), "%03d %%-%ds %%s NumDau:%%d VolID:%%08X Place:%%p %%c", level+1, 2*level+1);
1533  printout(INFO, "DetectorDump", fmt, "", de.path().c_str(), int(children.size()),
1534  (unsigned long)de.volumeID(), (void*)place.ptr(), sens);
1535  break;
1536  }
1537  std::snprintf(fmt, sizeof(fmt), "%03d %%-%ds %%s NumDau:%%d VolID:%%08X Place:%%p [ideal:%%p aligned:%%p] %%c",
1538  level+1, 2*level+1);
1539  printout(INFO, "DetectorDump", fmt, "", de.path().c_str(), int(children.size()),
1540  (unsigned long)de.volumeID(), (void*)de.idealPlacement().ptr(),
1541  (void*)place.ptr(), sens);
1542  break;
1543  case 1:
1544  ++count;
1545  std::snprintf(fmt, sizeof(fmt), "%03d %%-%ds Detector: %%s NumDau:%%d VolID:%%p", level+1, 2*level+1);
1546  printout(INFO, "DetectorDump", fmt, "", de.path().c_str(), int(children.size()), (void*)de.volumeID());
1547  if ( de.placement() == de.idealPlacement() ) {
1548  std::snprintf(fmt, sizeof(fmt), "%03d %%-%ds Placement: %%s %%c", level+1, 2*level+3);
1549  printout(INFO,"DetectorDump",fmt,"", de.placementPath().c_str(), sens);
1550  break;
1551  }
1552  std::snprintf(fmt,sizeof(fmt), "%03d %%-%ds Placement: %%s [ideal:%%p aligned:%%p] %%c",
1553  level+1,2*level+3);
1554  printout(INFO,"DetectorDump",fmt,"", de.placementPath().c_str(),
1555  (void*)de.idealPlacement().ptr(), (void*)place.ptr(), sens);
1556  break;
1557  default:
1558  break;
1559  }
1560  if ( (dump_materials || dump_shapes) && place.isValid() ) {
1561  Volume vol = place.volume();
1562  Material mat = vol.material();
1563  std::snprintf(fmt,sizeof(fmt), "%03d %%-%ds Material: %%-12s Shape: %%s", level+1,2*level+3);
1564  printout(INFO,"DetectorDump",fmt,"", mat.name(), toStringSolid(vol->GetShape()).c_str());
1565  }
1566  if ( dump_positions && place.isValid() ) {
1567  Position pos = place.position();
1568  Box box = place.volume().solid();
1569  double loc[3] = {0,0,0}, world[3] = {0,0,0};
1570  TGeoHMatrix tr = de.nominal().worldTransformation();
1571  tr.LocalToMaster(loc, world);
1572  std::snprintf(fmt,sizeof(fmt), "%03d %%-%ds BBox: (%%9.4f,%%9.4f,%%9.4f) [cm]", level+1,2*level+3);
1573  printout(INFO,"DetectorDump",fmt,"", box.x(), box.y(), box.z());
1574  std::snprintf(fmt,sizeof(fmt), "%03d %%-%ds Position: (%%9.4f,%%9.4f,%%9.4f) [cm] w/r to mother", level+1,2*level+3);
1575  printout(INFO,"DetectorDump",fmt,"", pos.X(), pos.Y(), pos.Z());
1576  std::snprintf(fmt,sizeof(fmt), "%03d %%-%ds Position: (%%9.4f,%%9.4f,%%9.4f) [cm] w/r to world", level+1,2*level+3);
1577  printout(INFO,"DetectorDump",fmt,"", world[0], world[1], world[2]);
1578  }
1579  if ( dump_volids && !place.volIDs().empty() ) {
1580  std::stringstream log;
1581  log << " VID:";
1582  for( const auto& i : chain )
1583  log << " " << i.first << ':' << std::dec << std::setw(2) << i.second;
1584  if ( id_desc.isValid() ) {
1585  log << " (encoded:0x" << std::setfill('0') << std::setw(8) << std::hex
1586  << id_desc.encode(chain)
1587  << std::setfill(' ') << std::dec << ") ";
1588  }
1589  std::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s", level+1, 2*level+1);
1590  printout(INFO,"DetectorDump", fmt, "", log.str().c_str());
1591  }
1592  }
1593  }
1594  for ( const auto& c : children ) {
1595  validate_id_descriptor(c.second, id_desc);
1596  dump(c.second, level+1, id_desc, chain);
1597  }
1598  return 1;
1599  }
1600  };
1601  VolIDs chain;
1602  IDDescriptor id_descriptor;
1603  Actor actor(description);
1604  actor.parse_args(argc, argv);
1605  return actor.dump(description.world(), 0, id_descriptor, std::move(chain));
1606 }
1607 DECLARE_APPLY(DD4hep_DetectorDump,dump_detelement_tree<0>)
1608 DECLARE_APPLY(DD4hep_DetectorVolumeDump,dump_detelement_tree<1>)
1609 
1610 
1618 static long detelement_cache(Detector& description, int argc, char** argv) {
1619  struct Actor {
1620  long cache(DetElement de) {
1621  const DetElement::Children& c = de.children();
1624  de.placementPath();
1625  de.path();
1626  for( const auto& i : c ) cache(i.second);
1627  return 1;
1628  }
1629  } actor;
1630  std::string detector = "/world";
1631  for(int i = 0; i < argc && argv[i]; ++i) {
1632  if ( 0 == ::strncmp("-detector",argv[i],4) )
1633  detector = argv[++i];
1634  else if ( 0 == ::strncmp("--detector",argv[i],5) )
1635  detector = argv[++i];
1636  else {
1637  std::cout <<
1638  "Usage: -plugin DD4hep_DetElementCache -arg [-arg] \n\n"
1639  " Fill cache with transformation information in DetElements. \n\n"
1640  " -detector <string> Top level DetElement path. Default: '/world'\n"
1641  " --detector <string> dto. \n"
1642  " -help Print this help. \n"
1643  " Arguments given: " << arguments(argc,argv) << std::endl << std::flush;
1644  ::exit(EINVAL);
1645  }
1646  }
1647  DetElement element = description.world();
1648  if ( detector != "/world" ) {
1649  element = detail::tools::findElement(description, detector);
1650  if ( !element.isValid() ) {
1651  except("VolumeDump","+++ Invalid DetElement path: %s", detector.c_str());
1652  }
1653  }
1654  return actor.cache(element);
1655 }
1656 DECLARE_APPLY(DD4hep_DetElementCache,detelement_cache)
1657 
1658 
1666 #include "../GeometryTreeDump.h"
1667 static long exec_GeometryTreeDump(Detector& description, int, char** ) {
1668  GeometryTreeDump dmp;
1669  dmp.create(description.world());
1670  return 1;
1671 }
1672 DECLARE_APPLY(DD4hep_GeometryTreeDump,exec_GeometryTreeDump)
1673 
1674 
1682 static long detectortype_cache(Detector& description, int argc, char** argv) {
1683  std::vector<std::string> types;
1684  for(int i = 0; i < argc && argv[i]; ++i) {
1685  if ( 0 == ::strncmp("-type",argv[i],4) )
1686  types.push_back(argv[++i]);
1687  else if ( 0 == ::strncmp("--type",argv[i],4) )
1688  types.push_back(argv[++i]);
1689  else {
1690  std::cout <<
1691  "Usage: DD4hep_DetectorTypes -type <type> -arg [-arg] \n"
1692  " Dump detector types from detector description. \n\n"
1693  " -type <string> Add new type to be listed. Multiple possible. \n"
1694  "\tArguments given: " << arguments(argc,argv) << std::endl << std::flush;
1695  ::exit(EINVAL);
1696  }
1697  }
1698  if ( types.empty() ) {
1699  types = description.detectorTypes();
1700  }
1701  printout(INFO,"DetectorTypes","Detector type dump: %ld types:", long(types.size()));
1702  for( const auto& type : types ) {
1703  const std::vector<DetElement>& detectors = description.detectors(type);
1704  printout(INFO,"DetectorTypes","\t --> %ld %s detectors:",long(detectors.size()), type.c_str());
1705  for( const auto& d : detectors ) {
1706  printout(INFO,"DetectorTypes","\t\t %-16s --> %s [%s]",type.c_str(),d.name(),d.type().c_str());
1707  }
1708  }
1709  return 1;
1710 }
1711 DECLARE_APPLY(DD4hep_DetectorTypes,detectortype_cache)
1712 
1713 
1721 #include <DD4hep/SurfaceInstaller.h>
1724 
1725 
1733 #include <DD4hep/PluginTester.h>
1734 static long install_plugin_tester(Detector& description, int , char** ) {
1735  PluginTester* test = description.extension<PluginTester>(false);
1736  if ( !test ) {
1737  description.addExtension<PluginTester>(new PluginTester());
1738  printout(INFO,"PluginTester",
1739  "+++ Successfully installed PluginTester instance to Detector.");
1740  }
1741  return 1;
1742 }
1743 DECLARE_APPLY(DD4hep_PluginTester,install_plugin_tester)
1744 
dd4hep::DetElement::children
const Children & children() const
Access to the list of children.
Definition: DetElement.cpp:207
dd4hep::Detector::manager
virtual TGeoManager & manager() const =0
Access the geometry manager of this instance.
dd4hep::DetElement::path
const std::string & path() const
Path of the detector element (not necessarily identical to placement path!)
Definition: DetElement.cpp:158
dd4hep::Detector::addExtension
IFACE * addExtension(CONCRETE *c)
Extend the sensitive detector element with an arbitrary structure accessible by the type.
Definition: Detector.h:331
dd4hep::xml::DocumentHandler::create
Document create(const char *tag, const char *comment=0) const
Create new XML document by parsing empty xml buffer.
Definition: DocumentHandler.cpp:681
dd4hep::run_interpreter
void run_interpreter(const std::string &name)
Definition: RootDictionary.h:53
DD4hepRootPersistency.h
dd4hep::Detector::world
virtual DetElement world() const =0
Return reference to the top-most (world) detector element.
dd4hep::DetectorScanner
Helper to run DetElement scans.
Definition: DetectorProcessor.h:173
DetectorProcessor.h
dd4hep::Alignment::detectorTransformation
const TGeoHMatrix & detectorTransformation() const
Access the alignment/placement matrix with respect to the world.
Definition: Alignments.cpp:73
v
View * v
Definition: MultiView.cpp:28
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:44
dd4hep::DetElement::parent
DetElement parent() const
Access to the detector elements's parent.
Definition: DetElement.cpp:239
DetectorImp.h
dd4hep::PlacedVolumeScanner::scanPlacements
int scanPlacements(PlacedVolumeProcessor &proc, PlacedVolume start, int level=0, bool recursive=true) const
PlacedVolume element tree scanner using wrapped PlacedVolumeProcessor objects.
Definition: VolumeProcessor.h:165
Detector.h
dd4hep::buildType
DetectorBuildType buildType(const char *value)
Translate string representation of the geometry build type to value.
Definition: BuildType.cpp:24
dd4hep::exception
void exception(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:69
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::Box::x
double x() const
Access half "length" of the box.
Definition: Shapes.cpp:155
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::detail::tools::placementPath
std::string placementPath(DetElement element)
Assemble the placement path from a given detector element to the world volume.
Definition: DetectorTools.cpp:276
dd4hep::IDDescriptor
Class implementing the ID encoding of the detector response.
Definition: IDDescriptor.h:37
DECLARE_APPLY
#define DECLARE_APPLY(name, func)
Definition: Factories.h:281
dd4hep::Volume::solid
Solid solid() const
Access to Solid (Shape)
Definition: Volumes.cpp:1223
dd4hep::Handle::isValid
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:128
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
dd4hep::xml::Handle_t
Class to easily access the properties of single XmlElements.
Definition: XMLElements.h:380
dd4hep::Volume::isSensitive
bool isSensitive() const
Accessor if volume is sensitive (ie. is attached to a sensitive detector)
Definition: Volumes.cpp:1293
dd4hep::DetElement::volumeID
VolumeID volumeID() const
The cached VolumeID of this subdetector element.
Definition: DetElement.cpp:344
dd4hep::DetectorLoad::processXMLElement
virtual void processXMLElement(const std::string &msg_source, const xml::Handle_t &root)
Process a given DOM (sub-) tree.
Definition: DetectorLoad.cpp:129
Factories.h
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dump_detelement_tree
long dump_detelement_tree(Detector &description, int argc, char **argv)
Basic entry point to print out the detector element hierarchy.
Definition: StandardPlugins.cpp:1417
dd4hep::Material::A
double A() const
atomic number of the underlying material
Definition: Objects.cpp:188
dd4hep::Box::z
double z() const
Access half "depth" of the box.
Definition: Shapes.cpp:165
dd4hep::Box::y
double y() const
Access half "width" of the box.
Definition: Shapes.cpp:160
dd4hep::Volume::material
Material material() const
Access to the Volume material.
Definition: Volumes.cpp:1122
dd4hep::detail::tools::findElement
DetElement findElement(const Detector &description, const std::string &path)
Find DetElement as child of the top level volume by its absolute path.
Definition: DetectorTools.cpp:214
DocumentHandler.h
DD4hepRootCheck
Helper class to check various ingredients of the Detector object after loaded from ROOT.
Definition: DD4hepRootPersistency.h:100
dd4hep::Material
Handle class describing a material.
Definition: Objects.h:272
dd4hep::toStringSolid
std::string toStringSolid(const TGeoShape *shape, int precision=2)
Pretty print of solid attributes.
Definition: ShapeUtilities.cpp:1148
DECLARE_CONSTRUCTOR
#define DECLARE_CONSTRUCTOR(name, func)
Definition: Factories.h:286
dd4hep::STD_Conditions::temperature
double temperature
Definition: Detector.h:69
dd4hep::Detector::getInstance
static Detector & getInstance(const std::string &name="default")
—Factory method----—
Definition: DetectorImp.cpp:150
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::PlacedVolumeExtension::VolIDs
Volume ID container.
Definition: Volumes.h:88
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:378
dd4hep::detail
DD4hep internal namespace.
Definition: Alignments.h:32
mix
#define mix(a, b, c)
Definition: Geant4EventSeed.h:113
dd4hep::DetectorScanner::scan
int scan(Q &p, DetElement start, int level=0, bool recursive=true) const
Detector element tree scanner using wrapped DetectorProcessor objects.
Definition: DetectorProcessor.h:194
dd4hep::Alignment::worldTransformation
const TGeoHMatrix & worldTransformation() const
Create cached matrix to transform to world coordinates.
Definition: Alignments.cpp:68
dd4hep::IDDescriptor::encode
static VolumeID encode(const Field *fld, VolumeID value)
Encode partial volume identifiers to a volumeID.
Definition: IDDescriptor.cpp:148
VolumeProcessor.h
DetectorTools.h
dd4hep::Material::Z
double Z() const
proton number of the underlying material
Definition: Objects.cpp:176
_U
#define _U(a)
Definition: Tags.h:23
TNamed
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:37
dd4hep::DetElement::placementPath
const std::string & placementPath() const
Access to the full path to the placed object.
Definition: DetElement.cpp:85
dd4hep::Detector::stdConditions
virtual const STD_Conditions & stdConditions() const =0
Access default conditions (temperature and pressure.
dd4hep::PlacedVolumeScanner
Helper to run placement scan through volume hierarchies scans.
Definition: VolumeProcessor.h:135
dd4hep::Detector::detectorTypes
virtual std::vector< std::string > detectorTypes() const =0
Access the availible detector types.
dd4hep::DetElement::nominal
Alignment nominal() const
Access to the constant ideal (nominal) alignment information.
Definition: DetElement.cpp:185
TestSurfacesPlugin
SurfaceInstaller TestSurfacesPlugin
Basic entry point to print out detector type map.
Definition: StandardPlugins.cpp:1722
dd4hep::Detector::fromCompact
virtual void fromCompact(const std::string &fname, DetectorBuildType type=BUILD_DEFAULT)=0
Deprecated call (use fromXML): Read compact geometry description or alignment file.
dd4hep::PlacedVolume::VolIDs
PlacedVolumeExtension::VolIDs VolIDs
Definition: Volumes.h:176
dd4hep::sim::IDDescriptor
IDDescriptor IDDescriptor
Definition: LCIOConversions.cpp:69
dd4hep::detail::GeometryTreeDump::create
void create(DetElement top)
Main entry point: create required object(s)
Definition: GeometryTreeDump.cpp:294
XML_IMPLEMENTATION_TYPE
#define XML_IMPLEMENTATION_TYPE
Definition: config.h:64
DECLARE_SURFACE_INSTALLER
#define DECLARE_SURFACE_INSTALLER(name, class)
Definition: SurfaceInstaller.h:108
detectors
DetectorMap detectors
Definition: AlignmentsCalculator.cpp:79
dd4hep::xml::Document
Class supporting the basic functionality of an XML document.
Definition: XMLElements.h:697
dd4hep::detail::tools::findNode
PlacedVolume findNode(PlacedVolume top_place, const std::string &place)
Find a given node in the hierarchy starting from the top node (absolute placement!...
Definition: DetectorTools.cpp:328
Memory.h
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
dd4hep::xml::DocumentHandler::output
virtual int output(Document doc, const std::string &fname) const
Write xml document to output file (stdout if file name empty)
Definition: DocumentHandler.cpp:396
dd4hep::PluginTester
Helper class to ease testing of plugins: Effectively a container of object extensions.
Definition: PluginTester.h:30
dd4hep::DetElement::Children
std::map< std::string, DetElement > Children
Definition: DetElement.h:206
dd4hep::Detector::buildType
virtual DetectorBuildType buildType() const =0
Access flag to steer the detail of building of the geometry/detector description.
dd4hep::Box
Class describing a box shape.
Definition: Shapes.h:294
dd4hep::xml::DocumentHandler
Class supporting to read and parse XML documents.
Definition: DocumentHandler.h:39
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:153
dd4hep::DetElement::idealPlacement
PlacedVolume idealPlacement() const
Access to the ideal physical volume of this detector element.
Definition: DetElement.cpp:312
XMLElements.h
dd4hep::xml::Element
User abstraction class to manipulate XML elements within a document.
Definition: XMLElements.h:769
TObject
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:41
dd4hep::Detector::extension
IFACE * extension(bool alert=true) const
Access extension element by the type.
Definition: Detector.h:342
DD4hepUI.h
dd4hep::DetectorBuildType
DetectorBuildType
Detector description build types.
Definition: BuildType.h:34
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::detail::tools::PlacementPath
std::vector< PlacedVolume > PlacementPath
Definition: DetectorTools.h:39
dd4hep::PlacedVolume::volume
Volume volume() const
Logical volume of this placement.
Definition: Volumes.cpp:452
dd4hep::STD_Conditions::pressure
double pressure
Definition: Detector.h:68
dd4hep::PlacedVolumeExtension::VolIDs::insert
std::pair< std::vector< VolID >::iterator, bool > insert(const std::string &name, int value)
Insert new entry.
Definition: Volumes.cpp:406
dd4hep::Detector::fromXML
virtual void fromXML(const std::string &fname, DetectorBuildType type=BUILD_DEFAULT)=0
Read any geometry description or alignment file.
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::SurfaceInstaller
Base class to implement surface installers for known detector patterns.
Definition: SurfaceInstaller.h:55
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:480
dd4hep::BUILD_DEFAULT
@ BUILD_DEFAULT
Definition: BuildType.h:36
XMLTags.h
DD4hepUnits.h
dd4hep::PlacedVolume::position
Position position() const
Access the translation vector to the parent volume.
Definition: Volumes.cpp:518
dd4hep::detail::GeometryTreeDump
Geometry to screen dump action.
Definition: GeometryTreeDump.h:41
Printout.h
dd4hep::DetectorImp::imp_loadVolumeManager
void imp_loadVolumeManager()
Local method (no interface): Load volume manager.
Definition: DetectorImp.cpp:282
dd4hep::DetectorImp
Concrete implementation class of the Detector interface.
Definition: DetectorImp.h:59
PluginCreators.h
dd4hep::dd4hep_ptr
Out version of the std auto_ptr implementation base either on auto_ptr or unique_ptr.
Definition: Memory.h:46
dd4hep::xml::Document::root
Handle_t root() const
Access the ROOT eleemnt of the DOM document.
Definition: XMLElements.cpp:1040