CMS 3D CMS Logo

List of all members | Public Member Functions | 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
 

Private Attributes

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

Detailed Description

Definition at line 8 of file TPNFit.h.

Constructor & Destructor Documentation

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:11
int fNum_samp_after_max
Definition: TPNFit.h:12
int fNsamples
Definition: TPNFit.h:10
TPNFit::~TPNFit ( )
override

Definition at line 22 of file TPNFit.cc.

22 {}

Member Function Documentation

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

Definition at line 39 of file TPNFit.cc.

References a, ampl, b, HltBtagPostValidation_cff::c, hltPixelTracks_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(), EcalLaserAnalyzer2::analyze(), and EcalLaserAnalyzer::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:11
double fv3[50]
Definition: TPNFit.h:16
int fNum_samp_after_max
Definition: TPNFit.h:12
double timeatmax
Definition: TPNFit.h:18
int fNsamples
Definition: TPNFit.h:10
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
double fv2[50]
Definition: TPNFit.h:16
double val[50]
Definition: TPNFit.h:15
double fv1[50]
Definition: TPNFit.h:16
double b
Definition: hdecay.h:118
int lastsample
Definition: TPNFit.h:14
double a
Definition: hdecay.h:119
int firstsample
Definition: TPNFit.h:14
double ampl
Definition: TPNFit.h:17
double TPNFit::getAmpl ( )
inline

Definition at line 31 of file TPNFit.h.

References ampl.

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

31 { return ampl; }
double ampl
Definition: TPNFit.h:17
double TPNFit::getTimax ( )
inline

Definition at line 32 of file TPNFit.h.

References timeatmax.

32 { return timeatmax; }
double timeatmax
Definition: TPNFit.h:18
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(), EcalLaserAnalyzer2::analyze(), and EcalLaserAnalyzer::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:11
int fNum_samp_after_max
Definition: TPNFit.h:12
int fNsamples
Definition: TPNFit.h:10
double t[50]
Definition: TPNFit.h:15
#define NMAXSAMP2
Definition: TPNFit.h:6
int lastsample
Definition: TPNFit.h:14
int firstsample
Definition: TPNFit.h:14

Member Data Documentation

double TPNFit::ampl
private

Definition at line 17 of file TPNFit.h.

Referenced by doFit(), and getAmpl().

int TPNFit::firstsample
private

Definition at line 14 of file TPNFit.h.

Referenced by doFit(), and init().

int TPNFit::fNsamples
private

Definition at line 10 of file TPNFit.h.

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

int TPNFit::fNum_samp_after_max
private

Definition at line 12 of file TPNFit.h.

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

int TPNFit::fNum_samp_bef_max
private

Definition at line 11 of file TPNFit.h.

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

double TPNFit::fv1[50]
private

Definition at line 16 of file TPNFit.h.

Referenced by doFit().

double TPNFit::fv2[50]
private

Definition at line 16 of file TPNFit.h.

Referenced by doFit().

double TPNFit::fv3[50]
private

Definition at line 16 of file TPNFit.h.

Referenced by doFit().

int TPNFit::lastsample
private

Definition at line 14 of file TPNFit.h.

Referenced by doFit(), and init().

double TPNFit::t[50]
private

Definition at line 15 of file TPNFit.h.

Referenced by init().

double TPNFit::timeatmax
private

Definition at line 18 of file TPNFit.h.

Referenced by doFit(), and getTimax().

double TPNFit::val[50]
private