CMS 3D CMS Logo

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

#include <TT6NoiseCalculator.h>

Inheritance diagram for TT6NoiseCalculator:
TkNoiseCalculator

Public Member Functions

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

Protected Member Functions

void init ()
 

Protected Attributes

bool alreadyUsedEvent
 
float cutToAvoidSignal_
 
int eventsRequiredToCalibrate_
 
int eventsRequiredToUpdate_
 
int numberOfEvents
 
ApvAnalysis::PedestalType theCMPSubtractedSignal
 
std::vector< unsigned short > theEventPerStrip
 
ApvAnalysis::PedestalType theNoise
 
std::vector< double > theNoiseSqSum
 
std::vector< double > theNoiseSum
 
- Protected Attributes inherited from TkNoiseCalculator
TkStateMachine theStatus
 

Detailed Description

Concrete implementation of TkNoiseCalculator for TT6.

Definition at line 9 of file TT6NoiseCalculator.h.

Constructor & Destructor Documentation

◆ TT6NoiseCalculator() [1/2]

TT6NoiseCalculator::TT6NoiseCalculator ( )

Definition at line 10 of file TT6NoiseCalculator.cc.

References gather_cfg::cout, and init().

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

◆ TT6NoiseCalculator() [2/2]

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

Definition at line 16 of file TT6NoiseCalculator.cc.

References gather_cfg::cout, cutToAvoidSignal_, eventsRequiredToCalibrate_, eventsRequiredToUpdate_, and init().

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

◆ ~TT6NoiseCalculator()

TT6NoiseCalculator::~TT6NoiseCalculator ( )
override

Definition at line 39 of file TT6NoiseCalculator.cc.

References gather_cfg::cout.

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

Member Function Documentation

◆ init()

void TT6NoiseCalculator::init ( void  )
protected

Definition at line 28 of file TT6NoiseCalculator.cc.

References TkStateMachine::setCalibrating(), theCMPSubtractedSignal, theEventPerStrip, theNoise, theNoiseSqSum, theNoiseSum, and TkNoiseCalculator::theStatus.

Referenced by TT6NoiseCalculator().

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

◆ nevents()

int TT6NoiseCalculator::nevents ( ) const
inline

Definition at line 23 of file TT6NoiseCalculator.h.

References numberOfEvents.

23 { return numberOfEvents; }

◆ newEvent()

void TT6NoiseCalculator::newEvent ( )
overridevirtual

Tell noise calculator that a new event is available

Reimplemented from TkNoiseCalculator.

Definition at line 115 of file TT6NoiseCalculator.cc.

References alreadyUsedEvent.

115 { alreadyUsedEvent = false; }

◆ noise()

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

Return reconstructed noise

Implements TkNoiseCalculator.

Definition at line 21 of file TT6NoiseCalculator.h.

References theNoise.

21 { return theNoise; }
ApvAnalysis::PedestalType theNoise

◆ resetNoise()

void TT6NoiseCalculator::resetNoise ( )
inlineoverridevirtual

Implements TkNoiseCalculator.

Definition at line 26 of file TT6NoiseCalculator.h.

References theNoise.

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

◆ setStripNoise()

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

Implements TkNoiseCalculator.

Definition at line 17 of file TT6NoiseCalculator.h.

References recoMuon::in, and theNoise.

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

◆ stripCMPSubtractedSignal()

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

Definition at line 30 of file TT6NoiseCalculator.h.

References theCMPSubtractedSignal.

30 { return theCMPSubtractedSignal; }
ApvAnalysis::PedestalType theCMPSubtractedSignal

◆ stripNoise()

float TT6NoiseCalculator::stripNoise ( int  in) const
inlineoverridevirtual

Implements TkNoiseCalculator.

Definition at line 22 of file TT6NoiseCalculator.h.

References recoMuon::in, and theNoise.

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

◆ updateNoise()

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

Update noise with current event

Implements TkNoiseCalculator.

Definition at line 54 of file TT6NoiseCalculator.cc.

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

