BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecGeoSvc.cxx
Go to the documentation of this file.
1#include "GaudiKernel/IInterface.h"
2#include "GaudiKernel/Kernel.h"
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/PropertyMgr.h"
5#include "GaudiKernel/StatusCode.h"
6
7#include "EmcRecGeoSvc.h"
8#include "EmcRecGeoSvc/EmcRecROOTGeo.h"
9
11
12// static SvcFactory<EmcRecGeoSvc> s_factory;
13// const ISvcFactory& EmcRecGeoSvcFactory = s_factory;
14
15EmcRecGeoSvc::EmcRecGeoSvc( const std::string& name, ISvcLocator* svcloc )
16 : base_class( name, svcloc ) {
17 fGdml = true;
18
19 // Declare the properties
20 declareProperty( "Gdml", fGdml );
21
22 if ( fGdml ) { fROOTGeo = new EmcRecROOTGeo(); }
23}
24
26 if ( fGdml )
27 {
28 if ( fROOTGeo ) delete fROOTGeo;
29 }
30}
31
32/*StatusCode EmcRecGeoSvc::queryInterface (const InterfaceID& riid, void** ppvInterface ){
33
34 if ( IID_IEmcRecGeoSvc.versionMatch(riid) ) {
35 *ppvInterface = static_cast<IEmcRecGeoSvc*> (this);
36 } else {
37 return Service::queryInterface(riid, ppvInterface) ;
38 }
39 return StatusCode::SUCCESS;
40}
41*/
43 MsgStream log( msgSvc(), name() );
44 log << MSG::INFO << name() << ": Start of run initialisation" << endmsg;
45
46 StatusCode sc = Service::initialize();
47 if ( sc.isFailure() ) return sc;
48
49 // initialize geometry from gdml
50 if ( fGdml ) { fROOTGeo->InitFromXML(); }
51 return StatusCode::SUCCESS;
52}
53
55 MsgStream log( msgSvc(), name() );
56 log << MSG::INFO << name() << ": End of Run" << endmsg;
57 return StatusCode::SUCCESS;
58}
59
61 if ( fGdml ) { return fROOTGeo->GetCrystal( id ); }
62 else
63 {
64 EmcRecCrystal cry;
65
66 if ( EmcID::is_barrel( id ) ) { cry = fBarrel.GetCrystal( id ); }
67 else { cry = fEndCap.GetCrystal( id ); }
68
69 return cry;
70 }
71}
72
73HepPoint3D EmcRecGeoSvc::GetCrystalPoint( const Identifier& id, const int i ) const {
74 EmcRecCrystal cry;
75 if ( fGdml ) { cry = fROOTGeo->GetCrystal( id ); }
76 else
77 {
78 if ( EmcID::is_barrel( id ) ) { cry = fBarrel.GetCrystal( id ); }
79 else { cry = fEndCap.GetCrystal( id ); }
80 }
81 return cry.Get( i ) / cm;
82}
83
85 if ( fGdml ) { return fROOTGeo->GetCCenter( id ) / cm; }
86 else
87 {
88 HepPoint3D center;
89
90 if ( EmcID::is_barrel( id ) ) { center = fBarrel.GetCCenter( id ); }
91 else { center = fEndCap.GetCCenter( id ); }
92
93 return center / cm;
94 }
95}
96
98 if ( fGdml ) { return fROOTGeo->GetCFrontCenter( id ) / cm; }
99 else
100 {
101 HepPoint3D frontCenter;
102
103 if ( EmcID::is_barrel( id ) ) { frontCenter = fBarrel.GetCFrontCenter( id ); }
104 else { frontCenter = fEndCap.GetCFrontCenter( id ); }
105
106 return frontCenter / cm;
107 }
108}
109
110double EmcRecGeoSvc::GetBarrelR() const { return fBarrel.GetBarrelR() / cm; }
111
112double EmcRecGeoSvc::GetBarrelOffset1() const { return fBarrel.GetBarrelOffset1() / cm; }
113
114double EmcRecGeoSvc::GetBarrelOffset2() const { return fBarrel.GetBarrelOffset2() / cm; }
115
116double EmcRecGeoSvc::GetBarrelh1() const { return fBarrel.GetBarrelh1() / cm; }
117
118double EmcRecGeoSvc::GetBarrelh2() const { return fBarrel.GetBarrelh2() / cm; }
119
120double EmcRecGeoSvc::GetBarrelh3() const { return fBarrel.GetBarrelh3() / cm; }
121
122double EmcRecGeoSvc::GetBarrelL() const { return fBarrel.GetBarrelL() / cm; }
123
124int EmcRecGeoSvc::GetBarrelNPhiMax() const { return fBarrel.GetBarrelNPhiMax(); }
125
126int EmcRecGeoSvc::GetBarrelNThetaMax() const { return fBarrel.GetBarrelNThetaMax(); }
DECLARE_COMPONENT(BesBdkRc)
HepGeom::Point3D< double > HepPoint3D
IMessageSvc * msgSvc()
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition EmcID.cxx:30
virtual double GetBarrelL() const
virtual HepPoint3D GetCrystalPoint(const Identifier &id, const int i) const
virtual int GetBarrelNPhiMax() const
virtual double GetBarrelR() const
virtual HepPoint3D GetCFrontCenter(const Identifier &id) const
EmcRecGeoSvc(const std::string &name, ISvcLocator *svcloc)
virtual EmcRecCrystal GetCrystal(const Identifier &id) const
virtual StatusCode initialize()
virtual StatusCode finalize()
virtual double GetBarrelh2() const
virtual double GetBarrelOffset1() const
virtual HepPoint3D GetCCenter(const Identifier &id) const
virtual double GetBarrelOffset2() const
virtual int GetBarrelNThetaMax() const
virtual double GetBarrelh1() const
virtual double GetBarrelh3() const