CMS 3D CMS Logo

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

#include <SimplePedestalCalculator.h>

Inheritance diagram for SimplePedestalCalculator:
TkPedestalCalculator

Public Member Functions

void newEvent () override
 
ApvAnalysis::PedestalType pedestal () const override
 
ApvAnalysis::PedestalType rawNoise () const override
 
void resetPedestals () override
 
void setPedestals (ApvAnalysis::PedestalType &in) override
 
void setRawNoise (ApvAnalysis::PedestalType &in)
 
 SimplePedestalCalculator (int evnt_ini)
 
void updatePedestal (ApvAnalysis::RawSignalType &in) override
 
void updateStatus () override
 
 ~SimplePedestalCalculator () override
 
- Public Member Functions inherited from TkPedestalCalculator
virtual void setNoise (ApvAnalysis::PedestalType &)
 
TkStateMachinestatus ()
 
virtual ~TkPedestalCalculator ()
 

Protected Attributes

bool alreadyUsedEvent
 
int eventsRequiredToCalibrate
 
int numberOfEvents
 
std::vector< unsigned short > theEventPerStrip
 
ApvAnalysis::PedestalType thePedestal
 
std::vector< int > thePedSqSum
 
std::vector< int > thePedSum
 
ApvAnalysis::PedestalType theRawNoise
 
- Protected Attributes inherited from TkPedestalCalculator
TkStateMachine theStatus
 

Private Member Functions

void init ()
 
void initializePedestal (ApvAnalysis::RawSignalType &in)
 
void refinePedestal (ApvAnalysis::RawSignalType &in)
 

Detailed Description

Concrete implementation of TkPedestalCalculator for Simple.

Definition at line 10 of file SimplePedestalCalculator.h.

Constructor & Destructor Documentation

◆ SimplePedestalCalculator()

SimplePedestalCalculator::SimplePedestalCalculator ( int  evnt_ini)

Definition at line 8 of file SimplePedestalCalculator.cc.

References gather_cfg::cout, eventsRequiredToCalibrate, and init().

8  : numberOfEvents(0), alreadyUsedEvent(false) {
9  if (false)
10  cout << "Constructing SimplePedestalCalculator " << endl;
11  eventsRequiredToCalibrate = evnt_ini;
12  // eventsRequiredToUpdate = evnt_iter;
13  // cutToAvoidSignal = sig_cut;
14  init();
15 }

◆ ~SimplePedestalCalculator()

SimplePedestalCalculator::~SimplePedestalCalculator ( )
override

Definition at line 30 of file SimplePedestalCalculator.cc.

References gather_cfg::cout.

30  {
31  if (false)
32  cout << "Destructing SimplePedestalCalculator " << endl;
33 }

Member Function Documentation

◆ init()

void SimplePedestalCalculator::init ( void  )
private

Definition at line 19 of file SimplePedestalCalculator.cc.

