#include <SimplePedestalCalculator.h>
Public Member Functions | |
void | newEvent () |
ApvAnalysis::PedestalType | pedestal () const |
ApvAnalysis::PedestalType | rawNoise () const |
void | resetPedestals () |
void | setPedestals (ApvAnalysis::PedestalType &in) |
void | setRawNoise (ApvAnalysis::PedestalType &in) |
SimplePedestalCalculator (int evnt_ini) | |
void | updatePedestal (ApvAnalysis::RawSignalType &in) |
void | updateStatus () |
virtual | ~SimplePedestalCalculator () |
Protected Attributes | |
bool | alreadyUsedEvent |
int | eventsRequiredToCalibrate |
int | numberOfEvents |
std::vector< unsigned short > | theEventPerStrip |
ApvAnalysis::PedestalType | thePedestal |
std::vector< int > | thePedSqSum |
std::vector< int > | thePedSum |
ApvAnalysis::PedestalType | theRawNoise |
Private Member Functions | |
void | init () |
void | initializePedestal (ApvAnalysis::RawSignalType &in) |
void | refinePedestal (ApvAnalysis::RawSignalType &in) |
Concrete implementation of TkPedestalCalculator for Simple.
Definition at line 10 of file SimplePedestalCalculator.h.
SimplePedestalCalculator::SimplePedestalCalculator | ( | int | evnt_ini | ) |
Definition at line 9 of file SimplePedestalCalculator.cc.
References gather_cfg::cout, eventsRequiredToCalibrate, and init().
: numberOfEvents(0), alreadyUsedEvent(false) { if (0) cout << "Constructing SimplePedestalCalculator " << endl; eventsRequiredToCalibrate = evnt_ini; // eventsRequiredToUpdate = evnt_iter; // cutToAvoidSignal = sig_cut; init(); }
SimplePedestalCalculator::~SimplePedestalCalculator | ( | ) | [virtual] |
Definition at line 34 of file SimplePedestalCalculator.cc.
References gather_cfg::cout.
{ if (0) cout << "Destructing SimplePedestalCalculator " << endl; }
void SimplePedestalCalculator::init | ( | void | ) | [private] |
Definition at line 22 of file SimplePedestalCalculator.cc.
References TkStateMachine::setCalibrating(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, theRawNoise, and TkPedestalCalculator::theStatus.
Referenced by SimplePedestalCalculator().
{ theRawNoise.clear(); thePedestal.clear(); thePedSum.clear(); thePedSqSum.clear(); theEventPerStrip.clear(); theStatus.setCalibrating(); }
void SimplePedestalCalculator::initializePedestal | ( | ApvAnalysis::RawSignalType & | in | ) | [private] |
Definition at line 72 of file SimplePedestalCalculator.cc.
References edm::DetSet< T >::data, eventsRequiredToCalibrate, i, numberOfEvents, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.
Referenced by updatePedestal().
{ if (numberOfEvents == 1) { thePedSum.clear(); thePedSqSum.clear(); theEventPerStrip.clear(); thePedSum.reserve(128); thePedSqSum.reserve(128); theEventPerStrip.reserve(128); thePedSum.resize(in.data.size(), 0); thePedSqSum.resize(in.data.size(), 0); theEventPerStrip.resize(in.data.size(),0); } //eventsRequiredToCalibrate is considered the minimum number of events to be used if (numberOfEvents <= eventsRequiredToCalibrate) { edm::DetSet<SiStripRawDigi>::const_iterator i = in.data.begin(); int ii=0; for (;i!=in.data.end() ; i++) { thePedSum[ii] += (*i).adc(); thePedSqSum[ii] += ((*i).adc())*((*i).adc()); theEventPerStrip[ii]++; ii++; } } if (numberOfEvents == eventsRequiredToCalibrate) { thePedestal.clear(); theRawNoise.clear(); edm::DetSet<SiStripRawDigi>::const_iterator i = in.data.begin(); int ii=0; for (;i!=in.data.end() ; i++) { // the pedestal is calculated as int, as required by FED. int avVal = (theEventPerStrip[ii]) ? thePedSum[ii]/theEventPerStrip[ii]:0; double sqAvVal = (theEventPerStrip[ii]) ? thePedSqSum[ii]/theEventPerStrip[ii]:0.0; double corr_fac = (theEventPerStrip[ii] > 1) ? (theEventPerStrip[ii]/(theEventPerStrip[ii]-1)) : 1.0; double rmsVal = (sqAvVal - avVal*avVal > 0.0) ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0; thePedestal.push_back(static_cast<float>(avVal)); theRawNoise.push_back(static_cast<float>(rmsVal)); ii++; } } }
void SimplePedestalCalculator::newEvent | ( | ) | [virtual] |
Return raw noise, determined without CMN subtraction Tell pedestal calculator that a new event is available
Reimplemented from TkPedestalCalculator.
Definition at line 178 of file SimplePedestalCalculator.cc.
References alreadyUsedEvent.
{ alreadyUsedEvent = false; }
ApvAnalysis::PedestalType SimplePedestalCalculator::pedestal | ( | ) | const [inline, virtual] |
Return reconstructed pedestals
Implements TkPedestalCalculator.
Definition at line 30 of file SimplePedestalCalculator.h.
References thePedestal.
{ return thePedestal;}
ApvAnalysis::PedestalType SimplePedestalCalculator::rawNoise | ( | ) | const [inline, virtual] |
Implements TkPedestalCalculator.
Definition at line 29 of file SimplePedestalCalculator.h.
References theRawNoise.
{ return theRawNoise;}
void SimplePedestalCalculator::refinePedestal | ( | ApvAnalysis::RawSignalType & | in | ) | [private] |
Definition at line 130 of file SimplePedestalCalculator.cc.
References edm::DetSet< T >::data, i, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.
Referenced by updatePedestal().
{ // keep adding th adc count for any events unsigned int ii=0; ApvAnalysis::RawSignalType::const_iterator i= in.data.begin(); for (; i < in.data.end(); i++) { thePedSum[ii] += (*i).adc(); thePedSqSum[ii] += ((*i).adc())*((*i).adc()); theEventPerStrip[ii]++; ii++; } // calculate a new pedestal any events, so it will come for free when for the last event for (unsigned int iii = 0; iii < in.data.size(); iii++) { if (theEventPerStrip[iii] > 10 ) { int avVal = (theEventPerStrip[iii]) ? thePedSum[iii]/theEventPerStrip[iii]:0; double sqAvVal = (theEventPerStrip[iii]) ? thePedSqSum[iii]/theEventPerStrip[iii]:0.0; double rmsVal = (sqAvVal - avVal*avVal > 0.0) ? sqrt(sqAvVal - avVal*avVal) : 0.0; if (avVal != 0 ) { thePedestal[iii] = static_cast<float>(avVal); theRawNoise[iii] = static_cast<float>(rmsVal); } } } }
void SimplePedestalCalculator::resetPedestals | ( | ) | [inline, virtual] |
Implements TkPedestalCalculator.
Definition at line 18 of file SimplePedestalCalculator.h.
References thePedestal, and theRawNoise.
{ thePedestal.clear(); theRawNoise.clear(); }
void SimplePedestalCalculator::setPedestals | ( | ApvAnalysis::PedestalType & | in | ) | [inline, virtual] |
Implements TkPedestalCalculator.
Definition at line 22 of file SimplePedestalCalculator.h.
References recoMuon::in, and thePedestal.
{thePedestal=in;}
void SimplePedestalCalculator::setRawNoise | ( | ApvAnalysis::PedestalType & | in | ) | [inline] |
Definition at line 23 of file SimplePedestalCalculator.h.
References recoMuon::in, and theRawNoise.
{theRawNoise=in;}
void SimplePedestalCalculator::updatePedestal | ( | ApvAnalysis::RawSignalType & | in | ) | [virtual] |
Update pedestals with current event
Implements TkPedestalCalculator.
Definition at line 53 of file SimplePedestalCalculator.cc.
References alreadyUsedEvent, initializePedestal(), TkStateMachine::isCalibrating(), TkStateMachine::isUpdating(), numberOfEvents, refinePedestal(), TkPedestalCalculator::theStatus, and updateStatus().
{ if (alreadyUsedEvent == false) { alreadyUsedEvent = true; numberOfEvents++; if (theStatus.isCalibrating()) { initializePedestal(in); } else if (theStatus.isUpdating()) { refinePedestal(in); } updateStatus(); } }
void SimplePedestalCalculator::updateStatus | ( | ) | [virtual] |
Request that status flag be updated
Implements TkPedestalCalculator.
Definition at line 42 of file SimplePedestalCalculator.cc.
References eventsRequiredToCalibrate, TkStateMachine::isCalibrating(), numberOfEvents, TkStateMachine::setUpdating(), and TkPedestalCalculator::theStatus.
Referenced by updatePedestal().
{ if (theStatus.isCalibrating() && numberOfEvents >= eventsRequiredToCalibrate) { theStatus.setUpdating(); } }
bool SimplePedestalCalculator::alreadyUsedEvent [protected] |
Definition at line 49 of file SimplePedestalCalculator.h.
Referenced by newEvent(), and updatePedestal().
int SimplePedestalCalculator::eventsRequiredToCalibrate [protected] |
Definition at line 46 of file SimplePedestalCalculator.h.
Referenced by initializePedestal(), SimplePedestalCalculator(), and updateStatus().
int SimplePedestalCalculator::numberOfEvents [protected] |
Definition at line 45 of file SimplePedestalCalculator.h.
Referenced by initializePedestal(), updatePedestal(), and updateStatus().
std::vector<unsigned short> SimplePedestalCalculator::theEventPerStrip [protected] |
Definition at line 44 of file SimplePedestalCalculator.h.
Referenced by init(), initializePedestal(), and refinePedestal().
Definition at line 41 of file SimplePedestalCalculator.h.
Referenced by init(), initializePedestal(), pedestal(), refinePedestal(), resetPedestals(), and setPedestals().
std::vector<int> SimplePedestalCalculator::thePedSqSum [protected] |
Definition at line 43 of file SimplePedestalCalculator.h.
Referenced by init(), initializePedestal(), and refinePedestal().
std::vector<int> SimplePedestalCalculator::thePedSum [protected] |
Definition at line 43 of file SimplePedestalCalculator.h.
Referenced by init(), initializePedestal(), and refinePedestal().
Definition at line 42 of file SimplePedestalCalculator.h.
Referenced by init(), initializePedestal(), rawNoise(), refinePedestal(), resetPedestals(), and setRawNoise().