00001 #include "EmcRawEvent/EmcDigi.h"
00002 #include "EmcWaveform/EmcWaveform.h"
00003 #include "RawEvent/RawDataUtil.h"
00004
00005 EmcDigi::EmcDigi(const Identifier& id, const unsigned int timeChannel, const unsigned int chargeChannel) :
00006 RawData(id, timeChannel, chargeChannel),
00007 m_measure(0) {
00008 }
00009
00010 EmcDigi::EmcDigi(const Identifier& id, const unsigned int timeChannel, const unsigned int chargeChannel,
00011 const unsigned int measure) :
00012 RawData(id, timeChannel, chargeChannel),
00013 m_measure(measure) {
00014 }
00015
00016 EmcDigi::EmcDigi(const unsigned int id) :
00017 RawData(id),
00018 m_measure(0) {
00019 }
00020
00021
00022 EmcDigi& EmcDigi::operator+=(const EmcDigi &digi)
00023 {
00024 if(m_id != digi.identify())
00025 return *this;
00026
00027 double e1=RawDataUtil::EmcCharge(m_measure,m_chargeChannel);
00028 double t1=RawDataUtil::EmcTime(m_timeChannel);
00029 double e2=RawDataUtil::EmcCharge(digi.getMeasure(),digi.getChargeChannel());
00030 double t2=RawDataUtil::EmcTime(digi.getTimeChannel());
00031
00032 EmcWaveform wave1,wave2;
00033 wave1.makeWaveform(e1,t1);
00034 wave2.makeWaveform(e2,t2);
00035
00036
00037 wave1 += wave2;
00038
00039 double energy;
00040 int time;
00041 energy = wave1.max(time);
00042
00043 m_chargeChannel = RawDataUtil::EmcChargeChannel(energy);
00044 m_timeChannel = RawDataUtil::EmcTimeChannel(time);
00045 m_measure = RawDataUtil::EmcChargeMeasure(energy);
00046
00047 return *this;
00048 }