References TkStateMachine::setCalibrating(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, theRawNoise, and TkPedestalCalculator::theStatus.

Referenced by SimplePedestalCalculator().

19  {
20  theRawNoise.clear();
21  thePedestal.clear();
22  thePedSum.clear();
23  thePedSqSum.clear();
24  theEventPerStrip.clear();
26 }
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
void setCalibrating()
ApvAnalysis::PedestalType thePedestal

◆ initializePedestal()

void SimplePedestalCalculator::initializePedestal ( ApvAnalysis::RawSignalType in)
private

Definition at line 63 of file SimplePedestalCalculator.cc.

References eventsRequiredToCalibrate, mps_fire::i, cuy::ii, recoMuon::in, numberOfEvents, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by updatePedestal().

63  {
64  if (numberOfEvents == 1) {
65  thePedSum.clear();
66  thePedSqSum.clear();
67  theEventPerStrip.clear();
68 
69  thePedSum.reserve(128);
70  thePedSqSum.reserve(128);
71  theEventPerStrip.reserve(128);
72 
73  thePedSum.resize(in.data.size(), 0);
74  thePedSqSum.resize(in.data.size(), 0);
75  theEventPerStrip.resize(in.data.size(), 0);
76  }
77 
78  //eventsRequiredToCalibrate is considered the minimum number of events to be used
79 
82  int ii = 0;
83  for (; i != in.data.end(); i++) {
84  thePedSum[ii] += (*i).adc();
85  thePedSqSum[ii] += ((*i).adc()) * ((*i).adc());
87  ii++;
88  }
89  }
91  thePedestal.clear();
92  theRawNoise.clear();
94  int ii = 0;
95  for (; i != in.data.end(); i++) {
96  // the pedestal is calculated as int, as required by FED.
97  int avVal = (theEventPerStrip[ii]) ? thePedSum[ii] / theEventPerStrip[ii] : 0;
98 
99  double sqAvVal = (theEventPerStrip[ii]) ? thePedSqSum[ii] / theEventPerStrip[ii] : 0.0;
100  double corr_fac = (theEventPerStrip[ii] > 1) ? (theEventPerStrip[ii] / (theEventPerStrip[ii] - 1)) : 1.0;
101  double rmsVal = (sqAvVal - avVal * avVal > 0.0) ? sqrt(corr_fac * (sqAvVal - avVal * avVal)) : 0.0;
102  thePedestal.push_back(static_cast<float>(avVal));
103  theRawNoise.push_back(static_cast<float>(rmsVal));
104  ii++;
105  }
106  }
107 }
std::vector< unsigned short > theEventPerStrip
T sqrt(T t)
Definition: SSEVec.h:19
ApvAnalysis::PedestalType theRawNoise
ii
Definition: cuy.py:589
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
ApvAnalysis::PedestalType thePedestal

◆ newEvent()

void SimplePedestalCalculator::newEvent ( )
overridevirtual

Return raw noise, determined without CMN subtraction Tell pedestal calculator that a new event is available

Reimplemented from TkPedestalCalculator.

Definition at line 148 of file SimplePedestalCalculator.cc.

References alreadyUsedEvent.

◆ pedestal()

ApvAnalysis::PedestalType SimplePedestalCalculator::pedestal ( ) const
inlineoverridevirtual

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 27 of file SimplePedestalCalculator.h.

References thePedestal.

27 { return thePedestal; }
ApvAnalysis::PedestalType thePedestal

◆ rawNoise()

ApvAnalysis::PedestalType SimplePedestalCalculator::rawNoise ( ) const
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 26 of file SimplePedestalCalculator.h.

References theRawNoise.

26 { return theRawNoise; }
ApvAnalysis::PedestalType theRawNoise

◆ refinePedestal()

void SimplePedestalCalculator::refinePedestal ( ApvAnalysis::RawSignalType in)
private

Definition at line 113 of file SimplePedestalCalculator.cc.

References mps_fire::i, cuy::ii, recoMuon::in, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by updatePedestal().

113  {
114  // keep adding th adc count for any events
115 
116  unsigned int ii = 0;
118  for (; i < in.data.end(); i++) {
119  thePedSum[ii] += (*i).adc();
120  thePedSqSum[ii] += ((*i).adc()) * ((*i).adc());
121  theEventPerStrip[ii]++;
122 
123  ii++;
124  }
125 
126  // calculate a new pedestal any events, so it will come for free when for the last event
127 
128  for (unsigned int iii = 0; iii < in.data.size(); iii++) {
129  if (theEventPerStrip[iii] > 10) {
130  int avVal = (theEventPerStrip[iii]) ? thePedSum[iii] / theEventPerStrip[iii] : 0;
131 
132  double sqAvVal = (theEventPerStrip[iii]) ? thePedSqSum[iii] / theEventPerStrip[iii] : 0.0;
133 
134  double rmsVal = (sqAvVal - avVal * avVal > 0.0) ? sqrt(sqAvVal - avVal * avVal) : 0.0;
135 
136  if (avVal != 0) {
137  thePedestal[iii] = static_cast<float>(avVal);
138  theRawNoise[iii] = static_cast<float>(rmsVal);
139  }
140  }
141  }
142 }
std::vector< unsigned short > theEventPerStrip
T sqrt(T t)
Definition: SSEVec.h:19
ApvAnalysis::PedestalType theRawNoise
ii
Definition: cuy.py:589
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
ApvAnalysis::PedestalType thePedestal

