24 #include "gear/GEAR.h"
25 #include "gearxml/GearXML.h"
27 #include "gearimpl/Util.h"
28 #include "gearimpl/ConstantBField.h"
29 #include "gearimpl/GearMgrImpl.h"
31 #include "geartgeo/TGeoGearPointProperties.h"
32 #include "geartgeo/TGeoGearDistanceProperties.h"
37 using namespace detail ;
41 int argc(0);
char** argv = 0 ;
43 description.
apply( pluginName.c_str() , argc, argv) ;
47 gear::GearMgrImpl* gearMgr =
new gear::GearMgrImpl() ;
49 gearMgr->setDetectorName( description.
header().
name() ) ;
51 std::cout <<
" **** will convert detector " << description.
header().
name() <<
" to Gear \n"
52 <<
" Iterating over all subdetectors: " << std::endl ;
57 std::vector< DetElement > dets ;
65 for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){
68 dets.push_back( subDet ) ;
73 for ( DetElement::Children::const_iterator jt=grCh.begin() ; jt != grCh.end() ; ++jt ){
75 dets.push_back( jdet ) ;
80 for(
unsigned i=0, N= dets.size() ; i<N ; ++i){
88 std::cout <<
" *** subdetector " << dets[i].
name() <<
" - found gear object : " << gearH->
name() << std::endl ;
100 if ( gearH->
name() ==
"TPCParameters" ) { gearMgr->setTPCParameters (
dynamic_cast<gear::TPCParameters*
>( gearH->
takeGearObject() ) ) ; }
101 else if( gearH->
name() ==
"EcalBarrelParameters" ) { gearMgr->setEcalBarrelParameters(
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
102 else if( gearH->
name() ==
"EcalEndcapParameters" ) { gearMgr->setEcalEndcapParameters(
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
103 else if( gearH->
name() ==
"EcalPlugParameters" ) { gearMgr->setEcalPlugParameters (
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
104 else if( gearH->
name() ==
"YokeBarrelParameters" ) { gearMgr->setYokeBarrelParameters(
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
105 else if( gearH->
name() ==
"YokeEndcapParameters" ) { gearMgr->setYokeEndcapParameters(
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
106 else if( gearH->
name() ==
"YokePlugParameters" ) { gearMgr->setYokePlugParameters (
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
107 else if( gearH->
name() ==
"HcalBarrelParameters" ) { gearMgr->setHcalBarrelParameters(
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
108 else if( gearH->
name() ==
"HcalEndcapParameters" ) { gearMgr->setHcalEndcapParameters(
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
109 else if( gearH->
name() ==
"HcalRingParameters" ) { gearMgr->setHcalRingParameters (
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
110 else if( gearH->
name() ==
"LcalParameters" ) { gearMgr->setLcalParameters (
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
111 else if( gearH->
name() ==
"LHcalParameters" ) { gearMgr->setLHcalParameters (
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
112 else if( gearH->
name() ==
"BeamCalParameters" ) { gearMgr->setBeamCalParameters (
dynamic_cast<gear::CalorimeterParameters*
>( gearH->
takeGearObject() ) ) ; }
113 else if( gearH->
name() ==
"VXDParameters" ) { gearMgr->setVXDParameters (
dynamic_cast<gear::ZPlanarParameters*
>( gearH->
takeGearObject() ) ) ; }
114 else if( gearH->
name() ==
"FTDParameters" ) { gearMgr->setFTDParameters (
dynamic_cast<gear::FTDParameters*
>( gearH->
takeGearObject() ) ) ; }
115 else if( gearH->
name() ==
"SITParameters" ) { gearMgr->setSITParameters (
dynamic_cast<gear::ZPlanarParameters*
>( gearH->
takeGearObject() ) ) ; }
116 else if( gearH->
name() ==
"SETParameters" ) { gearMgr->setSETParameters (
dynamic_cast<gear::ZPlanarParameters*
>( gearH->
takeGearObject() ) ) ; }
117 else if( gearH->
name() ==
"SiPlanesParameters" ) { gearMgr->setSiPlanesParameters (
dynamic_cast<gear::SiPlanesParameters*
>( gearH->
takeGearObject() ) ) ; }
126 for(
unsigned j=0, M=gearH->
materials().size() ; j<M ; ++j) {
128 gearMgr->registerSimpleMaterial( &gearH->
materials()[j] ) ;
133 std::cout << std::endl ;
138 double origin[3] = { 0., 0., 0. } ;
143 gearMgr->setBField(
new gear::ConstantBField( gear::Vector3D( bfield[0]/ dd4hep::tesla , bfield[1]/ dd4hep::tesla , bfield[2] / dd4hep::tesla ) ) ) ;
148 TGeoManager *geoManager = world.
volume()->GetGeoManager();
150 gearMgr->setPointProperties(
new gear::TGeoGearPointProperties( geoManager ) ) ;
152 gearMgr->setDistanceProperties(
new gear::TGeoGearDistanceProperties( geoManager ) ) ;