CMS 3D CMS Logo

TT6PedestalCalculator Class Reference

Concrete implementation of TkPedestalCalculator for TT6. More...

#include <CalibTracker/SiStripAPVAnalysis/interface/TT6PedestalCalculator.h>

Inheritance diagram for TT6PedestalCalculator:

TkPedestalCalculator

List of all members.

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)
 TT6PedestalCalculator (int evnt_ini, int evnt_iter, float sig_cut)
void updatePedestal (ApvAnalysis::RawSignalType &in)
 Update pedestals with current event.
void updateStatus ()
 Request that status flag be updated.
virtual ~TT6PedestalCalculator ()

Protected Attributes

bool alreadyUsedEvent
float cutToAvoidSignal
int eventsRequiredToCalibrate
int eventsRequiredToUpdate
int numberOfEvents
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType thePedestal
std::vector< double > thePedSqSum
std::vector< double > thePedSum
ApvAnalysis::PedestalType theRawNoise

Private Member Functions

void init ()
void initializePedestal (ApvAnalysis::RawSignalType &in)
void refinePedestal (ApvAnalysis::RawSignalType &in)


Detailed Description

Concrete implementation of TkPedestalCalculator for TT6.

Definition at line 10 of file TT6PedestalCalculator.h.


Constructor & Destructor Documentation

TT6PedestalCalculator::TT6PedestalCalculator ( int  evnt_ini,
int  evnt_iter,
float  sig_cut 
)

Definition at line 7 of file TT6PedestalCalculator.cc.

References GenMuonPlsPt100GeV_cfg::cout, cutToAvoidSignal, lat::endl(), eventsRequiredToCalibrate, eventsRequiredToUpdate, and init().

00008                                                       :   
00009                         numberOfEvents(0),
00010                         alreadyUsedEvent(false)
00011 {
00012   if (0) cout << "Constructing TT6PedestalCalculator " << endl;
00013   eventsRequiredToCalibrate = evnt_ini; 
00014   eventsRequiredToUpdate    = evnt_iter;
00015   cutToAvoidSignal          = sig_cut;
00016   init();
00017 }

TT6PedestalCalculator::~TT6PedestalCalculator (  )  [virtual]

Definition at line 32 of file TT6PedestalCalculator.cc.

References GenMuonPlsPt100GeV_cfg::cout, and lat::endl().

00032                                               {
00033   if (0) cout << "Destructing TT6PedestalCalculator " << endl;
00034 }


Member Function Documentation

void TT6PedestalCalculator::init (  )  [private]

Definition at line 21 of file TT6PedestalCalculator.cc.

