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.

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 }

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

◆ ~TT6PedestalCalculator()

TT6PedestalCalculator::~TT6PedestalCalculator ( )
override

Definition at line 30 of file TT6PedestalCalculator.cc.

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

References gather_cfg::cout.

Member Function Documentation

◆ init()

void TT6PedestalCalculator::init ( void  )
private

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

◆ initializePedestal()

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

Definition at line 60 of file TT6PedestalCalculator.cc.

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 }

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

Referenced by updatePedestal().

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

149 { alreadyUsedEvent = false; }

References alreadyUsedEvent.

◆ pedestal()

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

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 27 of file TT6PedestalCalculator.h.

27 { return thePedestal; }

References thePedestal.

◆ rawNoise()

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

Implements TkPedestalCalculator.

Definition at line 26 of file TT6PedestalCalculator.h.

26 { return theRawNoise; }

References theRawNoise.

◆ refinePedestal()

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

Definition at line 104 of file TT6PedestalCalculator.cc.

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 }

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

Referenced by updatePedestal().

◆ resetPedestals()

void TT6PedestalCalculator::resetPedestals ( )
inlineoverridevirtual

Implements TkPedestalCalculator.

Definition at line 15 of file TT6PedestalCalculator.h.

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

References thePedestal, and theRawNoise.

◆ setPedestals()

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

Implements TkPedestalCalculator.

Definition at line 19 of file TT6PedestalCalculator.h.

19 { thePedestal = in; }

References recoMuon::in, and thePedestal.

◆ setRawNoise()

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

Definition at line 20 of file TT6PedestalCalculator.h.

20 { theRawNoise = in; }

References recoMuon::in, and theRawNoise.

◆ updatePedestal()

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

Update pedestals with current event

Implements TkPedestalCalculator.

Definition at line 45 of file TT6PedestalCalculator.cc.

45  {
46  if (alreadyUsedEvent == false) {
47  alreadyUsedEvent = true;
49  if (theStatus.isCalibrating()) {
51  } else if (theStatus.isUpdating()) {
53  }
54  updateStatus();
55  }
56 }

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

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