◆ resetPedestals()

void SimplePedestalCalculator::resetPedestals ( )
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 15 of file SimplePedestalCalculator.h.

References thePedestal, and theRawNoise.

15  {
16  thePedestal.clear();
17  theRawNoise.clear();
18  }
ApvAnalysis::PedestalType theRawNoise
ApvAnalysis::PedestalType thePedestal

◆ setPedestals()

void SimplePedestalCalculator::setPedestals ( ApvAnalysis::PedestalType in)
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 19 of file SimplePedestalCalculator.h.

References recoMuon::in, and thePedestal.

19 { thePedestal = in; }
ApvAnalysis::PedestalType thePedestal

◆ setRawNoise()

void SimplePedestalCalculator::setRawNoise ( ApvAnalysis::PedestalType in)
inline

Definition at line 20 of file SimplePedestalCalculator.h.

References recoMuon::in, and theRawNoise.

20 { theRawNoise = in; }
ApvAnalysis::PedestalType theRawNoise

◆ updatePedestal()

void SimplePedestalCalculator::updatePedestal ( ApvAnalysis::RawSignalType in)
overridevirtual

Update pedestals with current event

Implements TkPedestalCalculator.

Definition at line 47 of file SimplePedestalCalculator.cc.

References alreadyUsedEvent, recoMuon::in, initializePedestal(), TkStateMachine::isCalibrating(), TkStateMachine::isUpdating(), numberOfEvents, refinePedestal(), TkPedestalCalculator::theStatus, and updateStatus().

47  {
48  if (alreadyUsedEvent == false) {
49  alreadyUsedEvent = true;
51  if (theStatus.isCalibrating()) {
53  } else if (theStatus.isUpdating()) {
55  }
56  updateStatus();
57  }
58 }
bool isUpdating() const
bool isCalibrating() const
void refinePedestal(ApvAnalysis::RawSignalType &in)
void initializePedestal(ApvAnalysis::RawSignalType &in)

◆ updateStatus()

void SimplePedestalCalculator::updateStatus ( )
overridevirtual

Member Data Documentation

◆ alreadyUsedEvent

bool SimplePedestalCalculator::alreadyUsedEvent
protected

Definition at line 45 of file SimplePedestalCalculator.h.

Referenced by newEvent(), and updatePedestal().

◆ eventsRequiredToCalibrate

int SimplePedestalCalculator::eventsRequiredToCalibrate
protected

◆ numberOfEvents

int SimplePedestalCalculator::numberOfEvents
protected

Definition at line 41 of file SimplePedestalCalculator.h.

Referenced by initializePedestal(), updatePedestal(), and updateStatus().

◆ theEventPerStrip

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

Definition at line 40 of file SimplePedestalCalculator.h.

Referenced by init(), initializePedestal(), and refinePedestal().

◆ thePedestal

ApvAnalysis::PedestalType SimplePedestalCalculator::thePedestal
protected

◆ thePedSqSum

std::vector<int> SimplePedestalCalculator::thePedSqSum
protected

Definition at line 39 of file SimplePedestalCalculator.h.

Referenced by init(), initializePedestal(), and refinePedestal().

◆ thePedSum

std::vector<int> SimplePedestalCalculator::thePedSum
protected

Definition at line 39 of file SimplePedestalCalculator.h.

Referenced by init(), initializePedestal(), and refinePedestal().

◆ theRawNoise

ApvAnalysis::PedestalType SimplePedestalCalculator::theRawNoise
protected