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.

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 }

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

◆ ~SimplePedestalCalculator()

SimplePedestalCalculator::~SimplePedestalCalculator ( )
override

Definition at line 30 of file SimplePedestalCalculator.cc.

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

References gather_cfg::cout.

Member Function Documentation

◆ init()

void SimplePedestalCalculator::init ( void  )
private

Definition at line 19 of file SimplePedestalCalculator.cc.

19  {
20  theRawNoise.clear();
21  thePedestal.clear();
22  thePedSum.clear();
23  thePedSqSum.clear();
24  theEventPerStrip.clear();
26 }

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

Referenced by SimplePedestalCalculator().

◆ initializePedestal()

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

Definition at line 63 of file SimplePedestalCalculator.cc.

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 }

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

Referenced by updatePedestal().

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

148 { alreadyUsedEvent = false; }

References alreadyUsedEvent.

◆ pedestal()

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

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 27 of file SimplePedestalCalculator.h.

27 { return thePedestal; }

References thePedestal.

◆ rawNoise()

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

Implements TkPedestalCalculator.

Definition at line 26 of file SimplePedestalCalculator.h.

26 { return theRawNoise; }

References theRawNoise.

◆ refinePedestal()

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

Definition at line 113 of file SimplePedestalCalculator.cc.

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 }

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

Referenced by updatePedestal().

◆ resetPedestals()

void SimplePedestalCalculator::resetPedestals ( )
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 15 of file SimplePedestalCalculator.h.

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

References thePedestal, and theRawNoise.

◆ setPedestals()

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

Implements TkPedestalCalculator.

Definition at line 19 of file SimplePedestalCalculator.h.

19 { thePedestal = in; }

References recoMuon::in, and thePedestal.

◆ setRawNoise()

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

Definition at line 20 of file SimplePedestalCalculator.h.

20 { theRawNoise = in; }

References recoMuon::in, and theRawNoise.

◆ updatePedestal()

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

Update pedestals with current event

Implements TkPedestalCalculator.

Definition at line 47 of file SimplePedestalCalculator.cc.

47  {
48  if (alreadyUsedEvent == false) {
49  alreadyUsedEvent = true;
51  if (theStatus.isCalibrating()) {
53  } else if (theStatus.isUpdating()) {
55  }
56  updateStatus();
57  }
58 }

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

◆ 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
SimplePedestalCalculator::init
void init()
Definition: SimplePedestalCalculator.cc:19
mps_fire.i
i
Definition: mps_fire.py:428
TkStateMachine::setUpdating
void setUpdating()
Definition: TkStateMachine.h:20
SimplePedestalCalculator::thePedestal
ApvAnalysis::PedestalType thePedestal
Definition: SimplePedestalCalculator.h:37
SimplePedestalCalculator::refinePedestal
void refinePedestal(ApvAnalysis::RawSignalType &in)
Definition: SimplePedestalCalculator.cc:113
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SimplePedestalCalculator::updateStatus
void updateStatus() override
Definition: SimplePedestalCalculator.cc:38
TkPedestalCalculator::theStatus
TkStateMachine theStatus
Definition: TkPedestalCalculator.h:41
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
SimplePedestalCalculator::thePedSqSum
std::vector< int > thePedSqSum
Definition: SimplePedestalCalculator.h:39
TkStateMachine::isCalibrating
bool isCalibrating() const
Definition: TkStateMachine.h:29
recoMuon::in
Definition: RecoMuonEnumerators.h:6
SimplePedestalCalculator::numberOfEvents
int numberOfEvents
Definition: SimplePedestalCalculator.h:41
SimplePedestalCalculator::theEventPerStrip
std::vector< unsigned short > theEventPerStrip
Definition: SimplePedestalCalculator.h:40
TkStateMachine::isUpdating
bool isUpdating() const
Definition: TkStateMachine.h:28
TkStateMachine::setCalibrating
void setCalibrating()
Definition: TkStateMachine.h:21
SimplePedestalCalculator::thePedSum
std::vector< int > thePedSum
Definition: SimplePedestalCalculator.h:39
SimplePedestalCalculator::theRawNoise
ApvAnalysis::PedestalType theRawNoise
Definition: SimplePedestalCalculator.h:38
SimplePedestalCalculator::alreadyUsedEvent
bool alreadyUsedEvent
Definition: SimplePedestalCalculator.h:45
SimplePedestalCalculator::eventsRequiredToCalibrate
int eventsRequiredToCalibrate
Definition: SimplePedestalCalculator.h:42
cuy.ii
ii
Definition: cuy.py:589
SimplePedestalCalculator::initializePedestal
void initializePedestal(ApvAnalysis::RawSignalType &in)
Definition: SimplePedestalCalculator.cc:63
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31