CMS 3D CMS Logo

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

#include <TT6PedestalCalculator.h>

Inheritance diagram for TT6PedestalCalculator:
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)
 
 TT6PedestalCalculator (int evnt_ini, int evnt_iter, float sig_cut)
 
void updatePedestal (ApvAnalysis::RawSignalType &in) override
 
void updateStatus () override
 
 ~TT6PedestalCalculator () override
 
- Public Member Functions inherited from TkPedestalCalculator
virtual void setNoise (ApvAnalysis::PedestalType &)
 
TkStateMachinestatus ()
 
virtual ~TkPedestalCalculator ()
 

Protected Attributes

bool alreadyUsedEvent
 
float cutToAvoidSignal
 
int eventsRequiredToCalibrate
 
int eventsRequiredToUpdate
 
int numberOfEvents
 
std::vector< unsigned short > theEventPerStrip
 
ApvAnalysis::PedestalType thePedestal
 
std::vector< double > thePedSqSum
 
std::vector< double > 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 TT6.

Definition at line 10 of file TT6PedestalCalculator.h.

Constructor & Destructor Documentation

TT6PedestalCalculator::TT6PedestalCalculator ( int  evnt_ini,
int  evnt_iter,
float  sig_cut 
)

Definition at line 7 of file TT6PedestalCalculator.cc.

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

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

Definition at line 32 of file TT6PedestalCalculator.cc.

References gather_cfg::cout.

32  {
33  if (false) cout << "Destructing TT6PedestalCalculator " << endl;
34 }

Member Function Documentation

void TT6PedestalCalculator::init ( void  )
private

Definition at line 21 of file TT6PedestalCalculator.cc.

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

Referenced by pedestal(), and TT6PedestalCalculator().

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

Definition at line 63 of file TT6PedestalCalculator.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().

63  {
64  if (numberOfEvents == 1) {
65 
66  thePedSum.clear();
67  thePedSqSum.clear();
68  theEventPerStrip.clear();
69 
70  thePedSum.reserve(128);
71  thePedSqSum.reserve(128);
72  theEventPerStrip.reserve(128);
73 
74  thePedSum.resize(in.data.size(), 0.0);
75  thePedSqSum.resize(in.data.size(), 0.0);
76  theEventPerStrip.resize(in.data.size(), 0);
77  }
80  int ii=0;
81  for (;i!=in.data.end() ; i++) {
82  thePedSum[ii] += (*i).adc();
83  thePedSqSum[ii] += ((*i).adc())*((*i).adc());
85  ii++;
86  }
87  }
89  thePedestal.clear();
90  theRawNoise.clear();
92  int ii=0;
93  for (;i!=in.data.end() ; i++) {
94  double avVal = (theEventPerStrip[ii]) ? thePedSum[ii]/theEventPerStrip[ii]:0.0;
95  double sqAvVal = (theEventPerStrip[ii]) ? thePedSqSum[ii]/theEventPerStrip[ii]:0.0;
96  double corr_fac = (theEventPerStrip[ii] > 1) ? (theEventPerStrip[ii]/(theEventPerStrip[ii]-1)) : 1.0;
97  double rmsVal = (sqAvVal - avVal*avVal > 0.0) ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0;
98 
99  thePedestal.push_back(static_cast<float>(avVal));
100  theRawNoise.push_back(static_cast<float>(rmsVal));
101  ii++;
102  }
103  }
104 }
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< double > thePedSum
ApvAnalysis::PedestalType thePedestal
ii
Definition: cuy.py:590
collection_type data
Definition: DetSet.h:78
std::vector< double > thePedSqSum
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
void TT6PedestalCalculator::newEvent ( )
overridevirtual

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

Reimplemented from TkPedestalCalculator.

Definition at line 156 of file TT6PedestalCalculator.cc.

References alreadyUsedEvent.

Referenced by pedestal().

156  {
157  alreadyUsedEvent = false;
158 }
ApvAnalysis::PedestalType TT6PedestalCalculator::pedestal ( ) const
inlineoverridevirtual

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 30 of file TT6PedestalCalculator.h.

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

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

Implements TkPedestalCalculator.

Definition at line 29 of file TT6PedestalCalculator.h.

References theRawNoise.

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

Definition at line 108 of file TT6PedestalCalculator.cc.

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

Referenced by pedestal(), and updatePedestal().