54  {
55  if (alreadyUsedEvent == false) {
56  alreadyUsedEvent = true;
58 
59  if (numberOfEvents == 1 && theNoise.size() != in.size()) {
60  edm::LogError("TT6NoiseCalculator:updateNoise")
61  << " You did not initialize the Noise correctly prior to noise calibration.";
62  }
63 
64  // Initialize sums used for estimating noise.
65  if ((theStatus.isCalibrating() && 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  // Update sums used for estimating noise.
79  for (i = 0; i < in.size(); i++) {
80  if (fabs(in[i]) < cutToAvoidSignal_ * theNoise[i]) {
81  theNoiseSum[i] += in[i];
82  theNoiseSqSum[i] += in[i] * in[i];
84  }
85  }
86 
87  // Calculate noise.
90  theCMPSubtractedSignal.clear();
91  theNoise.clear();
92 
93  for (i = 0; i < in.size(); i++) {
94  double avVal = (theEventPerStrip[i]) ? theNoiseSum[i] / (theEventPerStrip[i]) : 0.0;
95  double sqAvVal = (theEventPerStrip[i]) ? theNoiseSqSum[i] / (theEventPerStrip[i]) : 0.0;
96  double corr_fac = (theEventPerStrip[i] > 1) ? (theEventPerStrip[i] / (theEventPerStrip[i] - 1)) : 1.0;
97  double rmsVal = (sqAvVal - avVal * avVal > 0.0) ? sqrt(corr_fac * (sqAvVal - avVal * avVal)) : 0.0;
98 
99  theCMPSubtractedSignal.push_back(static_cast<float>(avVal));
100 
101  theNoise.push_back(static_cast<float>(rmsVal));
102 
103  if (false)
104  cout << " TT6NoiseCalculator::updateNoise " << theNoiseSum[i] << " " << theNoiseSqSum[i] << " "
105  << theEventPerStrip[i] << " " << avVal << " " << sqAvVal << " " << (sqAvVal - avVal * avVal) << " "
106  << rmsVal << endl;
107  }
108  }
109  updateStatus();
110  }
111 }
bool isUpdating() const
Log< level::Error, false > LogError
TkStateMachine theStatus
std::vector< double > theNoiseSum
std::vector< unsigned short > theEventPerStrip
T sqrt(T t)
Definition: SSEVec.h:23
bool isCalibrating() const
std::vector< double > theNoiseSqSum
ApvAnalysis::PedestalType theNoise
ApvAnalysis::PedestalType theCMPSubtractedSignal
void updateStatus() override

◆ updateStatus()

void TT6NoiseCalculator::updateStatus ( )
overridevirtual

Member Data Documentation

◆ alreadyUsedEvent

bool TT6NoiseCalculator::alreadyUsedEvent
protected

Definition at line 41 of file TT6NoiseCalculator.h.

Referenced by newEvent(), and updateNoise().

◆ cutToAvoidSignal_

float TT6NoiseCalculator::cutToAvoidSignal_
protected

Definition at line 45 of file TT6NoiseCalculator.h.

Referenced by TT6NoiseCalculator(), and updateNoise().

◆ eventsRequiredToCalibrate_

int TT6NoiseCalculator::eventsRequiredToCalibrate_
protected

Definition at line 43 of file TT6NoiseCalculator.h.

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

◆ eventsRequiredToUpdate_

int TT6NoiseCalculator::eventsRequiredToUpdate_
protected

Definition at line 44 of file TT6NoiseCalculator.h.

Referenced by TT6NoiseCalculator(), and updateNoise().

◆ numberOfEvents

int TT6NoiseCalculator::numberOfEvents
protected

Definition at line 40 of file TT6NoiseCalculator.h.

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

◆ theCMPSubtractedSignal

ApvAnalysis::PedestalType TT6NoiseCalculator::theCMPSubtractedSignal
protected

Definition at line 37 of file TT6NoiseCalculator.h.

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

◆ theEventPerStrip

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

Definition at line 39 of file TT6NoiseCalculator.h.

Referenced by init(), and updateNoise().

◆ theNoise

ApvAnalysis::PedestalType TT6NoiseCalculator::theNoise
protected

Definition at line 36 of file TT6NoiseCalculator.h.

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

◆ theNoiseSqSum

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

Definition at line 38 of file TT6NoiseCalculator.h.

Referenced by init(), and updateNoise().

◆ theNoiseSum

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

Definition at line 38 of file TT6NoiseCalculator.h.

Referenced by init(), and updateNoise().