CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  : numberOfEvents(0), alreadyUsedEvent(false) {
9  if (false)
10  cout << "Constructing TT6PedestalCalculator " << endl;
11  eventsRequiredToCalibrate = evnt_ini;
12  eventsRequiredToUpdate = evnt_iter;
13  cutToAvoidSignal = sig_cut;
14  init();
15 }
tuple cout
Definition: gather_cfg.py:144
TT6PedestalCalculator::~TT6PedestalCalculator ( )
override

Definition at line 30 of file TT6PedestalCalculator.cc.

References gather_cfg::cout.

30  {
31  if (false)
32  cout << "Destructing TT6PedestalCalculator " << endl;
33 }
tuple cout
Definition: gather_cfg.py:144

Member Function Documentation

void TT6PedestalCalculator::init ( void  )
private

Definition at line 19 of file TT6PedestalCalculator.cc.

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

Referenced by TT6PedestalCalculator().

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
std::vector< double > thePedSum
ApvAnalysis::PedestalType thePedestal
std::vector< double > thePedSqSum
void setCalibrating()
void TT6PedestalCalculator::initializePedestal ( ApvAnalysis::RawSignalType in)
private

Definition at line 60 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 updatePedestal().

60  {
61  if (numberOfEvents == 1) {
62  thePedSum.clear();
63  thePedSqSum.clear();
64  theEventPerStrip.clear();
65 
66  thePedSum.reserve(128);
67  thePedSqSum.reserve(128);
68  theEventPerStrip.reserve(128);
69 
70  thePedSum.resize(in.data.size(), 0.0);
71  thePedSqSum.resize(in.data.size(), 0.0);
72  theEventPerStrip.resize(in.data.size(), 0);
73  }
76  int ii = 0;
77  for (; i != in.data.end(); i++) {
78  thePedSum[ii] += (*i).adc();
79  thePedSqSum[ii] += ((*i).adc()) * ((*i).adc());
81  ii++;
82  }
83  }
85  thePedestal.clear();
86  theRawNoise.clear();
88  int ii = 0;
89  for (; i != in.data.end(); i++) {
90  double avVal = (theEventPerStrip[ii]) ? thePedSum[ii] / theEventPerStrip[ii] : 0.0;
91  double sqAvVal = (theEventPerStrip[ii]) ? thePedSqSum[ii] / theEventPerStrip[ii] : 0.0;
92  double corr_fac = (theEventPerStrip[ii] > 1) ? (theEventPerStrip[ii] / (theEventPerStrip[ii] - 1)) : 1.0;
93  double rmsVal = (sqAvVal - avVal * avVal > 0.0) ? sqrt(corr_fac * (sqAvVal - avVal * avVal)) : 0.0;
94 
95  thePedestal.push_back(static_cast<float>(avVal));
96  theRawNoise.push_back(static_cast<float>(rmsVal));
97  ii++;
98  }
99  }
100 }
int ii
Definition: cuy.py:589
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< double > thePedSum
ApvAnalysis::PedestalType thePedestal
collection_type data
Definition: DetSet.h:80
std::vector< double > thePedSqSum
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
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 149 of file TT6PedestalCalculator.cc.

References alreadyUsedEvent.

149 { alreadyUsedEvent = false; }
ApvAnalysis::PedestalType TT6PedestalCalculator::pedestal ( ) const
inlineoverridevirtual

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 27 of file TT6PedestalCalculator.h.

References thePedestal.

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

Implements TkPedestalCalculator.

Definition at line 26 of file TT6PedestalCalculator.h.

References theRawNoise.

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

Definition at line 104 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 updatePedestal().

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

Implements TkPedestalCalculator.

Definition at line 15 of file TT6PedestalCalculator.h.

References thePedestal, and theRawNoise.

15  {
16  thePedestal.clear();
17  theRawNoise.clear();
18  }
ApvAnalysis::PedestalType theRawNoise
ApvAnalysis::PedestalType thePedestal
void TT6PedestalCalculator::setPedestals ( ApvAnalysis::PedestalType in)
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 19 of file TT6PedestalCalculator.h.

References recoMuon::in, and thePedestal.

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

Definition at line 20 of file TT6PedestalCalculator.h.

References recoMuon::in, and theRawNoise.

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

Update pedestals with current event

Implements TkPedestalCalculator.

Definition at line 45 of file TT6PedestalCalculator.cc.

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

45  {
46  if (alreadyUsedEvent == false) {
47  alreadyUsedEvent = true;
49  if (theStatus.isCalibrating()) {
51  } else if (theStatus.isUpdating()) {
52  refinePedestal(in);
53  }
54  updateStatus();
55  }
56 }
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 45 of file TT6PedestalCalculator.h.

Referenced by newEvent(), and updatePedestal().

float TT6PedestalCalculator::cutToAvoidSignal
protected

Definition at line 44 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

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

Definition at line 43 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

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

Definition at line 40 of file TT6PedestalCalculator.h.

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

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

Definition at line 39 of file TT6PedestalCalculator.h.

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

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

Definition at line 39 of file TT6PedestalCalculator.h.

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

ApvAnalysis::PedestalType TT6PedestalCalculator::theRawNoise
protected