CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
EcalUncalibRecHitRecChi2Algo< C > Class Template Reference

#include <EcalUncalibRecHitRecChi2Algo.h>

Public Member Functions

virtual double chi2 ()
 
virtual double chi2OutOfTime ()
 
 EcalUncalibRecHitRecChi2Algo ()
 
 EcalUncalibRecHitRecChi2Algo (const C &dataFrame, const double amplitude, const EcalTimeCalibConstant &timeIC, const double amplitudeOutOfTime, const double jitter, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalShapeBase &testbeamPulseShape, const std::vector< double > &chi2Parameters)
 
virtual ~EcalUncalibRecHitRecChi2Algo ()
 

Private Attributes

double chi2_
 
double chi2OutOfTime_
 

Detailed Description

template<class C>
class EcalUncalibRecHitRecChi2Algo< C >

Template used to compute the chi2 of an MGPA pulse for in-time and out-of-time signals, algorithm based on the chi2express. The in-time chi2 is calculated against the time intercalibrations from the DB while the out-of-time chi2 is calculated against the Tmax measurement on event by event basis.

Author
Konstantinos Theofilatos 02 Feb 2010

Definition at line 24 of file EcalUncalibRecHitRecChi2Algo.h.

Constructor & Destructor Documentation

template<class C>
virtual EcalUncalibRecHitRecChi2Algo< C >::~EcalUncalibRecHitRecChi2Algo ( )
inlinevirtual

Definition at line 29 of file EcalUncalibRecHitRecChi2Algo.h.

29 { };
template<class C>
EcalUncalibRecHitRecChi2Algo< C >::EcalUncalibRecHitRecChi2Algo ( )
inline

Definition at line 31 of file EcalUncalibRecHitRecChi2Algo.h.

31 { };
template<class C >
EcalUncalibRecHitRecChi2Algo< C >::EcalUncalibRecHitRecChi2Algo ( const C &  dataFrame,
const double  amplitude,
const EcalTimeCalibConstant timeIC,
const double  amplitudeOutOfTime,
const double  jitter,
const double *  pedestals,
const double *  pedestalsRMS,
const double *  gainRatios,
const EcalShapeBase testbeamPulseShape,
const std::vector< double > &  chi2Parameters 
)

Definition at line 57 of file EcalUncalibRecHitRecChi2Algo.h.

References ecalMGPA::gainId(), CastorSimpleRecAlgoImpl::isSaturated(), cmsBatch::log, EcalShapeBase::timeToRise(), and tzero.

69 {
70 
71  double noise_A = chi2Parameters[0]; // noise term for in-time chi2
72  double const_A = chi2Parameters[1]; // constant term for in-time chi2
73  double noise_B = chi2Parameters[2]; // noise term for out-of-time chi2
74  double const_B = chi2Parameters[3]; // constant term for out-of-time chi2
75 
76 
77  chi2_=0;
79  double S_0=0; // will store the first mgpa sample
80  double ped_ave=0; // will store the average pedestal
81 
82  int gainId0 = 1;
83  int iGainSwitch = 0;
84  bool isSaturated = 0;
85  for(int iSample = 0; iSample < C::MAXSAMPLES; iSample++) // if gain switch use later the pedestal RMS, otherwise we use the pedestal from the DB
86  {
87  int gainId = dataFrame.sample(iSample).gainId();
88  if(gainId == 0)
89  {
90  gainId = 3; // if saturated, treat it as G1
91  isSaturated = 1;
92  }
93  if(gainId != gainId0)iGainSwitch = 1;
94 
95  if(gainId==1 && iSample==0)S_0 = dataFrame.sample(iSample).adc(); // take only first presample to estimate the pedestal
96  if(gainId==1 && iSample<3)ped_ave += (1/3.0)*dataFrame.sample(iSample).adc(); // take first 3 presamples to estimate the pedestal
97  }
98 
99 
100  // compute testbeamPulseShape shape parameters
101  double ADC_clock = 25; // 25 ns
102  double risingTime = testbeamPulseShape.timeToRise();
103  double tzero = risingTime - 5*ADC_clock; // 5 samples before the peak
104 
105  double shiftTime = + timeIC; // we put positive here
106  double shiftTimeOutOfTime = -jitter*ADC_clock; // we put negative here
107 
108 
109  bool readoutError = false;
110 
111  for(int iSample = 0; iSample < C::MAXSAMPLES; iSample++)
112  {
113  int gainId = dataFrame.sample(iSample).gainId();
114  if(dataFrame.sample(iSample).adc()==0)readoutError=true;
115  if(gainId==0)continue; // skip saturated samples
116 
117 
118  double ped = !iGainSwitch ? ped_ave:pedestals[gainId-1]; // use dynamic pedestal for G12 and average pedestal for G6,G1
119  //double pedRMS = pedestalsRMS[gainId-1];
120  double S_i = double(dataFrame.sample(iSample).adc());
121 
122  // --- calculate in-time chi2
123 
124 
125  double f_i = (testbeamPulseShape)(tzero + shiftTime + iSample*ADC_clock);
126  double R_i = (S_i- ped)*gainRatios[gainId-1] - f_i*amplitude;
127  double R_iErrorSquare = noise_A*noise_A + const_A*const_A*amplitude*amplitude;
128 
129  chi2_ += R_i*R_i/R_iErrorSquare;
130 
131  // --- calculate out-of-time chi2
132 
133  double g_i = (testbeamPulseShape)(tzero + shiftTimeOutOfTime + iSample*ADC_clock); // calculate out of time chi2
134 
135  double R_iOutOfTime = (S_i- S_0)*gainRatios[gainId-1] - g_i*amplitudeOutOfTime;
136  double R_iOutOfTimeErrorSquare = noise_B*noise_B + const_B*const_B*amplitudeOutOfTime*amplitudeOutOfTime;
137 
138 
139  chi2OutOfTime_ += R_iOutOfTime*R_iOutOfTime/R_iOutOfTimeErrorSquare;
140  }
141 
142 
143  if(!isSaturated && !iGainSwitch && chi2_>0 && chi2OutOfTime_>0)
144  {
145  chi2_ = 7*(3+log(chi2_)); chi2_ = chi2_<0 ? 0:chi2_; // this is just a convinient mapping for storing in the calibRecHit bit map
147  }else
148  {
149  chi2_=0;
150  chi2OutOfTime_=0;
151  }
152 
153  if(readoutError) // rare situation
154  {
155  chi2_=99.0; // chi2 is very large in these cases, put a code value to discriminate against normal noise
156  chi2OutOfTime_=99.0;
157  }
158 }
int gainId(sample_type sample)
get the gainId (2 bits)
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
static const double tzero[3]
virtual double timeToRise() const
tuple log
Definition: cmsBatch.py:347

Member Function Documentation

template<class C>
virtual double EcalUncalibRecHitRecChi2Algo< C >::chi2 ( void  )
inlinevirtual
template<class C>
virtual double EcalUncalibRecHitRecChi2Algo< C >::chi2OutOfTime ( )
inlinevirtual

Member Data Documentation

template<class C>
double EcalUncalibRecHitRecChi2Algo< C >::chi2_
private
template<class C>
double EcalUncalibRecHitRecChi2Algo< C >::chi2OutOfTime_
private