File indexing completed on 2025-07-02 07:53:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/Detector.h>
0016 #include <DD4hep/Printout.h>
0017 #include <DD4hep/Factories.h>
0018 #include <DD4hep/DetectorHelper.h>
0019
0020
0021
0022 using namespace dd4hep;
0023
0024 namespace {
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 struct DetectorHelperTest {
0042
0043 DetectorHelperTest(Detector& description, int argc, char** argv) {
0044 DetectorHelper h(&description);
0045 const char* nam = argc>1 ? argv[1]+1 : "SiVertexEndcap";
0046 printSD(h,nam);
0047 walkSD(h,description.detector(nam));
0048 }
0049
0050 virtual ~DetectorHelperTest() {}
0051
0052 void walkSD(DetectorHelper h, DetElement de) const {
0053 printSD(h,de);
0054 for(DetElement::Children::const_iterator i=de.children().begin(); i!=de.children().end(); ++i) {
0055 DetElement child = (*i).second;
0056 printSD(h,child);
0057 if ( child.children().size() > 0 ) walkSD(h,child);
0058 }
0059 }
0060 void printSD(DetectorHelper h, DetElement de) const {
0061 SensitiveDetector sd = h.sensitiveDetector(de);
0062 printout(INFO,"DetectorHelperTest","Sensitive detector[%s]: %p --> %s",de.path().c_str(),(void*)sd.ptr(),
0063 sd.ptr() ? sd.name() : "????");
0064
0065 }
0066 void printSD(DetectorHelper h, const char* nam) const {
0067 SensitiveDetector sd = h.sensitiveDetector(nam);
0068 printout(INFO,"DetectorHelperTest","Sensitive detector[%s]: %p --> %s",nam,(void*)sd.ptr(),
0069 sd.ptr() ? sd.name() : "????");
0070
0071 }
0072
0073 static long run(Detector& description,int argc,char** argv) {
0074 DetectorHelperTest test(description,argc,argv);
0075 return 1;
0076 }
0077 };
0078 }
0079
0080 namespace dd4hep {
0081 using ::DetectorHelperTest;
0082 }
0083 DECLARE_APPLY(CLICSiD_DetectorHelperTest,DetectorHelperTest::run)