15 #include "DD4hep/Detector.h"
16 #include "DD4hep/DD4hepUnits.h"
17 #include "DD4hep/Fields.h"
18 #include "DD4hep/Plugins.h"
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) ;
45 DetElement world = description.world() ;
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 ;
60 DetElement::Children chMap = world.children() ;
65 for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){
67 DetElement subDet = (*it).second ;
71 DetElement::Children grCh = subDet.children() ;
73 for ( DetElement::Children::const_iterator jt=grCh.begin() ; jt != grCh.end() ; ++jt ){
74 DetElement jdet = (*jt).second ;
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] ) ;
138 double origin[3] = { 0., 0., 0. } ;
140 OverlayedField ovField = description.field() ;
141 ovField.magneticField( origin , bfield ) ;
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 ) ) ;
const std::vector< gear::SimpleMaterialImpl > & materials()
get all materials assigned to this wrapper
const std::string & name()
Name of GearParametersImpl object - should be the canonical name used in gear, eg.
gear::GearMgr * createGearMgr(Detector &description, const std::string &pluginName="GearForILD")
Factory method that creates a GearMgr object pobulated with the GearParametersImpl objects from all (...
gear::GearParametersImpl * takeGearObject()
Get GearParametersImpl object and transfer ownership.
Simple wrapper class for objects of type GearParametersImpl that can be added to DetElements with the...