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) {
37 declareProperty(
"ReadSatuDeadEnDb", m_readSatuDeadEnDb =
true);
39 for(
int i=0;i<6240;i++){
43 if (m_readSatuDeadEnDb==
true){
49 if (m_readSatuDeadEnDb==
false){
61 for(
int i=0;i<6240;i++){
80 string paraPath = getenv(
"EMCCALIBCONSTSVCROOT");
81 paraPath +=
"/share/emax_data.dat";
83 in.open(paraPath.c_str());
86 while (in.peek() != EOF)
89 in >> ixtal>>emaxData;
100 string paraPath2 = getenv(
"EMCCALIBCONSTSVCROOT");
101 paraPath2 +=
"/share/emax_data_2.dat";
104 in2.open(paraPath2.c_str());
108 while (in2.peek() != EOF)
111 in2 >> ixtal>>emaxData;
123 string paraPath4740 = getenv(
"EMCCALIBCONSTSVCROOT");
124 paraPath4740 +=
"/share/emax_data_4740.dat";
127 in4740.open(paraPath4740.c_str());
131 while (in4740.peek() != EOF)
134 in4740 >> ixtal>>emaxData;
146 string paraPath4750 = getenv(
"EMCCALIBCONSTSVCROOT");
147 paraPath4750 +=
"/share/emax_data_4750.dat";
150 in4750.open(paraPath4750.c_str());
154 while (in4750.peek() != EOF)
157 in4750 >> ixtal>>emaxData;
169 string paraPath4780 = getenv(
"EMCCALIBCONSTSVCROOT");
170 paraPath4780 +=
"/share/emax_data_4780.dat";
173 in4780.open(paraPath4780.c_str());
177 while (in4780.peek() != EOF)
180 in4780 >> ixtal>>emaxData;
192 string paraPath4840 = getenv(
"EMCCALIBCONSTSVCROOT");
193 paraPath4840 +=
"/share/emax_data_4840.dat";
196 in4840.open(paraPath4840.c_str());
200 while (in4840.peek() != EOF)
203 in4840 >> ixtal>>emaxData;
216 string paraPath4914 = getenv(
"EMCCALIBCONSTSVCROOT");
217 paraPath4914 +=
"/share/emax_data_4914.dat";
220 in4914.open(paraPath4914.c_str());
224 while (in4914.peek() != EOF)
227 in4914 >> ixtal>>emaxData;
239 string paraPath4946 = getenv(
"EMCCALIBCONSTSVCROOT");
240 paraPath4946 +=
"/share/emax_data_4946.dat";
243 in4946.open(paraPath4946.c_str());
247 while (in4946.peek() != EOF)
250 in4946 >> ixtal>>emaxData;
263 string paraPath3 = getenv(
"EMCCALIBCONSTSVCROOT");
264 paraPath3 +=
"/share/DeadThresholdEcut_2020.conf";
267 in3.open(paraPath3.c_str());
272 double DeltaEcut=0.0;
274 while (in3.peek() != EOF)
277 in3 >> ixtal>>satuEn>>Ecut;
278 if ((Ecut-satuEn)>DeltaEcut) {
307 MsgStream log(messageService(), name());
308 log << MSG::INFO <<
"EmcCalibConstSvc::initialize()" << endreq;
310 StatusCode sc = Service::initialize();
311 if( sc.isFailure() )
return sc;
314 IIncidentSvc* incsvc;
315 sc = service(
"IncidentSvc", incsvc);
317 if( sc.isSuccess() ){
318 incsvc -> addListener(
this,
"NewRun", priority);
321 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
322 if (sc .isFailure() ) {
323 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
328 if( sc == StatusCode::SUCCESS ){
329 log << MSG::INFO <<
"Retrieve IDataProviderSvc" << endreq;
331 log << MSG::FATAL <<
"can not get IDataProviderSvc" << endreq;
343 ISvcLocator* svcLocator = Gaudi::svcLocator();
344 sc = svcLocator->service(
"EmcSatuDeadEnSvc", m_EmcSatuDeadEnSvc);
347 if( sc == StatusCode::SUCCESS){
349 std::cout<<
"Retrieve EmcSatuDeadEnSvc" << endl;
354 log << MSG::FATAL <<
"can not get EmcSatuDeadEnSvc" << endreq;
362 return StatusCode::SUCCESS;
369 MsgStream log(messageService(), name());
370 log << MSG::INFO <<
"EmcCalibConstSvc::finalize()" << endreq;
371 return StatusCode::SUCCESS;
376 MsgStream log( messageService(), name() );
377 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
379 if ( inc.type() ==
"NewRun" ){
380 log << MSG::DEBUG <<
"NewRun" << endreq;
382 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
383 int run = eventHeader->runNumber();
385 log << MSG::DEBUG <<
"handle: " <<
"Run in handle is: "<<run<< endreq;
387 if (m_readSatuDeadEnDb==
true&&run<0){
388 if (run<0) run = -run;
390 if (run>=m_runFrom&&run<=m_runTo) {
395 if (m_inFlag==
false){
397 getSatuDead=m_EmcSatuDeadEnSvc ->getEmcSatuDeadEnSvcInfo();
399 log << MSG::ERROR <<
"can not get EmcSatuDeadEnSvc" << endreq;
401 m_runFrom=m_EmcSatuDeadEnSvc -> getRunFrom();
402 m_runTo=m_EmcSatuDeadEnSvc -> getRunTo();
404 cout <<
"current run=" << run<<endl;
405 cout <<
"RunFrom="<< m_runFrom<<
",RunTo="<< m_runTo<<endl;
406 cout <<
"in EmcCalibConstSvc open getSatuEnFile()= " << m_EmcSatuDeadEnSvc -> getSatuEnFile()<<endl;
407 cout <<
"open getDeadEnFile()= " << m_EmcSatuDeadEnSvc -> getDeadEnFile()<<endl;
408 string aEmcSatuEnFile;
409 string aEmcDeadEnFile;
410 aEmcSatuEnFile= m_EmcSatuDeadEnSvc -> getSatuEnFile();
411 aEmcDeadEnFile= m_EmcSatuDeadEnSvc -> getDeadEnFile();
414 inSatuEn.open(aEmcSatuEnFile.c_str());
417 if (inSatuEn.is_open()){
421 while (inSatuEn.peek() != EOF)
423 inSatuEn >> ixtal>>emaxData;
429 std::cout <<
"EmcCalibConstSvc ERROR::Could not open the file of " <<aEmcSatuEnFile<< endl;
435 inDeadEn.open(aEmcDeadEnFile.c_str());
437 if (inDeadEn.is_open()){
440 double satuEn,deadEn;
441 while (inDeadEn.peek() != EOF)
443 inDeadEn >> ixtal>>satuEn>>deadEn;
450 std::cout <<
"EmcCalibConstSvc ERROR::Could not open the file of " <<aEmcDeadEnFile<< endl;
463 if (m_readSatuDeadEnDb==
false&&run<0){
466 if (run<0) run = -run;
469 log << MSG::DEBUG <<
"handle: " <<
"Run in handle is: "<<run<< endreq;
471 cout<<
"handle: " <<
"Run in handle is: "<<run<<endl;
486 cout<<
"handle: " <<
"EmaxVersion="<<
"111111111111111"<<endl;
501 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from topup data 4680@2020"<<endl;
517 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4740data@2021"<<endl;
532 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4750data@2021"<<endl;
547 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4780data@2021"<<endl;
563 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4840data@2021"<<endl;
578 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4914data@2021"<<endl;
593 cout<<
"handle: " <<
"EmaxVersion="<<
"emax data from 4946data@2021"<<endl;
599 cout<<
"handle: " <<
"DeadEcutVersion="<<
"2020"<<endl;
619 double digiCalibConst = 0.0;
620 MsgStream log(messageService(), name());
622 std::string fullPath =
"/Calib/EmcCal";
623 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
625 log << MSG::ERROR <<
"can not access to EmcDigi CalibData via SmartPtr"
628 digiCalibConst = calConst->getDigiCalibConst(No);
631 return digiCalibConst;
636 int IxtalNumber = 999999;
637 MsgStream log(messageService(), name());
639 std::string fullPath =
"/Calib/EmcCal";
640 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
642 log << MSG::ERROR <<
"can not access to EmcDigi CalibData via SmartPtr"
645 IxtalNumber = calConst->getIxtalNumber(No);
653 int digiCalibConstNo = 0;
654 MsgStream log(messageService(), name());
656 std::string fullPath =
"/Calib/EmcCal";
657 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
659 log << MSG::ERROR <<
"can not access to EmcDigiNo CalibData via SmartPtr"
662 digiCalibConstNo = calConst->getDigiCalibConstNo();
665 return digiCalibConstNo;
670 int IxtalNumberNo = 0;
671 MsgStream log(messageService(), name());
673 std::string fullPath =
"/Calib/EmcCal";
674 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
676 log << MSG::ERROR <<
"can not access to EmcDigiNo CalibData via SmartPtr"
679 IxtalNumberNo = calConst->getIxtalNumberNo();
682 return IxtalNumberNo;
688 unsigned int ThetaIndex,
689 unsigned int PhiIndex)
const
691 return m_theEmcStruc->getGeomIndex(PartId, ThetaIndex, PhiIndex);
720 double CrystalDeadEcut;
722 return CrystalDeadEcut;
729 for(
int iNo=0;iNo<6;iNo++){
753 for(
int i=480;i<600;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
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