CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
SimpleNoiseCalculator Class Reference

#include <SimpleNoiseCalculator.h>

Inheritance diagram for SimpleNoiseCalculator:
TkNoiseCalculator

Public Member Functions

int nevents () const
 
void newEvent () override
 
ApvAnalysis::PedestalType noise () const override
 
void resetNoise () override
 
void setStripNoise (ApvAnalysis::PedestalType &in) override
 
 SimpleNoiseCalculator ()
 
 SimpleNoiseCalculator (int evnt_ini, bool useDB)
 
ApvAnalysis::PedestalType stripCMPSubtractedSignal () const
 
float stripNoise (int in) const override
 
void updateNoise (ApvAnalysis::PedestalType &in) override
 
void updateStatus () override
 
 ~SimpleNoiseCalculator () override
 
- Public Member Functions inherited from TkNoiseCalculator
TkStateMachinestatus ()
 
virtual ~TkNoiseCalculator ()
 

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_
 
- Protected Attributes inherited from TkNoiseCalculator
TkStateMachine theStatus
 

Detailed Description

Concrete implementation of TkNoiseCalculator for Simple.

Definition at line 9 of file SimpleNoiseCalculator.h.

Constructor & Destructor Documentation

◆ SimpleNoiseCalculator() [1/2]

SimpleNoiseCalculator::SimpleNoiseCalculator ( )

Definition at line 10 of file SimpleNoiseCalculator.cc.

References gather_cfg::cout, and init().

10  : numberOfEvents(0), alreadyUsedEvent(false) {
11  if (false)
12  cout << "Constructing SimpleNoiseCalculator " << endl;
13  init();
14 }

◆ SimpleNoiseCalculator() [2/2]

SimpleNoiseCalculator::SimpleNoiseCalculator ( int  evnt_ini,
bool  useDB 
)

Definition at line 16 of file SimpleNoiseCalculator.cc.

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

16  : numberOfEvents(0), alreadyUsedEvent(false) {
17  if (false)
18  cout << "Constructing SimpleNoiseCalculator " << endl;
19  useDB_ = use_DB;
20  eventsRequiredToCalibrate_ = evnt_ini;
21  // eventsRequiredToUpdate_ = evnt_iter;
22  // cutToAvoidSignal_ = sig_cut;
23  init();
24 }

◆ ~SimpleNoiseCalculator()

SimpleNoiseCalculator::~SimpleNoiseCalculator ( )
override

Definition at line 39 of file SimpleNoiseCalculator.cc.

References gather_cfg::cout.

39  {
40  if (false)
41  cout << "Destructing SimpleNoiseCalculator " << endl;
42 }

Member Function Documentation

◆ init()

void SimpleNoiseCalculator::init ( void  )
protected

Definition at line 28 of file SimpleNoiseCalculator.cc.

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

Referenced by SimpleNoiseCalculator().

28  {
29  theCMPSubtractedSignal.clear();
30  theNoise.clear();
31  theNoiseSum.clear();
32  theNoiseSqSum.clear();
33  theEventPerStrip.clear();
34  // theStatus.setCalibrating();
35 }
ApvAnalysis::PedestalType theNoise
std::vector< double > theNoiseSum
std::vector< double > theNoiseSqSum
ApvAnalysis::PedestalType theCMPSubtractedSignal
std::vector< unsigned short > theEventPerStrip

◆ nevents()

int SimpleNoiseCalculator::nevents ( ) const
inline

Definition at line 23 of file SimpleNoiseCalculator.h.

References numberOfEvents.

◆ newEvent()

void SimpleNoiseCalculator::newEvent ( )
overridevirtual

Tell noise calculator that a new event is available

Reimplemented from TkNoiseCalculator.

Definition at line 112 of file SimpleNoiseCalculator.cc.

References alreadyUsedEvent.

◆ noise()

ApvAnalysis::PedestalType SimpleNoiseCalculator::noise ( ) const
inlineoverridevirtual

Return reconstructed noise

Implements TkNoiseCalculator.

Definition at line 21 of file SimpleNoiseCalculator.h.

References theNoise.

21 { return theNoise; }
ApvAnalysis::PedestalType theNoise

◆ resetNoise()

void SimpleNoiseCalculator::resetNoise ( )
inlineoverridevirtual

Implements TkNoiseCalculator.

Definition at line 26 of file SimpleNoiseCalculator.h.

References theNoise.

26 { theNoise.clear(); }
ApvAnalysis::PedestalType theNoise

◆ setStripNoise()

void SimpleNoiseCalculator::setStripNoise ( ApvAnalysis::PedestalType in)
inlineoverridevirtual

Implements TkNoiseCalculator.

Definition at line 17 of file SimpleNoiseCalculator.h.

References recoMuon::in, and theNoise.

17  {
18  theNoise.clear();
19  theNoise = in;
20  }
ApvAnalysis::PedestalType theNoise

◆ stripCMPSubtractedSignal()

ApvAnalysis::PedestalType SimpleNoiseCalculator::stripCMPSubtractedSignal ( ) const
inline

Definition at line 30 of file SimpleNoiseCalculator.h.

References theCMPSubtractedSignal.

30 { return theCMPSubtractedSignal; }
ApvAnalysis::PedestalType theCMPSubtractedSignal

