CMS 3D CMS Logo

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

#include <PulseFitWithFunction.h>

Inheritance diagram for PulseFitWithFunction:

Public Member Functions

virtual double doFit (double *)
 
double getAmpl ()
 
double getAmpl_parab ()
 
double getMax_parab ()
 
int getSampMax_parab ()
 
double getTime ()
 
double getTime_parab ()
 
virtual void init (int, int, int, int, double, double)
 
 PulseFitWithFunction ()
 
 ~PulseFitWithFunction () override
 

Public Attributes

double fAmp_fitted_max
 
double fFunc_max
 
int fNumber_samp_max
 
double fSigma_ped
 
double fTim_fitted_max
 
double fTim_max
 
double fValue_tim_max
 

Private Member Functions

double Electronic_shape (double)
 
double Fit_electronic (int, double *, double)
 
void Fit_parab (double *, int, int, double *)
 

Private Attributes

double amp_max
 
double amp_parab
 
double fAlpha
 
double fAlpha_beam
 
double fAlpha_laser
 
double fBeta
 
double fBeta_beam
 
double fBeta_laser
 
int fNb_iter
 
int fNsamples
 
int fNum_samp_after_max
 
int fNum_samp_bef_max
 
int imax
 
double tim_parab
 

Detailed Description

Definition at line 26 of file PulseFitWithFunction.h.

Constructor & Destructor Documentation

◆ PulseFitWithFunction()

PulseFitWithFunction::PulseFitWithFunction ( )

Definition at line 26 of file PulseFitWithFunction.cc.

26  {
27  fNsamples = 0;
30 }

References fNsamples, fNum_samp_after_max, and fNum_samp_bef_max.

◆ ~PulseFitWithFunction()

PulseFitWithFunction::~PulseFitWithFunction ( )
override

Definition at line 33 of file PulseFitWithFunction.cc.

33 {}

Member Function Documentation

◆ doFit()

double PulseFitWithFunction::doFit ( double *  adc)
virtual

Definition at line 60 of file PulseFitWithFunction.cc.

60  {
61  double parout[4]; // amp_max ;
62  //double amp_parab , tim_parab ;
63  double chi2;
64  //int imax ;
65  //
66  // first one has to get starting point first with parabolic fun// //
67  Fit_parab(&adc[0], 3, fNsamples, parout);
68  amp_parab = parout[0];
69  tim_parab = parout[1];
70  imax = (int)parout[2];
71  amp_max = parout[3];
72  //printf("amp_parab= %f tim_parab=%f amp_max=%f imax=%d\n",amp_parab,tim_parab,amp_max,imax);
74  //
75 
76  if (amp_parab < 1.) {
77  tim_parab = (double)imax;
79  }
80  //
84 
85  // here to fit maximum amplitude and time of arrival ...
86 
87  chi2 = Fit_electronic(0, &adc[0], 8.);
88  // adc is an array to be filled with samples
89  // 0 is for Laser (1 for electron)
90  // 8 is for sigma of pedestals
91  // which (can be computed)
92 
93  // double amplitude = fAmp_fitted_max ; // amplitude fitted
94  // double time = fTim_fitted_max ; // time fitted
95 
96  return chi2; // return amplitude fitted
97 }

References gpuClustering::adc, amp_max, amp_parab, hltPixelTracks_cff::chi2, fFunc_max, Fit_electronic(), Fit_parab(), fNsamples, fNumber_samp_max, fTim_max, fValue_tim_max, imax, createfilelist::int, and tim_parab.

Referenced by EcalPerEvtLaserAnalyzer::endJob(), and EcalLaserAnalyzer::endJob().

◆ Electronic_shape()

double PulseFitWithFunction::Electronic_shape ( double  tim)
private

Definition at line 212 of file PulseFitWithFunction.cc.

212  {
213  // electronic function (from simulation) to fit ECAL pulse shape
214  double func_electronic, dtsbeta, variable, puiss;
215  double albet = fAlpha * fBeta;
216  if (albet <= 0)
217  return ((Double_t)0.);
218  double dt = tim - fTim_max;
219  if (dt > -albet) {
220  dtsbeta = dt / fBeta;
221  variable = 1. + dt / albet;
222  puiss = TMath::Power(variable, fAlpha);
223  func_electronic = fFunc_max * puiss * TMath::Exp(-dtsbeta);
224  } else
225  func_electronic = 0.;
226  //
227  return func_electronic;
228 }

