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
cbb8487f
Commit
cbb8487f
authored
Dec 17, 2020
by
Keerthi Nakkalil
Browse files
6 bad data points still remains.
parent
e3b614b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
gain_measurement.cpp
View file @
cbb8487f
...
...
@@ -45,6 +45,7 @@ void fit_modified_erf(TH1D* hist_255,int colors,int markers,double injected_volt
TF1
*
fiterf
=
new
TF1
(
"fiterf"
,
"([0]/2)*(1-TMath::Erf((x-[1])/(sqrt(2)*[2])))"
,
fitmin
,
fitmax
);
ROOT
::
Math
::
MinimizerOptions
::
SetDefaultMaxFunctionCalls
(
10000
);
/*Setting parameter names*/
fiterf
->
SetParNames
(
"constant"
,
"mean"
,
"noise"
);
...
...
@@ -52,20 +53,28 @@ void fit_modified_erf(TH1D* hist_255,int colors,int markers,double injected_volt
//Assigning Initial values to the parameters
fiterf
->
SetParameter
(
0
,
200.0
);
int
lastbin1
=
hist_255
->
FindLastBinAbove
(
200
);
int
lastbin1
=
hist_255
->
FindLastBinAbove
(
200
,
1
);
double
mean
=
hist_255
->
GetBinCenter
(
lastbin1
);
fiterf
->
SetParameter
(
1
,
mean
);
cout
<<
"The initial mean value is "
<<
mean
<<
std
::
endl
;
int
lastbin2
=
hist_255
->
FindLastBinAbove
(
150
);
int
lastbin3
=
hist_255
->
FindLastBinAbove
(
50
);
int
lastbin2
=
hist_255
->
FindLastBinAbove
(
150
,
1
);
int
lastbin3
=
hist_255
->
FindLastBinAbove
(
50
,
1
);
int
sigma
=
lastbin3
-
lastbin2
;
fiterf
->
SetParameter
(
2
,
sigma
);
cout
<<
"The initial noise value is "
<<
sigma
<<
std
::
endl
;
fiterf
->
SetLineWidth
(
2
);
fiterf
->
SetLineColor
(
2
);
hist_255
->
Fit
(
"fiterf"
,
" R"
);
/* if(mean<1000&&sigma<0){
TF1::RejectPoint();
return 0;
}
else{*/
hist_255
->
Fit
(
"fiterf"
,
"R"
);
std
::
ofstream
fitpars
;
fitpars
.
open
(
"fit_parameters.txt"
,
std
::
ofstream
::
app
);
fitpars
<<
std
::
setw
(
3
)
<<
std
::
setfill
(
'0'
)
<<
pixel_address
<<
"_"
...
...
@@ -75,6 +84,7 @@ void fit_modified_erf(TH1D* hist_255,int colors,int markers,double injected_volt
// fitpars <<injected_voltage<<"\t"<< fiterf->GetParameter(1)<<std::endl;
hist_255
->
GetListOfFunctions
()
->
FindObject
(
"fiterf"
)
->
Draw
(
"same"
);
hist_255
->
SetStats
(
0
);
// }
}
std
::
vector
<
TH1D
*>
gain_measurement_pixel
(
int
i
,
int
j
)
...
...
@@ -140,59 +150,52 @@ std::vector<TH1D*> gain_measurement_pixel(int i, int j)
return
hist_255
;
}
void
linear_fit
(
int
x
){
ifstream
fitpars
;
fitpars
.
open
(
"fit_parameters.txt"
);
void
linear_fit
(){
ifstream
fitpars
(
"fit_parameters.txt"
);
std
::
string
pixel_address
;
std
::
vector
<
double
>
amp_vec
,
mean_vec
;
double
amp_vals
,
mean_vals
;
std
::
vector
<
TGraph
*>
gr
;
std
::
vector
<
TGraph
*>
gr3
;
TGraph
*
gr2
=
new
TGraph
();
int
ctr
=
0
;
int
k
=
0
;
auto
mg
=
new
TMultiGraph
();
int
ctr
=
0
;
while
(
fitpars
>>
pixel_address
){
cout
<<
"ctr: "
<<
ctr
<<
" modulo: "
<<
ctr
%
3
<<
endl
;
if
(
ctr
%
3
==
0
){
gr
.
push_back
(
new
TGraph
());
}
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
]));
gr
.
back
()
->
SetPoint
(
ctr
%
3
,
amp_vals
,
mean_vals
);
ctr
++
;
}
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
++
){
cout
<<
gr
.
size
()
<<
std
::
endl
;
for
(
int
j
=
0
;
j
<
gr
.
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*"
);
cout
<<
"graph "
<<
j
<<
" Number of points : "
<<
gr
.
at
(
j
)
->
GetN
()
<<
std
::
endl
;
gr
.
at
(
j
)
->
Fit
(
linear_fit
);
mg
->
Add
(
gr
.
at
(
j
));
mg
->
SetTitle
(
"injected voltage vs mean vals for 256 graphs ;injected voltage;mean values"
);
std
::
ofstream
slopes
;
slopes
.
open
(
"slopes.txt"
,
std
::
ofstream
::
app
);
slopes
<<
linear_fit
->
GetParameter
(
0
)
<<
" "
;
}
mg
->
Draw
(
"A*"
);
}
void
slope_distribution
(
int
y
)
void
slope_distribution
()
{
ifstream
slopes
(
"slopes.txt"
);
double
slopeval
;
TH1D
*
hist
=
new
TH1D
(
"slope"
,
"slope distribution"
,
200
,
-
0.24540
,
-
.24510
);
TH1D
*
hist
=
new
TH1D
(
"slope"
,
"slope distribution"
,
200
,
0
,
3
);
if
(
slopes
.
is_open
()){
while
(
!
slopes
.
eof
()){
...
...
@@ -207,7 +210,7 @@ void slope_distribution(int y)
void
gain_
9
()
void
gain_
measurement
()
{
int
row
,
col
;
THStack
*
hs
=
new
THStack
(
"hs"
,
"Gain measurements"
);
...
...
@@ -264,9 +267,9 @@ void gain_9()
leg
->
Draw
(
"SAME"
);
c1
->
cd
(
2
);
linear_fit
(
5
);
linear_fit
();
c1
->
cd
(
3
);
slope_distribution
(
5
);
slope_distribution
();
}
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