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 ()
 
ApvAnalysis::PedestalType noise () const
 
void resetNoise ()
 
void setStripNoise (ApvAnalysis::PedestalType &in)
 
ApvAnalysis::PedestalType stripCMPSubtractedSignal () const
 
float stripNoise (int in) const
 
 TT6NoiseCalculator ()
 
 TT6NoiseCalculator (int evnt_ini, int evnt_iter, float sig_cut)
 
void updateNoise (ApvAnalysis::PedestalType &in)
 
void updateStatus ()
 
virtual ~TT6NoiseCalculator ()
 
- 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::TT6NoiseCalculator ( )

Definition at line 10 of file TT6NoiseCalculator.cc.

References gather_cfg::cout, and init().

10  :
11  numberOfEvents(0) ,
12  alreadyUsedEvent(false)
13 {
14  if (0) cout << "Constructing TT6NoiseCalculator " << endl;
15  init();
16 }
TT6NoiseCalculator::TT6NoiseCalculator ( int  evnt_ini,
int  evnt_iter,
float  sig_cut 
)

Definition at line 18 of file TT6NoiseCalculator.cc.

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

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

Definition at line 43 of file TT6NoiseCalculator.cc.

References gather_cfg::cout.

43  {
44  if (0) cout << "Destructing TT6NoiseCalculator " << endl;
45 }

Member Function Documentation

void TT6NoiseCalculator::init ( void  )
protected

Definition at line 32 of file TT6NoiseCalculator.cc.

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

Referenced by stripCMPSubtractedSignal(), and TT6NoiseCalculator().

32  {
33  theCMPSubtractedSignal.clear();
34  theNoise.clear();
35  theNoiseSum.clear();
36  theNoiseSqSum.clear();
37  theEventPerStrip.clear();
39 }
TkStateMachine theStatus
std::vector< double > theNoiseSum
std::vector< unsigned short > theEventPerStrip
std::vector< double > theNoiseSqSum
void setCalibrating()
ApvAnalysis::PedestalType theNoise
ApvAnalysis::PedestalType theCMPSubtractedSignal
int TT6NoiseCalculator::nevents ( ) const
inline

Definition at line 22 of file TT6NoiseCalculator.h.

References numberOfEvents, and updateStatus().

void TT6NoiseCalculator::newEvent ( )
virtual

Tell noise calculator that a new event is available

Reimplemented from TkNoiseCalculator.

Definition at line 124 of file TT6NoiseCalculator.cc.

References alreadyUsedEvent.

Referenced by resetNoise().

124  {
125  alreadyUsedEvent = false;
126 }
ApvAnalysis::PedestalType TT6NoiseCalculator::noise ( ) const
inlinevirtual

Return reconstructed noise

Implements TkNoiseCalculator.

Definition at line 20 of file TT6NoiseCalculator.h.

References theNoise.

20 {return theNoise;}
ApvAnalysis::PedestalType theNoise
void TT6NoiseCalculator::resetNoise ( )
inlinevirtual

Implements TkNoiseCalculator.

Definition at line 25 of file TT6NoiseCalculator.h.

References recoMuon::in, newEvent(), theNoise, and updateNoise().

25 {theNoise.clear();}
ApvAnalysis::PedestalType theNoise
void TT6NoiseCalculator::setStripNoise ( ApvAnalysis::PedestalType in)
inlinevirtual

Implements TkNoiseCalculator.

Definition at line 19 of file TT6NoiseCalculator.h.

References recoMuon::in, and theNoise.

19 {theNoise.clear(); theNoise = in;}
ApvAnalysis::PedestalType theNoise
ApvAnalysis::PedestalType TT6NoiseCalculator::stripCMPSubtractedSignal ( ) const
inline

Definition at line 29 of file TT6NoiseCalculator.h.

References init(), and theCMPSubtractedSignal.

30  {return theCMPSubtractedSignal;}
ApvAnalysis::PedestalType theCMPSubtractedSignal
float TT6NoiseCalculator::stripNoise ( int  in) const
inlinevirtual

Implements TkNoiseCalculator.

Definition at line 21 of file TT6NoiseCalculator.h.

References recoMuon::in, and theNoise.

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

Update noise with current event

Implements TkNoiseCalculator.

Definition at line 58 of file TT6NoiseCalculator.cc.

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

Referenced by resetNoise().

