2#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/SmartDataPtr.h"
13#include "GaudiKernel/ThreadGaudi.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" ){
59 if(log.level()<=MSG::INFO){
60 std::cout <<
"EmcRawDataProvider:: " <<
"elow=" << m_adcLowThreshold <<
", tlow=" << m_tLowThreshold
61 <<
", thigh=" << m_tHighThreshold << std::endl;
62 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
63 std::cout <<
" hot crystals ";
64 for(;it!=m_hotCrystals.end();it++){
65 std::cout << *it <<
" ";
67 std::cout << std::endl <<
" dead crystals ";
68 for(it=m_deadCrystals.begin();it!=m_deadCrystals.end();it++){
69 std::cout << *it <<
" ";
71 std::cout << std::endl;
75 StatusCode sc =
m_svcLocator->service(
"EmcCalibConstSvc", m_emcCalibConstSvc);
76 if(sc != StatusCode::SUCCESS) {
77 log << MSG::ERROR <<
"Can't get EmcCalibConstSvc." << endreq;
82 return StatusCode::SUCCESS;
86 uint32_t adc, uint32_t tdc){
88 if(measure==0&&adc<m_adcLowThreshold)
return false;
91 if(measure==3)
return false;
94 if(tdc<m_tLowThreshold||tdc>m_tHighThreshold)
return false;
97 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
98 for(;it!=m_hotCrystals.end();it++){
99 if((*it)==
id)
return false;
103 std::vector<uint32_t>::iterator it=m_deadCrystals.begin();
104 for(;it!=m_deadCrystals.end();it++){
105 if((*it)==
id)
return false;
116 return isGoodEmcDigi(control,
id.get_value(),measure,adc,tdc);
124 int index = m_emcCalibConstSvc->
getIndex(part,itheta,iphi);
143 log << MSG::INFO <<
"EmcRawDataProvider::getEmcDigiVec..." << endreq;
144 log << MSG::DEBUG <<
"vector size=" << m_emcDigiVec.size() << endreq;
146 if(m_emcDigiVec.size()>0){
147 if(control&
Redo) m_emcDigiVec.clear();
148 else return m_emcDigiVec;
152 std::string evtDataSvc_name(
"EventDataSvc");
153 if(isGaudiThreaded(
m_name)){
154 evtDataSvc_name += getGaudiThreadIDfromName(
m_name);
157 IDataProviderSvc* evtSvc;
158 StatusCode sc =
m_svcLocator->service(evtDataSvc_name.c_str(),evtSvc,
true);
159 if (!sc.isSuccess()){
160 log << MSG::FATAL <<
"EmcRawDataProvider: ERROR Could not load EventDataSvc" << endreq;
163 SmartDataPtr<EmcDigiCol> emcDigiCol(evtSvc,
"/Event/Digi/EmcDigiCol");
165 log << MSG::FATAL <<
"Could not find Emc digi!!" << endreq;
168 log << MSG::DEBUG <<
"start dealing with EmcRawCol " << emcDigiCol->size() << endreq;
169 EmcDigiCol::iterator iterEMC=emcDigiCol->begin();
170 for(;iterEMC!= emcDigiCol->end();iterEMC++) {
171 log << MSG::NIL <<
"vector size=" << m_emcDigiVec.size() << endreq;
172 if(
isGoodEmcDigi(control,*iterEMC)) m_emcDigiVec.insert(m_emcDigiVec.end(),*iterEMC);
174 if(m_emcCalibConstSvc!=0)
doCalib(*iterEMC);
176 log << MSG::WARNING <<
"require EMC calibration, but none service, ignore." << endreq;
181 log << MSG::VERBOSE <<
"ready for return" << endreq;
186 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
187 for(;it!=m_hotCrystals.end();it++){
189 m_hotCrystals.erase(it);
193 if(it==m_hotCrystals.end())
return false;
199 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
200 for(;it!=m_deadCrystals.end();it++){
202 m_deadCrystals.erase(it);
206 if(it==m_deadCrystals.end())
return false;
212 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
213 for(;it!=m_hotCrystals.end();it++){
214 if((*it)==teid)
break;
216 if(it==m_hotCrystals.end()) m_hotCrystals.push_back(teid);
222 std::vector<uint32_t>::iterator it=m_hotCrystals.begin();
223 for(;it!=m_deadCrystals.end();it++){
224 if((*it)==teid)
break;
226 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
StatusCode initialize(ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
ISvcLocator * m_svcLocator
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