1 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitFixedAlphaBetaAlgo_HH 2 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitFixedAlphaBetaAlgo_HH 14 #include "CLHEP/Matrix/Vector.h" 15 #include "CLHEP/Matrix/SymMatrix.h" 65 EcalUncalibRecHitFixedAlphaBetaAlgo<C>():
fAlpha_(0.),
fBeta_(0.),
fAmp_max_(-1.),
fTim_max_(-1),
fPed_max_(0),
alfabeta_(0),
fNb_iter_(4),
fNum_samp_bef_max_(1),
fNum_samp_after_max_(3),
fSigma_ped(1.1),
DM1_(3),
temp_(3){
66 un_sur_sigma = 1./double(fSigma_ped) ;
67 for (
int i=0;
i<36;
i++){
68 for(
int j=0;j<1701;j++){
69 alpha_table_[
i][j] = 1.2 ;
70 beta_table_[
i][j] = 1.7 ;
77 EcalUncalibRecHitFixedAlphaBetaAlgo<C>(
int n_iter,
int n_bef_max =1,
int n_aft_max =3,
float sigma_ped = 1.1):fAlpha_(0.),fBeta_(0.),fAmp_max_(-1.),fTim_max_(-1),fPed_max_(0),alfabeta_(0),DM1_(3),temp_(3){
80 fNum_samp_bef_max_ = n_bef_max ;
81 fNum_samp_after_max_ = n_aft_max ;
82 fSigma_ped = sigma_ped;
83 un_sur_sigma = 1./double(fSigma_ped) ;
84 for (
int i=0;
i<36;
i++){
85 for(
int j=0;j<1701;j++){
86 alpha_table_[
i][j] = 1.2 ;
87 beta_table_[
i][j] = 1.7 ;
97 const double* gainRatios,
109 const double* gainRatios,
115 double frame[C::MAXSAMPLES];
121 double maxsample(-1);
123 bool external_pede =
false;
128 external_pede =
true;
129 if(
dyn_pedestal) { pedestal = (double(dataFrame.sample(0).adc()) +
double(dataFrame.sample(1).adc()))/2.;}
130 else{ pedestal = pedestals[0];}
131 for(
int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
133 GainId = dataFrame.sample(iSample).gainId();
144 if (GainId != gainId0) iGainSwitch = 1;
146 if(GainId==gainId0){frame[iSample] = double(dataFrame.sample(iSample).adc())-pedestal ;}
147 else {frame[iSample] = (double(dataFrame.sample(iSample).adc())-pedestals[GainId-1])*gainRatios[GainId-1];}
149 if( frame[iSample]>maxsample ) {
150 maxsample = frame[iSample];
156 external_pede =
false;
157 pedestal = (double(dataFrame.sample(0).adc()) +
double(dataFrame.sample(1).adc()))/2.;
159 for(
int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
161 GainId = dataFrame.sample(iSample).gainId();
169 frame[iSample] = double(dataFrame.sample(iSample).adc())-pedestal ;
171 if (GainId > gainId0) iGainSwitch = 1;
172 if( frame[iSample]>maxsample ) {
173 maxsample = frame[iSample];
179 if( (iGainSwitch==1 && external_pede==
false) ||
219 double sumA = samples[5]+samples[4]+samples[6];
220 if(sumA != 0) {
fTim_max_ = 5+(samples[6]-samples[4])/sumA; }
225 else if(max_sample <1 || max_sample > 7)
230 float a =
float(samples[max_sample-1]+samples[max_sample+1]-2*samples[max_sample])/2.;
231 if(a==0){
doFit_ =
false;
return;}
232 float b =
float(samples[max_sample+1]-samples[max_sample-1])/2.;
249 double chi2=-1 , db[3] ;
257 if (num_fit_min<0) num_fit_min = 0 ;
259 if (num_fit_max>= C::MAXSAMPLES ) {num_fit_max = C::MAXSAMPLES-1 ;}
262 LogDebug(
"EcalUncalibRecHitFixedAlphaBetaAlgo")<<
"No fit performed. The amplitude of sample 5 will be used";
267 double variation_func_max = 0. ;
double variation_tim_max = 0. ;
double variation_ped_max = 0. ;
269 for (
int iter=0 ; iter <
fNb_iter_ ; iter ++) {
273 for(
int i1=0 ; i1<3 ; i1++) {
275 for(
int j1=i1 ; j1<3 ; j1++) {
276 DM1_.fast(j1+1,i1+1) = 0; }
284 for(
int i = num_fit_min ;
i <= num_fit_max ;
i++) {
291 double dt_sur_beta = dt/
fBeta_ ;
293 double expo =
exp(-dt_sur_beta) ;
300 db[0]=0. ; db[1]=0. ;
304 for(
int i1=0 ; i1<3 ; i1++) {
305 for(
int j1=i1 ; j1<3 ; j1++) {
307 DM1_.fast(j1+1,i1+1) += db[i1]*db[j1]; }
313 chi2 += delta *
delta ;
342 variation_func_max = PROD[0] ;
343 variation_tim_max = PROD[1] ;
344 variation_ped_max = PROD[2] ;
350 if( variation_func_max > 2000. || variation_func_max < -1000. ) {
void InitFitParameters(double *samples, int max_sample)
float beta_table_[36][1701]
constexpr bool isNotFinite(T x)
std::vector< Variable::Flags > flags
double pulseShapeFunction(double t)
EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix) override
Compute parameters.
float alpha_table_[36][1701]
void SetMinAmpl(double ampl)
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
void SetAlphaBeta(double alpha, double beta)
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
math::Matrix< 3, 10 >::type EcalWeightMatrix
float PerformAnalyticFit(double *samples, int max_sample)
void SetDynamicPedestal(bool dyn_pede)
Power< A, B >::type pow(const A &a, const B &b)