Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Keerthi Nakkalil
gain_measurement
Commits
e3b614b1
Commit
e3b614b1
authored
Dec 13, 2020
by
Keerthi Nakkalil
Browse files
fitting function modified
parent
76dbc9ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
gain_measurement.cpp
View file @
e3b614b1
...
...
@@ -71,6 +71,8 @@ void fit_modified_erf(TH1D* hist_255,int colors,int markers,double injected_volt
fitpars
<<
std
::
setw
(
3
)
<<
std
::
setfill
(
'0'
)
<<
pixel_address
<<
"_"
<<
std
::
setw
(
3
)
<<
std
::
setfill
(
'0'
)
<<
pixel_address
<<
"
\t
"
<<
injected_voltage
<<
"
\t
"
<<
fiterf
->
GetParameter
(
1
)
<<
std
::
endl
;
// fitpars <<injected_voltage<<"\t"<< fiterf->GetParameter(1)<<std::endl;
hist_255
->
GetListOfFunctions
()
->
FindObject
(
"fiterf"
)
->
Draw
(
"same"
);
hist_255
->
SetStats
(
0
);
}
...
...
@@ -138,52 +140,59 @@ std::vector<TH1D*> gain_measurement_pixel(int i, int j)
return
hist_255
;
}
void
linear_fit
(
int
x
)
{
ifstream
fitpars
(
"fit_parameters.txt"
);
void
linear_fit
(
int
x
)
{
ifstream
fitpars
;
fitpars
.
open
(
"fit_parameters.txt"
);
std
::
string
pixel_address
;
std
::
vector
<
double
>
injected_
amp_vec
,
signals
_vec
;
double
injected_amplitude
,
sign
als
;
std
::
vector
<
double
>
amp_vec
,
mean
_vec
;
double
amp_vals
,
mean_v
als
;
std
::
vector
<
TGraph
*>
gr
;
std
::
vector
<
TGraph
*>
gr3
;
TGraph
*
gr2
=
new
TGraph
();
int
ctr
=
0
;
int
k
=
0
;
while
(
fitpars
>>
pixel_address
){
fitpars
>>
amp_vals
>>
mean_vals
;
amp_vec
.
push_back
(
amp_vals
);
mean_vec
.
push_back
(
mean_vals
);
gr
.
push_back
(
new
TGraph
(
amp_vec
.
size
(),
&
amp_vec
[
0
],
&
mean_vec
[
0
]));
ctr
++
;
}
if
(
fitpars
.
is_open
()){
while
(
!
fitpars
.
eof
()){
while
(
fitpars
>>
pixel_address
){
// cout<<"The injected amplitudes and the corresponding mean values for "<<pixel_address<<"are : " <<std::endl;
fitpars
>>
injected_amplitude
>>
signals
;
//cout<<injected_amplitude<<" "<<signals<<std::endl;
injected_amp_vec
.
push_back
(
injected_amplitude
);
signals_vec
.
push_back
(
signals
);
for
(
int
i
=
0
;
i
<
3
;
i
++
){
gr
.
push_back
(
new
TGraph
(
injected_amp_vec
.
size
(),
&
(
injected_amp_vec
[
i
]),
&
(
signals_vec
[
i
])));
}
}
for
(
int
j
=
0
;
j
<
256
;
j
++
){
auto
linear_fit
=
new
TF1
(
"linear_fit"
,
"[0]*x +[1]"
,
0
,
300
);
linear_fit
->
SetParNames
(
"slope"
,
"offset"
);
linear_fit
->
SetParameter
(
0
,
2
);
linear_fit
->
SetParameter
(
1
,
1200
);
linear_fit
->
SetLineColor
(
2
);
gr
.
at
(
j
)
->
Fit
(
linear_fit
);
gr
.
at
(
j
)
->
Draw
(
"AL*"
);
gr
.
at
(
j
)
->
GetXaxis
()
->
SetTitle
(
"Injected amplitude"
);
gr
.
at
(
j
)
->
GetYaxis
()
->
SetTitle
(
"mean values"
);
std
::
ofstream
slopes
;
slopes
.
open
(
"slopes.txt"
,
std
::
ofstream
::
app
);
slopes
<<
linear_fit
->
GetParameter
(
0
)
<<
" "
;
for
(
ctr
=
0
;
ctr
<
amp_vec
.
size
();
ctr
++
){
if
(
ctr
%
3
==
0
&&
ctr
>=
0
&&
ctr
<
amp_vec
.
size
()){
for
(
k
=
ctr
;
k
<
ctr
+
3
;
k
++
){
gr2
->
SetPoint
(
gr
.
at
(
k
)
->
GetN
(),
amp_vec
[
k
],
mean_vec
[
k
]);
}
gr3
.
push_back
(
gr2
);
}
}
cout
<<
gr3
.
size
()
<<
std
::
endl
;
for
(
int
j
=
0
;
j
<
gr3
.
size
();
j
++
){
auto
linear_fit
=
new
TF1
(
"linear_fit"
,
"[0]*x +[1]"
,
0
,
300
);
linear_fit
->
SetParNames
(
"slope"
,
"offset"
);
linear_fit
->
SetParameter
(
0
,
2
);
linear_fit
->
SetParameter
(
1
,
1200
);
linear_fit
->
SetLineColor
(
2
);
gr3
.
at
(
j
)
->
Fit
(
linear_fit
);
gr3
.
at
(
j
)
->
SetTitle
(
"injected voltage vs mean vals for 256 graphs "
);
gr3
.
at
(
j
)
->
GetXaxis
()
->
SetTitle
(
"injected voltage"
);
gr3
.
at
(
j
)
->
GetYaxis
()
->
SetTitle
(
"mean vals"
);
gr3
.
at
(
j
)
->
Draw
(
"A*"
);
std
::
ofstream
slopes
;
slopes
.
open
(
"slopes.txt"
,
std
::
ofstream
::
app
);
slopes
<<
linear_fit
->
GetParameter
(
0
)
<<
" "
;
}
}
void
slope_distribution
(
int
y
)
{
ifstream
slopes
(
"slopes.txt"
);
double
slopeval
;
TH1D
*
hist
=
new
TH1D
(
"slope"
,
"slope distribution"
,
200
,
-
2.0
,
10.
0
);
TH1D
*
hist
=
new
TH1D
(
"slope"
,
"slope distribution"
,
200
,
-
0.24540
,
-
.2451
0
);
if
(
slopes
.
is_open
()){
while
(
!
slopes
.
eof
()){
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment