DD4hep  1.31.0
Detector Description Toolkit for High Energy Physics
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DetectorHelperTest.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/Detector.h>
16 #include <DD4hep/Printout.h>
17 #include <DD4hep/Factories.h>
18 #include <DD4hep/DetectorHelper.h>
19 
20 // C/C++ include files
21 
22 using namespace dd4hep;
23 
24 namespace {
25 
41  struct DetectorHelperTest {
43  DetectorHelperTest(Detector& description, int argc, char** argv) {
44  DetectorHelper h(&description);
45  const char* nam = argc>1 ? argv[1]+1 : "SiVertexEndcap";
46  printSD(h,nam);
47  walkSD(h,description.detector(nam));
48  }
50  virtual ~DetectorHelperTest() {}
51 
52  void walkSD(DetectorHelper h, DetElement de) const {
53  printSD(h,de);
54  for(DetElement::Children::const_iterator i=de.children().begin(); i!=de.children().end(); ++i) {
55  DetElement child = (*i).second;
56  printSD(h,child);
57  if ( child.children().size() > 0 ) walkSD(h,child);
58  }
59  }
60  void printSD(DetectorHelper h, DetElement de) const {
62  printout(INFO,"DetectorHelperTest","Sensitive detector[%s]: %p --> %s",de.path().c_str(),(void*)sd.ptr(),
63  sd.ptr() ? sd.name() : "????");
64 
65  }
66  void printSD(DetectorHelper h, const char* nam) const {
68  printout(INFO,"DetectorHelperTest","Sensitive detector[%s]: %p --> %s",nam,(void*)sd.ptr(),
69  sd.ptr() ? sd.name() : "????");
70 
71  }
73  static long run(Detector& description,int argc,char** argv) {
74  DetectorHelperTest test(description,argc,argv);
75  return 1;
76  }
77  };
78 }
79 
80 namespace dd4hep {
81  using ::DetectorHelperTest;
82 }
83 DECLARE_APPLY(CLICSiD_DetectorHelperTest,DetectorHelperTest::run)
dd4hep::DetElement::children
const Children & children() const
Access to the list of children.
Definition: DetElement.cpp:207
dd4hep::DetElement::path
const std::string & path() const
Path of the detector element (not necessarily identical to placement path!)
Definition: DetElement.cpp:158
dd4hep::Detector::detector
virtual DetElement detector(const std::string &name) const =0
Retrieve a subdetector element by its name from the detector description.
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:43
Detector.h
DECLARE_APPLY
#define DECLARE_APPLY(name, func)
Definition: Factories.h:281
DetectorHelper.h
Factories.h
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:187
dd4hep::DetectorHelper
DetectorHelper: class to shortcut certain questions to the dd4hep detector description interface.
Definition: DetectorHelper.h:32
dd4hep::DetectorHelper::sensitiveDetector
SensitiveDetector sensitiveDetector(const std::string &detector) const
Access the sensitive detector of a given subdetector (if the sub-detector is sensitive!...
Definition: DetectorHelper.cpp:23
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:151
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
Printout.h