References dt, fAlpha, fBeta, fFunc_max, fTim_max, and taus_updatedMVAIds_cff::variable.

Referenced by Fit_electronic().

◆ Fit_electronic()

double PulseFitWithFunction::Fit_electronic ( int  data,
double *  adc_to_fit,
double  sigmas_sample 
)
private

Definition at line 103 of file PulseFitWithFunction.cc.

103  {
104  // fit electronic function from simulation
105  // parameters fAlpha and fBeta are fixed and fit is providing
106  // the maximum amplitude ( fAmp_fitted_max ) and the time of
107  // the maximum amplitude ( fTim_fitted_max)
108  // initialization of parameters
109  double chi2 = 0;
110  double d_alpha, d_beta;
111  // first initialize parameters fAlpha and fBeta ( depending of beam or laser)
113  fBeta = fBeta_laser;
114  if (data == 1) {
116  fBeta = fBeta_beam;
117  }
118  //
119  fAmp_fitted_max = 0.;
120  fTim_fitted_max = 0.;
121  double un_sur_sigma = 1. / fSigma_ped;
122  double variation_func_max = 0.;
123  double variation_tim_max = 0.;
124  //
125  if (fValue_tim_max > 20. || fValue_tim_max < 3.) {
127  }
128  int num_fit_min = (int)(fValue_tim_max - fNum_samp_bef_max);
129  int num_fit_max = (int)(fValue_tim_max + fNum_samp_after_max);
130  //
131 
132  if (sigmas_sample > 0.)
133  un_sur_sigma = 1. / sigmas_sample;
134  else
135  un_sur_sigma = 1.;
136 
137  double func, delta;
138  // Loop on iterations
139  for (int iter = 0; iter < fNb_iter; iter++) {
140  // initialization inside iteration loop !
141  chi2 = 0.;
142  double d11 = 0.;
143  double d12 = 0.;
144  double d22 = 0.;
145  double z1 = 0.;
146  double z2 = 0.;
147  fFunc_max += variation_func_max;
148  fTim_max += variation_tim_max;
149  int nsamp_used = 0;
150  //
151 
152  // Then we loop on samples to be fitted
153 
154  for (int i = num_fit_min; i < num_fit_max + 1; i++) {
155  // calculate function to be fitted
156 
157  func = Electronic_shape((double)i);
158 
159  // then calculate derivatives of function to be fitted
160  double dt = (double)i - fTim_max;
161  double alpha_beta = fAlpha * fBeta;
162 
163  if (dt > -alpha_beta) {
164  double dt_sur_beta = dt / fBeta;
165 
166  double variable = (double)1. + dt / alpha_beta;
167  double expo = TMath::Exp(-dt_sur_beta);
168 
169  double puissance = TMath::Power(variable, fAlpha);
170  d_alpha = un_sur_sigma * puissance * expo;
171  d_beta = fFunc_max * d_alpha * dt_sur_beta / (alpha_beta * variable);
172  } else {
173  continue;
174  }
175 
176  nsamp_used++; // number of samples used inside the fit
177  // compute matrix elements D (symetric --> d12 = d21 )
178  d11 += d_alpha * d_alpha;
179  d12 += d_alpha * d_beta;
180  d22 += d_beta * d_beta;
181  // compute delta
182  delta = (adc_to_fit[i] - func) * un_sur_sigma;
183  // compute vector elements Z
184  z1 += delta * d_alpha;
185  z2 += delta * d_beta;
186  chi2 += delta * delta;
187  } // end of loop on samples
188  double denom = d11 * d22 - d12 * d12;
189  if (denom == 0.) {
190  //printf( "attention denom = 0 signal pas fitte \n") ;
191  return 101;
192  }
193  if (nsamp_used < 3) {
194  //printf( "Attention nsamp = %d ---> no function fit provided \n",nsamp_used) ;
195  return 102;
196  }
197  // compute variations of parameters fAmp_max and fTim_max
198  variation_func_max = (z1 * d22 - z2 * d12) / denom;
199  variation_tim_max = (-z1 * d12 + z2 * d11) / denom;
200  chi2 = chi2 / ((double)nsamp_used - 2.);
201  } // end of loop on iterations
202  // results of the fit are calculated
203  fAmp_fitted_max = fFunc_max + variation_func_max;
204  fTim_fitted_max = fTim_max + variation_tim_max;
205  //
206  return chi2;
207 }

