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) {
41 for(
int i=0;i<6240;i++){
54 string paraPath = getenv(
"EMCCALIBCONSTSVCROOT");
55 paraPath +=
"/share/emax_data.dat";
57 in.open(paraPath.c_str());
60 while (in.peek() != EOF)
63 in >> ixtal>>emaxData;
74 string paraPath2 = getenv(
"EMCCALIBCONSTSVCROOT");
75 paraPath2 +=
"/share/emax_data_2.dat";
78 in2.open(paraPath2.c_str());
82 while (in2.peek() != EOF)
85 in2 >> ixtal>>emaxData;
96 string paraPath3 = getenv(
"EMCCALIBCONSTSVCROOT");
97 paraPath3 +=
"/share/DeadThresholdEcut_2020.conf";
100 in3.open(paraPath3.c_str());
105 double DeltaEcut=0.0;
107 while (in3.peek() != EOF)
110 in3 >> ixtal>>satuEn>>Ecut;
111 if ((Ecut-satuEn)>DeltaEcut) {
129 if( IID_IEmcCalibConstSvc.versionMatch(riid) ){
132 return Service::queryInterface(riid, ppvInterface);
134 return StatusCode::SUCCESS;
138 MsgStream log(messageService(), name());
139 log << MSG::INFO <<
"EmcCalibConstSvc::initialize()" << endreq;
141 StatusCode sc = Service::initialize();
142 if( sc.isFailure() )
return sc;
145 IIncidentSvc* incsvc;
146 sc = service(
"IncidentSvc", incsvc);
148 if( sc.isSuccess() ){
149 incsvc -> addListener(
this,
"NewRun", priority);
152 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
153 if (sc .isFailure() ) {
154 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
159 if( sc == StatusCode::SUCCESS ){
160 log << MSG::INFO <<
"Retrieve IDataProviderSvc" << endreq;
162 log << MSG::FATAL <<
"can not get IDataProviderSvc" << endreq;
175 return StatusCode::SUCCESS;
182 MsgStream log(messageService(), name());
183 log << MSG::INFO <<
"EmcCalibConstSvc::finalize()" << endreq;
184 return StatusCode::SUCCESS;
189 MsgStream log( messageService(), name() );
190 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
194 if ( inc.type() ==
"NewRun" ){
195 log << MSG::DEBUG <<
"NewRun" << endreq;
198 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
199 int run = eventHeader->runNumber();
201 if (run<0) run = -run;
204 log << MSG::DEBUG <<
"handle: " <<
"Run in handle is: "<<run<< endreq;
206 cout<<
"handle: " <<
"Run in handle is: "<<run<<endl;
213 cout<<
"handle: " <<
"EmaxVersion="<<
"111111111111111"<<endl;
221 cout<<
"handle: " <<
"EmaxVersion="<<
"222222222222"<<endl;
227 cout<<
"handle: " <<
"DeadEcutVersion="<<
"2020"<<endl;
244 double digiCalibConst = 0.0;
245 MsgStream log(messageService(), name());
247 std::string fullPath =
"/Calib/EmcCal";
248 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
250 log << MSG::ERROR <<
"can not access to EmcDigi CalibData via SmartPtr"
253 digiCalibConst = calConst->getDigiCalibConst(No);
256 return digiCalibConst;
261 int IxtalNumber = 999999;
262 MsgStream log(messageService(), name());
264 std::string fullPath =
"/Calib/EmcCal";
265 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
267 log << MSG::ERROR <<
"can not access to EmcDigi CalibData via SmartPtr"
270 IxtalNumber = calConst->getIxtalNumber(No);
278 int digiCalibConstNo = 0;
279 MsgStream log(messageService(), name());
281 std::string fullPath =
"/Calib/EmcCal";
282 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
284 log << MSG::ERROR <<
"can not access to EmcDigiNo CalibData via SmartPtr"
287 digiCalibConstNo = calConst->getDigiCalibConstNo();
290 return digiCalibConstNo;
295 int IxtalNumberNo = 0;
296 MsgStream log(messageService(), name());
298 std::string fullPath =
"/Calib/EmcCal";
299 SmartDataPtr<CalibData::EmcCalibData> calConst(
m_calDataSvc, fullPath);
301 log << MSG::ERROR <<
"can not access to EmcDigiNo CalibData via SmartPtr"
304 IxtalNumberNo = calConst->getIxtalNumberNo();
307 return IxtalNumberNo;
313 unsigned int ThetaIndex,
314 unsigned int PhiIndex)
const
375 for(
int i=0;i<6240;i++){
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
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
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 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