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
4f1c14a2
Commit
4f1c14a2
authored
Nov 17, 2020
by
Keerthi Nakkalil
Browse files
Fitting function works
parent
99eced95
Changes
1
Hide whitespace changes
Inline
Side-by-side
gain_measurement.cpp
View file @
4f1c14a2
void
gain_measurement
()
{
ifstream
file_255
;
file_255
.
open
(
"255_255.dat"
);
cout
<<
"The data file 255_255 is opened..."
<<
std
::
endl
;
TCanvas
*
c1
=
new
TCanvas
();
TTree
*
tree
=
new
TTree
(
"tree"
,
"tree"
);
TH1D
*
hist_255
=
new
TH1D
(
"hist_255"
,
" Threshold gain measurement"
,
1
00
,
90
0
,
1
30
0
);
TH1D
*
hist_255
=
new
TH1D
(
"hist_255"
,
" Threshold gain measurement"
,
5
00
,
85
0
,
1
75
0
);
tree
->
ReadFile
(
"255_255.dat"
,
"x/D:y/D"
);
tree
->
SetEstimate
(
-
1
);
//Set the #entries to estimate variable limits. n=-1, estimate is set to current maximum of the tree.
tree
->
Draw
(
"x>>hist_255"
,
"y"
,
"HIST"
);
hist_255
->
SetMarkerStyle
(
3
);
tree
->
Draw
(
"x>>hist_255"
,
"y"
,
"HIST P"
);
hist_255
->
GetXaxis
()
->
SetTitle
(
"Threshold"
);
hist_255
->
GetYaxis
()
->
SetTitle
(
"# signals above the threshold"
);
//fitting the histogram with modified error function
TF1
*
modified_erf
=
new
TF1
(
"modified_erf"
,
"[0]*(1-TMath::Erf((x-[1])/(sqrt(2)*[2])))"
,
1000
,
1250
);
//Not sure how to give the fit range
modified_erf
->
SetParameter
(
0
,
100
);
modified_erf
->
SetParameter
(
1
,
1115
);
modified_erf
->
SetParameter
(
2
,
0
);
//Not sure how to give the initial value
TF1
*
modified_erf
=
new
TF1
(
"modified_erf"
,
"([0]/2)*(1-TMath::Erf((x-[1])/(sqrt(2)*[2])))"
,
1220
,
1700
);
modified_erf
->
SetParNames
(
"constant"
,
"mean"
,
"noise"
);
hist_255
->
Fit
(
"modified_erf"
);
hist_255
->
Draw
();
//file_255.close();
modified_erf
->
SetParNames
(
"constant"
,
"mean"
,
"noise"
);
modified_erf
->
SetParameter
(
1
,
hist_255
->
GetMean
());
modified_erf
->
SetParameter
(
2
,
hist_255
->
GetRMS
());
modified_erf
->
SetParLimits
(
0
,
200
,
250.0
);
modified_erf
->
SetLineWidth
(
2
);
modified_erf
->
SetLineColor
(
2
);
hist_255
->
Fit
(
"modified_erf"
,
"R"
);
hist_255
->
GetListOfFunctions
()
->
FindObject
(
"modified_erf"
)
->
Draw
(
"same"
);
cout
<<
"Code succesfull..."
<<
std
::
endl
;
}
...
...
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