CMS 3D CMS Logo

Public Member Functions | Protected Attributes | Private Member Functions

TT6PedestalCalculator Class Reference

#include <TT6PedestalCalculator.h>

Inheritance diagram for TT6PedestalCalculator:
TkPedestalCalculator

List of all members.

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)
 TT6PedestalCalculator (int evnt_ini, int evnt_iter, float sig_cut)
void updatePedestal (ApvAnalysis::RawSignalType &in)
void updateStatus ()
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 gather_cfg::cout, cutToAvoidSignal, eventsRequiredToCalibrate, eventsRequiredToUpdate, and init().

                                                      :   
                        numberOfEvents(0),
                        alreadyUsedEvent(false)
{
  if (0) cout << "Constructing TT6PedestalCalculator " << endl;
  eventsRequiredToCalibrate = evnt_ini; 
  eventsRequiredToUpdate    = evnt_iter;
  cutToAvoidSignal          = sig_cut;
  init();
}
TT6PedestalCalculator::~TT6PedestalCalculator ( ) [virtual]

Definition at line 32 of file TT6PedestalCalculator.cc.

References gather_cfg::cout.

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

Member Function Documentation

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

Definition at line 63 of file TT6PedestalCalculator.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.0);
    thePedSqSum.resize(in.data.size(), 0.0);
    theEventPerStrip.resize(in.data.size(), 0);
  }
  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++) {
      double avVal   = (theEventPerStrip[ii])   ? thePedSum[ii]/theEventPerStrip[ii]:0.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 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.

                                    {
  alreadyUsedEvent = false;
}
ApvAnalysis::PedestalType TT6PedestalCalculator::pedestal ( ) const [inline, virtual]

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 30 of file TT6PedestalCalculator.h.

References thePedestal.

{ return thePedestal;}
ApvAnalysis::PedestalType TT6PedestalCalculator::rawNoise ( ) const [inline, virtual]

Implements TkPedestalCalculator.

Definition at line 29 of file TT6PedestalCalculator.h.

References theRawNoise.

{ 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, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by updatePedestal().

                                                                       {
  if (((numberOfEvents-eventsRequiredToCalibrate)%eventsRequiredToUpdate) == 1) {
    
    thePedSum.clear();
    thePedSqSum.clear();
    theEventPerStrip.clear();
    
    thePedSum.reserve(128);
    thePedSqSum.reserve(128);
    theEventPerStrip.reserve(128);
    
    thePedSum.resize(in.data.size(), 0.0);
    thePedSqSum.resize(in.data.size(), 0.0);
    theEventPerStrip.resize(in.data.size(), 0);
  }
  unsigned int ii=0;
  ApvAnalysis::RawSignalType::const_iterator i= in.data.begin();
  for (; i < in.data.end(); i++) {
    if (fabs((*i).adc()-thePedestal[ii]) < cutToAvoidSignal*theRawNoise[ii]) {
      thePedSum[ii]   += (*i).adc();
      thePedSqSum[ii] += ((*i).adc())*((*i).adc());
      theEventPerStrip[ii]++;
    }
    ii++;
  }
  if (((numberOfEvents-eventsRequiredToCalibrate) % eventsRequiredToUpdate) == 0) {
    
    for (unsigned int iii = 0; iii < in.data.size(); iii++) {
      if (theEventPerStrip[iii] > 10 ) {
        double avVal   = (theEventPerStrip[iii]) ? thePedSum[iii]/theEventPerStrip[iii]:0.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);
        }
      }
    }
    thePedSum.clear();
    thePedSqSum.clear();
    theEventPerStrip.clear();    
        }
      }
void TT6PedestalCalculator::resetPedestals ( ) [inline, virtual]

Implements TkPedestalCalculator.

Definition at line 18 of file TT6PedestalCalculator.h.

References thePedestal, and theRawNoise.

                        {
    thePedestal.clear();
    theRawNoise.clear();
  } 
void TT6PedestalCalculator::setPedestals ( ApvAnalysis::PedestalType in) [inline, virtual]

Implements TkPedestalCalculator.

Definition at line 22 of file TT6PedestalCalculator.h.

References recoMuon::in, and thePedestal.

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

Definition at line 23 of file TT6PedestalCalculator.h.

References recoMuon::in, and theRawNoise.

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

Member Data Documentation

Definition at line 49 of file TT6PedestalCalculator.h.

Referenced by newEvent(), and updatePedestal().

Definition at line 48 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

Definition at line 47 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

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

Definition at line 44 of file TT6PedestalCalculator.h.

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

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().