CMS 3D CMS Logo

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

#include <TPNFit.h>

Inheritance diagram for TPNFit:

Public Member Functions

double doFit (int, double *)
 
double getAmpl ()
 
double getTimax ()
 
void init (int, int, int)
 
 TPNFit ()
 
 ~TPNFit () override
 

Static Public Attributes

static constexpr int NMAXSAMP2 = 50
 

Private Attributes

double ampl
 
int firstsample
 
int fNsamples
 
int fNum_samp_after_max
 
int fNum_samp_bef_max
 
double fv1 [NMAXSAMP2]
 
double fv2 [NMAXSAMP2]
 
double fv3 [NMAXSAMP2]
 
int lastsample
 
double t [NMAXSAMP2]
 
double timeatmax
 
double val [NMAXSAMP2]
 

Detailed Description

Definition at line 6 of file TPNFit.h.

Constructor & Destructor Documentation

◆ TPNFit()

TPNFit::TPNFit ( )

Definition at line 15 of file TPNFit.cc.

References fNsamples, fNum_samp_after_max, and fNum_samp_bef_max.

15  {
16  fNsamples = 0;
19 }
int fNum_samp_bef_max
Definition: TPNFit.h:12
int fNum_samp_after_max
Definition: TPNFit.h:13
int fNsamples
Definition: TPNFit.h:11

◆ ~TPNFit()

TPNFit::~TPNFit ( )
override

Definition at line 22 of file TPNFit.cc.

22 {}

Member Function Documentation

◆ doFit()

double TPNFit::doFit ( int  maxsample,
double *  adc 
)

Definition at line 39 of file TPNFit.cc.

References a, gpuClustering::adc, ampl, b, DummyCfis::c, nano_mu_local_reco_cff::chi2, DeadROC_duringRun::f1, DeadROC_duringRun::f2, firstsample, fNsamples, fNum_samp_after_max, fNum_samp_bef_max, fv1, fv2, fv3, mps_fire::i, lastsample, timeatmax, val, and y.

Referenced by EcalPerEvtLaserAnalyzer::analyze(), EcalTestPulseAnalyzer::analyze(), EcalLaserAnalyzer::analyze(), and EcalLaserAnalyzer2::analyze().

39  {
40  double chi2 = 0.;
41  ampl = 0.;
42  timeatmax = 0.;
43 
44  //printf("maxsample=%d\n",maxsample);
45  firstsample = maxsample - fNum_samp_bef_max;
46  lastsample = maxsample + fNum_samp_after_max;
47 
48  if (firstsample <= 0)
49  return 101;
50  if (lastsample >= fNsamples)
51  lastsample = fNsamples - 1;
52  if (lastsample - firstsample < 1)
53  return 102;
54  int nval = lastsample - firstsample + 1;
55  //printf("firstsample=%d lastsample=%d nval=%d\n",
56  // firstsample,lastsample,nval);
57  int testneg = 0;
58  for (int kn = firstsample; kn <= lastsample; kn++) {
59  //printf("adc[%d]=%f\n",kn,adc[kn]);
60  if (adc[kn] < 0.)
61  testneg = 1;
62  }
63  if (testneg == 1)
64  return 103;
65 
66  for (int i = firstsample; i <= lastsample; i++) {
67  val[i - firstsample] = adc[i];
68  fv1[i - firstsample] = 1.;
69  fv2[i - firstsample] = (double)(i);
70  fv3[i - firstsample] = ((double)(i)) * ((double)(i));
71  }
72 
73  TVectorD y(nval, val);
74  //y.Print();
75  TVectorD f1(nval, fv1);
76  //f1.Print();
77  TVectorD f2(nval, fv2);
78  //f2.Print();
79  TVectorD f3(nval, fv3);
80  //f3.Print();
81 
82  double bj[3];
83  bj[0] = f1 * y;
84  bj[1] = f2 * y;
85  bj[2] = f3 * y;
86  TVectorD b(3, bj);
87  //b.Print();
88 
89  double aij[9];
90  aij[0] = f1 * f1;
91  aij[1] = f1 * f2;
92  aij[2] = f1 * f3;
93  aij[3] = f2 * f1;
94  aij[4] = f2 * f2;
95  aij[5] = f2 * f3;
96  aij[6] = f3 * f1;
97  aij[7] = f3 * f2;
98  aij[8] = f3 * f3;
99  TMatrixD a(3, 3, aij);
100  //a.Print();
101 
102  double det1;
103  a.InvertFast(&det1);
104  //a.Print();
105 
106  TVectorD c = a * b;
107  //c.Print();
108 
109  double *par = c.GetMatrixArray();
110  //printf("par0=%f par1=%f par2=%f\n",par[0],par[1],par[2]);
111  if (par[2] != 0.) {
112  timeatmax = -par[1] / (2. * par[2]);
113  ampl = par[0] - par[2] * (timeatmax * timeatmax);
114  }
115  //printf("amp=%f time=%f\n",amp_max,timeatmax);
116 
117  if (ampl <= 0.) {
118  ampl = adc[maxsample];
119  return 1.;
120  }
121 
122  if ((int)timeatmax > lastsample)
123  return 103;
124  if ((int)timeatmax < firstsample)
125  return 103;
126 
127  return chi2;
128 }
int fNum_samp_bef_max
Definition: TPNFit.h:12
double fv1[NMAXSAMP2]
Definition: TPNFit.h:17
double fv3[NMAXSAMP2]
Definition: TPNFit.h:17
int fNum_samp_after_max
Definition: TPNFit.h:13
double timeatmax
Definition: TPNFit.h:19
int fNsamples
Definition: TPNFit.h:11
double b
Definition: hdecay.h:120
int lastsample
Definition: TPNFit.h:15
double a
Definition: hdecay.h:121
int firstsample
Definition: TPNFit.h:15
double fv2[NMAXSAMP2]
Definition: TPNFit.h:17
double val[NMAXSAMP2]
Definition: TPNFit.h:16
uint16_t *__restrict__ uint16_t const *__restrict__ adc
double ampl
Definition: TPNFit.h:18

