#include <CalibTracker/SiStripAPVAnalysis/interface/SimpleNoiseCalculator.h>
Public Member Functions | |
int | nevents () const |
void | newEvent () |
Tell noise calculator that a new event is available. | |
ApvAnalysis::PedestalType | noise () const |
Return reconstructed noise. | |
void | resetNoise () |
void | setStripNoise (ApvAnalysis::PedestalType &in) |
SimpleNoiseCalculator (int evnt_ini, bool useDB) | |
SimpleNoiseCalculator () | |
ApvAnalysis::PedestalType | stripCMPSubtractedSignal () const |
float | stripNoise (int in) const |
void | updateNoise (ApvAnalysis::PedestalType &in) |
Update noise with current event. | |
void | updateStatus () |
Request that status flag be updated. | |
virtual | ~SimpleNoiseCalculator () |
Protected Member Functions | |
void | init () |
Protected Attributes | |
bool | alreadyUsedEvent |
int | eventsRequiredToCalibrate_ |
int | numberOfEvents |
ApvAnalysis::PedestalType | theCMPSubtractedSignal |
std::vector< unsigned short > | theEventPerStrip |
ApvAnalysis::PedestalType | theNoise |
std::vector< double > | theNoiseSqSum |
std::vector< double > | theNoiseSum |
bool | useDB_ |
Definition at line 9 of file SimpleNoiseCalculator.h.
SimpleNoiseCalculator::SimpleNoiseCalculator | ( | ) |
Definition at line 10 of file SimpleNoiseCalculator.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and init().
00010 : 00011 numberOfEvents(0) , 00012 alreadyUsedEvent(false) 00013 { 00014 if (0) cout << "Constructing SimpleNoiseCalculator " << endl; 00015 init(); 00016 } //
Definition at line 18 of file SimpleNoiseCalculator.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), eventsRequiredToCalibrate_, init(), and useDB_.
00018 : 00019 numberOfEvents(0) , 00020 alreadyUsedEvent(false) 00021 { 00022 if (0) cout << "Constructing SimpleNoiseCalculator " << endl; 00023 useDB_ = use_DB; 00024 eventsRequiredToCalibrate_ = evnt_ini; 00025 // eventsRequiredToUpdate_ = evnt_iter; 00026 // cutToAvoidSignal_ = sig_cut; 00027 init(); 00028 } //
SimpleNoiseCalculator::~SimpleNoiseCalculator | ( | ) | [virtual] |
Definition at line 43 of file SimpleNoiseCalculator.cc.
References GenMuonPlsPt100GeV_cfg::cout, and lat::endl().
void SimpleNoiseCalculator::init | ( | ) | [protected] |
Definition at line 32 of file SimpleNoiseCalculator.cc.
References theCMPSubtractedSignal, theEventPerStrip, theNoise, theNoiseSqSum, and theNoiseSum.
Referenced by SimpleNoiseCalculator().
00032 { 00033 theCMPSubtractedSignal.clear(); 00034 theNoise.clear(); 00035 theNoiseSum.clear(); 00036 theNoiseSqSum.clear(); 00037 theEventPerStrip.clear(); 00038 // theStatus.setCalibrating(); 00039 }
int SimpleNoiseCalculator::nevents | ( | ) | const [inline] |
Definition at line 22 of file SimpleNoiseCalculator.h.
References numberOfEvents.
00022 {return numberOfEvents;}
void SimpleNoiseCalculator::newEvent | ( | ) | [virtual] |
Tell noise calculator that a new event is available.
Reimplemented from TkNoiseCalculator.
Definition at line 124 of file SimpleNoiseCalculator.cc.
References alreadyUsedEvent.
00124 { 00125 alreadyUsedEvent = false; 00126 }
ApvAnalysis::PedestalType SimpleNoiseCalculator::noise | ( | ) | const [inline, virtual] |
Return reconstructed noise.
Implements TkNoiseCalculator.
Definition at line 20 of file SimpleNoiseCalculator.h.
References theNoise.
00020 {return theNoise;}
void SimpleNoiseCalculator::resetNoise | ( | ) | [inline, virtual] |
Implements TkNoiseCalculator.
Definition at line 25 of file SimpleNoiseCalculator.h.
References theNoise.
00025 {theNoise.clear();}
void SimpleNoiseCalculator::setStripNoise | ( | ApvAnalysis::PedestalType & | in | ) | [inline, virtual] |
Implements TkNoiseCalculator.
Definition at line 19 of file SimpleNoiseCalculator.h.
References theNoise.
ApvAnalysis::PedestalType SimpleNoiseCalculator::stripCMPSubtractedSignal | ( | ) | const [inline] |
Definition at line 29 of file SimpleNoiseCalculator.h.
References theCMPSubtractedSignal.
00030 {return theCMPSubtractedSignal;}
float SimpleNoiseCalculator::stripNoise | ( | int | in | ) | const [inline, virtual] |
Implements TkNoiseCalculator.
Definition at line 21 of file SimpleNoiseCalculator.h.
References theNoise.
void SimpleNoiseCalculator::updateNoise | ( | ApvAnalysis::PedestalType & | ) | [virtual] |
Update noise with current event.
Implements TkNoiseCalculator.
Definition at line 57 of file SimpleNoiseCalculator.cc.
References alreadyUsedEvent, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), eventsRequiredToCalibrate_, i, TkStateMachine::isCalibrating(), TkStateMachine::isUpdating(), numberOfEvents, funct::sqrt(), theCMPSubtractedSignal, theEventPerStrip, theNoise, theNoiseSqSum, theNoiseSum, TkNoiseCalculator::theStatus, and updateStatus().
00057 { 00058 if (alreadyUsedEvent == false) { 00059 alreadyUsedEvent = true; 00060 numberOfEvents++; 00061 00062 if (numberOfEvents == 1 && theNoise.size() != in.size()) { 00063 edm::LogError("SimpleNoiseCalculator:updateNoise") << " You did not initialize the Noise correctly prior to noise calibration."; 00064 } 00065 00066 // Initialize sums used for estimating noise. 00067 if (numberOfEvents == 1) 00068 { 00069 theNoiseSum.clear(); 00070 theNoiseSqSum.clear(); 00071 theEventPerStrip.clear(); 00072 00073 theNoiseSum.resize(in.size(),0.0); 00074 theNoiseSqSum.resize(in.size(),0.0); 00075 theEventPerStrip.resize(in.size(),0); 00076 } 00077 00078 unsigned int i; 00079 00080 // At every event Update sums used for estimating noise. 00081 for (i = 0; i < in.size(); i++) { 00082 00083 theNoiseSum[i] += in[i]; 00084 theNoiseSqSum[i] += in[i]*in[i]; 00085 theEventPerStrip[i]++; 00086 } 00087 00088 // Calculate noise. 00089 if ((theStatus.isCalibrating() && numberOfEvents == eventsRequiredToCalibrate_) || theStatus.isUpdating() ) 00090 { 00091 theCMPSubtractedSignal.clear(); 00092 theNoise.clear(); 00093 00094 for (i = 0; i < in.size(); i++) { 00095 double avVal = (theEventPerStrip[i]) 00096 ? theNoiseSum[i]/(theEventPerStrip[i]):0.0; 00097 double sqAvVal = (theEventPerStrip[i]) 00098 ? theNoiseSqSum[i]/(theEventPerStrip[i]):0.0; 00099 double corr_fac = (theEventPerStrip[i] > 1) 00100 ? (theEventPerStrip[i]/(theEventPerStrip[i]-1)) : 1.0; 00101 double rmsVal = (sqAvVal - avVal*avVal > 0.0) 00102 ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0; 00103 00104 theCMPSubtractedSignal.push_back(static_cast<float>(avVal)); 00105 00106 theNoise.push_back(static_cast<float>(rmsVal)); 00107 00108 if (0) cout << " SimpleNoiseCalculator::updateNoise " 00109 << theNoiseSum[i] << " " 00110 << theNoiseSqSum[i] << " " 00111 << theEventPerStrip[i] << " " 00112 << avVal << " " 00113 << sqAvVal << " " 00114 << (sqAvVal - avVal*avVal) << " " 00115 << rmsVal << endl; 00116 } 00117 } 00118 updateStatus(); 00119 } 00120 }
void SimpleNoiseCalculator::updateStatus | ( | ) | [virtual] |
Request that status flag be updated.
Implements TkNoiseCalculator.
Definition at line 49 of file SimpleNoiseCalculator.cc.
References eventsRequiredToCalibrate_, TkStateMachine::isCalibrating(), numberOfEvents, TkStateMachine::setUpdating(), TkNoiseCalculator::theStatus, and useDB_.
Referenced by updateNoise().
00049 { 00050 if ( (theStatus.isCalibrating() && numberOfEvents >= eventsRequiredToCalibrate_) || (useDB_==true && numberOfEvents ==1) ) { 00051 theStatus.setUpdating(); 00052 } 00053 }
bool SimpleNoiseCalculator::alreadyUsedEvent [protected] |
int SimpleNoiseCalculator::eventsRequiredToCalibrate_ [protected] |
Definition at line 44 of file SimpleNoiseCalculator.h.
Referenced by SimpleNoiseCalculator(), updateNoise(), and updateStatus().
int SimpleNoiseCalculator::numberOfEvents [protected] |
Definition at line 40 of file SimpleNoiseCalculator.h.
Referenced by nevents(), updateNoise(), and updateStatus().
Definition at line 37 of file SimpleNoiseCalculator.h.
Referenced by init(), stripCMPSubtractedSignal(), and updateNoise().
std::vector<unsigned short> SimpleNoiseCalculator::theEventPerStrip [protected] |
Definition at line 36 of file SimpleNoiseCalculator.h.
Referenced by init(), noise(), resetNoise(), setStripNoise(), stripNoise(), and updateNoise().
std::vector<double> SimpleNoiseCalculator::theNoiseSqSum [protected] |
std::vector<double> SimpleNoiseCalculator::theNoiseSum [protected] |
bool SimpleNoiseCalculator::useDB_ [protected] |
Definition at line 42 of file SimpleNoiseCalculator.h.
Referenced by SimpleNoiseCalculator(), and updateStatus().