2#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/SmartDataPtr.h"
7#include "EmcRawEvent/EmcDigi.h"
8#include "Identifier/EmcID.h"
9#include "Identifier/Identifier.h"
10#include "RawEvent/RawDataUtil.h"
16#include "RawDataProviderSvc/EmcRawDataProvider.h"
20 , m_adcLowThreshold( 0 )
21 , m_tLowThreshold( 0 )
22 , m_tHighThreshold( 60 )
26 m_emcCalibConstSvc = 0;
32 , m_adcLowThreshold( elow )
33 , m_tLowThreshold( tlow )
34 , m_tHighThreshold( thigh )
38 m_emcCalibConstSvc = 0;
42 std::vector<uint32_t>& dead, uint32_t elow,
43 uint32_t tlow, uint32_t thigh )
45 , m_adcLowThreshold( elow )
46 , m_tLowThreshold( tlow )
47 , m_tHighThreshold( thigh )
48 , m_hotCrystals( hot )
49 , m_deadCrystals( dead )
51 m_emcCalibConstSvc = 0;
56 log << MSG::DEBUG <<
"inc.type=" << inc.type() << endmsg;
57 if ( inc.type() ==
"BeginEvent" )
72 if ( log.level() <= MSG::INFO )
74 std::cout <<
"EmcRawDataProvider:: "
75 <<
"elow=" << m_adcLowThreshold <<
", tlow=" << m_tLowThreshold
76 <<
", thigh=" << m_tHighThreshold << std::endl;
77 std::vector<uint32_t>::iterator it = m_hotCrystals.begin();
78 std::cout <<
" hot crystals ";
79 for ( ; it != m_hotCrystals.end(); it++ ) { std::cout << *it <<
" "; }
80 std::cout << std::endl <<
" dead crystals ";
81 for ( it = m_deadCrystals.begin(); it != m_deadCrystals.end(); it++ )
82 { std::cout << *it <<
" "; }
83 std::cout << std::endl;
87 StatusCode sc =
m_svcLocator->service(
"EmcCalibConstSvc", m_emcCalibConstSvc );
88 if ( sc != StatusCode::SUCCESS )
90 log << MSG::ERROR <<
"Can't get EmcCalibConstSvc." << endmsg;
91 m_emcCalibConstSvc = 0;
93 else if ( mode ) m_emcCalibConstSvc->getDigiCalibConst( 0 );
95 return StatusCode::SUCCESS;
99 uint32_t adc, uint32_t tdc ) {
102 if ( measure == 0 && adc < m_adcLowThreshold )
return false;
106 if ( measure == 3 )
return false;
110 if ( tdc < m_tLowThreshold || tdc > m_tHighThreshold )
return false;
114 std::vector<uint32_t>::iterator it = m_hotCrystals.begin();
115 for ( ; it != m_hotCrystals.end(); it++ )
117 if ( ( *it ) ==
id )
return false;
122 std::vector<uint32_t>::iterator it = m_deadCrystals.begin();
123 for ( ; it != m_deadCrystals.end(); it++ )
125 if ( ( *it ) ==
id )
return false;
136 return isGoodEmcDigi( control,
id.get_value(), measure, adc, tdc );
144 int index = m_emcCalibConstSvc->getIndex( part, itheta, iphi );
145 double adc2e = m_emcCalibConstSvc->getDigiCalibConst( index );
163 log << MSG::INFO <<
"EmcRawDataProvider::getEmcDigiVec..." << endmsg;
164 log << MSG::DEBUG <<
"vector size=" << m_emcDigiVec.size() << endmsg;
166 if ( m_emcDigiVec.size() > 0 )
168 if ( control &
Redo ) m_emcDigiVec.clear();
169 else return m_emcDigiVec;
185 IDataProviderSvc* evtSvc=0;
186 SmartDataPtr<EmcDigiCol> emcDigiCol( evtSvc,
"/Event/Digi/EmcDigiCol" );
189 log << MSG::FATAL <<
"Could not find Emc digi!!" << endmsg;
192 log << MSG::DEBUG <<
"start dealing with EmcRawCol " << emcDigiCol->size() << endmsg;
193 EmcDigiCol::iterator iterEMC = emcDigiCol->begin();
194 for ( ; iterEMC != emcDigiCol->end(); iterEMC++ )
196 log << MSG::NIL <<
"vector size=" << m_emcDigiVec.size() << endmsg;
198 m_emcDigiVec.insert( m_emcDigiVec.end(), *iterEMC );
201 if ( m_emcCalibConstSvc != 0 )
doCalib( *iterEMC );
204 log << MSG::WARNING <<
"require EMC calibration, but none service, ignore." << endmsg;
209 log << MSG::VERBOSE <<
"ready for return" << endmsg;
214 std::vector<uint32_t>::iterator it = m_hotCrystals.begin();
215 for ( ; it != m_hotCrystals.end(); it++ )
217 if ( ( *it ) == teid )
219 m_hotCrystals.erase( it );
223 if ( it == m_hotCrystals.end() )
return false;
229 std::vector<uint32_t>::iterator it = m_hotCrystals.begin();
230 for ( ; it != m_deadCrystals.end(); it++ )
232 if ( ( *it ) == teid )
234 m_deadCrystals.erase( it );
238 if ( it == m_deadCrystals.end() )
return false;
244 std::vector<uint32_t>::iterator it = m_hotCrystals.begin();
245 for ( ; it != m_hotCrystals.end(); it++ )
247 if ( ( *it ) == teid )
break;
249 if ( it == m_hotCrystals.end() ) m_hotCrystals.push_back( teid );
255 std::vector<uint32_t>::iterator it = m_hotCrystals.begin();
256 for ( ; it != m_deadCrystals.end(); it++ )
258 if ( ( *it ) == teid )
break;
260 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)
ISvcLocator * m_svcLocator
StatusCode initialize(ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
RawDataProviderBase(const char *name)
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