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 ( int  evnt_ini)

Definition at line 8 of file SimplePedestalCalculator.cc.

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

8  :
10  alreadyUsedEvent(false)
11 {
12  if (false) cout << "Constructing SimplePedestalCalculator " << endl;
13  eventsRequiredToCalibrate = evnt_ini;
14  // eventsRequiredToUpdate = evnt_iter;
15  // cutToAvoidSignal = sig_cut;
16  init();
17 }
SimplePedestalCalculator::~SimplePedestalCalculator ( )
override

Definition at line 33 of file SimplePedestalCalculator.cc.

References gather_cfg::cout.

33  {
34  if (false) cout << "Destructing SimplePedestalCalculator " << endl;
35 }

Member Function Documentation

void SimplePedestalCalculator::init ( void  )
private

Definition at line 21 of file SimplePedestalCalculator.cc.

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

Referenced by pedestal(), and SimplePedestalCalculator().

21  {
22  theRawNoise.clear();
23  thePedestal.clear();
24  thePedSum.clear();
25  thePedSqSum.clear();
26  theEventPerStrip.clear();
28 
29 }
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
void setCalibrating()
ApvAnalysis::PedestalType thePedestal
void SimplePedestalCalculator::initializePedestal ( ApvAnalysis::RawSignalType in)
private

Definition at line 71 of file SimplePedestalCalculator.cc.

References edm::DetSet< T >::data, eventsRequiredToCalibrate, mps_fire::i, cuy::ii, numberOfEvents, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by pedestal(), and updatePedestal().

71  {
72  if (numberOfEvents == 1) {
73 
74  thePedSum.clear();
75  thePedSqSum.clear();
76  theEventPerStrip.clear();
77 
78  thePedSum.reserve(128);
79  thePedSqSum.reserve(128);
80  theEventPerStrip.reserve(128);
81 
82  thePedSum.resize(in.data.size(), 0);
83  thePedSqSum.resize(in.data.size(), 0);
84  theEventPerStrip.resize(in.data.size(),0);
85  }
86 
87  //eventsRequiredToCalibrate is considered the minimum number of events to be used
88 
91  int ii=0;
92  for (;i!=in.data.end() ; i++) {
93  thePedSum[ii] += (*i).adc();
94  thePedSqSum[ii] += ((*i).adc())*((*i).adc());
96  ii++;
97  }
98  }
100  thePedestal.clear();
101  theRawNoise.clear();
103  int ii=0;
104  for (;i!=in.data.end() ; i++) {
105 
106 
107  // the pedestal is calculated as int, as required by FED.
108  int avVal = (theEventPerStrip[ii])
109  ? thePedSum[ii]/theEventPerStrip[ii]:0;
110 
111  double sqAvVal = (theEventPerStrip[ii])
112  ? thePedSqSum[ii]/theEventPerStrip[ii]:0.0;
113  double corr_fac = (theEventPerStrip[ii] > 1)
114  ? (theEventPerStrip[ii]/(theEventPerStrip[ii]-1)) : 1.0;
115  double rmsVal = (sqAvVal - avVal*avVal > 0.0)
116  ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0;
117  thePedestal.push_back(static_cast<float>(avVal));
118  theRawNoise.push_back(static_cast<float>(rmsVal));
119  ii++;
120  }
121 
122  }
123 }
std::vector< unsigned short > theEventPerStrip
T sqrt(T t)
Definition: SSEVec.h:18
ApvAnalysis::PedestalType theRawNoise
ii
Definition: cuy.py:589
collection_type data
Definition: DetSet.h:78
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
ApvAnalysis::PedestalType thePedestal
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 177 of file SimplePedestalCalculator.cc.

References alreadyUsedEvent.

Referenced by pedestal().

177  {
178  alreadyUsedEvent = false;
179 }
ApvAnalysis::PedestalType SimplePedestalCalculator::pedestal ( ) const
inlineoverridevirtual

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 30 of file SimplePedestalCalculator.h.

References init(), initializePedestal(), newEvent(), refinePedestal(), and thePedestal.

30 { return thePedestal;}
ApvAnalysis::PedestalType thePedestal
ApvAnalysis::PedestalType SimplePedestalCalculator::rawNoise ( ) const
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 29 of file SimplePedestalCalculator.h.

References theRawNoise.

