CMS 3D CMS Logo

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

#include <SimplePedestalCalculator.h>

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

Protected Attributes

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

Definition at line 10 of file SimplePedestalCalculator.h.

Constructor & Destructor Documentation

SimplePedestalCalculator::SimplePedestalCalculator ( int  evnt_ini)

Definition at line 9 of file SimplePedestalCalculator.cc.

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

9  :
10  numberOfEvents(0),
11  alreadyUsedEvent(false)
12 {
13  if (0) cout << "Constructing SimplePedestalCalculator " << endl;
14  eventsRequiredToCalibrate = evnt_ini;
15  // eventsRequiredToUpdate = evnt_iter;
16  // cutToAvoidSignal = sig_cut;
17  init();
18 }
SimplePedestalCalculator::~SimplePedestalCalculator ( )
virtual

Definition at line 34 of file SimplePedestalCalculator.cc.

References gather_cfg::cout.

34  {
35  if (0) cout << "Destructing SimplePedestalCalculator " << endl;
36 }

Member Function Documentation

void SimplePedestalCalculator::init ( void  )
private

Definition at line 22 of file SimplePedestalCalculator.cc.

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

Referenced by pedestal(), and SimplePedestalCalculator().

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

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

72  {
73  if (numberOfEvents == 1) {
74 
75  thePedSum.clear();
76  thePedSqSum.clear();
77  theEventPerStrip.clear();
78 
79  thePedSum.reserve(128);
80  thePedSqSum.reserve(128);
81  theEventPerStrip.reserve(128);
82 
83  thePedSum.resize(in.data.size(), 0);
84  thePedSqSum.resize(in.data.size(), 0);
85  theEventPerStrip.resize(in.data.size(),0);
86  }
87 
88  //eventsRequiredToCalibrate is considered the minimum number of events to be used
89 
92  int ii=0;
93  for (;i!=in.data.end() ; i++) {
94  thePedSum[ii] += (*i).adc();
95  thePedSqSum[ii] += ((*i).adc())*((*i).adc());
97  ii++;
98  }
99  }
101  thePedestal.clear();
102  theRawNoise.clear();
104  int ii=0;
105  for (;i!=in.data.end() ; i++) {
106 
107 
108  // the pedestal is calculated as int, as required by FED.
109  int avVal = (theEventPerStrip[ii])
110  ? thePedSum[ii]/theEventPerStrip[ii]:0;
111 
112  double sqAvVal = (theEventPerStrip[ii])
113  ? thePedSqSum[ii]/theEventPerStrip[ii]:0.0;
114  double corr_fac = (theEventPerStrip[ii] > 1)
115  ? (theEventPerStrip[ii]/(theEventPerStrip[ii]-1)) : 1.0;
116  double rmsVal = (sqAvVal - avVal*avVal > 0.0)
117  ? sqrt(corr_fac * (sqAvVal - avVal*avVal)) : 0.0;
118  thePedestal.push_back(static_cast<float>(avVal));
119  theRawNoise.push_back(static_cast<float>(rmsVal));
120  ii++;
121  }
122 
123  }
124 }
std::vector< unsigned short > theEventPerStrip
T sqrt(T t)
Definition: SSEVec.h:18
ApvAnalysis::PedestalType theRawNoise
ii
Definition: cuy.py:588
collection_type data
Definition: DetSet.h:78
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
ApvAnalysis::PedestalType thePedestal
void SimplePedestalCalculator::newEvent ( )
virtual

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

Reimplemented from TkPedestalCalculator.

Definition at line 178 of file SimplePedestalCalculator.cc.

References alreadyUsedEvent.

Referenced by pedestal().

178  {
179  alreadyUsedEvent = false;
180 }
ApvAnalysis::PedestalType SimplePedestalCalculator::pedestal ( ) const
inlinevirtual

Return reconstructed pedestals

Implements TkPedestalCalculator.

Definition at line 30 of file SimplePedestalCalculator.h.

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

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

Implements TkPedestalCalculator.

Definition at line 29 of file SimplePedestalCalculator.h.

