CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
virtual ~TPNFit ()
 

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 16 of file TPNFit.cc.

References fNsamples, fNum_samp_after_max, and fNum_samp_bef_max.

17 {
18 
19  fNsamples = 0;
22 }
int fNum_samp_bef_max
Definition: TPNFit.h:14
int fNum_samp_after_max
Definition: TPNFit.h:15
int fNsamples
Definition: TPNFit.h:13
TPNFit::~TPNFit ( )
virtual

Definition at line 25 of file TPNFit.cc.

26 {
27 }

Member Function Documentation

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

Definition at line 45 of file TPNFit.cc.

References a, ampl, b, EnergyCorrector::c, python.connectstrParser::f1, python.connectstrParser::f2, python.connectstrParser::f3, firstsample, fNsamples, fNum_samp_after_max, fNum_samp_bef_max, fv1, fv2, fv3, i, lastsample, timeatmax, val, and y.

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

Definition at line 35 of file TPNFit.h.

References ampl.

35 {return ampl;}
double ampl
Definition: TPNFit.h:20
double TPNFit::getTimax ( )
inline

Definition at line 36 of file TPNFit.h.

References timeatmax.

36 {return timeatmax;}
double timeatmax
Definition: TPNFit.h:21
void TPNFit::init ( int  nsamples,
int  firstsample,
int  lastsample 
)

Definition at line 29 of file TPNFit.cc.

References firstsample, fNsamples, fNum_samp_after_max, fNum_samp_bef_max, relval_steps::k, lastsample, NMAXSAMP2, mathSSE::return(), and t.

30 {
31  fNsamples = nsamples ;
34  //printf("nsamples=%d firstsample=%d lastsample=%d\n",nsamples,firstsample,lastsample);
35 
36  if(fNsamples > NMAXSAMP2)
37  printf("number of PN samples exceed maximum\n");
38 
39  for(int k=0;k<NMAXSAMP2;k++)
40  t[k]= (double) k;
41 
42  return ;
43 }
int fNum_samp_bef_max
Definition: TPNFit.h:14
int fNum_samp_after_max
Definition: TPNFit.h:15
int fNsamples
Definition: TPNFit.h:13
return((rh^lh)&mask)
double t[50]
Definition: TPNFit.h:18
#define NMAXSAMP2
Definition: TPNFit.h:6
int lastsample
Definition: TPNFit.h:17
int firstsample
Definition: TPNFit.h:17

Member Data Documentation

double TPNFit::ampl
private

Definition at line 20 of file TPNFit.h.

Referenced by doFit(), and getAmpl().

int TPNFit::firstsample
private

Definition at line 17 of file TPNFit.h.

Referenced by doFit(), and init().

int TPNFit::fNsamples
private

Definition at line 13 of file TPNFit.h.

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

int TPNFit::fNum_samp_after_max
private

Definition at line 15 of file TPNFit.h.

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

int TPNFit::fNum_samp_bef_max
private

Definition at line 14 of file TPNFit.h.

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

double TPNFit::fv1[50]
private

Definition at line 19 of file TPNFit.h.

Referenced by doFit().

double TPNFit::fv2[50]
private

Definition at line 19 of file TPNFit.h.

Referenced by doFit().

double TPNFit::fv3[50]
private

Definition at line 19 of file TPNFit.h.

Referenced by doFit().

int TPNFit::lastsample
private

Definition at line 17 of file TPNFit.h.

Referenced by doFit(), and init().

double TPNFit::t[50]
private

Definition at line 18 of file TPNFit.h.

Referenced by init().

double TPNFit::timeatmax
private

Definition at line 21 of file TPNFit.h.

Referenced by doFit(), and getTimax().

double TPNFit::val[50]
private