BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcCalibConstSvc.cxx
Go to the documentation of this file.
1#include "EmcCalibConstSvc/EmcCalibConstSvc.h"
2#include "GaudiKernel/Kernel.h"
3#include "GaudiKernel/IInterface.h"
4#include "GaudiKernel/StatusCode.h"
5#include "GaudiKernel/SvcFactory.h"
6#include "GaudiKernel/MsgStream.h"
7
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/Bootstrap.h"
10
11#include "GaudiKernel/IDataProviderSvc.h"
12#include "GaudiKernel/SmartDataPtr.h"
13#include "GaudiKernel/DataSvc.h"
14
15#include "EmcGeneralClass/EmcStructure.h"
16#include "CalibData/CalibModel.h"
17#include "CalibData/Emc/EmcCalibData.h"
18
19#include <vector>
20#include <math.h>
21#include <fstream>
22
23
24EmcCalibConstSvc::EmcCalibConstSvc( const std::string& name, ISvcLocator* svcloc) :
25 Service (name, svcloc) {
26
27
28 for(int i=0;i<6240;i++){
30 }
31
32
33 string paraPath = getenv("EMCCALIBCONSTSVCROOT");
34 paraPath += "/share/emax_data.dat";
35
36 ifstream in;
37 in.open(paraPath.c_str());
38 assert(in);
39 int ixtal;
40 double emaxData;
41 int Nixt=0;
42 while (in.peek() != EOF)
43 {
44
45 in >> ixtal>>emaxData;
46
47 m_CrystalEmaxData[ixtal]=emaxData;
48 Nixt++;
49 }
50
51 in.close();
52
53
54}
55
57
58}
59
60StatusCode EmcCalibConstSvc::queryInterface(const InterfaceID& riid, void** ppvInterface){
61 if( IID_IEmcCalibConstSvc.versionMatch(riid) ){
62 *ppvInterface = static_cast<IEmcCalibConstSvc*> (this);
63 } else{
64 return Service::queryInterface(riid, ppvInterface);
65 }
66 return StatusCode::SUCCESS;
67}
68
70 MsgStream log(messageService(), name());
71 log << MSG::INFO << "EmcCalibConstSvc::initialize()" << endreq;
72
73 StatusCode sc = Service::initialize();
74 if( sc.isFailure() ) return sc;
75
76 sc = service("CalibDataSvc", m_calDataSvc, true);
77 if( sc == StatusCode::SUCCESS ){
78 log << MSG::INFO << "Retrieve IDataProviderSvc" << endreq;
79 }else{
80 log << MSG::FATAL << "can not get IDataProviderSvc" << endreq;
81 }
82
83 // sc = service("EmcRecGeoSvc", m_emcGeomSvc);
84 // if( sc != StatusCode::SUCCESS ){
85 // log << MSG::ERROR << "can not use EmcRecGeoSvc" << endreq;
86 // }
87
90
91 // Dump();
92
93 return StatusCode::SUCCESS;
94}
95
97
98 delete m_theEmcStruc;
99
100 MsgStream log(messageService(), name());
101 log << MSG::INFO << "EmcCalibConstSvc::finalize()" << endreq;
102 return StatusCode::SUCCESS;
103
104}
105
107 {
108 double digiCalibConst = 0.0;
109 MsgStream log(messageService(), name());
110
111 std::string fullPath = "/Calib/EmcCal";
112 SmartDataPtr<CalibData::EmcCalibData> calConst(m_calDataSvc, fullPath);
113 if( ! calConst ){
114 log << MSG::ERROR << "can not access to EmcDigi CalibData via SmartPtr"
115 << endreq;
116 }else {
117 digiCalibConst = calConst->getDigiCalibConst(No);
118 }
119
120 return digiCalibConst;
121}
122
124 {
125 int IxtalNumber = 999999;
126 MsgStream log(messageService(), name());
127
128 std::string fullPath = "/Calib/EmcCal";
129 SmartDataPtr<CalibData::EmcCalibData> calConst(m_calDataSvc, fullPath);
130 if( ! calConst ){
131 log << MSG::ERROR << "can not access to EmcDigi CalibData via SmartPtr"
132 << endreq;
133 }else {
134 IxtalNumber = calConst->getIxtalNumber(No);
135 }
136
137 return IxtalNumber;
138}
139
141 {
142 int digiCalibConstNo = 0;
143 MsgStream log(messageService(), name());
144
145 std::string fullPath = "/Calib/EmcCal";
146 SmartDataPtr<CalibData::EmcCalibData> calConst(m_calDataSvc, fullPath);
147 if( ! calConst ){
148 log << MSG::ERROR << "can not access to EmcDigiNo CalibData via SmartPtr"
149 << endreq;
150 }else {
151 digiCalibConstNo = calConst->getDigiCalibConstNo();
152 }
153
154 return digiCalibConstNo;
155}
156
158 {
159 int IxtalNumberNo = 0;
160 MsgStream log(messageService(), name());
161
162 std::string fullPath = "/Calib/EmcCal";
163 SmartDataPtr<CalibData::EmcCalibData> calConst(m_calDataSvc, fullPath);
164 if( ! calConst ){
165 log << MSG::ERROR << "can not access to EmcDigiNo CalibData via SmartPtr"
166 << endreq;
167 }else {
168 IxtalNumberNo = calConst->getIxtalNumberNo();
169 }
170
171 return IxtalNumberNo;
172}
173
174
175
176int EmcCalibConstSvc::getIndex( unsigned int PartId,
177 unsigned int ThetaIndex,
178 unsigned int PhiIndex) const
179{
180 return m_theEmcStruc->getGeomIndex(PartId, ThetaIndex, PhiIndex);
181}
182
183
184unsigned int EmcCalibConstSvc::getPartID(int Index) const
185{
186 return m_theEmcStruc->getPartId(Index);
187}
188
189unsigned int EmcCalibConstSvc::getThetaIndex( int Index) const
190{
191 return m_theEmcStruc->getTheta(Index);
192}
193
194unsigned int EmcCalibConstSvc::getPhiIndex( int Index) const
195{
196 return m_theEmcStruc->getPhi(Index);
197}
198
199
200
202{
203 return m_CrystalEmaxData[Index];
204}
205
206
207
209{
210 /*
211 for(int iNo=0;iNo<6;iNo++){
212 cout<<"getDigiCalibConst "<<getDigiCalibConst(iNo)<<endl;
213 }
214
215 cout<<"getDigiCalibConstNo "<<getDigiCalibConstNo()<<endl;
216
217
218 cout<<"ind"<<" "<<"getThetaIndex(ind)"<<" "
219 <<"getPhiIndex(ind)"<<"getPartID"<<endl;
220
221 for(int ind=0; ind<6240;ind++){
222
223 cout<<ind<<" "<<getThetaIndex(ind)<<" "
224 <<getPhiIndex(ind)<<" "<<getPartID(ind)<<endl;
225
226 }
227
228 cout<<"getIndex(0,5,95)="<<getIndex(0,5,95)<<endl;
229 cout<<"getIndex(1,43,119)="<<getIndex(1,43,119)<<endl;
230 cout<<"getIndex(2,5,95)="<<getIndex(2,5,95)<<endl;
231 cout<<"getIndex(0,5,96)="<<getIndex(0,5,96)<<endl;
232 cout<<"getIndex(1,43,120)="<<getIndex(1,43,120)<<endl;
233 cout<<"getIndex(2,5,96)="<<getIndex(2,5,96)<<endl;
234
235 for(int i=0;i<6240;i++){
236 cout<<i<<"\t"<<getCrystalEmaxData(i) <<endl;
237 }
238 */
239
240}
EmcCalibConstSvc(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode finalize()
int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const
virtual StatusCode initialize()
int getIxtalNumberNo() const
unsigned int getPartID(int Index) const
int getDigiCalibConstNo() const
int getIxtalNumber(int No) const
double getCrystalEmaxData(int Index) const
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
unsigned int getPhiIndex(int Index) const
unsigned int getThetaIndex(int Index) const
double getDigiCalibConst(int No) const
int getGeomIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const
void setEmcStruc()