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.

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

References gather_cfg::cout, and init().

◆ SimpleNoiseCalculator() [2/2]

SimpleNoiseCalculator::SimpleNoiseCalculator ( int  evnt_ini,
bool  useDB 
)

Definition at line 16 of file SimpleNoiseCalculator.cc.

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 }

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

◆ ~SimpleNoiseCalculator()

SimpleNoiseCalculator::~SimpleNoiseCalculator ( )
override

Definition at line 39 of file SimpleNoiseCalculator.cc.

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

References gather_cfg::cout.

Member Function Documentation

◆ init()

void SimpleNoiseCalculator::init ( void  )
protected

Definition at line 28 of file SimpleNoiseCalculator.cc.

28  {
29  theCMPSubtractedSignal.clear();
30  theNoise.clear();
31  theNoiseSum.clear();
32  theNoiseSqSum.clear();
33  theEventPerStrip.clear();
34  // theStatus.setCalibrating();
35 }

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

Referenced by SimpleNoiseCalculator().

◆ nevents()

int SimpleNoiseCalculator::nevents ( ) const
inline

Definition at line 23 of file SimpleNoiseCalculator.h.

23 { return numberOfEvents; }

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.

112 { alreadyUsedEvent = false; }

References alreadyUsedEvent.

◆ noise()

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

Return reconstructed noise

Implements TkNoiseCalculator.

Definition at line 21 of file SimpleNoiseCalculator.h.

21 { return theNoise; }

References theNoise.

◆ resetNoise()

void SimpleNoiseCalculator::resetNoise ( )
inlineoverridevirtual

Implements TkNoiseCalculator.

Definition at line 26 of file SimpleNoiseCalculator.h.

26 { theNoise.clear(); }

References theNoise.

◆ setStripNoise()

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

Implements TkNoiseCalculator.

Definition at line 17 of file SimpleNoiseCalculator.h.

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

References recoMuon::in, and theNoise.

◆ stripCMPSubtractedSignal()

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

Definition at line 30 of file SimpleNoiseCalculator.h.

30 { return theCMPSubtractedSignal; }

References theCMPSubtractedSignal.

◆ stripNoise()

float SimpleNoiseCalculator::stripNoise ( int  in) const
inlineoverridevirtual

Implements TkNoiseCalculator.

Definition at line 22 of file SimpleNoiseCalculator.h.

22 { return theNoise[in]; }

References recoMuon::in, and theNoise.

◆ updateNoise()

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

Update noise with current event

Implements TkNoiseCalculator.

Definition at line 55 of file SimpleNoiseCalculator.cc.

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 }

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

◆ updateStatus()

void SimpleNoiseCalculator::updateStatus ( )
overridevirtual

Request that status flag be updated

Implements TkNoiseCalculator.

Definition at line 46 of file SimpleNoiseCalculator.cc.

46  {
48  (useDB_ == true && numberOfEvents == 1)) {
50  }
51 }

References eventsRequiredToCalibrate_, TkStateMachine::isCalibrating(), numberOfEvents, TkStateMachine::setUpdating(), TkNoiseCalculator::theStatus, and useDB_.

Referenced by updateNoise().

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

SimpleNoiseCalculator::theEventPerStrip
std::vector< unsigned short > theEventPerStrip
Definition: SimpleNoiseCalculator.h:39
mps_fire.i
i
Definition: mps_fire.py:355
TkStateMachine::setUpdating
void setUpdating()
Definition: TkStateMachine.h:20
SimpleNoiseCalculator::alreadyUsedEvent
bool alreadyUsedEvent
Definition: SimpleNoiseCalculator.h:41
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SimpleNoiseCalculator::theNoiseSqSum
std::vector< double > theNoiseSqSum
Definition: SimpleNoiseCalculator.h:38
SimpleNoiseCalculator::useDB_
bool useDB_
Definition: SimpleNoiseCalculator.h:42
SimpleNoiseCalculator::theCMPSubtractedSignal
ApvAnalysis::PedestalType theCMPSubtractedSignal
Definition: SimpleNoiseCalculator.h:37
SimpleNoiseCalculator::theNoise
ApvAnalysis::PedestalType theNoise
Definition: SimpleNoiseCalculator.h:36
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
SimpleNoiseCalculator::updateStatus
void updateStatus() override
Definition: SimpleNoiseCalculator.cc:46
SimpleNoiseCalculator::init
void init()
Definition: SimpleNoiseCalculator.cc:28
TkStateMachine::isCalibrating
bool isCalibrating() const
Definition: TkStateMachine.h:29
TkNoiseCalculator::theStatus
TkStateMachine theStatus
Definition: TkNoiseCalculator.h:34
edm::LogError
Definition: MessageLogger.h:183
SimpleNoiseCalculator::eventsRequiredToCalibrate_
int eventsRequiredToCalibrate_
Definition: SimpleNoiseCalculator.h:44
recoMuon::in
Definition: RecoMuonEnumerators.h:6
SimpleNoiseCalculator::theNoiseSum
std::vector< double > theNoiseSum
Definition: SimpleNoiseCalculator.h:38
TkStateMachine::isUpdating
bool isUpdating() const
Definition: TkStateMachine.h:28
SimpleNoiseCalculator::numberOfEvents
int numberOfEvents
Definition: SimpleNoiseCalculator.h:40