108  {
110 
111  thePedSum.clear();
112  thePedSqSum.clear();
113  theEventPerStrip.clear();
114 
115  thePedSum.reserve(128);
116  thePedSqSum.reserve(128);
117  theEventPerStrip.reserve(128);
118 
119  thePedSum.resize(in.data.size(), 0.0);
120  thePedSqSum.resize(in.data.size(), 0.0);
121  theEventPerStrip.resize(in.data.size(), 0);
122  }
123  unsigned int ii=0;
125  for (; i < in.data.end(); i++) {
126  if (fabs((*i).adc()-thePedestal[ii]) < cutToAvoidSignal*theRawNoise[ii]) {
127  thePedSum[ii] += (*i).adc();
128  thePedSqSum[ii] += ((*i).adc())*((*i).adc());
129  theEventPerStrip[ii]++;
130  }
131  ii++;
132  }
133  if (((numberOfEvents-eventsRequiredToCalibrate) % eventsRequiredToUpdate) == 0) {
134 
135  for (unsigned int iii = 0; iii < in.data.size(); iii++) {
136  if (theEventPerStrip[iii] > 10 ) {
137  double avVal = (theEventPerStrip[iii]) ? thePedSum[iii]/theEventPerStrip[iii]:0.0;
138  double sqAvVal = (theEventPerStrip[iii]) ? thePedSqSum[iii]/theEventPerStrip[iii]:0.0;
139  double rmsVal = (sqAvVal - avVal*avVal > 0.0) ? sqrt(sqAvVal - avVal*avVal) : 0.0;
140 
141 
142  if (avVal != 0 ) {
143  thePedestal[iii] = static_cast<float>(avVal);
144  theRawNoise[iii] = static_cast<float>(rmsVal);
145  }
146  }
147  }
148  thePedSum.clear();
149  thePedSqSum.clear();
150  theEventPerStrip.clear();
151  }
152  }
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< double > thePedSum
ApvAnalysis::PedestalType thePedestal
ii
Definition: cuy.py:590
collection_type data
Definition: DetSet.h:78
std::vector< double > thePedSqSum
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
void TT6PedestalCalculator::resetPedestals ( )
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 18 of file TT6PedestalCalculator.h.

References thePedestal, and theRawNoise.

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

Implements TkPedestalCalculator.

Definition at line 22 of file TT6PedestalCalculator.h.

References recoMuon::in, and thePedestal.

22 {thePedestal=in;}
ApvAnalysis::PedestalType thePedestal
void TT6PedestalCalculator::setRawNoise ( ApvAnalysis::PedestalType in)
inline

Definition at line 23 of file TT6PedestalCalculator.h.

References recoMuon::in, theRawNoise, updatePedestal(), and updateStatus().

23 {theRawNoise=in;}
ApvAnalysis::PedestalType theRawNoise
void TT6PedestalCalculator::updatePedestal ( ApvAnalysis::RawSignalType in)
overridevirtual

Update pedestals with current event

Implements TkPedestalCalculator.

Definition at line 48 of file TT6PedestalCalculator.cc.

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

Referenced by setRawNoise().

48  {
49  if (alreadyUsedEvent == false) {
50  alreadyUsedEvent = true;
52  if (theStatus.isCalibrating()) {
54  } else if (theStatus.isUpdating()) {
55  refinePedestal(in);
56  }
57  updateStatus();
58  }
59 }
void initializePedestal(ApvAnalysis::RawSignalType &in)
void refinePedestal(ApvAnalysis::RawSignalType &in)
bool isUpdating() const
bool isCalibrating() const
void TT6PedestalCalculator::updateStatus ( )
overridevirtual

Member Data Documentation

bool TT6PedestalCalculator::alreadyUsedEvent
protected

Definition at line 49 of file TT6PedestalCalculator.h.

Referenced by newEvent(), and updatePedestal().

float TT6PedestalCalculator::cutToAvoidSignal
protected

Definition at line 48 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

int TT6PedestalCalculator::eventsRequiredToCalibrate
protected
int TT6PedestalCalculator::eventsRequiredToUpdate
protected

Definition at line 47 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

int TT6PedestalCalculator::numberOfEvents
protected
std::vector<unsigned short> TT6PedestalCalculator::theEventPerStrip
protected

Definition at line 44 of file TT6PedestalCalculator.h.

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

ApvAnalysis::PedestalType TT6PedestalCalculator::thePedestal
protected
std::vector<double> TT6PedestalCalculator::thePedSqSum
protected

Definition at line 43 of file TT6PedestalCalculator.h.

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

std::vector<double> TT6PedestalCalculator::thePedSum
protected

Definition at line 43 of file TT6PedestalCalculator.h.

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

ApvAnalysis::PedestalType TT6PedestalCalculator::theRawNoise
protected