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::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 }

◆ ~TT6PedestalCalculator()

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 }

Member Function Documentation

◆ init()

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

◆ initializePedestal()

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

Definition at line 60 of file TT6PedestalCalculator.cc.

References eventsRequiredToCalibrate, mps_fire::i, cuy::ii, recoMuon::in, 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 }
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< double > thePedSum
ApvAnalysis::PedestalType thePedestal
ii
Definition: cuy.py:589
std::vector< double > thePedSqSum
collection_type::const_iterator const_iterator
Definition: DetSet.h:31

◆ newEvent()

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.

◆ pedestal()

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

◆ rawNoise()

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

Implements TkPedestalCalculator.

Definition at line 26 of file TT6PedestalCalculator.h.

References theRawNoise.

26 { return theRawNoise; }
ApvAnalysis::PedestalType theRawNoise

◆ refinePedestal()

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

Definition at line 104 of file TT6PedestalCalculator.cc.

References cutToAvoidSignal, eventsRequiredToCalibrate, eventsRequiredToUpdate, mps_fire::i, cuy::ii, recoMuon::in, 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  }
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 }
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< double > thePedSum
ApvAnalysis::PedestalType thePedestal
ii
Definition: cuy.py:589
std::vector< double > thePedSqSum
collection_type::const_iterator const_iterator
Definition: DetSet.h:31

◆ resetPedestals()

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

◆ setPedestals()

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

◆ setRawNoise()

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

◆ updatePedestal()

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

Update pedestals with current event

Implements TkPedestalCalculator.

Definition at line 45 of file TT6PedestalCalculator.cc.

References alreadyUsedEvent, recoMuon::in, 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()) {
53  }
54  updateStatus();
55  }
56 }
bool isUpdating() const
void initializePedestal(ApvAnalysis::RawSignalType &in)
void refinePedestal(ApvAnalysis::RawSignalType &in)
bool isCalibrating() const

◆ updateStatus()

void TT6PedestalCalculator::updateStatus ( )
overridevirtual

Member Data Documentation

◆ alreadyUsedEvent

bool TT6PedestalCalculator::alreadyUsedEvent
protected

Definition at line 45 of file TT6PedestalCalculator.h.

Referenced by newEvent(), and updatePedestal().

◆ cutToAvoidSignal

float TT6PedestalCalculator::cutToAvoidSignal
protected

Definition at line 44 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

◆ eventsRequiredToCalibrate

int TT6PedestalCalculator::eventsRequiredToCalibrate
protected

◆ eventsRequiredToUpdate

int TT6PedestalCalculator::eventsRequiredToUpdate
protected

Definition at line 43 of file TT6PedestalCalculator.h.

Referenced by refinePedestal(), and TT6PedestalCalculator().

◆ numberOfEvents

int TT6PedestalCalculator::numberOfEvents
protected

◆ theEventPerStrip

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

Definition at line 40 of file TT6PedestalCalculator.h.

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

◆ thePedestal

ApvAnalysis::PedestalType TT6PedestalCalculator::thePedestal
protected

◆ thePedSqSum

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

Definition at line 39 of file TT6PedestalCalculator.h.

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

◆ thePedSum

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

Definition at line 39 of file TT6PedestalCalculator.h.

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

◆ theRawNoise

ApvAnalysis::PedestalType TT6PedestalCalculator::theRawNoise
protected