References hltPixelTracks_cff::chi2, data, dumpMFGeometry_cfg::delta, makePileupJSON::denom, dt, Electronic_shape(), fAlpha, fAlpha_beam, fAlpha_laser, fAmp_fitted_max, fBeta, fBeta_beam, fBeta_laser, fFunc_max, fNb_iter, fNum_samp_after_max, fNum_samp_bef_max, fNumber_samp_max, fSigma_ped, fTim_fitted_max, fTim_max, TrackCollections2monitor_cff::func, fValue_tim_max, mps_fire::i, createfilelist::int, taus_updatedMVAIds_cff::variable, and testProducerWithPsetDescEmpty_cfi::z2.

Referenced by doFit().

◆ Fit_parab()

void PulseFitWithFunction::Fit_parab ( double *  ,
int  ,
int  ,
double *   
)
private

Definition at line 229 of file PulseFitWithFunction.cc.

229  {
230  /* Now we calculate the parabolic adjustement in order to get */
231  /* maximum and time max */
232 
233  double denom, dt, amp1, amp2, amp3;
234  double ampmax = 0.;
235  int imax = 0;
236  int k;
237  /*
238  */
239  for (k = nmin; k < nmax; k++) {
240  //printf("ampl[%d]=%f\n",k,ampl[k]);
241  if (ampl[k] > ampmax) {
242  ampmax = ampl[k];
243  imax = k;
244  }
245  }
246  amp1 = ampl[imax - 1];
247  amp2 = ampl[imax];
248  amp3 = ampl[imax + 1];
249  denom = 2. * amp2 - amp1 - amp3;
250  /* */
251  if (denom > 0.) {
252  dt = 0.5 * (amp3 - amp1) / denom;
253  } else {
254  //printf("denom =%f\n",denom) ;
255  dt = 0.5;
256  }
257  /* */
258  /* ampmax correspond au maximum d'amplitude parabolique et dt */
259  /* decalage en temps par rapport au sample maximum soit k + dt */
260 
261  parout[0] = amp2 + (amp3 - amp1) * dt * 0.25;
262  parout[1] = (double)imax + dt;
263  parout[2] = (double)imax;
264  parout[3] = ampmax;
265  return;
266 }

References makePileupJSON::denom, dt, imax, dqmdumpme::k, and nmin.

Referenced by doFit().

◆ getAmpl()

double PulseFitWithFunction::getAmpl ( )
inline

Definition at line 52 of file PulseFitWithFunction.h.

52 { return fAmp_fitted_max; }

References fAmp_fitted_max.

Referenced by EcalPerEvtLaserAnalyzer::endJob(), and EcalLaserAnalyzer::endJob().

◆ getAmpl_parab()

double PulseFitWithFunction::getAmpl_parab ( )
inline

Definition at line 49 of file PulseFitWithFunction.h.

49 { return amp_parab; }

References amp_parab.

◆ getMax_parab()

double PulseFitWithFunction::getMax_parab ( )
inline

Definition at line 55 of file PulseFitWithFunction.h.

55 { return amp_max; }

References amp_max.

◆ getSampMax_parab()

int PulseFitWithFunction::getSampMax_parab ( )
inline

Definition at line 56 of file PulseFitWithFunction.h.

56 { return imax; }

References imax.

◆ getTime()

double PulseFitWithFunction::getTime ( )
inline

Definition at line 53 of file PulseFitWithFunction.h.

53 { return fTim_fitted_max; }

References fTim_fitted_max.

Referenced by EcalPerEvtLaserAnalyzer::endJob(), and EcalLaserAnalyzer::endJob().

◆ getTime_parab()

double PulseFitWithFunction::getTime_parab ( )
inline

Definition at line 50 of file PulseFitWithFunction.h.

50 { return tim_parab; }

References tim_parab.

◆ init()

void PulseFitWithFunction::init ( int  n_samples,
int  samplb,
int  sampla,
int  niter,
double  alfa,
double  beta 
)
virtual

Definition at line 37 of file PulseFitWithFunction.cc.

