00001 #include "GaudiKernel/Kernel.h" 00002 #include "GaudiKernel/IInterface.h" 00003 #include "GaudiKernel/StatusCode.h" 00004 //#include "GaudiKernel/ISvcFactory.h" 00005 //#include "GaudiKernel/SvcFactory.h" 00006 #include "GaudiKernel/MsgStream.h" 00007 #include "GaudiKernel/PropertyMgr.h" 00008 00009 #include "EmcRecGeoSvc/EmcRecGeoSvc.h" 00010 #include "EmcRecGeoSvc/EmcRecROOTGeo.h" 00011 00012 //static SvcFactory<EmcRecGeoSvc> s_factory; 00013 //const ISvcFactory& EmcRecGeoSvcFactory = s_factory; 00014 00015 EmcRecGeoSvc::EmcRecGeoSvc( const std::string& name, ISvcLocator* svcloc ) : Service(name, svcloc) 00016 { 00017 fGdml = true; 00018 00019 // Declare the properties 00020 declareProperty("Gdml",fGdml); 00021 00022 if(fGdml) { 00023 fROOTGeo = new EmcRecROOTGeo(); 00024 } 00025 } 00026 00027 EmcRecGeoSvc::~EmcRecGeoSvc() 00028 { 00029 if(fGdml) { 00030 if(fROOTGeo) delete fROOTGeo; 00031 } 00032 } 00033 00034 StatusCode EmcRecGeoSvc::queryInterface (const InterfaceID& riid, void** ppvInterface ){ 00035 00036 if ( IID_IEmcRecGeoSvc.versionMatch(riid) ) { 00037 *ppvInterface = static_cast<IEmcRecGeoSvc*> (this); 00038 } else { 00039 return Service::queryInterface(riid, ppvInterface) ; 00040 } 00041 return StatusCode::SUCCESS; 00042 } 00043 00044 StatusCode EmcRecGeoSvc::initialize ( ) { 00045 MsgStream log(messageService(), name()); 00046 log << MSG::INFO << name() << ": Start of run initialisation" << endreq; 00047 00048 StatusCode sc = Service::initialize(); 00049 if ( sc.isFailure() ) return sc; 00050 00051 // initialize geometry from gdml 00052 if(fGdml) { 00053 fROOTGeo->InitFromXML(); 00054 } 00055 return StatusCode::SUCCESS; 00056 } 00057 00058 00059 StatusCode EmcRecGeoSvc::finalize ( ) { 00060 MsgStream log(messageService(), name()); 00061 log << MSG::INFO << name() << ": End of Run" << endreq; 00062 return StatusCode::SUCCESS; 00063 } 00064 00065 EmcRecCrystal EmcRecGeoSvc::GetCrystal(const Identifier& id) const{ 00066 if(fGdml) { 00067 return fROOTGeo->GetCrystal(id); 00068 } else { 00069 EmcRecCrystal cry; 00070 00071 if(EmcID::is_barrel(id)) { 00072 cry=fBarrel.GetCrystal(id); 00073 } else { 00074 cry=fEndCap.GetCrystal(id); 00075 } 00076 00077 return cry; 00078 } 00079 00080 } 00081 00082 HepPoint3D EmcRecGeoSvc::GetCrystalPoint(const Identifier& id, const int i) const{ 00083 EmcRecCrystal cry; 00084 if(fGdml) { 00085 cry=fROOTGeo->GetCrystal(id); 00086 } else { 00087 if(EmcID::is_barrel(id)) { 00088 cry=fBarrel.GetCrystal(id); 00089 } else { 00090 cry=fEndCap.GetCrystal(id); 00091 } 00092 } 00093 return cry.Get(i)/cm; 00094 } 00095 00096 HepPoint3D EmcRecGeoSvc::GetCCenter(const Identifier& id) const{ 00097 if(fGdml) { 00098 return fROOTGeo->GetCCenter(id)/cm; 00099 } else { 00100 HepPoint3D center; 00101 00102 if(EmcID::is_barrel(id)) { 00103 center=fBarrel.GetCCenter(id); 00104 } else { 00105 center=fEndCap.GetCCenter(id); 00106 } 00107 00108 return center/cm; 00109 } 00110 } 00111 00112 HepPoint3D EmcRecGeoSvc::GetCFrontCenter(const Identifier& id) const{ 00113 if(fGdml) { 00114 return fROOTGeo->GetCFrontCenter(id)/cm; 00115 } else { 00116 HepPoint3D frontCenter; 00117 00118 if(EmcID::is_barrel(id)) { 00119 frontCenter=fBarrel.GetCFrontCenter(id); 00120 } else { 00121 frontCenter=fEndCap.GetCFrontCenter(id); 00122 } 00123 00124 return frontCenter/cm; 00125 } 00126 } 00127 00128 double EmcRecGeoSvc::GetBarrelR() const 00129 { 00130 return fBarrel.GetBarrelR()/cm; 00131 } 00132 00133 double EmcRecGeoSvc::GetBarrelOffset1() const 00134 { 00135 return fBarrel.GetBarrelOffset1()/cm; 00136 } 00137 00138 double EmcRecGeoSvc::GetBarrelOffset2() const 00139 { 00140 return fBarrel.GetBarrelOffset2()/cm; 00141 } 00142 00143 double EmcRecGeoSvc::GetBarrelh1() const 00144 { 00145 return fBarrel.GetBarrelh1()/cm; 00146 } 00147 00148 double EmcRecGeoSvc::GetBarrelh2() const 00149 { 00150 return fBarrel.GetBarrelh2()/cm; 00151 } 00152 00153 double EmcRecGeoSvc::GetBarrelh3() const 00154 { 00155 return fBarrel.GetBarrelh3()/cm; 00156 } 00157 00158 double EmcRecGeoSvc::GetBarrelL() const 00159 { 00160 return fBarrel.GetBarrelL()/cm; 00161 } 00162 00163 int EmcRecGeoSvc::GetBarrelNPhiMax() const 00164 { 00165 return fBarrel.GetBarrelNPhiMax(); 00166 } 00167 00168 int EmcRecGeoSvc::GetBarrelNThetaMax() const 00169 { 00170 return fBarrel.GetBarrelNThetaMax(); 00171 }