◆ stripNoise()

float SimpleNoiseCalculator::stripNoise ( int  in) const
inlineoverridevirtual

Implements TkNoiseCalculator.

Definition at line 22 of file SimpleNoiseCalculator.h.

References recoMuon::in, and theNoise.

22 { return theNoise[in]; }
ApvAnalysis::PedestalType theNoise

◆ updateNoise()

void SimpleNoiseCalculator::updateNoise ( ApvAnalysis::PedestalType )
overridevirtual

Update noise with current event

Implements TkNoiseCalculator.

Definition at line 55 of file SimpleNoiseCalculator.cc.

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

55  {
56  if (alreadyUsedEvent == false) {
57  alreadyUsedEvent = true;
59 
60  if (numberOfEvents == 1 && theNoise.size() != in.size()) {
61  edm::LogError("SimpleNoiseCalculator:updateNoise")
62  << " You did not initialize the Noise correctly prior to noise calibration.";
63  }
64 
65  // Initialize sums used for estimating noise.
66  if (numberOfEvents == 1) {
67  theNoiseSum.clear();
68  theNoiseSqSum.clear();
69  theEventPerStrip.clear();
70 
71  theNoiseSum.resize(in.size(), 0.0);
72  theNoiseSqSum.resize(in.size(), 0.0);
73  theEventPerStrip.resize(in.size(), 0);
74  }
75 
76  unsigned int i;
77 
78  // At every event Update sums used for estimating noise.
79  for (i = 0; i < in.size(); i++) {
80  theNoiseSum[i] += in[i];
81  theNoiseSqSum[i] += in[i] * in[i];
83  }
84 
85  // Calculate noise.
87  theCMPSubtractedSignal.clear();
88  theNoise.clear();
89 
90  for (i = 0; i < in.size(); i++) {
91  double avVal = (theEventPerStrip[i]) ? theNoiseSum[i] / (theEventPerStrip[i]) : 0.0;
92  double sqAvVal = (theEventPerStrip[i]) ? theNoiseSqSum[i] / (theEventPerStrip[i]) : 0.0;
93  double corr_fac = (theEventPerStrip[i] > 1) ? (theEventPerStrip[i] / (theEventPerStrip[i] - 1)) : 1.0;
94  double rmsVal = (sqAvVal - avVal * avVal > 0.0) ? sqrt(corr_fac * (sqAvVal - avVal * avVal)) : 0.0;
95 
96  theCMPSubtractedSignal.push_back(static_cast<float>(avVal));
97 
98  theNoise.push_back(static_cast<float>(rmsVal));
99 
100  if (false)
101  cout << " SimpleNoiseCalculator::updateNoise " << theNoiseSum[i] << " " << theNoiseSqSum[i] << " "
102  << theEventPerStrip[i] << " " << avVal << " " << sqAvVal << " " << (sqAvVal - avVal * avVal) << " "
103  << rmsVal << endl;
104  }
105  }
106  updateStatus();
107  }
108 }
bool isUpdating() const
ApvAnalysis::PedestalType theNoise
std::vector< double > theNoiseSum
std::vector< double > theNoiseSqSum
Log< level::Error, false > LogError
ApvAnalysis::PedestalType theCMPSubtractedSignal
TkStateMachine theStatus
T sqrt(T t)
Definition: SSEVec.h:23
bool isCalibrating() const
std::vector< unsigned short > theEventPerStrip

◆ updateStatus()

void SimpleNoiseCalculator::updateStatus ( )
overridevirtual

Member Data Documentation

◆ alreadyUsedEvent

bool SimpleNoiseCalculator::alreadyUsedEvent
protected

Definition at line 41 of file SimpleNoiseCalculator.h.

Referenced by newEvent(), and updateNoise().

◆ eventsRequiredToCalibrate_

int SimpleNoiseCalculator::eventsRequiredToCalibrate_
protected

Definition at line 44 of file SimpleNoiseCalculator.h.

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

◆ numberOfEvents

int SimpleNoiseCalculator::numberOfEvents
protected

Definition at line 40 of file SimpleNoiseCalculator.h.

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

◆ theCMPSubtractedSignal

ApvAnalysis::PedestalType SimpleNoiseCalculator::theCMPSubtractedSignal
protected

Definition at line 37 of file SimpleNoiseCalculator.h.

Referenced by init(), stripCMPSubtractedSignal(), and updateNoise().

◆ theEventPerStrip

std::vector<unsigned short> SimpleNoiseCalculator::theEventPerStrip
protected

Definition at line 39 of file SimpleNoiseCalculator.h.

Referenced by init(), and updateNoise().

◆ theNoise

ApvAnalysis::PedestalType SimpleNoiseCalculator::theNoise
protected

Definition at line 36 of file SimpleNoiseCalculator.h.

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

◆ theNoiseSqSum

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

Definition at line 38 of file SimpleNoiseCalculator.h.

Referenced by init(), and updateNoise().

◆ theNoiseSum

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

Definition at line 38 of file SimpleNoiseCalculator.h.

Referenced by init(), and updateNoise().

◆ useDB_

bool SimpleNoiseCalculator::useDB_
protected

Definition at line 42 of file SimpleNoiseCalculator.h.

Referenced by SimpleNoiseCalculator(), and updateStatus().