Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
CalibCalorimetry
EcalLaserAnalyzer
src
TPNFit.cc
Go to the documentation of this file.
1
/*
2
* \class TPNFit
3
*
4
* \author: Patrice Verrecchia - CEA/Saclay
5
*/
6
7
#include <
CalibCalorimetry/EcalLaserAnalyzer/interface/TPNFit.h
>
8
9
#include <iostream>
10
#include "TVectorD.h"
11
12
//ClassImp(TPNFit)
13
14
15
// Constructor...
16
TPNFit::TPNFit
()
17
{
18
19
fNsamples
= 0;
20
fNum_samp_bef_max
= 0;
21
fNum_samp_after_max
= 0;
22
}
23
24
// Destructor
25
TPNFit::~TPNFit
()
26
{
27
}
28
29
void
TPNFit::init
(
int
nsamples,
int
firstsample,
int
lastsample)
30
{
31
fNsamples
= nsamples ;
32
fNum_samp_bef_max
=
firstsample
;
33
fNum_samp_after_max
=
lastsample
;
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
}
44
45
double
TPNFit::doFit
(
int
maxsample,
double
*
adc
)
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;
55
if
(
lastsample
>=
fNsamples
)
lastsample
=
fNsamples
-1;
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
}
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:25
TPNFit::fv3
double fv3[50]
Definition:
TPNFit.h:19
TPNFit::init
void init(int, int, int)
Definition:
TPNFit.cc:29
TPNFit::fNum_samp_after_max
int fNum_samp_after_max
Definition:
TPNFit.h:15
EnergyCorrector.c
tuple c
Definition:
EnergyCorrector.py:43
TPNFit::timeatmax
double timeatmax
Definition:
TPNFit.h:21
TPNFit::fNsamples
int fNsamples
Definition:
TPNFit.h:13
TPNFit.h
mathSSE::return
return((rh^lh)&mask)
python.connectstrParser.f2
string f2
Definition:
connectstrParser.py:80
TPNFit::t
double t[50]
Definition:
TPNFit.h:18
NMAXSAMP2
#define NMAXSAMP2
Definition:
TPNFit.h:6
TPNFit::TPNFit
TPNFit()
Definition:
TPNFit.cc:16
TPNFit::fv2
double fv2[50]
Definition:
TPNFit.h:19
TPNFit::val
double val[50]
Definition:
TPNFit.h:18
detailsBasic3DVector::y
float float y
Definition:
extBasic3DVector.h:15
TPNFit::fv1
double fv1[50]
Definition:
TPNFit.h:19
b
double b
Definition:
hdecay.h:120
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:45
relval_steps.k
list k
Definition:
relval_steps.py:1508
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