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"
35 Service (name, svcloc) {
50 for(
int i=0;i<6240;i++){
70 string paraPath = getenv(
"EMCCALIBCONSTSVCROOT");
71 paraPath +=
"/share/emax_data.dat";
73 in.open(paraPath.c_str());
76 while (in.peek() != EOF)
79 in >> ixtal>>emaxData;
90 string paraPath2 = getenv(
"EMCCALIBCONSTSVCROOT");
91 paraPath2 +=
"/share/emax_data_2.dat";
94 in2.open(paraPath2.c_str());
98 while (in2.peek() != EOF)
101 in2 >> ixtal>>emaxData;
113 string paraPath4740 = getenv(
"EMCCALIBCONSTSVCROOT");
114 paraPath4740 +=
"/share/emax_data_4740.dat";
117 in4740.open(paraPath4740.c_str());
121 while (in4740.peek() != EOF)
124 in4740 >> ixtal>>emaxData;
136 string paraPath4750 = getenv(
"EMCCALIBCONSTSVCROOT");
137 paraPath4750 +=
"/share/emax_data_4750.dat";
140 in4750.open(paraPath4750.c_str());
144 while (in4750.peek() != EOF)
147 in4750 >> ixtal>>emaxData;
159 string paraPath4780 = getenv(
"EMCCALIBCONSTSVCROOT");
160 paraPath4780 +=
"/share/emax_data_4780.dat";
163 in4780.open(paraPath4780.c_str());
167 while (in4780.peek() != EOF)
170 in4780 >> ixtal>>emaxData;
182 string paraPath4840 = getenv(
"EMCCALIBCONSTSVCROOT");
183 paraPath4840 +=
"/share/emax_data_4840.dat";
186 in4840.open(paraPath4840.c_str());
190 while (in4840.peek() != EOF)
193 in4840 >> ixtal>>emaxData;
206 string paraPath4914 = getenv(
"EMCCALIBCONSTSVCROOT");
207 paraPath4914 +=
"/share/emax_data_4914.dat";
210 in4914.open(paraPath4914.c_str());
214 while (in4914.peek() != EOF)
217 in4914 >> ixtal>>emaxData;
229 string paraPath4946 = getenv(
"EMCCALIBCONSTSVCROOT");
230 paraPath4946 +=
"/share/emax_data_4946.dat";
233 in4946.open(paraPath4946.c_str());
237 while (in4946.peek() != EOF)
240 in4946 >> ixtal>>emaxData;
253 string paraPath3 = getenv(
"EMCCALIBCONSTSVCROOT");
254 paraPath3 +=
"/share/DeadThresholdEcut_2020.conf";
257 in3.open(paraPath3.c_str());
262 double DeltaEcut=0.0;
264 while (in3.peek() != EOF)
267 in3 >> ixtal>>satuEn>>Ecut;
268 if ((Ecut-satuEn)>DeltaEcut) {
286 if( IID_IEmcCalibConstSvc.versionMatch(riid) ){
289 return Service::queryInterface(riid, ppvInterface);
291 return StatusCode::SUCCESS;
295 MsgStream log(messageService(), name());
296 log << MSG::INFO <<
"EmcCalibConstSvc::initialize()" << endreq;
298 StatusCode sc = Service::initialize();
299 if( sc.isFailure() )
return sc;
302 IIncidentSvc* incsvc;
303 sc = service(
"IncidentSvc", incsvc);
305 if( sc.isSuccess() ){
306 incsvc -> addListener(
this,
"NewRun", priority);
309 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
310 if (sc .isFailure() ) {
311 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
316 if( sc == StatusCode::SUCCESS ){
317 log << MSG::INFO <<
"Retrieve IDataProviderSvc" << endreq;
319 log << MSG::FATAL <<
"can not get IDataProviderSvc" << endreq;
332 return StatusCode::SUCCESS;
339 MsgStream log(messageService(), name());
340 log << MSG::INFO <<
"EmcCalibConstSvc::finalize()" << endreq;
341 return StatusCode::SUCCESS;
346 MsgStream log( messageService(), name() );
347 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
351 if ( inc.type() ==
"NewRun" ){
352 log << MSG::DEBUG <<
"NewRun" << endreq;
355 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
356 int run = eventHeader->runNumber();
358 if (run<0) run = -run;
361 log << MSG::DEBUG <<
"handle: " <<
"Run in handle is: "<<run<< endreq;
363 cout<<
"handle: " <<
"Run in handle is: "<<run<<endl;
376 cout<<
"handle: " <<
"EmaxVersion="<<
"111111111111111"<<endl;
391 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from topup data 4680@2020"<<endl;
407 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4740data@2021"<<endl;
422 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4750data@2021"<<endl;
437 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4780data@2021"<<endl;
453 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4840data@2021"<<endl;
468 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4914data@2021"<<endl;
483 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4946data@2021"<<endl;
490 cout<<
"handle: " <<
"DeadEcutVersion="<<
"2020"<<endl;
507 double digiCalibConst = 0.0;
508 MsgStream log(messageService(), name());
510 std::string fullPath =
"/Calib/EmcCal";
511 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
513 log << MSG::ERROR <<
"can not access to EmcDigi CalibData via SmartPtr"
516 digiCalibConst = calConst->getDigiCalibConst(No);
519 return digiCalibConst;
524 int IxtalNumber = 999999;
525 MsgStream log(messageService(), name());
527 std::string fullPath =
"/Calib/EmcCal";
528 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
530 log << MSG::ERROR <<
"can not access to EmcDigi CalibData via SmartPtr"
533 IxtalNumber = calConst->getIxtalNumber(No);
541 int digiCalibConstNo = 0;
542 MsgStream log(messageService(), name());
544 std::string fullPath =
"/Calib/EmcCal";
545 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
547 log << MSG::ERROR <<
"can not access to EmcDigiNo CalibData via SmartPtr"
550 digiCalibConstNo = calConst->getDigiCalibConstNo();
553 return digiCalibConstNo;
558 int IxtalNumberNo = 0;
559 MsgStream log(messageService(), name());
561 std::string fullPath =
"/Calib/EmcCal";
562 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
564 log << MSG::ERROR <<
"can not access to EmcDigiNo CalibData via SmartPtr"
567 IxtalNumberNo = calConst->getIxtalNumberNo();
570 return IxtalNumberNo;
576 unsigned int ThetaIndex,
577 unsigned int PhiIndex)
const
638 for(
int i=0;i<6240;i++){
double m_CrystalEmaxData_4740[6240]
EmcCalibConstSvc(const std::string &name, ISvcLocator *svcloc)
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
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
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