7 #include "DD4hep/Detector.h" 8 #include "DD4hep/DetType.h" 9 #include "DD4hep/DetectorSelector.h" 10 #include "DD4hep/DD4hepUnits.h" 11 #include "DDRec/Surface.h" 12 #include "DDRec/DetectorSurfaces.h" 13 #include "DDRec/DetectorData.h" 14 #include "DDRec/SurfaceHelper.h" 36 const void *handle()
const ;
38 std::type_index typeIndex()
const ;
39 void dumpGeometry()
const ;
42 void printDetectorData( dd4hep::DetElement det )
const ;
43 void printDetectorSets(
const std::string &name,
unsigned int includeFlag,
unsigned int excludeFlag )
const ;
47 "The DD4hep geometry compact XML file" } ;
50 "Whether to dump detector data while dumping the geometry",
false } ;
53 "Whether to dump surfaces while dumping the geometry",
false } ;
59 DD4hepGeometry::DD4hepGeometry() :
61 setDescription(
"DD4hep geometry plugin. Use geoMgr->geometry<dd4hep::Detector>() to access the geometry" ) ;
67 dd4hep::Detector& theDetector = dd4hep::Detector::getInstance() ;
74 return &dd4hep::Detector::getInstance() ;
80 dd4hep::Detector::getInstance().destroyInstance() ;
86 return std::type_index(
typeid( dd4hep::Detector ) ) ;
93 FixedPadSizeTPCData* d = det.extension<FixedPadSizeTPCData>() ;
98 ZPlanarData* d = det.extension<ZPlanarData>() ;
103 ZDiskPetalsData* d = det.extension<ZDiskPetalsData>() ;
104 _logger->log<MESSAGE>() << *d ;
108 ConicalSupportData* d = det.extension<ConicalSupportData>() ;
109 _logger->log<MESSAGE>() << *d ;
113 LayeredCalorimeterData* d = det.extension<LayeredCalorimeterData>() ;
114 _logger->log<MESSAGE>() << *d ;
123 const std::vector<DetElement>& dets = DetectorSelector(description).detectors( includeFlag, excludeFlag ) ;
124 _logger->log<MESSAGE>() <<
" " << name ;
125 for(
int i=0,N=dets.size();i<N;++i) {
126 _logger->log<MESSAGE>() << dets[i].
name() <<
", " ;
128 _logger->log<MESSAGE>() << std::endl ;
135 _logger->log<MESSAGE>() <<
"############################################################################### " << std::endl ;
136 Header h = description.header() ;
138 <<
" detector model : " << h.name() << std::endl
139 <<
" title : " << h.title() << std::endl
140 <<
" author : " << h.author() << std::endl
141 <<
" status : " << h.status() << std::endl ;
143 printDetectorSets(
" barrel trackers : " , ( DetType::TRACKER | DetType::BARREL ) , ( DetType::VERTEX) ) ;
144 printDetectorSets(
" endcap trackers : " , ( DetType::TRACKER | DetType::ENDCAP ) , ( DetType::VERTEX) ) ;
145 printDetectorSets(
" vertex barrel trackers : " , ( DetType::TRACKER | DetType::BARREL | DetType::VERTEX), DetType::IGNORE ) ;
146 printDetectorSets(
" vertex endcap trackers : " , ( DetType::TRACKER | DetType::ENDCAP | DetType::VERTEX), DetType::IGNORE ) ;
147 printDetectorSets(
" barrel calorimeters : " , ( DetType::CALORIMETER | DetType::BARREL ), DetType::IGNORE ) ;
148 printDetectorSets(
" endcap calorimeters : " , ( DetType::CALORIMETER | DetType::ENDCAP ), DetType::IGNORE ) ;
150 printDetectorSets(
" other detecors : " , ( DetType::IGNORE ) , ( DetType::CALORIMETER | DetType::TRACKER ) ) ;
153 _logger->log<MESSAGE>() <<
"############################################################################### " << std::endl ;
154 dd4hep::Detector::HandleMap dets = description.detectors() ;
155 for( dd4hep::Detector::HandleMap::const_iterator it = dets.begin() ; it != dets.end() ; ++it ) {
156 DetElement det = it->second ;
157 _logger->log<MESSAGE>() <<
" ---------------------------- " << det.name() <<
" ----------------------------- " << std::endl ;
158 DetType
type( det.typeFlag() ) ;
159 _logger->log<MESSAGE>() <<
" ------ " <<
type << std:: endl ;
162 _logger->log<MESSAGE>() <<
"############################################################################### " << std::endl ;
164 dd4hep::Detector::HandleMap sensDet = description.sensitiveDetectors() ;
165 _logger->log<MESSAGE>() <<
"############################################################################### " << std::endl ;
166 _logger->log<MESSAGE>() <<
" sensitive detectors: " << std::endl ;
167 for( dd4hep::Detector::HandleMap::const_iterator it = sensDet.begin() ; it != sensDet.end() ; ++it ){
168 SensitiveDetector sDet = it->second ;
169 _logger->log<MESSAGE>() <<
" " << it->first <<
" : type = " << sDet.type() << std::endl ;
171 std::cout <<
"############################################################################### " << std::endl << std::endl ;
172 DetElement world = description.world() ;
174 std::list< DetElement > dets ;
175 std::list< DetElement > daugs ;
176 std::list< DetElement > gdaugs ;
177 daugs.push_back( world ) ;
178 while( ! daugs.empty() ) {
179 for( std::list< DetElement >::iterator li=daugs.begin() ; li != daugs.end() ; ++li ){
180 DetElement dau = *li ;
181 DetElement::Children chMap = dau.children() ;
182 for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){
183 DetElement de = (*it).second ;
184 gdaugs.push_back( de ) ;
187 dets.splice( dets.end() , daugs ) ;
188 daugs.splice( daugs.end() , gdaugs ) ;
193 for ( std::list< DetElement >::const_iterator it=dets.begin() ; it != dets.end() ; ++it ) {
194 DetElement de = (*it) ;
195 DetElement mother = de.parent() ;
196 unsigned parentCount = 0 ;
197 while( mother.isValid() ) {
198 mother = mother.parent() ;
201 SurfaceHelper surfMan( de ) ;
202 const SurfaceList& sL = surfMan.surfaceList() ;
203 _logger->log<MESSAGE>() <<
"DetElement: " ;
204 for(
unsigned i=0 ; i < parentCount ; ++i ) {
205 _logger->log<MESSAGE>() <<
"\t" ;
209 <<
"[ path: "<< de.placementPath () <<
"] (id: " << de.id() <<
") - sens type : " 210 << description.sensitiveDetector( de.name() ).
type()
211 <<
"\t surfaces : " << ( sL.empty() ? 0 : sL.size() )
214 for( SurfaceList::const_iterator sit = sL.begin() ; sit != sL.end() ; ++sit ) {
215 const ISurface* surf = *sit ;
216 _logger->log<MESSAGE>() <<
" ------------------------- " 217 <<
" surface: " << *surf << std::endl
218 <<
" ------------------------- " << std::endl ;
222 _logger->log<MESSAGE>() <<
"############################################################################### " << std::endl << std::endl ;
const std::string & name() const
Get the component name.
#define MARLINMT_DECLARE_GEOMETRY(Class)
BoolParameter _dumpDetectorData
LoggerPtr _logger
The logger instance.
DD4hepGeometry class Responsible for loading DD4hep geometry in MarlinMT.
const std::string & type() const
Get the component name.
void setDescription(const std::string &desc)
Set the component description.
const std::string & description() const
Get the component description.
void printDetectorSets(const std::string &name, unsigned int includeFlag, unsigned int excludeFlag) const
void dumpGeometry() const
Dump the geometry in the console.
const void * handle() const
Get a handle on the geometry instance.
std::type_index typeIndex() const
Get a type index object from the geometry handle.
BoolParameter _dumpDetectorSurfaces
void printDetectorData(dd4hep::DetElement det) const
GeometryPlugin class Responsible for loading geometry in Marlin and providing access to it through th...
void loadGeometry()
Load the geometry.
StringParameter _compactFile
void destroy()
Cleanup geometry.