29 { return theRawNoise;}
ApvAnalysis::PedestalType theRawNoise
void SimplePedestalCalculator::refinePedestal ( ApvAnalysis::RawSignalType in)
private

Definition at line 129 of file SimplePedestalCalculator.cc.

References edm::DetSet< T >::data, mps_fire::i, cuy::ii, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by pedestal(), and updatePedestal().

129  {
130 
131 
132  // keep adding th adc count for any events
133 
134  unsigned int ii=0;
136  for (; i < in.data.end(); i++) {
137 
138  thePedSum[ii] += (*i).adc();
139  thePedSqSum[ii] += ((*i).adc())*((*i).adc());
140  theEventPerStrip[ii]++;
141 
142  ii++;
143  }
144 
145 
146  // calculate a new pedestal any events, so it will come for free when for the last event
147 
148  for (unsigned int iii = 0; iii < in.data.size(); iii++) {
149  if (theEventPerStrip[iii] > 10 ) {
150  int avVal = (theEventPerStrip[iii])
151  ? thePedSum[iii]/theEventPerStrip[iii]:0;
152 
153  double sqAvVal = (theEventPerStrip[iii])
154  ? thePedSqSum[iii]/theEventPerStrip[iii]:0.0;
155 
156  double rmsVal = (sqAvVal - avVal*avVal > 0.0)
157  ? sqrt(sqAvVal - avVal*avVal) : 0.0;
158 
159 
160  if (avVal != 0 ) {
161  thePedestal[iii] = static_cast<float>(avVal);
162  theRawNoise[iii] = static_cast<float>(rmsVal);
163  }
164  }
165  }
166 
167 }
std::vector< unsigned short > theEventPerStrip
T sqrt(T t)
Definition: SSEVec.h:18
ApvAnalysis::PedestalType theRawNoise
ii
Definition: cuy.py:589
collection_type data
Definition: DetSet.h:78
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
ApvAnalysis::PedestalType thePedestal
void SimplePedestalCalculator::resetPedestals ( )
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 18 of file SimplePedestalCalculator.h.

References thePedestal, and theRawNoise.

18  {
19  thePedestal.clear();
20  theRawNoise.clear();
21  }
ApvAnalysis::PedestalType theRawNoise
ApvAnalysis::PedestalType thePedestal
void SimplePedestalCalculator::setPedestals ( ApvAnalysis::PedestalType in)
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 22 of file SimplePedestalCalculator.h.

References recoMuon::in, and thePedestal.

void SimplePedestalCalculator::setRawNoise ( ApvAnalysis::PedestalType in)
inline
void SimplePedestalCalculator::updatePedestal ( ApvAnalysis::RawSignalType in)
overridevirtual

Update pedestals with current event

Implements TkPedestalCalculator.

Definition at line 52 of file SimplePedestalCalculator.cc.

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

Referenced by setRawNoise().

52  {
53 
54  if (alreadyUsedEvent == false) {
55  alreadyUsedEvent = true;
57  if (theStatus.isCalibrating()) {
59  } else if (theStatus.isUpdating()) {
60  refinePedestal(in);
61  }
62  updateStatus();
63  }
64 
65 
66 }
bool isUpdating() const
bool isCalibrating() const
void refinePedestal(ApvAnalysis::RawSignalType &in)
void initializePedestal(ApvAnalysis::RawSignalType &in)
void SimplePedestalCalculator::updateStatus ( )
overridevirtual

Member Data Documentation

bool SimplePedestalCalculator::alreadyUsedEvent
protected

Definition at line 49 of file SimplePedestalCalculator.h.

Referenced by newEvent(), and updatePedestal().

int SimplePedestalCalculator::eventsRequiredToCalibrate
protected
int SimplePedestalCalculator::numberOfEvents
protected

Definition at line 45 of file SimplePedestalCalculator.h.

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

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

Definition at line 44 of file SimplePedestalCalculator.h.

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

ApvAnalysis::PedestalType SimplePedestalCalculator::thePedestal
protected
std::vector<int> SimplePedestalCalculator::thePedSqSum
protected

Definition at line 43 of file SimplePedestalCalculator.h.

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

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

Definition at line 43 of file SimplePedestalCalculator.h.

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

ApvAnalysis::PedestalType SimplePedestalCalculator::theRawNoise
protected