2#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/SmartDataPtr.h"
7#include "Identifier/Identifier.h"
8#include "Identifier/EmcID.h"
9#include "RawEvent/RawDataUtil.h"
10#include "EmcRawEvent/EmcDigi.h"
13#include "GaudiKernel/ThreadGaudi.h"
16#include "RawDataProviderSvc/EmcRawDataProvider.h"
20 m_adcLowThreshold(0), m_tLowThreshold(0), m_tHighThreshold(60),
21 m_hotCrystals(0), m_deadCrystals(0),
28 m_adcLowThreshold(elow), m_tLowThreshold(tlow), m_tHighThreshold(thigh),
29 m_hotCrystals(0), m_deadCrystals(0),
35 uint32_t elow, uint32_t tlow, uint32_t thigh):
37 m_adcLowThreshold(elow), m_tLowThreshold(tlow), m_tHighThreshold(thigh),
38 m_hotCrystals(hot), m_deadCrystals(dead),
45 log << MSG::DEBUG <<
"inc.type=" << inc.type() << endreq;
46 if ( inc.type() ==
"BeginEvent" ){
58 if(log.level()<=MSG::INFO){
59 std::cout <<
"EmcRawDataProvider:: " <<
"elow=" << m_adcLowThreshold <<
", tlow=" << m_tLowThreshold
60 <<
", thigh=" << m_tHighThreshold << std::endl;
61 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
62 std::cout <<
" hot crystals ";
63 for(;it!=m_hotCrystals.end();it++){
64 std::cout << *it <<
" ";
66 std::cout << std::endl <<
" dead crystals ";
67 for(it=m_deadCrystals.begin();it!=m_deadCrystals.end();it++){
68 std::cout << *it <<
" ";
70 std::cout << std::endl;
74 StatusCode sc =
m_svcLocator->service(
"EmcCalibConstSvc", m_emcCalibConstSvc);
75 if(sc != StatusCode::SUCCESS) {
76 log << MSG::ERROR <<
"Can't get EmcCalibConstSvc." << endreq;
81 return StatusCode::SUCCESS;
85 uint32_t adc, uint32_t tdc){
87 if(measure==0&&adc<m_adcLowThreshold)
return false;
90 if(measure==3)
return false;
93 if(tdc<m_tLowThreshold||tdc>m_tHighThreshold)
return false;
96 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
97 for(;it!=m_hotCrystals.end();it++){
98 if((*it)==
id)
return false;
102 std::vector<uint32_t>::iterator it=m_deadCrystals.begin();
103 for(;it!=m_deadCrystals.end();it++){
104 if((*it)==
id)
return false;
115 return isGoodEmcDigi(control,
id.get_value(),measure,adc,tdc);
123 int index = m_emcCalibConstSvc->
getIndex(part,itheta,iphi);
142 log << MSG::INFO <<
"EmcRawDataProvider::getEmcDigiVec..." << endreq;
143 log << MSG::DEBUG <<
"vector size=" << m_emcDigiVec.size() << endreq;
145 if(m_emcDigiVec.size()>0){
147 else return m_emcDigiVec;
151 std::string evtDataSvc_name(
"EventDataSvc");
152 if(isGaudiThreaded(
m_name)){
153 evtDataSvc_name += getGaudiThreadIDfromName(
m_name);
156 IDataProviderSvc* evtSvc;
157 StatusCode sc =
m_svcLocator->service(evtDataSvc_name.c_str(),evtSvc,
true);
158 if (!sc.isSuccess()){
159 log << MSG::FATAL <<
"EmcRawDataProvider: ERROR Could not load EventDataSvc" << endreq;
162 SmartDataPtr<EmcDigiCol> emcDigiCol(evtSvc,
"/Event/Digi/EmcDigiCol");
164 log << MSG::FATAL <<
"Could not find Emc digi!!" << endreq;
167 log << MSG::DEBUG <<
"start dealing with EmcRawCol " << emcDigiCol->size() << endreq;
168 EmcDigiCol::iterator iterEMC=emcDigiCol->begin();
169 for(;iterEMC!= emcDigiCol->end();iterEMC++) {
170 log << MSG::NIL <<
"vector size=" << m_emcDigiVec.size() << endreq;
171 if(
isGoodEmcDigi(control,*iterEMC)) m_emcDigiVec.insert(m_emcDigiVec.end(),*iterEMC);
173 if(m_emcCalibConstSvc!=0)
doCalib(*iterEMC);
175 log << MSG::WARNING <<
"require EMC calibration, but none service, ignore." << endreq;
180 log << MSG::VERBOSE <<
"ready for return" << endreq;
185 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
186 for(;it!=m_hotCrystals.end();it++){
188 m_hotCrystals.erase(it);
192 if(it==m_hotCrystals.end())
return false;
198 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
199 for(;it!=m_deadCrystals.end();it++){
201 m_deadCrystals.erase(it);
205 if(it==m_deadCrystals.end())
return false;
211 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
212 for(;it!=m_hotCrystals.end();it++){
213 if((*it)==teid)
break;
215 if(it==m_hotCrystals.end()) m_hotCrystals.push_back(teid);
221 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
222 for(;it!=m_deadCrystals.end();it++){
223 if((*it)==teid)
break;
225 if(it==m_deadCrystals.end()) m_deadCrystals.push_back(teid);
ObjectVector< EmcDigi > EmcDigiCol
unsigned int getMeasure() const
void setMeasure(const unsigned int measure)
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
static unsigned int theta_module(const Identifier &id)
static unsigned int phi_module(const Identifier &id)
bool removeDeadCrystal(const uint32_t id)
bool isGoodEmcDigi(uint32_t control, uint32_t id, uint32_t measure, uint32_t adc, uint32_t tdc)
bool removeHotCrystal(const uint32_t id)
void doCalib(Identifier &id, uint32_t &measure, uint32_t &adc)
EmcDigiCol & getEmcDigiVec(uint32_t control)
void addDeadCrystal(const uint32_t id)
void addHotCrystal(const uint32_t id)
void handle(const Incident &)
virtual StatusCode initialize(bool mode=0, ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
virtual double getDigiCalibConst(int No) const =0
virtual int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const =0
ISvcLocator * m_svcLocator
StatusCode initialize(ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
static int EmcChargeChannel(double charge)
static int EmcChargeMeasure(double charge)
static double EmcCharge(int measure, int chargeChannel)
virtual Identifier identify() const
void setChargeChannel(const unsigned int chargeChannel)
unsigned int getChargeChannel() const
unsigned int getTimeChannel() const