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 [NMAXSAMP2]
 
double fv2 [NMAXSAMP2]
 
double fv3 [NMAXSAMP2]
 
int lastsample
 
double t [NMAXSAMP2]
 
double timeatmax
 
double val [NMAXSAMP2]
 

Detailed Description

Definition at line 8 of file TPNFit.h.

Constructor & Destructor Documentation

TPNFit::TPNFit ( )

Definition at line 17 of file TPNFit.cc.

References fNsamples, fNum_samp_after_max, and fNum_samp_bef_max.

18 {
19 
20  fNsamples = 0;
23 }
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 26 of file TPNFit.cc.

27 {
28 }

Member Function Documentation

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

Definition at line 46 of file TPNFit.cc.

References a, ampl, b, trackerHits::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 detailsBasic3DVector::y.

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

References firstsample, fNsamples, fNum_samp_after_max, fNum_samp_bef_max, gen::k, lastsample, NMAXSAMP2, hitfit::return, and t.

31 {
32  fNsamples = nsamples ;
35  //printf("nsamples=%d firstsample=%d lastsample=%d\n",nsamples,firstsample,lastsample);
36 
37  if(fNsamples > NMAXSAMP2)
38  printf("number of PN samples exceed maximum\n");
39 
40  for(int k=0;k<NMAXSAMP2;k++)
41  t[k]= (double) k;
42 
43  return ;
44 }
int fNum_samp_bef_max
Definition: TPNFit.h:14
int fNum_samp_after_max
Definition: TPNFit.h:15
int fNsamples
Definition: TPNFit.h:13
double t[NMAXSAMP2]
Definition: TPNFit.h:18
#define NMAXSAMP2
Definition: TPNFit.h:6
int k[5][pyjets_maxn]
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[NMAXSAMP2]
private

Definition at line 19 of file TPNFit.h.

Referenced by doFit().

double TPNFit::fv2[NMAXSAMP2]
private

Definition at line 19 of file TPNFit.h.

Referenced by doFit().

double TPNFit::fv3[NMAXSAMP2]
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[NMAXSAMP2]
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[NMAXSAMP2]
private

Definition at line 18 of file TPNFit.h.

Referenced by doFit().