CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 ()
 
ApvAnalysis::PedestalType pedestal () const
 
ApvAnalysis::PedestalType rawNoise () const
 
void resetPedestals ()
 
void setPedestals (ApvAnalysis::PedestalType &in)
 
void setRawNoise (ApvAnalysis::PedestalType &in)
 
 TT6PedestalCalculator (int evnt_ini, int evnt_iter, float sig_cut)
 
void updatePedestal (ApvAnalysis::RawSignalType &in)
 
void updateStatus ()
 
virtual ~TT6PedestalCalculator ()
 
- 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 (0) cout << "Constructing TT6PedestalCalculator " << endl;
13  eventsRequiredToCalibrate = evnt_ini;
14  eventsRequiredToUpdate = evnt_iter;
15  cutToAvoidSignal = sig_cut;
16  init();
17 }
tuple cout
Definition: gather_cfg.py:121
TT6PedestalCalculator::~TT6PedestalCalculator ( )
virtual

Definition at line 32 of file TT6PedestalCalculator.cc.

References gather_cfg::cout.

32  {
33  if (0) cout << "Destructing TT6PedestalCalculator " << endl;
34 }
tuple cout
Definition: gather_cfg.py:121

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 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, i, numberOfEvents, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by 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());
84  theEventPerStrip[ii]++;
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 }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< double > thePedSum
ApvAnalysis::PedestalType thePedestal
collection_type data
Definition: DetSet.h:79
std::vector< double > thePedSqSum
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
void TT6PedestalCalculator::newEvent ( )
virtual

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.

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

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 30 of file TT6PedestalCalculator.h.

References thePedestal.

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

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, i, numberOfEvents, mathSSE::sqrt(), theEventPerStrip, thePedestal, thePedSqSum, thePedSum, and theRawNoise.

Referenced by 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  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned short > theEventPerStrip
ApvAnalysis::PedestalType theRawNoise
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< double > thePedSum
ApvAnalysis::PedestalType thePedestal
collection_type data
Definition: DetSet.h:79
std::vector< double > thePedSqSum
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
void TT6PedestalCalculator::resetPedestals ( )
inlinevirtual

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

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, and theRawNoise.

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

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

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

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