diff --git a/DDRec/CMakeLists.txt b/DDRec/CMakeLists.txt index 99390e5a6242af6eeeb376a1f2c975fffec51cd5..be8a53031aba147e0dfe349feb96f829baa2c10d 100644 --- a/DDRec/CMakeLists.txt +++ b/DDRec/CMakeLists.txt @@ -21,8 +21,14 @@ if(DD4HEP_USE_GEAR) add_definitions("-D DD4HEP_USE_GEAR") endif() +#dd4hep_add_dictionary( G__DDRec +# SOURCES include/DDRec/*.h +# OPTIONAL [GEAR REQUIRED] +#) + dd4hep_add_package_library(DDRec - SOURCES src/*.cpp + SOURCES src/*.cpp +# GENERATED G__DDRec.cxx OPTIONAL [GEAR COMPONENTS geartgeo SOURCES src/gear/DDGear.cpp DEFINITIONS DD4HEP_USE_GEAR ] ) dd4hep_add_plugin(DDRecPlugins diff --git a/DDRec/include/DDRec/DetectorData.h b/DDRec/include/DDRec/DetectorData.h index 7f65638e3604ef677ef61873c10bd12b7ae8777f..0a0f8257380a756a248d029e7242c9ef9725e8a9 100644 --- a/DDRec/include/DDRec/DetectorData.h +++ b/DDRec/include/DDRec/DetectorData.h @@ -2,6 +2,7 @@ #define DDRec_DetectorData_H_ #include <bitset> +#include <ostream> #include "DD4hep/Detector.h" @@ -64,7 +65,8 @@ namespace DD4hep { }; typedef StructExtension<FixedPadSizeTPCStruct> FixedPadSizeTPCData ; - + std::ostream& operator<<( std::ostream& io , const FixedPadSizeTPCData& d ) ; + /** Simple data structure with key parameters for * reconstruction of a planar silicon tracking detector @@ -138,6 +140,8 @@ namespace DD4hep { } ; typedef StructExtension<ZPlanarStruct> ZPlanarData ; + std::ostream& operator<<( std::ostream& io , const ZPlanarData& d ) ; + /** Simple data structure with key parameters for @@ -233,6 +237,7 @@ namespace DD4hep { } ; typedef StructExtension<ZDiskPetalsStruct> ZDiskPetalsData ; + std::ostream& operator<<( std::ostream& io , const ZDiskPetalsData& d ) ; /** Simple data structure defining a support * structure built from consecutive conical @@ -268,6 +273,7 @@ namespace DD4hep { typedef StructExtension<ConicalSupportStruct> ConicalSupportData ; + std::ostream& operator<<( std::ostream& io , const ConicalSupportData& d ) ; /** Simple data structure defining a layered calorimeter layout for @@ -374,6 +380,7 @@ namespace DD4hep { typedef StructExtension<LayeredCalorimeterStruct> LayeredCalorimeterData ; + std::ostream& operator<<( std::ostream& io , const LayeredCalorimeterData& d ) ; } /* namespace DDRec */ diff --git a/DDRec/src/DetectorData.cpp b/DDRec/src/DetectorData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb0cc55b59a05903745d3c9b6405f8270c151e3b --- /dev/null +++ b/DDRec/src/DetectorData.cpp @@ -0,0 +1,182 @@ +#include "DDRec/DetectorData.h" + +namespace DD4hep { + namespace DDRec { + + + std::ostream& operator<<( std::ostream& io , const FixedPadSizeTPCData& d ){ + io << " --FixedPadSizeTPCData: " << std::scientific << std::endl ; + io << " zHalf : " << d.zHalf << std::endl ; + io << " rMin : " << d.rMin << std::endl ; + io << " rMax : " << d.rMax << std::endl ; + io << " driftLength : " << d.driftLength << std::endl ; + io << " rMinReadout : " << d.rMinReadout << std::endl ; + io << " rMaxReadout : " << d.rMaxReadout << std::endl ; + io << " innerWallThickness : " << d.innerWallThickness << std::endl ; + io << " outerWallThickness : " << d.outerWallThickness << std::endl ; + io << " padHeight : " << d.padHeight << std::endl ; + io << " padWidth : " << d.padWidth << std::endl ; + io << " maxRow : " << d.maxRow << std::endl ; + io << " padGap : " << d.padGap << std::endl ; + // io << " : " << d. << std::endl ; + return io ; + } + + + + std::ostream& operator<<( std::ostream& io , const ZPlanarData& d ) { + + io << " -- ZPlanarData: " << std::scientific << std::endl ; + io << " zHalfShell : " << d.zHalfShell << std::endl ; + io << " gapShell : " << d.gapShell << std::endl ; + io << " rInnerShell : " << d.rInnerShell << std::endl ; + io << " rOuterShell : " << d.rOuterShell << std::endl ; + io << " widthStrip : " << d.widthStrip << std::endl ; + io << " lengthStrip : " << d.lengthStrip << std::endl ; + io << " pitchStrip : " << d.pitchStrip << std::endl ; + io << " angleStrip : " << d.angleStrip << std::endl ; + + std::vector<ZPlanarData::LayerLayout> layers = d.layers ; + + io << " Layers : " << std::endl + << " nLadder phi0 nSensors lengthSensor distSupport thickSupport offsetSupport widthSupport zHalfSupport distSense thickSense offsetSense widthSense zHalfSense" << std::endl ; + + //"ladderNumber phi0 sensorsPerLadder lengthSensor distanceSupport thicknessSupport offsetSupport widthSupport zHalfSupport distanceSensitive thicknessSensitive offsetSensitive widthSensitive zHalfSensitive" << std::endl ; + + for(unsigned i=0,N=layers.size() ; i<N ; ++i){ + + ZPlanarData::LayerLayout l = layers[i] ; + + io << " " << l.ladderNumber + << " " << l.phi0 + << " " << l.sensorsPerLadder + << " " << l.lengthSensor + << " " << l.distanceSupport + << " " << l.thicknessSupport + << " " << l.offsetSupport + << " " << l.widthSupport + << " " << l.zHalfSupport + << " " << l.distanceSensitive + << " " << l.thicknessSensitive + << " " << l.offsetSensitive + << " " << l.widthSensitive + << " " << l.zHalfSensitive + << std::endl ; + } + + + return io ; + } + + std::ostream& operator<<( std::ostream& io , const ZDiskPetalsData& d ) { + + io << " -- ZDiskPetalsData: " << std::scientific << std::endl ; + io << " widthStrip : " << d.widthStrip << std::endl ; + io << " lengthStrip : " << d.lengthStrip << std::endl ; + io << " pitchStrip : " << d.pitchStrip << std::endl ; + io << " angleStrip : " << d.angleStrip << std::endl ; + + std::vector<ZDiskPetalsData::LayerLayout> layers = d.layers ; + + io << " Layers : " << std::endl + << " petHalfAngle alphaPetal zPosition nP n d p phi0 zOffsetSup distSupport thickSupport widthInSup widthOutSup lengthSup zOffsetSense distSense thickSense widthInSense widthOutSense lenSense" << std::endl ; + + //"petalHalfAngle alphaPetal zPosition petalNumber sensorsPerPetal DoubleSided Pixel phi0 zOffsetSupport distanceSupport thicknessSupport widthInnerSupport widthOuterSupport lengthSupport zOffsetSensitive distanceSensitive thicknessSensitive widthInnerSensitive widthOuterSensitive lengthSensitive" << std::endl ; + + for(unsigned i=0,N=layers.size() ; i<N ; ++i){ + + ZDiskPetalsData::LayerLayout l = layers[i] ; + + io << " " << l.petalHalfAngle + << " " << l.alphaPetal + << " " << l.zPosition + << " " << l.petalNumber + << " " << l.sensorsPerPetal + << " " << l.typeFlags[ ZDiskPetalsData::SensorType::DoubleSided ] + << " " << l.typeFlags[ ZDiskPetalsData::SensorType::Pixel ] + << " " << l.phi0 + << " " << l.zOffsetSupport + << " " << l.distanceSupport + << " " << l.thicknessSupport + << " " << l.widthInnerSupport + << " " << l.widthOuterSupport + << " " << l.lengthSupport + << " " << l.zOffsetSensitive + << " " << l.distanceSensitive + << " " << l.thicknessSensitive + << " " << l.widthInnerSensitive + << " " << l.widthOuterSensitive + << " " << l.lengthSensitive + << std::endl ; + } + + io << " nP:petalNumber n:sensorsPerPetal d:DoubleSided p: Pixel " << std::endl ; + return io ; + } + + + std::ostream& operator<<( std::ostream& io , const ConicalSupportData& d ) { + + io << " -- ConicalSupportData : " << std::scientific << std::endl ; + io << " isSymmetricInZ : " << d.isSymmetricInZ << std::endl ; + + std::vector<ConicalSupportData::Section> layers = d.sections ; + + io << " Sections : " << std::endl + << "rInner rOuter zPos " << std::endl ; + + for(unsigned i=0,N=layers.size() ; i<N ; ++i){ + + ConicalSupportData::Section l = layers[i] ; + + io << " " << l.rInner + << " " << l.rOuter + << " " << l.zPos + << std::endl ; + } + return io ; + } + + + std::ostream& operator<<( std::ostream& io , const LayeredCalorimeterData& d ) { + + io << " -- LayeredCalorimeterData : " << std::scientific << std::endl ; + io << " LayoutType : " << ( d.layoutType == LayeredCalorimeterStruct::BarrelLayout ? + "BarrelLayout" : "EndcapLayout" ) << std::endl ; + io << " extent[ rmin, rmax, zmin, zmax ] : " + << d.extent[0] << " " << d.extent[1] << " " << d.extent[2] << " " << d.extent[3] << std::endl ; + io << " outer_symmetry : " << d.outer_symmetry << std::endl ; + io << " inner_symmetry : " << d.inner_symmetry << std::endl ; + io << " outer_phi0 : " << d.outer_phi0 << std::endl ; + io << " inner_phi0 : " << d.inner_phi0 << std::endl ; + io << " gap1 : " << d.gap1 << std::endl ; + io << " gap2 : " << d.gap2 << std::endl ; + + std::vector<LayeredCalorimeterData::Layer> layers = d.layers ; + + io << " Layers : " << std::endl + << " distance inner_nX0 outer_nX0 inner_nInt outer_nInt inner_thick outer_thick sense_thick" + << std::endl ; + //"distance inner_nX0 outer_nX0 inner_nLambda outer_nLambda inner_thick outer_thick sensitive_thick" << std::endl ; + + for(unsigned i=0,N=layers.size() ; i<N ; ++i){ + + LayeredCalorimeterData::Layer l = layers[i] ; + + io << " " << l.distance + << " " << l.inner_nRadiationLengths + << " " << l.outer_nRadiationLengths + << " " << l.inner_nInteractionLengths + << " " << l.outer_nInteractionLengths + << " " << l.inner_thickness + << " " << l.outer_thickness + << " " << l.sensitive_thickness + << std::endl ; + } + + return io ; + } + + + } // namespace +} diff --git a/UtilityApps/src/dumpdetector.cpp b/UtilityApps/src/dumpdetector.cpp index 9c9f346a5994c361ab36a117ca264dc9a1977f87..292a3629ec0750c029942d03123b18a305243c1b 100644 --- a/UtilityApps/src/dumpdetector.cpp +++ b/UtilityApps/src/dumpdetector.cpp @@ -22,6 +22,7 @@ #include "DDRec/Surface.h" #include "DDRec/DetectorSurfaces.h" +#include "DDRec/DetectorData.h" #include "DDRec/SurfaceHelper.h" // C/C++ include files @@ -35,12 +36,39 @@ using namespace DD4hep::DDRec; using namespace DDSurfaces ; using namespace dd4hep ; +//============================================================================= +void printDetectorData( DetElement det ){ + + try{ + FixedPadSizeTPCData* d = det.extension<FixedPadSizeTPCData>() ; + std::cout << *d ; + } catch(...){} + try{ + ZPlanarData* d = det.extension<ZPlanarData>() ; + std::cout << *d ; + } catch(...){} + try{ + ZDiskPetalsData* d = det.extension<ZDiskPetalsData>() ; + std::cout << *d ; + } catch(...){} + try{ + ConicalSupportData* d = det.extension<ConicalSupportData>() ; + std::cout << *d ; + } catch(...){} + try{ + LayeredCalorimeterData* d = det.extension<LayeredCalorimeterData>() ; + std::cout << *d ; + } catch(...){} + +} + //============================================================================= int main(int argc, char** argv ){ if( argc < 2 ) { std::cout << " usage: dumpdetector compact.xml [-s]" + << " -d : only print DetectorData objects " << " -s : also print surfaces " << std::endl ; @@ -50,6 +78,8 @@ int main(int argc, char** argv ){ std::string inFile = argv[1] ; + bool printDetData = ( argc>2 && !strcmp( argv[2] , "-d" ) ); + bool printSurfaces = ( argc>2 && !strcmp( argv[2] , "-s" ) ); @@ -60,6 +90,37 @@ int main(int argc, char** argv ){ DetElement world = lcdd.world() ; + std::cout << "############################################################################### " << std::endl ; + + Header h = lcdd.header() ; + + std::cout << " detector model : " << h.name() << std::endl + << " title : " << h.title() << std::endl + << " author : " << h.author() << std::endl + << " status : " << h.status() << std::endl ; + + if( printDetData ){ + + DD4hep::Geometry::LCDD::HandleMap dets = lcdd.detectors() ; + + for( DD4hep::Geometry::LCDD::HandleMap::const_iterator it = dets.begin() ; it != dets.end() ; ++it ){ + + DetElement det = it->second ; + + std::cout << " ---------------------------- " << det.name() << " ----------------------------- " << std::endl ; + + printDetectorData( det ) ; + + } + + std::cout << "############################################################################### " << std::endl ; + + return 0; + } + + + + DD4hep::Geometry::LCDD::HandleMap sensDet = lcdd.sensitiveDetectors() ; @@ -117,6 +178,9 @@ int main(int argc, char** argv ){ std::cout << de.name() << "[ path: "<< de.placementPath () << "] (id: " << de.id() << ") - sens type : " << lcdd.sensitiveDetector( de.name() ).type() << "\t surfaces : " << ( sL.empty() ? 0 : sL.size() ) << std::endl ; + + printDetectorData( de ) ; + if( printSurfaces ){ for( SurfaceList::const_iterator sit = sL.begin() ; sit != sL.end() ; ++sit ){ const ISurface* surf = *sit ; @@ -129,8 +193,13 @@ int main(int argc, char** argv ){ std::cout << "############################################################################### " << std::endl << std::endl ; + // FixedPadSizeTPCData* tpc = tpcDE.extension<FixedPadSizeTPCData>() ; return 0; } + + + + //=============================================================================