References TkStateMachine::setCalibrating(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, theRawNoise, and TkPedestalCalculator::theStatus.

Referenced by TT6PedestalCalculator().

00021                                  { 
00022   theRawNoise.clear();
00023   thePedestal.clear();
00024   thePedSum.clear();
00025   thePedSqSum.clear();
00026   theEventPerStrip.clear();
00027   theStatus.setCalibrating();
00028 }

void TT6PedestalCalculator::initializePedestal ( ApvAnalysis::RawSignalType in  )  [private]

Definition at line 63 of file TT6PedestalCalculator.cc.

References edm::DetSet< T >::data, eventsRequiredToCalibrate, i, numberOfEvents, funct::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by updatePedestal().

00063                                                                            {
00064   if (numberOfEvents == 1) {
00065 
00066     thePedSum.clear();
00067     thePedSqSum.clear();
00068     theEventPerStrip.clear();
00069     
00070     thePedSum.reserve(128);
00071     thePedSqSum.reserve(128);
00072     theEventPerStrip.reserve(128);
00073     
00074     thePedSum.resize(in.data.size(), 0.0);
00075     thePedSqSum.resize(in.data.size(), 0.0);
00076     theEventPerStrip.resize(in.data.size(), 0);
00077   }
00078   if (numberOfEvents <= eventsRequiredToCalibrate) {
00079     edm::DetSet<SiStripRawDigi>::const_iterator i = in.data.begin();
00080     int ii=0;
00081     for (;i!=in.data.end() ; i++) {
00082       thePedSum[ii]   += (*i).adc();
00083       thePedSqSum[ii] += ((*i).adc())*((*i).adc());
00084       theEventPerStrip[ii]++;
00085       ii++;
00086     }
00087   }
00088   if (numberOfEvents == eventsRequiredToCalibrate) {
00089     thePedestal.clear();
00090     theRawNoise.clear();
00091     edm::DetSet<SiStripRawDigi>::const_iterator i = in.data.begin();
00092     int ii=0;
00093     for (;i!=in.data.end() ; i++) {
00094       double avVal   = (theEventPerStrip[ii])   ? thePedSum[ii]/theEventPerStrip[ii]:0.0;
00095       double sqAvVal = (theEventPerStrip[ii])   ? thePedSqSum[ii]/theEventPerStrip[ii]:0.0;
00096       double corr_fac = (theEventPerStrip[ii] > 1) ? (theEventPerStrip[ii]/(theEventPerStrip[ii]-1)) : 1.0;
00097       double rmsVal  =  (sqAvVal - avVal*avVal > 0.0) ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0; 
00098 
00099       thePedestal.push_back(static_cast<float>(avVal));
00100       theRawNoise.push_back(static_cast<float>(rmsVal));
00101       ii++;
00102     }
00103   }
00104 }

void TT6PedestalCalculator::newEvent (  )  [virtual]

Return raw noise, determined without CMN subtraction.

Tell pedestal calculator that a new event is available

Reimplemented from TkPedestalCalculator.

Definition at line 156 of file TT6PedestalCalculator.cc.

References alreadyUsedEvent.

00156                                     {
00157   alreadyUsedEvent = false;
00158 }

ApvAnalysis::PedestalType TT6PedestalCalculator::pedestal (  )  const [inline, virtual]

Return reconstructed pedestals.

Implements TkPedestalCalculator.

Definition at line 30 of file TT6PedestalCalculator.h.

References thePedestal.

00030 { return thePedestal;}

ApvAnalysis::PedestalType TT6PedestalCalculator::rawNoise (  )  const [inline, virtual]

Implements TkPedestalCalculator.

Definition at line 29 of file TT6PedestalCalculator.h.

References theRawNoise.

00029 { return theRawNoise;}

void TT6PedestalCalculator::refinePedestal ( ApvAnalysis::RawSignalType in  )  [private]

Definition at line 108 of file TT6PedestalCalculator.cc.

References cutToAvoidSignal, edm::DetSet< T >::data, eventsRequiredToCalibrate, eventsRequiredToUpdate, i, numberOfEvents, funct::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by updatePedestal().

00108                                                                        {
00109   if (((numberOfEvents-eventsRequiredToCalibrate)%eventsRequiredToUpdate) == 1) {
00110     
00111     thePedSum.clear();
00112     thePedSqSum.clear();
00113     theEventPerStrip.clear();
00114     
00115     thePedSum.reserve(128);
00116     thePedSqSum.reserve(128);
00117     theEventPerStrip.reserve(128);
00118     
00119     thePedSum.resize(in.data.size(), 0.0);
00120     thePedSqSum.resize(in.data.size(), 0.0);
00121     theEventPerStrip.resize(in.data.size(), 0);
00122   }
00123   unsigned int ii=0;
00124   ApvAnalysis::RawSignalType::const_iterator i= in.data.begin();
00125   for (; i < in.data.end(); i++) {
00126     if (fabs((*i).adc()-thePedestal[ii]) < cutToAvoidSignal*theRawNoise[ii]) {
00127       thePedSum[ii]   += (*i).adc();
00128       thePedSqSum[ii] += ((*i).adc())*((*i).adc());
00129       theEventPerStrip[ii]++;
00130     }
00131     ii++;
00132   }
00133   if (((numberOfEvents-eventsRequiredToCalibrate) % eventsRequiredToUpdate) == 0) {
00134     
00135     for (unsigned int iii = 0; iii < in.data.size(); iii++) {
00136       if (theEventPerStrip[iii] > 10 ) {
00137         double avVal   = (theEventPerStrip[iii]) ? thePedSum[iii]/theEventPerStrip[iii]:0.0;
00138         double sqAvVal = (theEventPerStrip[iii]) ? thePedSqSum[iii]/theEventPerStrip[iii]:0.0;
00139         double rmsVal  =  (sqAvVal - avVal*avVal > 0.0) ? sqrt(sqAvVal - avVal*avVal) : 0.0;    
00140 
00141         
00142         if (avVal != 0 ) {
00143           thePedestal[iii] = static_cast<float>(avVal);
00144           theRawNoise[iii] = static_cast<float>(rmsVal);
00145         }
00146       }
00147     }
00148     thePedSum.clear();
00149     thePedSqSum.clear();
00150     theEventPerStrip.clear();    
00151         }
00152       }

void TT6PedestalCalculator::resetPedestals (  )  [inline, virtual]

Implements TkPedestalCalculator.

Definition at line 18 of file TT6PedestalCalculator.h.

References thePedestal, and theRawNoise.

00018                         {
00019     thePedestal.clear();
00020     theRawNoise.clear();
00021   } 

void TT6PedestalCalculator::setPedestals ( ApvAnalysis::PedestalType in  )  [inline, virtual]

Implements TkPedestalCalculator.

Definition at line 22 of file TT6PedestalCalculator.h.

References thePedestal.

00022 {thePedestal=in;}

void TT6PedestalCalculator::setRawNoise ( ApvAnalysis::PedestalType in  )  [inline]

Definition at line 23 of file TT6PedestalCalculator.h.

References theRawNoise.

00023 {theRawNoise=in;}

void TT6PedestalCalculator::updatePedestal ( ApvAnalysis::RawSignalType in  )  [virtual]

Update pedestals with current event.

Implements TkPedestalCalculator.

Definition at line 48 of file TT6PedestalCalculator.cc.

References alreadyUsedEvent, initializePedestal(), TkStateMachine::isCalibrating(), TkStateMachine::isUpdating(), numberOfEvents, refinePedestal(), TkPedestalCalculator::theStatus, and updateStatus().

00048                                                                        {
00049   if (alreadyUsedEvent == false) {
00050     alreadyUsedEvent = true;
00051     numberOfEvents++;
00052     if (theStatus.isCalibrating()) {
00053       initializePedestal(in);
00054     } else if (theStatus.isUpdating()) {
00055       refinePedestal(in);
00056     }  
00057     updateStatus();
00058   }
00059 }

void TT6PedestalCalculator::updateStatus (  )  [virtual]

Request that status flag be updated.

Implements TkPedestalCalculator.

Definition at line 38 of file TT6PedestalCalculator.cc.

References eventsRequiredToCalibrate, TkStateMachine::isCalibrating(), numberOfEvents, TkStateMachine::setUpdating(), and TkPedestalCalculator::theStatus.

Referenced by updatePedestal().

00038                                         {
00039 
00040   if (theStatus.isCalibrating() && 
00041       numberOfEvents >= eventsRequiredToCalibrate) {
00042     theStatus.setUpdating();
00043   }
00044 }


Member Data Documentation

bool TT6PedestalCalculator::alreadyUsedEvent [protected]

Definition at line 49 of file TT6PedestalCalculator.h.

Referenced by newEvent(), and updatePedestal().

float TT6PedestalCalculator::cutToAvoidSignal [protected]

Definition at line 48 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

int TT6PedestalCalculator::eventsRequiredToCalibrate [protected]

Definition at line 46 of file TT6PedestalCalculator.h.

Referenced by initializePedestal(), refinePedestal(), TT6PedestalCalculator(), and updateStatus().

int TT6PedestalCalculator::eventsRequiredToUpdate [protected]

Definition at line 47 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

int TT6PedestalCalculator::numberOfEvents [protected]

Definition at line 45 of file TT6PedestalCalculator.h.

Referenced by initializePedestal(), refinePedestal(), updatePedestal(), and updateStatus().

std::vector<unsigned short> TT6PedestalCalculator::theEventPerStrip [protected]

Definition at line 44 of file TT6PedestalCalculator.h.

Referenced by init(), initializePedestal(), and refinePedestal().

ApvAnalysis::PedestalType TT6PedestalCalculator::thePedestal [protected]

Definition at line 41 of file TT6PedestalCalculator.h.

Referenced by init(), initializePedestal(), pedestal(), refinePedestal(), resetPedestals(), and setPedestals().

std::vector<double> TT6PedestalCalculator::thePedSqSum [protected]

Definition at line 43 of file TT6PedestalCalculator.h.

Referenced by init(), initializePedestal(), and refinePedestal().

std::vector<double> TT6PedestalCalculator::thePedSum [protected]

Definition at line 43 of file TT6PedestalCalculator.h.

Referenced by init(), initializePedestal(), and refinePedestal().

ApvAnalysis::PedestalType TT6PedestalCalculator::theRawNoise [protected]

Definition at line 42 of file TT6PedestalCalculator.h.

Referenced by init(), initializePedestal(), rawNoise(), refinePedestal(), resetPedestals(), and setRawNoise().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:34:42 2009 for CMSSW by  doxygen 1.5.4