12 #include "gear/GEAR.h"
13 #include "gearxml/GearXML.h"
15 #include "gearimpl/Util.h"
16 #include "gearimpl/ConstantBField.h"
17 #include "gearimpl/GearMgrImpl.h"
19 #include "geartgeo/TGeoGearPointProperties.h"
20 #include "geartgeo/TGeoGearDistanceProperties.h"
25 using namespace Geometry ;
30 int argc(0);
char** argv = 0 ;
32 lcdd.
apply( pluginName.c_str() , argc, argv) ;
36 gear::GearMgrImpl* gearMgr =
new gear::GearMgrImpl() ;
38 gearMgr->setDetectorName( lcdd.
header().
name() ) ;
40 std::cout <<
" **** will convert detector " << lcdd.
header().
name() <<
" to Gear \n"
41 <<
" Iterating over all subdetectors: " << std::endl ;
46 std::vector< DetElement > dets ;
54 for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){
57 dets.push_back( subDet ) ;
62 for ( DetElement::Children::const_iterator jt=grCh.begin() ; jt != grCh.end() ; ++jt ){
64 dets.push_back( jdet ) ;
69 for(
unsigned i=0, N= dets.size() ; i<N ; ++i){
77 std::cout <<
" *** subdetector " << dets[i].
name() <<
" - found gear object : " << gearH->
name() << std::endl ;
79 }
catch( std::exception&
e) {
89 if ( gearH->
name() ==
"TPCParameters" ) { gearMgr->setTPCParameters ( dynamic_cast<gear::TPCParameters* >( gearH->
takeGearObject() ) ) ; }
90 else if( gearH->
name() ==
"EcalBarrelParameters" ) { gearMgr->setEcalBarrelParameters( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
91 else if( gearH->
name() ==
"EcalEndcapParameters" ) { gearMgr->setEcalEndcapParameters( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
92 else if( gearH->
name() ==
"EcalPlugParameters" ) { gearMgr->setEcalPlugParameters ( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
93 else if( gearH->
name() ==
"YokeBarrelParameters" ) { gearMgr->setYokeBarrelParameters( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
94 else if( gearH->
name() ==
"YokeEndcapParameters" ) { gearMgr->setYokeEndcapParameters( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
95 else if( gearH->
name() ==
"YokePlugParameters" ) { gearMgr->setYokePlugParameters ( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
96 else if( gearH->
name() ==
"HcalBarrelParameters" ) { gearMgr->setHcalBarrelParameters( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
97 else if( gearH->
name() ==
"HcalEndcapParameters" ) { gearMgr->setHcalEndcapParameters( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
98 else if( gearH->
name() ==
"HcalRingParameters" ) { gearMgr->setHcalRingParameters ( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
99 else if( gearH->
name() ==
"LcalParameters" ) { gearMgr->setLcalParameters ( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
100 else if( gearH->
name() ==
"LHcalParameters" ) { gearMgr->setLHcalParameters ( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
101 else if( gearH->
name() ==
"BeamCalParameters" ) { gearMgr->setBeamCalParameters ( dynamic_cast<gear::CalorimeterParameters* >( gearH->
takeGearObject() ) ) ; }
102 else if( gearH->
name() ==
"VXDParameters" ) { gearMgr->setVXDParameters ( dynamic_cast<gear::ZPlanarParameters* >( gearH->
takeGearObject() ) ) ; }
103 else if( gearH->
name() ==
"FTDParameters" ) { gearMgr->setFTDParameters ( dynamic_cast<gear::FTDParameters* >( gearH->
takeGearObject() ) ) ; }
104 else if( gearH->
name() ==
"SITParameters" ) { gearMgr->setSITParameters ( dynamic_cast<gear::ZPlanarParameters* >( gearH->
takeGearObject() ) ) ; }
105 else if( gearH->
name() ==
"SETParameters" ) { gearMgr->setSETParameters ( dynamic_cast<gear::ZPlanarParameters* >( gearH->
takeGearObject() ) ) ; }
106 else if( gearH->
name() ==
"SiPlanesParameters" ) { gearMgr->setSiPlanesParameters ( dynamic_cast<gear::SiPlanesParameters* >( gearH->
takeGearObject() ) ) ; }
115 for(
unsigned j=0, M=gearH->
materials().size() ; j<M ; ++j) {
117 gearMgr->registerSimpleMaterial( &gearH->
materials()[j] ) ;
122 std::cout << std::endl ;
127 double origin[3] = { 0., 0., 0. } ;
137 TGeoManager *geoManager = world.
volume()->GetGeoManager();
139 gearMgr->setPointProperties(
new gear::TGeoGearPointProperties( geoManager ) ) ;
141 gearMgr->setDistanceProperties(
new gear::TGeoGearDistanceProperties( geoManager ) ) ;
virtual long apply(const char *factory, int argc, char **argv)=0
Manipulate geometry using factory converter.
virtual DetElement world() const =0
Return reference to the top-most (world) detector element.
Volume volume() const
Access to the logical volume of the detector element's placement.
void magneticField(const Position &pos, Direction &field) const
Returns the 3 magnetic field components (x, y, z).
virtual OverlayedField field() const =0
Return handle to the combined electromagentic field description.
const Children & children() const
Access to the list of children.
Class describing a field overlay with several sources.
static const double tesla
const std::vector< gear::SimpleMaterialImpl > & materials()
get all materials assigned to this wrapper
const std::string & name()
virtual Header header() const =0
Accessor to the map of header entries.
Handle class describing a detector element.
The main interface to the DD4hep detector description package.
std::map< std::string, DetElement > Children
gear::GearMgr * createGearMgr(Geometry::LCDD &lcdd, const std::string &pluginName)
gear::GearParametersImpl * takeGearObject()