◆ getAmpl()

double TPNFit::getAmpl ( )
inline

Definition at line 32 of file TPNFit.h.

References ampl.

Referenced by EcalPerEvtLaserAnalyzer::analyze(), EcalTestPulseAnalyzer::analyze(), EcalLaserAnalyzer::analyze(), and EcalLaserAnalyzer2::analyze().

32 { return ampl; }
double ampl
Definition: TPNFit.h:18

◆ getTimax()

double TPNFit::getTimax ( )
inline

Definition at line 33 of file TPNFit.h.

References timeatmax.

33 { return timeatmax; }
double timeatmax
Definition: TPNFit.h:19

◆ init()

void TPNFit::init ( int  nsamples,
int  firstsample,
int  lastsample 
)

Definition at line 24 of file TPNFit.cc.

References firstsample, fNsamples, fNum_samp_after_max, fNum_samp_bef_max, dqmdumpme::k, lastsample, NMAXSAMP2, and t.

Referenced by EcalPerEvtLaserAnalyzer::analyze(), EcalTestPulseAnalyzer::analyze(), EcalLaserAnalyzer::analyze(), and EcalLaserAnalyzer2::analyze().

24  {
25  fNsamples = nsamples;
28  //printf("nsamples=%d firstsample=%d lastsample=%d\n",nsamples,firstsample,lastsample);
29 
30  if (fNsamples > NMAXSAMP2)
31  printf("number of PN samples exceed maximum\n");
32 
33  for (int k = 0; k < NMAXSAMP2; k++)
34  t[k] = (double)k;
35 
36  return;
37 }
int fNum_samp_bef_max
Definition: TPNFit.h:12
int fNum_samp_after_max
Definition: TPNFit.h:13
int fNsamples
Definition: TPNFit.h:11
double t[NMAXSAMP2]
Definition: TPNFit.h:16
static constexpr int NMAXSAMP2
Definition: TPNFit.h:8
int lastsample
Definition: TPNFit.h:15
int firstsample
Definition: TPNFit.h:15

Member Data Documentation

◆ ampl

double TPNFit::ampl
private

Definition at line 18 of file TPNFit.h.

Referenced by doFit(), and getAmpl().

◆ firstsample

int TPNFit::firstsample
private

Definition at line 15 of file TPNFit.h.

Referenced by doFit(), and init().

◆ fNsamples

int TPNFit::fNsamples
private

Definition at line 11 of file TPNFit.h.

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

◆ fNum_samp_after_max

int TPNFit::fNum_samp_after_max
private

Definition at line 13 of file TPNFit.h.

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

◆ fNum_samp_bef_max

int TPNFit::fNum_samp_bef_max
private

Definition at line 12 of file TPNFit.h.

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

◆ fv1

double TPNFit::fv1[NMAXSAMP2]
private

Definition at line 17 of file TPNFit.h.

Referenced by doFit().

◆ fv2

double TPNFit::fv2[NMAXSAMP2]
private

Definition at line 17 of file TPNFit.h.

Referenced by doFit().

◆ fv3

double TPNFit::fv3[NMAXSAMP2]
private

Definition at line 17 of file TPNFit.h.

Referenced by doFit().

◆ lastsample

int TPNFit::lastsample
private

Definition at line 15 of file TPNFit.h.

Referenced by doFit(), and init().

◆ NMAXSAMP2

constexpr int TPNFit::NMAXSAMP2 = 50
static

Definition at line 8 of file TPNFit.h.

Referenced by init().

◆ t

double TPNFit::t[NMAXSAMP2]
private

Definition at line 16 of file TPNFit.h.

Referenced by init().

◆ timeatmax

double TPNFit::timeatmax
private

Definition at line 19 of file TPNFit.h.

Referenced by doFit(), and getTimax().

◆ val

double TPNFit::val[NMAXSAMP2]
private