CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

SimpleNoiseCalculator Class Reference

#include <SimpleNoiseCalculator.h>

Inheritance diagram for SimpleNoiseCalculator:
TkNoiseCalculator

List of all members.

Public Member Functions

int nevents () const
void newEvent ()
ApvAnalysis::PedestalType noise () const
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)
void updateStatus ()
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_

Detailed Description

Concrete implementation of TkNoiseCalculator for Simple.

Definition at line 9 of file SimpleNoiseCalculator.h.


Constructor & Destructor Documentation

SimpleNoiseCalculator::SimpleNoiseCalculator ( )

Definition at line 10 of file SimpleNoiseCalculator.cc.

References gather_cfg::cout, and init().

                                             :
  numberOfEvents(0) ,
  alreadyUsedEvent(false)  
{
  if (0) cout << "Constructing SimpleNoiseCalculator " << endl;
  init();
}
SimpleNoiseCalculator::SimpleNoiseCalculator ( int  evnt_ini,
bool  useDB 
)

Definition at line 18 of file SimpleNoiseCalculator.cc.

References gather_cfg::cout, eventsRequiredToCalibrate_, init(), and useDB_.

                                                                      :
  numberOfEvents(0) ,
  alreadyUsedEvent(false)  
{
  if (0) cout << "Constructing SimpleNoiseCalculator " << endl;
  useDB_ = use_DB;
  eventsRequiredToCalibrate_ = evnt_ini;
  //  eventsRequiredToUpdate_    = evnt_iter;
  //  cutToAvoidSignal_          = sig_cut;
  init();
}
SimpleNoiseCalculator::~SimpleNoiseCalculator ( ) [virtual]

Definition at line 43 of file SimpleNoiseCalculator.cc.

References gather_cfg::cout.

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

Member Function Documentation

void SimpleNoiseCalculator::init ( void  ) [protected]

Definition at line 32 of file SimpleNoiseCalculator.cc.

References theCMPSubtractedSignal, theEventPerStrip, theNoise, theNoiseSqSum, and theNoiseSum.

Referenced by SimpleNoiseCalculator().

                                 {
  theCMPSubtractedSignal.clear();
  theNoise.clear();
  theNoiseSum.clear();
  theNoiseSqSum.clear();
  theEventPerStrip.clear();
  // theStatus.setCalibrating();
}
int SimpleNoiseCalculator::nevents ( ) const [inline]

Definition at line 22 of file SimpleNoiseCalculator.h.

References numberOfEvents.

