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"
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/Bootstrap.h"
11#include "GaudiKernel/IDataProviderSvc.h"
12#include "GaudiKernel/SmartDataPtr.h"
13#include "GaudiKernel/DataSvc.h"
14#include "GaudiKernel/PropertyMgr.h"
23#include "GaudiKernel/IIncidentSvc.h"
24#include "GaudiKernel/Incident.h"
25#include "GaudiKernel/IIncidentListener.h"
36 base_class (name, svcloc) {
40 m_EmaxVersion4740=
false;
41 m_EmaxVersion4750=
false;
42 m_EmaxVersion4780=
false;
43 m_EmaxVersion4840=
false;
44 m_EmaxVersion4914=
false;
45 m_EmaxVersion4946=
false;
49 m_DeadEcutVersion2020=
false;
51 for(
int i=0;i<6240;i++){
52 m_CrystalEmaxData[i]=0;
53 m_CrystalEmaxData_1[i]=0;
54 m_CrystalEmaxData_2[i]=0;
55 m_CrystalEmaxData_4740[i]=0;
56 m_CrystalEmaxData_4750[i]=0;
57 m_CrystalEmaxData_4780[i]=0;
58 m_CrystalEmaxData_4840[i]=0;
59 m_CrystalEmaxData_4914[i]=0;
60 m_CrystalEmaxData_4946[i]=0;
62 m_CrystalDeadEcut[i]=-1;
63 m_CrystalDeadEcut_2020[i]=-1;
71 string paraPath = getenv(
"EMCCALIBCONSTSVCROOT");
72 paraPath +=
"/share/emax_data.dat";
74 in.open(paraPath.c_str());
77 while (in.peek() != EOF)
80 in >> ixtal>>emaxData;
82 m_CrystalEmaxData_1[ixtal]=emaxData;
91 string paraPath2 = getenv(
"EMCCALIBCONSTSVCROOT");
92 paraPath2 +=
"/share/emax_data_2.dat";
95 in2.open(paraPath2.c_str());
99 while (in2.peek() != EOF)
102 in2 >> ixtal>>emaxData;
104 m_CrystalEmaxData_2[ixtal]=emaxData;
114 string paraPath4740 = getenv(
"EMCCALIBCONSTSVCROOT");
115 paraPath4740 +=
"/share/emax_data_4740.dat";
118 in4740.open(paraPath4740.c_str());
122 while (in4740.peek() != EOF)
125 in4740 >> ixtal>>emaxData;
127 m_CrystalEmaxData_4740[ixtal]=emaxData;
137 string paraPath4750 = getenv(
"EMCCALIBCONSTSVCROOT");
138 paraPath4750 +=
"/share/emax_data_4750.dat";
141 in4750.open(paraPath4750.c_str());
145 while (in4750.peek() != EOF)
148 in4750 >> ixtal>>emaxData;
150 m_CrystalEmaxData_4750[ixtal]=emaxData;
160 string paraPath4780 = getenv(
"EMCCALIBCONSTSVCROOT");
161 paraPath4780 +=
"/share/emax_data_4780.dat";
164 in4780.open(paraPath4780.c_str());
168 while (in4780.peek() != EOF)
171 in4780 >> ixtal>>emaxData;
173 m_CrystalEmaxData_4780[ixtal]=emaxData;
183 string paraPath4840 = getenv(
"EMCCALIBCONSTSVCROOT");
184 paraPath4840 +=
"/share/emax_data_4840.dat";
187 in4840.open(paraPath4840.c_str());
191 while (in4840.peek() != EOF)
194 in4840 >> ixtal>>emaxData;
196 m_CrystalEmaxData_4840[ixtal]=emaxData;
207 string paraPath4914 = getenv(
"EMCCALIBCONSTSVCROOT");
208 paraPath4914 +=
"/share/emax_data_4914.dat";
211 in4914.open(paraPath4914.c_str());
215 while (in4914.peek() != EOF)
218 in4914 >> ixtal>>emaxData;
220 m_CrystalEmaxData_4914[ixtal]=emaxData;
230 string paraPath4946 = getenv(
"EMCCALIBCONSTSVCROOT");
231 paraPath4946 +=
"/share/emax_data_4946.dat";
234 in4946.open(paraPath4946.c_str());
238 while (in4946.peek() != EOF)
241 in4946 >> ixtal>>emaxData;
243 m_CrystalEmaxData_4946[ixtal]=emaxData;
254 string paraPath3 = getenv(
"EMCCALIBCONSTSVCROOT");
255 paraPath3 +=
"/share/DeadThresholdEcut_2020.conf";
258 in3.open(paraPath3.c_str());
263 double DeltaEcut=0.0;
265 while (in3.peek() != EOF)
268 in3 >> ixtal>>satuEn>>Ecut;
269 if ((Ecut-satuEn)>DeltaEcut) {
270 m_CrystalDeadEcut_2020[ixtal]=Ecut-DeltaEcut;
272 m_CrystalDeadEcut_2020[ixtal]=Ecut;
296 MsgStream log(messageService(), name());
297 log << MSG::INFO <<
"EmcCalibConstSvc::initialize()" << endreq;
299 StatusCode sc = Service::initialize();
300 if( sc.isFailure() )
return sc;
303 IIncidentSvc* incsvc;
304 sc = service(
"IncidentSvc", incsvc);
306 if( sc.isSuccess() ){
307 incsvc -> addListener(
this,
"NewRun", priority);
310 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
311 if (sc .isFailure() ) {
312 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
317 if( sc == StatusCode::SUCCESS ){
318 log << MSG::INFO <<
"Retrieve IDataProviderSvc" << endreq;
320 log << MSG::FATAL <<
"can not get IDataProviderSvc" << endreq;
333 return StatusCode::SUCCESS;
340 MsgStream log(messageService(), name());
341 log << MSG::INFO <<
"EmcCalibConstSvc::finalize()" << endreq;
342 return StatusCode::SUCCESS;
347 MsgStream log( messageService(), name() );
348 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
352 if ( inc.type() ==
"NewRun" ){
353 log << MSG::DEBUG <<
"NewRun" << endreq;
356 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
357 int run = eventHeader->runNumber();
359 if (run<0) run = -run;
362 log << MSG::DEBUG <<
"handle: " <<
"Run in handle is: "<<run<< endreq;
364 cout<<
"handle: " <<
"Run in handle is: "<<run<<endl;
377 cout<<
"handle: " <<
"EmaxVersion="<<
"111111111111111"<<endl;
392 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from topup data 4680@2020"<<endl;
408 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4740data@2021"<<endl;
423 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4750data@2021"<<endl;
438 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4780data@2021"<<endl;
454 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4840data@2021"<<endl;
469 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4914data@2021"<<endl;
484 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4946data@2021"<<endl;
491 cout<<
"handle: " <<
"DeadEcutVersion="<<
"2020"<<endl;
508 double digiCalibConst = 0.0;
509 MsgStream log(messageService(), name());
511 std::string fullPath =
"/Calib/EmcCal";
512 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
514 log << MSG::ERROR <<
"can not access to EmcDigi CalibData via SmartPtr"
517 digiCalibConst = calConst->getDigiCalibConst(No);
520 return digiCalibConst;
525 int IxtalNumber = 999999;
526 MsgStream log(messageService(), name());
528 std::string fullPath =
"/Calib/EmcCal";
529 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
531 log << MSG::ERROR <<
"can not access to EmcDigi CalibData via SmartPtr"
534 IxtalNumber = calConst->getIxtalNumber(No);
542 int digiCalibConstNo = 0;
543 MsgStream log(messageService(), name());
545 std::string fullPath =
"/Calib/EmcCal";
546 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
548 log << MSG::ERROR <<
"can not access to EmcDigiNo CalibData via SmartPtr"
551 digiCalibConstNo = calConst->getDigiCalibConstNo();
554 return digiCalibConstNo;
559 int IxtalNumberNo = 0;
560 MsgStream log(messageService(), name());
562 std::string fullPath =
"/Calib/EmcCal";
563 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
565 log << MSG::ERROR <<
"can not access to EmcDigiNo CalibData via SmartPtr"
568 IxtalNumberNo = calConst->getIxtalNumberNo();
571 return IxtalNumberNo;
577 unsigned int ThetaIndex,
578 unsigned int PhiIndex)
const
639 for(
int i=0;i<6240;i++){
double m_CrystalEmaxData_4740[6240]
double m_CrystalDeadEcut_2020[6240]
void handle(const Incident &)
double m_CrystalEmaxData_2[6240]
virtual StatusCode finalize()
double m_CrystalEmaxData[6240]
void setCrystalDeadEcut(double CrystalDeadEcut[6240])
bool m_DeadEcutVersion2020
double m_CrystalEmaxData_4946[6240]
int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const
virtual StatusCode initialize()
double m_CrystalEmaxData_1[6240]
int getIxtalNumberNo() const
unsigned int getPartID(int Index) const
double m_CrystalDeadEcut[6240]
void setCrystalEmaxData(double CrystalEmaxData[6240])
int getDigiCalibConstNo() const
double m_CrystalEmaxData_4840[6240]
double m_CrystalEmaxData_4750[6240]
int getIxtalNumber(int No) const
double getCrystalEmaxData(int Index) const
EmcStructure * m_theEmcStruc
unsigned int getPhiIndex(int Index) const
IDataProviderSvc * m_calDataSvc
unsigned int getThetaIndex(int Index) const
double m_CrystalEmaxData_4914[6240]
double m_CrystalEmaxData_4780[6240]
double getDigiCalibConst(int No) const
double getCrystalDeadEcut(int Index) const
int getGeomIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const
unsigned int getPartId(long Index) const
unsigned int getPhi(long Index) const
unsigned int getTheta(long Index) const