References theRawNoise.

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

Definition at line 130 of file SimplePedestalCalculator.cc.

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

Referenced by pedestal(), and updatePedestal().

130  {
131 
132 
133  // keep adding th adc count for any events
134 
135  unsigned int ii=0;
137  for (; i < in.data.end(); i++) {
138 
139  thePedSum[ii] += (*i).adc();
140  thePedSqSum[ii] += ((*i).adc())*((*i).adc());
141  theEventPerStrip[ii]++;
142 
143  ii++;
144  }
145 
146 
147  // calculate a new pedestal any events, so it will come for free when for the last event
148 
149  for (unsigned int iii = 0; iii < in.data.size(); iii++) {
150  if (theEventPerStrip[iii] > 10 ) {
151  int avVal = (theEventPerStrip[iii])
152  ? thePedSum[iii]/theEventPerStrip[iii]:0;
153 
154  double sqAvVal = (theEventPerStrip[iii])
155  ? thePedSqSum[iii]/theEventPerStrip[iii]:0.0;
156 
157  double rmsVal = (sqAvVal - avVal*avVal > 0.0)
158  ? sqrt(sqAvVal - avVal*avVal) : 0.0;
159 
160 
161  if (avVal != 0 ) {
162  thePedestal[iii] = static_cast<float>(avVal);
163  theRawNoise[iii] = static_cast<float>(rmsVal);
164  }
165  }
166  }
167 
168 }
std::vector< unsigned short > theEventPerStrip
T sqrt(T t)
Definition: SSEVec.h:18
ApvAnalysis::PedestalType theRawNoise
ii
Definition: cuy.py:588
collection_type data
Definition: DetSet.h:78
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
ApvAnalysis::PedestalType thePedestal
void SimplePedestalCalculator::resetPedestals ( )
inlinevirtual

Implements TkPedestalCalculator.

Definition at line 18 of file SimplePedestalCalculator.h.

References thePedestal, and theRawNoise.

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

Implements TkPedestalCalculator.

Definition at line 22 of file SimplePedestalCalculator.h.

References recoMuon::in, and thePedestal.

void SimplePedestalCalculator::setRawNoise ( ApvAnalysis::PedestalType in)
inline
void SimplePedestalCalculator::updatePedestal ( ApvAnalysis::RawSignalType in)
virtual

Update pedestals with current event

Implements TkPedestalCalculator.

Definition at line 53 of file SimplePedestalCalculator.cc.

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

Referenced by setRawNoise().

53  {
54 
55  if (alreadyUsedEvent == false) {
56  alreadyUsedEvent = true;
58  if (theStatus.isCalibrating()) {
60  } else if (theStatus.isUpdating()) {
61  refinePedestal(in);
62  }
63  updateStatus();
64  }
65 
66 
67 }
bool isUpdating() const
bool isCalibrating() const
void refinePedestal(ApvAnalysis::RawSignalType &in)
void initializePedestal(ApvAnalysis::RawSignalType &in)
void SimplePedestalCalculator::updateStatus ( )
virtual

Member Data Documentation

bool SimplePedestalCalculator::alreadyUsedEvent
protected

Definition at line 49 of file SimplePedestalCalculator.h.

Referenced by newEvent(), and updatePedestal().

int SimplePedestalCalculator::eventsRequiredToCalibrate
protected
int SimplePedestalCalculator::numberOfEvents
protected

Definition at line 45 of file SimplePedestalCalculator.h.

Referenced by initializePedestal(), updatePedestal(), and updateStatus().

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

Definition at line 44 of file SimplePedestalCalculator.h.

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

ApvAnalysis::PedestalType SimplePedestalCalculator::thePedestal
protected
std::vector<int> SimplePedestalCalculator::thePedSqSum
protected

Definition at line 43 of file SimplePedestalCalculator.h.

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

std::vector<int> SimplePedestalCalculator::thePedSum
protected

Definition at line 43 of file SimplePedestalCalculator.h.

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

ApvAnalysis::PedestalType SimplePedestalCalculator::theRawNoise
protected