{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.

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

Return reconstructed noise

Implements TkNoiseCalculator.

Definition at line 20 of file SimpleNoiseCalculator.h.

References theNoise.

{return theNoise;}
void SimpleNoiseCalculator::resetNoise ( ) [inline, virtual]

Implements TkNoiseCalculator.

Definition at line 25 of file SimpleNoiseCalculator.h.

References theNoise.

{theNoise.clear();}
void SimpleNoiseCalculator::setStripNoise ( ApvAnalysis::PedestalType in) [inline, virtual]

Implements TkNoiseCalculator.

Definition at line 19 of file SimpleNoiseCalculator.h.

References recoMuon::in, and theNoise.

{theNoise.clear(); theNoise = in;}
ApvAnalysis::PedestalType SimpleNoiseCalculator::stripCMPSubtractedSignal ( ) const [inline]

Definition at line 29 of file SimpleNoiseCalculator.h.

References theCMPSubtractedSignal.

float SimpleNoiseCalculator::stripNoise ( int  in) const [inline, virtual]

Implements TkNoiseCalculator.

Definition at line 21 of file SimpleNoiseCalculator.h.

References recoMuon::in, and theNoise.

{return theNoise[in];}
void SimpleNoiseCalculator::updateNoise ( ApvAnalysis::PedestalType ) [virtual]

Update noise with current event

Implements TkNoiseCalculator.

Definition at line 57 of file SimpleNoiseCalculator.cc.

References alreadyUsedEvent, gather_cfg::cout, eventsRequiredToCalibrate_, i, TkStateMachine::isCalibrating(), TkStateMachine::isUpdating(), numberOfEvents, mathSSE::sqrt(), theCMPSubtractedSignal, theEventPerStrip, theNoise, theNoiseSqSum, theNoiseSum, TkNoiseCalculator::theStatus, and updateStatus().

                                                                  {
  if (alreadyUsedEvent == false) {
    alreadyUsedEvent = true;
    numberOfEvents++;

    if (numberOfEvents == 1 && theNoise.size() != in.size()) {
      edm::LogError("SimpleNoiseCalculator:updateNoise") << " You did not initialize the Noise correctly prior to noise calibration.";
    }

    // Initialize sums used for estimating noise.
    if (numberOfEvents == 1)
    {
      theNoiseSum.clear();
      theNoiseSqSum.clear();
      theEventPerStrip.clear();

      theNoiseSum.resize(in.size(),0.0);
      theNoiseSqSum.resize(in.size(),0.0);
      theEventPerStrip.resize(in.size(),0);
    }    

    unsigned int i;

    // At every event Update sums used for estimating noise.
    for (i = 0; i < in.size(); i++) {

        theNoiseSum[i]   += in[i];
        theNoiseSqSum[i] += in[i]*in[i];
        theEventPerStrip[i]++;
    }

    // Calculate noise.
    if ((theStatus.isCalibrating() && numberOfEvents == eventsRequiredToCalibrate_) || theStatus.isUpdating() )
    {
      theCMPSubtractedSignal.clear();
      theNoise.clear();

      for (i = 0; i < in.size(); i++) {
        double avVal   = (theEventPerStrip[i]) 
          ? theNoiseSum[i]/(theEventPerStrip[i]):0.0;
        double sqAvVal = (theEventPerStrip[i]) 
          ? theNoiseSqSum[i]/(theEventPerStrip[i]):0.0;
        double corr_fac = (theEventPerStrip[i] > 1) 
          ? (theEventPerStrip[i]/(theEventPerStrip[i]-1)) : 1.0;
        double rmsVal  =  (sqAvVal - avVal*avVal > 0.0) 
          ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0;     
      
        theCMPSubtractedSignal.push_back(static_cast<float>(avVal));

        theNoise.push_back(static_cast<float>(rmsVal));
  
        if (0) cout << " SimpleNoiseCalculator::updateNoise " 
                    << theNoiseSum[i] << " " 
                    << theNoiseSqSum[i] << " "
                    << theEventPerStrip[i] << " "  
                    << avVal << " " 
                    << sqAvVal << " " 
                    << (sqAvVal - avVal*avVal) << " " 
                    << rmsVal << endl;
      }
    }
    updateStatus();
  }
}
void SimpleNoiseCalculator::updateStatus ( ) [virtual]

Member Data Documentation

Definition at line 41 of file SimpleNoiseCalculator.h.

Referenced by newEvent(), and updateNoise().

Definition at line 44 of file SimpleNoiseCalculator.h.

Referenced by SimpleNoiseCalculator(), updateNoise(), and updateStatus().

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 39 of file SimpleNoiseCalculator.h.

Referenced by init(), and updateNoise().

Definition at line 36 of file SimpleNoiseCalculator.h.

Referenced by init(), noise(), resetNoise(), setStripNoise(), stripNoise(), and updateNoise().

std::vector<double> SimpleNoiseCalculator::theNoiseSqSum [protected]

Definition at line 38 of file SimpleNoiseCalculator.h.

Referenced by init(), and updateNoise().

std::vector<double> SimpleNoiseCalculator::theNoiseSum [protected]

Definition at line 38 of file SimpleNoiseCalculator.h.

Referenced by init(), and updateNoise().

Definition at line 42 of file SimpleNoiseCalculator.h.

Referenced by SimpleNoiseCalculator(), and updateStatus().