37  {
38  //printf("\n");
39  //printf(" =========================================================\n");
40  //printf(" == Initialising the function fit method ==\n");
41  //printf(" == PulseFitWithFunction::init ==\n");
42  //printf(" == ==\n");
43 
44  fNsamples = n_samples;
45  fAlpha_laser = alfa;
46  fBeta_laser = beta;
47  fAlpha_beam = 0.98;
48  fBeta_beam = 2.04;
49  fNb_iter = niter;
50  fNum_samp_bef_max = samplb;
51  fNum_samp_after_max = sampla;
52  //printf(" == # samples used = %3d ==\n",fNsamples);
53  //printf(" == #sample before max= %1d and #sample after maximum= %1d ==\n",fNum_samp_bef_max,fNum_samp_after_max);
54  //printf(" == alpha= %5.4f beta= %5.4f ==\n",fAlpha_laser,fBeta_laser);
55  //printf(" =========================================================\n\n");
56  return;
57 }

References HLT_FULL_cff::beta, fAlpha_beam, fAlpha_laser, fBeta_beam, fBeta_laser, fNb_iter, fNsamples, fNum_samp_after_max, and fNum_samp_bef_max.

Referenced by EcalPerEvtLaserAnalyzer::endJob(), and EcalLaserAnalyzer::endJob().

Member Data Documentation

◆ amp_max

double PulseFitWithFunction::amp_max
private

Definition at line 59 of file PulseFitWithFunction.h.

Referenced by doFit(), and getMax_parab().

◆ amp_parab

double PulseFitWithFunction::amp_parab
private

Definition at line 59 of file PulseFitWithFunction.h.

Referenced by doFit(), and getAmpl_parab().

◆ fAlpha

double PulseFitWithFunction::fAlpha
private

Definition at line 68 of file PulseFitWithFunction.h.

Referenced by Electronic_shape(), and Fit_electronic().

◆ fAlpha_beam

double PulseFitWithFunction::fAlpha_beam
private

Definition at line 66 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), and init().

◆ fAlpha_laser

double PulseFitWithFunction::fAlpha_laser
private

Definition at line 64 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), and init().

◆ fAmp_fitted_max

double PulseFitWithFunction::fAmp_fitted_max

Definition at line 43 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), and getAmpl().

◆ fBeta

double PulseFitWithFunction::fBeta
private

Definition at line 69 of file PulseFitWithFunction.h.

Referenced by Electronic_shape(), and Fit_electronic().

◆ fBeta_beam

double PulseFitWithFunction::fBeta_beam
private

Definition at line 67 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), and init().

◆ fBeta_laser

double PulseFitWithFunction::fBeta_laser
private

Definition at line 65 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), and init().

◆ fFunc_max

double PulseFitWithFunction::fFunc_max

Definition at line 41 of file PulseFitWithFunction.h.

Referenced by doFit(), Electronic_shape(), and Fit_electronic().

◆ fNb_iter

int PulseFitWithFunction::fNb_iter
private

Definition at line 70 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), and init().

◆ fNsamples

int PulseFitWithFunction::fNsamples
private

Definition at line 62 of file PulseFitWithFunction.h.

Referenced by doFit(), init(), and PulseFitWithFunction().

◆ fNum_samp_after_max

int PulseFitWithFunction::fNum_samp_after_max
private

Definition at line 72 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), init(), and PulseFitWithFunction().

◆ fNum_samp_bef_max

int PulseFitWithFunction::fNum_samp_bef_max
private

Definition at line 71 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), init(), and PulseFitWithFunction().

◆ fNumber_samp_max

int PulseFitWithFunction::fNumber_samp_max

Definition at line 46 of file PulseFitWithFunction.h.

Referenced by doFit(), and Fit_electronic().

◆ fSigma_ped

double PulseFitWithFunction::fSigma_ped

Definition at line 47 of file PulseFitWithFunction.h.

Referenced by Fit_electronic().

◆ fTim_fitted_max

double PulseFitWithFunction::fTim_fitted_max

Definition at line 44 of file PulseFitWithFunction.h.

Referenced by Fit_electronic(), and getTime().

◆ fTim_max

double PulseFitWithFunction::fTim_max

Definition at line 42 of file PulseFitWithFunction.h.

Referenced by doFit(), Electronic_shape(), and Fit_electronic().

◆ fValue_tim_max

