![]() |
![]() |
#include <CalibTracker/SiStripAPVAnalysis/interface/SimplePedestalCalculator.h>
Public Member Functions | |
void | newEvent () |
Return raw noise, determined without CMN subtraction. | |
ApvAnalysis::PedestalType | pedestal () const |
Return reconstructed pedestals. | |
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) |
Update pedestals with current event. | |
void | updateStatus () |
Request that status flag be updated. | |
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) |
Definition at line 10 of file SimplePedestalCalculator.h.
SimplePedestalCalculator::SimplePedestalCalculator | ( | int | evnt_ini | ) |
Definition at line 9 of file SimplePedestalCalculator.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), eventsRequiredToCalibrate, and init().
00009 : 00010 numberOfEvents(0), 00011 alreadyUsedEvent(false) 00012 { 00013 if (0) cout << "Constructing SimplePedestalCalculator " << endl; 00014 eventsRequiredToCalibrate = evnt_ini; 00015 // eventsRequiredToUpdate = evnt_iter; 00016 // cutToAvoidSignal = sig_cut; 00017 init(); 00018 }
SimplePedestalCalculator::~SimplePedestalCalculator | ( | ) | [virtual] |
Definition at line 34 of file SimplePedestalCalculator.cc.
References GenMuonPlsPt100GeV_cfg::cout, and lat::endl().
void SimplePedestalCalculator::init | ( | ) | [private] |
Definition at line 22 of file SimplePedestalCalculator.cc.
References TkStateMachine::setCalibrating(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, theRawNoise, and TkPedestalCalculator::theStatus.
Referenced by SimplePedestalCalculator().
00022 { 00023 theRawNoise.clear(); 00024 thePedestal.clear(); 00025 thePedSum.clear(); 00026 thePedSqSum.clear(); 00027 theEventPerStrip.clear(); 00028 theStatus.setCalibrating(); 00029 00030 }
void SimplePedestalCalculator::initializePedestal | ( | ApvAnalysis::RawSignalType & | in | ) | [private] |
Definition at line 72 of file SimplePedestalCalculator.cc.
References edm::DetSet< T >::data, eventsRequiredToCalibrate, i, numberOfEvents, funct::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.
Referenced by updatePedestal().
00072 { 00073 if (numberOfEvents == 1) { 00074 00075 thePedSum.clear(); 00076 thePedSqSum.clear(); 00077 theEventPerStrip.clear(); 00078 00079 thePedSum.reserve(128); 00080 thePedSqSum.reserve(128); 00081 theEventPerStrip.reserve(128); 00082 00083 thePedSum.resize(in.data.size(), 0); 00084 thePedSqSum.resize(in.data.size(), 0); 00085 theEventPerStrip.resize(in.data.size(),0); 00086 } 00087 00088 //eventsRequiredToCalibrate is considered the minimum number of events to be used 00089 00090 if (numberOfEvents <= eventsRequiredToCalibrate) { 00091 edm::DetSet<SiStripRawDigi>::const_iterator i = in.data.begin(); 00092 int ii=0; 00093 for (;i!=in.data.end() ; i++) { 00094 thePedSum[ii] += (*i).adc(); 00095 thePedSqSum[ii] += ((*i).adc())*((*i).adc()); 00096 theEventPerStrip[ii]++; 00097 ii++; 00098 } 00099 } 00100 if (numberOfEvents == eventsRequiredToCalibrate) { 00101 thePedestal.clear(); 00102 theRawNoise.clear(); 00103 edm::DetSet<SiStripRawDigi>::const_iterator i = in.data.begin(); 00104 int ii=0; 00105 for (;i!=in.data.end() ; i++) { 00106 00107 00108 // the pedestal is calculated as int, as required by FED. 00109 int avVal = (theEventPerStrip[ii]) 00110 ? thePedSum[ii]/theEventPerStrip[ii]:0; 00111 00112 double sqAvVal = (theEventPerStrip[ii]) 00113 ? thePedSqSum[ii]/theEventPerStrip[ii]:0.0; 00114 double corr_fac = (theEventPerStrip[ii] > 1) 00115 ? (theEventPerStrip[ii]/(theEventPerStrip[ii]-1)) : 1.0; 00116 double rmsVal = (sqAvVal - avVal*avVal > 0.0) 00117 ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0; 00118 thePedestal.push_back(static_cast<float>(avVal)); 00119 theRawNoise.push_back(static_cast<float>(rmsVal)); 00120 ii++; 00121 } 00122 00123 } 00124 }
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.
00178 { 00179 alreadyUsedEvent = false; 00180 }
ApvAnalysis::PedestalType SimplePedestalCalculator::pedestal | ( | ) | const [inline, virtual] |
Return reconstructed pedestals.
Implements TkPedestalCalculator.
Definition at line 30 of file SimplePedestalCalculator.h.
References thePedestal.
00030 { return thePedestal;}
ApvAnalysis::PedestalType SimplePedestalCalculator::rawNoise | ( | ) | const [inline, virtual] |
Implements TkPedestalCalculator.
Definition at line 29 of file SimplePedestalCalculator.h.
References theRawNoise.
00029 { return theRawNoise;}
void SimplePedestalCalculator::refinePedestal | ( | ApvAnalysis::RawSignalType & | in | ) | [private] |
Definition at line 130 of file SimplePedestalCalculator.cc.
References edm::DetSet< T >::data, i, funct::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.
Referenced by updatePedestal().
00130 { 00131 00132 00133 // keep adding th adc count for any events 00134 00135 unsigned int ii=0; 00136 ApvAnalysis::RawSignalType::const_iterator i= in.data.begin(); 00137 for (; i < in.data.end(); i++) { 00138 00139 thePedSum[ii] += (*i).adc(); 00140 thePedSqSum[ii] += ((*i).adc())*((*i).adc()); 00141 theEventPerStrip[ii]++; 00142 00143 ii++; 00144 } 00145 00146 00147 // calculate a new pedestal any events, so it will come for free when for the last event 00148 00149 for (unsigned int iii = 0; iii < in.data.size(); iii++) { 00150 if (theEventPerStrip[iii] > 10 ) { 00151 int avVal = (theEventPerStrip[iii]) 00152 ? thePedSum[iii]/theEventPerStrip[iii]:0; 00153 00154 double sqAvVal = (theEventPerStrip[iii]) 00155 ? thePedSqSum[iii]/theEventPerStrip[iii]:0.0; 00156 00157 double rmsVal = (sqAvVal - avVal*avVal > 0.0) 00158 ? sqrt(sqAvVal - avVal*avVal) : 0.0; 00159 00160 00161 if (avVal != 0 ) { 00162 thePedestal[iii] = static_cast<float>(avVal); 00163 theRawNoise[iii] = static_cast<float>(rmsVal); 00164 } 00165 } 00166 } 00167 00168 }
void SimplePedestalCalculator::resetPedestals | ( | ) | [inline, virtual] |
Implements TkPedestalCalculator.
Definition at line 18 of file SimplePedestalCalculator.h.
References thePedestal, and theRawNoise.
00018 { 00019 thePedestal.clear(); 00020 theRawNoise.clear(); 00021 }
void SimplePedestalCalculator::setPedestals | ( | ApvAnalysis::PedestalType & | in | ) | [inline, virtual] |
Implements TkPedestalCalculator.
Definition at line 22 of file SimplePedestalCalculator.h.
References thePedestal.
00022 {thePedestal=in;}
void SimplePedestalCalculator::setRawNoise | ( | ApvAnalysis::PedestalType & | in | ) | [inline] |
Definition at line 23 of file SimplePedestalCalculator.h.
References theRawNoise.
00023 {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().
00053 { 00054 00055 if (alreadyUsedEvent == false) { 00056 alreadyUsedEvent = true; 00057 numberOfEvents++; 00058 if (theStatus.isCalibrating()) { 00059 initializePedestal(in); 00060 } else if (theStatus.isUpdating()) { 00061 refinePedestal(in); 00062 } 00063 updateStatus(); 00064 } 00065 00066 00067 }
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().
00042 { 00043 if (theStatus.isCalibrating() && 00044 numberOfEvents >= eventsRequiredToCalibrate) { 00045 theStatus.setUpdating(); 00046 } 00047 }
bool SimplePedestalCalculator::alreadyUsedEvent [protected] |
Definition at line 49 of file SimplePedestalCalculator.h.
Referenced by newEvent(), and updatePedestal().
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().