58  {
59  if (alreadyUsedEvent == false) {
60  alreadyUsedEvent = true;
62 
63  if (numberOfEvents == 1 && theNoise.size() != in.size()) {
64  edm::LogError("TT6NoiseCalculator:updateNoise") << " You did not initialize the Noise correctly prior to noise calibration.";
65  }
66 
67  // Initialize sums used for estimating noise.
68  if ((theStatus.isCalibrating() && numberOfEvents == 1) ||
70  {
71  theNoiseSum.clear();
72  theNoiseSqSum.clear();
73  theEventPerStrip.clear();
74 
75  theNoiseSum.resize(in.size(),0.0);
76  theNoiseSqSum.resize(in.size(),0.0);
77  theEventPerStrip.resize(in.size(),0);
78  }
79 
80  unsigned int i;
81 
82  // Update sums used for estimating noise.
83  for (i = 0; i < in.size(); i++) {
84  if (fabs(in[i]) < cutToAvoidSignal_*theNoise[i]) {
85  theNoiseSum[i] += in[i];
86  theNoiseSqSum[i] += in[i]*in[i];
88  }
89  }
90 
91  // Calculate noise.
94  {
95  theCMPSubtractedSignal.clear();
96  theNoise.clear();
97 
98  for (i = 0; i < in.size(); i++) {
99  double avVal = (theEventPerStrip[i]) ? theNoiseSum[i]/(theEventPerStrip[i]):0.0;
100  double sqAvVal = (theEventPerStrip[i]) ? theNoiseSqSum[i]/(theEventPerStrip[i]):0.0;
101  double corr_fac = (theEventPerStrip[i] > 1) ? (theEventPerStrip[i]/(theEventPerStrip[i]-1)) : 1.0;
102  double rmsVal = (sqAvVal - avVal*avVal > 0.0) ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0;
103 
104  theCMPSubtractedSignal.push_back(static_cast<float>(avVal));
105 
106  theNoise.push_back(static_cast<float>(rmsVal));
107 
108  if (0) cout << " TT6NoiseCalculator::updateNoise "
109  << theNoiseSum[i] << " "
110  << theNoiseSqSum[i] << " "
111  << theEventPerStrip[i] << " "
112  << avVal << " "
113  << sqAvVal << " "
114  << (sqAvVal - avVal*avVal) << " "
115  << rmsVal << endl;
116  }
117  }
118  updateStatus();
119  }
120 }
TkStateMachine theStatus
std::vector< double > theNoiseSum
std::vector< unsigned short > theEventPerStrip
T sqrt(T t)
Definition: SSEVec.h:18
bool isUpdating() const
std::vector< double > theNoiseSqSum
bool isCalibrating() const
ApvAnalysis::PedestalType theNoise
ApvAnalysis::PedestalType theCMPSubtractedSignal
void TT6NoiseCalculator::updateStatus ( )
virtual

Request that status flag be updated

Implements TkNoiseCalculator.

Definition at line 49 of file TT6NoiseCalculator.cc.

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

Referenced by nevents(), and updateNoise().

49  {
50  if (theStatus.isCalibrating() &&
53  }
54 }
TkStateMachine theStatus
bool isCalibrating() const

Member Data Documentation

bool TT6NoiseCalculator::alreadyUsedEvent
protected

Definition at line 41 of file TT6NoiseCalculator.h.

Referenced by newEvent(), and updateNoise().

float TT6NoiseCalculator::cutToAvoidSignal_
protected

Definition at line 45 of file TT6NoiseCalculator.h.

Referenced by TT6NoiseCalculator(), and updateNoise().

int TT6NoiseCalculator::eventsRequiredToCalibrate_
protected

Definition at line 43 of file TT6NoiseCalculator.h.

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

int TT6NoiseCalculator::eventsRequiredToUpdate_
protected

Definition at line 44 of file TT6NoiseCalculator.h.

Referenced by TT6NoiseCalculator(), and updateNoise().

int TT6NoiseCalculator::numberOfEvents
protected

Definition at line 40 of file TT6NoiseCalculator.h.

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

ApvAnalysis::PedestalType TT6NoiseCalculator::theCMPSubtractedSignal
protected

Definition at line 37 of file TT6NoiseCalculator.h.

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

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

Definition at line 39 of file TT6NoiseCalculator.h.

Referenced by init(), and updateNoise().

ApvAnalysis::PedestalType TT6NoiseCalculator::theNoise
protected

Definition at line 36 of file TT6NoiseCalculator.h.

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

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

Definition at line 38 of file TT6NoiseCalculator.h.

Referenced by init(), and updateNoise().

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

Definition at line 38 of file TT6NoiseCalculator.h.

Referenced by init(), and updateNoise().