CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
ApvAnalysis::PedestalType noise () const
 
void resetNoise ()
 
void setStripNoise (ApvAnalysis::PedestalType &in)
 
 SimpleNoiseCalculator ()
 
 SimpleNoiseCalculator (int evnt_ini, bool useDB)
 
ApvAnalysis::PedestalType stripCMPSubtractedSignal () const
 
float stripNoise (int in) const
 
void updateNoise (ApvAnalysis::PedestalType &in)
 
void updateStatus ()
 
virtual ~SimpleNoiseCalculator ()
 
- 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::SimpleNoiseCalculator ( )

Definition at line 10 of file SimpleNoiseCalculator.cc.

References gather_cfg::cout, and init().

10  :
11  numberOfEvents(0) ,
12  alreadyUsedEvent(false)
13 {
14  if (0) cout << "Constructing SimpleNoiseCalculator " << endl;
15  init();
16 }
tuple cout
Definition: gather_cfg.py:121
SimpleNoiseCalculator::SimpleNoiseCalculator ( int  evnt_ini,
bool  useDB 
)

Definition at line 18 of file SimpleNoiseCalculator.cc.

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

18  :
19  numberOfEvents(0) ,
20  alreadyUsedEvent(false)
21 {
22  if (0) cout << "Constructing SimpleNoiseCalculator " << endl;
23  useDB_ = use_DB;
24  eventsRequiredToCalibrate_ = evnt_ini;
25  // eventsRequiredToUpdate_ = evnt_iter;
26  // cutToAvoidSignal_ = sig_cut;
27  init();
28 }
tuple cout
Definition: gather_cfg.py:121
SimpleNoiseCalculator::~SimpleNoiseCalculator ( )
virtual

Definition at line 43 of file SimpleNoiseCalculator.cc.

References gather_cfg::cout.

43  {
44  if (0) cout << "Destructing SimpleNoiseCalculator " << endl;
45 }
tuple cout
Definition: gather_cfg.py:121

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

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

Definition at line 22 of file SimpleNoiseCalculator.h.

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

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

Return reconstructed noise

Implements TkNoiseCalculator.

Definition at line 20 of file SimpleNoiseCalculator.h.

References theNoise.

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

Implements TkNoiseCalculator.

Definition at line 25 of file SimpleNoiseCalculator.h.

References theNoise.

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

Implements TkNoiseCalculator.

Definition at line 19 of file SimpleNoiseCalculator.h.

References recoMuon::in, and theNoise.

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

Definition at line 29 of file SimpleNoiseCalculator.h.

References theCMPSubtractedSignal.

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

Implements TkNoiseCalculator.

Definition at line 21 of file SimpleNoiseCalculator.h.

References recoMuon::in, and theNoise.

21 {return theNoise[in];}
ApvAnalysis::PedestalType theNoise
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().

57  {
58  if (alreadyUsedEvent == false) {
59  alreadyUsedEvent = true;
61 
62  if (numberOfEvents == 1 && theNoise.size() != in.size()) {
63  edm::LogError("SimpleNoiseCalculator:updateNoise") << " You did not initialize the Noise correctly prior to noise calibration.";
64  }
65 
66  // Initialize sums used for estimating noise.
67  if (numberOfEvents == 1)
68  {
69  theNoiseSum.clear();
70  theNoiseSqSum.clear();
71  theEventPerStrip.clear();
72 
73  theNoiseSum.resize(in.size(),0.0);
74  theNoiseSqSum.resize(in.size(),0.0);
75  theEventPerStrip.resize(in.size(),0);
76  }
77 
78  unsigned int i;
79 
80  // At every event Update sums used for estimating noise.
81  for (i = 0; i < in.size(); i++) {
82 
83  theNoiseSum[i] += in[i];
84  theNoiseSqSum[i] += in[i]*in[i];
86  }
87 
88  // Calculate noise.
90  {
91  theCMPSubtractedSignal.clear();
92  theNoise.clear();
93 
94  for (i = 0; i < in.size(); i++) {
95  double avVal = (theEventPerStrip[i])
96  ? theNoiseSum[i]/(theEventPerStrip[i]):0.0;
97  double sqAvVal = (theEventPerStrip[i])
98  ? theNoiseSqSum[i]/(theEventPerStrip[i]):0.0;
99  double corr_fac = (theEventPerStrip[i] > 1)
100  ? (theEventPerStrip[i]/(theEventPerStrip[i]-1)) : 1.0;
101  double rmsVal = (sqAvVal - avVal*avVal > 0.0)
102  ? 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 << " SimpleNoiseCalculator::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 }
int i
Definition: DBlmapReader.cc:9
ApvAnalysis::PedestalType theNoise
std::vector< double > theNoiseSum
std::vector< double > theNoiseSqSum
ApvAnalysis::PedestalType theCMPSubtractedSignal
TkStateMachine theStatus
T sqrt(T t)
Definition: SSEVec.h:46
bool isUpdating() const
std::vector< unsigned short > theEventPerStrip
bool isCalibrating() const
tuple cout
Definition: gather_cfg.py:121
void SimpleNoiseCalculator::updateStatus ( )
virtual

Member Data Documentation

bool SimpleNoiseCalculator::alreadyUsedEvent
protected

Definition at line 41 of file SimpleNoiseCalculator.h.

Referenced by newEvent(), and updateNoise().

int SimpleNoiseCalculator::eventsRequiredToCalibrate_
protected

Definition at line 44 of file SimpleNoiseCalculator.h.

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

int SimpleNoiseCalculator::numberOfEvents
protected

Definition at line 40 of file SimpleNoiseCalculator.h.

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

ApvAnalysis::PedestalType SimpleNoiseCalculator::theCMPSubtractedSignal
protected

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

ApvAnalysis::PedestalType SimpleNoiseCalculator::theNoise
protected

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

bool SimpleNoiseCalculator::useDB_
protected

Definition at line 42 of file SimpleNoiseCalculator.h.

Referenced by SimpleNoiseCalculator(), and updateStatus().