Main Page
Namespaces
Classes
Package Documentation
CVS Directory
WorkBook
Offline Guide
Release schedule
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
CalibCalorimetry
EcalLaserAnalyzer
src
TPNFit.cc
Go to the documentation of this file.
1
/*
2
* \class TPNFit
3
*
4
* $Date: 2012/02/09 10:08:10 $
5
* \author: Patrice Verrecchia - CEA/Saclay
6
*/
7
8
#include <
CalibCalorimetry/EcalLaserAnalyzer/interface/TPNFit.h
>
9
10
#include <iostream>
11
#include "TVectorD.h"
12
13
//ClassImp(TPNFit)
14
15
16
// Constructor...
17
TPNFit::TPNFit
()
18
{
19
20
fNsamples
= 0;
21
fNum_samp_bef_max
= 0;
22
fNum_samp_after_max
= 0;
23
}
24
25
// Destructor
26
TPNFit::~TPNFit
()
27
{
28
}
29
30
void
TPNFit::init
(
int
nsamples,
int
firstsample,
int
lastsample)
31
{
32
fNsamples
= nsamples ;
33
fNum_samp_bef_max
=
firstsample
;
34
fNum_samp_after_max
=
lastsample
;
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
}
45
46
double
TPNFit::doFit
(
int
maxsample,
double
*
adc
)
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;
56
if
(
lastsample
>=
fNsamples
)
lastsample
=
fNsamples
-1;
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
}
ecalMGPA::adc
int adc(sample_type sample)
get the ADC sample (12 bits)
Definition:
EcalMGPASample.h:11
TPNFit::fNum_samp_bef_max
int fNum_samp_bef_max
Definition:
TPNFit.h:14
i
int i
Definition:
DBlmapReader.cc:9
TPNFit::~TPNFit
virtual ~TPNFit()
Definition:
TPNFit.cc:26
TPNFit::fv1
double fv1[NMAXSAMP2]
Definition:
TPNFit.h:19
TPNFit::init
void init(int, int, int)
Definition:
TPNFit.cc:30
TPNFit::fv3
double fv3[NMAXSAMP2]
Definition:
TPNFit.h:19
TPNFit::fNum_samp_after_max
int fNum_samp_after_max
Definition:
TPNFit.h:15
TPNFit::timeatmax
double timeatmax
Definition:
TPNFit.h:21
TPNFit::fNsamples
int fNsamples
Definition:
TPNFit.h:13
TPNFit.h
python.connectstrParser.f2
string f2
Definition:
connectstrParser.py:80
TPNFit::t
double t[NMAXSAMP2]
Definition:
TPNFit.h:18
NMAXSAMP2
#define NMAXSAMP2
Definition:
TPNFit.h:6
TPNFit::TPNFit
TPNFit()
Definition:
TPNFit.cc:17
gen::k
int k[5][pyjets_maxn]
Definition:
Cascade2Hadronizer.cc:81
hitfit::return
return
Definition:
Lepjets_Event_Jet.cc:278
detailsBasic3DVector::y
float float y
Definition:
newBasic3DVector.h:15
b
double b
Definition:
hdecay.h:120
trackerHits.c
tuple c
Definition:
trackerHits.py:26
TPNFit::lastsample
int lastsample
Definition:
TPNFit.h:17
python.connectstrParser.f3
string f3
Definition:
connectstrParser.py:85
a
double a
Definition:
hdecay.h:121
TPNFit::firstsample
int firstsample
Definition:
TPNFit.h:17
TPNFit::doFit
double doFit(int, double *)
Definition:
TPNFit.cc:46
TPNFit::fv2
double fv2[NMAXSAMP2]
Definition:
TPNFit.h:19
TPNFit::val
double val[NMAXSAMP2]
Definition:
TPNFit.h:18
TPNFit::ampl
double ampl
Definition:
TPNFit.h:20
python.connectstrParser.f1
string f1
Definition:
connectstrParser.py:75
Generated for CMSSW Reference Manual by
1.8.5