double PulseFitWithFunction::fValue_tim_max

Definition at line 45 of file PulseFitWithFunction.h.

Referenced by doFit(), and Fit_electronic().

◆ imax

int PulseFitWithFunction::imax
private

Definition at line 60 of file PulseFitWithFunction.h.

Referenced by doFit(), Fit_parab(), and getSampMax_parab().

◆ tim_parab

double PulseFitWithFunction::tim_parab
private

Definition at line 59 of file PulseFitWithFunction.h.

Referenced by doFit(), and getTime_parab().

PulseFitWithFunction::fNumber_samp_max
int fNumber_samp_max
Definition: PulseFitWithFunction.h:46
mps_fire.i
i
Definition: mps_fire.py:428
makePileupJSON.denom
denom
Definition: makePileupJSON.py:147
PulseFitWithFunction::imax
int imax
Definition: PulseFitWithFunction.h:60
HLT_FULL_cff.beta
beta
Definition: HLT_FULL_cff.py:8686
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
PulseFitWithFunction::fBeta_beam
double fBeta_beam
Definition: PulseFitWithFunction.h:67
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
PulseFitWithFunction::Fit_parab
void Fit_parab(double *, int, int, double *)
Definition: PulseFitWithFunction.cc:229
PulseFitWithFunction::fNsamples
int fNsamples
Definition: PulseFitWithFunction.h:62
testProducerWithPsetDescEmpty_cfi.z2
z2
Definition: testProducerWithPsetDescEmpty_cfi.py:41
PulseFitWithFunction::fAlpha_beam
double fAlpha_beam
Definition: PulseFitWithFunction.h:66
dt
float dt
Definition: AMPTWrapper.h:136
PulseFitWithFunction::fBeta_laser
double fBeta_laser
Definition: PulseFitWithFunction.h:65
PulseFitWithFunction::tim_parab
double tim_parab
Definition: PulseFitWithFunction.h:59
PulseFitWithFunction::fNb_iter
int fNb_iter
Definition: PulseFitWithFunction.h:70
dqmdumpme.k
k
Definition: dqmdumpme.py:60
PulseFitWithFunction::fAlpha
double fAlpha
Definition: PulseFitWithFunction.h:68
nmin
const HitContainer *__restrict__ const TkSoA *__restrict__ Quality *__restrict__ uint16_t nmin
Definition: CAHitNtupletGeneratorKernelsImpl.h:477
PulseFitWithFunction::fTim_fitted_max
double fTim_fitted_max
Definition: PulseFitWithFunction.h:44
PulseFitWithFunction::fValue_tim_max
double fValue_tim_max
Definition: PulseFitWithFunction.h:45
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
createfilelist.int
int
Definition: createfilelist.py:10
PulseFitWithFunction::amp_max
double amp_max
Definition: PulseFitWithFunction.h:59
PulseFitWithFunction::Electronic_shape
double Electronic_shape(double)
Definition: PulseFitWithFunction.cc:212
PulseFitWithFunction::Fit_electronic
double Fit_electronic(int, double *, double)
Definition: PulseFitWithFunction.cc:103
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359
PulseFitWithFunction::fNum_samp_bef_max
int fNum_samp_bef_max
Definition: PulseFitWithFunction.h:71
PulseFitWithFunction::fAmp_fitted_max
double fAmp_fitted_max
Definition: PulseFitWithFunction.h:43
taus_updatedMVAIds_cff.variable
variable
Definition: taus_updatedMVAIds_cff.py:33
PulseFitWithFunction::fBeta
double fBeta
Definition: PulseFitWithFunction.h:69
PulseFitWithFunction::amp_parab
double amp_parab
Definition: PulseFitWithFunction.h:59
PulseFitWithFunction::fAlpha_laser
double fAlpha_laser
Definition: PulseFitWithFunction.h:64
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
PulseFitWithFunction::fSigma_ped
double fSigma_ped
Definition: PulseFitWithFunction.h:47
PulseFitWithFunction::fTim_max
double fTim_max
Definition: PulseFitWithFunction.h:42
PulseFitWithFunction::fFunc_max
double fFunc_max
Definition: PulseFitWithFunction.h:41
PulseFitWithFunction::fNum_samp_after_max
int fNum_samp_after_max
Definition: PulseFitWithFunction.h:72