1 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitFixedAlphaBetaAlgo_HH 2 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitFixedAlphaBetaAlgo_HH 14 #include "CLHEP/Matrix/Vector.h" 15 #include "CLHEP/Matrix/SymMatrix.h" 76 un_sur_sigma = 1. / double(fSigma_ped);
77 for (
int i = 0;
i < 36;
i++) {
78 for (
int j = 0;
j < 1701;
j++) {
79 alpha_table_[
i][
j] = 1.2;
80 beta_table_[
i][
j] = 1.7;
88 : fAlpha_(0.), fBeta_(0.), fAmp_max_(-1.), fTim_max_(-1), fPed_max_(0), alfabeta_(0), DM1_(3), temp_(3) {
90 fNum_samp_bef_max_ = n_bef_max;
91 fNum_samp_after_max_ = n_aft_max;
92 fSigma_ped = sigma_ped;
93 un_sur_sigma = 1. / double(fSigma_ped);
94 for (
int i = 0;
i < 36;
i++) {
95 for (
int j = 0;
j < 1701;
j++) {
96 alpha_table_[
i][
j] = 1.2;
97 beta_table_[
i][
j] = 1.7;
107 const double* pedestals,
108 const double* gainRatios,
120 const double* pedestals,
121 const double* gainRatios,
127 double frame[C::MAXSAMPLES];
133 double maxsample(-1);
135 bool external_pede =
false;
140 external_pede =
true;
142 pedestal = (double(dataFrame.sample(0).adc()) +
double(dataFrame.sample(1).adc())) / 2.;
144 pedestal = pedestals[0];
146 for (
int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
148 GainId = dataFrame.sample(iSample).gainId();
158 if (GainId != gainId0)
161 if (GainId == gainId0) {
162 frame[iSample] = double(dataFrame.sample(iSample).adc()) - pedestal;
164 frame[iSample] = (double(dataFrame.sample(iSample).adc()) - pedestals[GainId - 1]) * gainRatios[GainId - 1];
167 if (frame[iSample] > maxsample) {
168 maxsample = frame[iSample];
173 external_pede =
false;
174 pedestal = (double(dataFrame.sample(0).adc()) +
double(dataFrame.sample(1).adc())) / 2.;
176 for (
int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
178 GainId = dataFrame.sample(iSample).gainId();
185 frame[iSample] = double(dataFrame.sample(iSample).adc()) - pedestal;
187 if (GainId > gainId0)
189 if (frame[iSample] > maxsample) {
190 maxsample = frame[iSample];
196 if ((iGainSwitch == 1 && external_pede ==
false) ||
239 double sumA = samples[5] + samples[4] + samples[6];
241 fTim_max_ = 5 + (samples[6] - samples[4]) / sumA;
248 else if (max_sample < 1 || max_sample > 7) {
253 float a =
float(samples[max_sample - 1] + samples[max_sample + 1] - 2 * samples[max_sample]) / 2.;
258 float b =
float(samples[max_sample + 1] - samples[max_sample - 1]) / 2.;
261 fAmp_max_ = samples[max_sample] - b * b / (4 *
a);
284 if (num_fit_max >= C::MAXSAMPLES) {
285 num_fit_max = C::MAXSAMPLES - 1;
289 LogDebug(
"EcalUncalibRecHitFixedAlphaBetaAlgo") <<
"No fit performed. The amplitude of sample 5 will be used";
294 double variation_func_max = 0.;
295 double variation_tim_max = 0.;
296 double variation_ped_max = 0.;
298 for (
int iter = 0; iter <
fNb_iter_; iter++) {
302 for (
int i1 = 0;
i1 < 3;
i1++) {
304 for (
int j1 =
i1; j1 < 3; j1++) {
305 DM1_.fast(j1 + 1,
i1 + 1) = 0;
314 for (
int i = num_fit_min;
i <= num_fit_max;
i++) {
321 double dt_sur_beta = dt /
fBeta_;
323 double expo =
exp(-dt_sur_beta);
334 for (
int i1 = 0;
i1 < 3;
i1++) {
335 for (
int j1 =
i1; j1 < 3; j1++) {
343 for (
int ii = 0;
ii < 3;
ii++) {
346 chi2 += delta *
delta;
375 variation_func_max = PROD[0];
376 variation_tim_max = PROD[1];
377 variation_ped_max = PROD[2];
382 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)
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
math::Matrix< 3, 10 >::type EcalWeightMatrix
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)
void SetAlphaBeta(double alpha, double beta)
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
float PerformAnalyticFit(double *samples, int max_sample)
void SetDynamicPedestal(bool dyn_pede)
alpha
zGenParticlesMatch = cms.InputTag(""),
Power< A, B >::type pow(const A &a, const B &b)