Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ROOT_tutorial
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vratislav Chudoba
ROOT_tutorial
Commits
cf40581b
Commit
cf40581b
authored
Feb 07, 2017
by
Vratislav Chudoba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Script modified; two files added.
parent
fd30f2e5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
245 additions
and
107 deletions
+245
-107
.rootrc
.rootrc
+5
-0
fittingBetter.cxx
fittingBetter.cxx
+128
-107
rootlogon.C
rootlogon.C
+112
-0
No files found.
.rootrc
0 → 100644
View file @
cf40581b
Canvas.ShowEventStatus: true
Canvas.ShowToolTips: true
Canvas.ShowToolBar: true
Canvas.ShowEditor: true
\ No newline at end of file
fittingBetter.cxx
View file @
cf40581b
...
...
@@ -10,27 +10,147 @@
void
fittingBetter
()
{
// gStyle->ToggleEditor()
;
const
Int_t
bins
=
500
;
TFile
*
fr
=
new
TFile
(
"simeventsNew.root"
);
TFile
*
fr
=
new
TFile
(
"simeventsNew
1
.root"
);
TTree
*
tr
=
(
TTree
*
)
fr
->
Get
(
"simevents"
);
TCanvas
*
c1
=
new
TCanvas
(
"name1"
,
"title of canvas 1"
);
c1
->
Divide
(
2
,
2
);
// c1->Divide(2,2,0.00005,0.00005);
// c1->Divide(2,2,0,0);
c1
->
cd
(
1
);
tr
->
Draw
(
"E"
,
"E>0"
);
TH1F
*
htemp
=
(
TH1F
*
)
gPad
->
GetPrimitive
(
"htemp"
);
htemp
->
GetXaxis
()
->
CenterTitle
();
htemp
->
GetXaxis
()
->
SetTitle
(
"E [MeV]"
);
htemp
->
GetXaxis
()
->
SetTitleSize
(
0.06
);
htemp
->
GetXaxis
()
->
SetTitleOffset
(
0.74
);
htemp
->
GetYaxis
()
->
CenterTitle
();
htemp
->
GetYaxis
()
->
SetTitle
(
"Events"
);
htemp
->
GetYaxis
()
->
SetTitleSize
(
0.06
);
htemp
->
GetYaxis
()
->
SetTitleOffset
(
0.85
);
c1
->
cd
(
2
);
TH1F
*
hE
=
new
TH1F
(
"hE"
,
"Interesting region"
,
200
,
0.7
,
1.3
);
TH1F
*
hE
=
new
TH1F
(
"hE"
,
"Interesting region"
,
bins
,
0.7
,
1.3
);
tr
->
Draw
(
"E>>hE"
,
"E>0.7"
);
// tr1->SetLineColor(kRed
);
// tr1->Draw("E", "E>0", "same
");
// tr2->SetLineColor(kBlue
);
// tr2->Draw("E", "E>0", "same
");
hE
->
GetXaxis
()
->
CenterTitle
(
);
hE
->
GetXaxis
()
->
SetTitle
(
"E [MeV]
"
);
hE
->
GetYaxis
()
->
CenterTitle
(
);
hE
->
GetYaxis
()
->
SetTitle
(
"Events
"
);
c1
->
cd
(
3
);
TH1F
*
hEfitSep
=
new
TH1F
(
"hEfitSep"
,
"Fit by two functions"
,
bins
,
0.7
,
1.3
);
hEfitSep
->
GetXaxis
()
->
CenterTitle
();
hEfitSep
->
GetXaxis
()
->
SetTitle
(
"E [MeV]"
);
hEfitSep
->
GetYaxis
()
->
CenterTitle
();
hEfitSep
->
GetYaxis
()
->
SetTitle
(
"Events"
);
tr
->
Draw
(
"E >> hEfitSep"
,
""
,
""
);
TF1
*
g1
=
new
TF1
(
"m1"
,
"gaus"
,
0.9
,
1.05
);
TF1
*
g2
=
new
TF1
(
"m2"
,
"gaus"
,
1.08
,
1.15
);
// The total is the sum of the three, each has 3 parameters
TF1
*
total
=
new
TF1
(
"mstotal"
,
"gaus(0)+gaus(3)"
,
0.9
,
1.3
);
Double_t
par
[
6
];
// Fit each function and add it to the list of functions
hEfitSep
->
Fit
(
g1
,
"R"
);
hEfitSep
->
Fit
(
g2
,
"R+"
);
c1
->
cd
(
4
);
TH1F
*
hEtot
=
new
TH1F
(
"hEtot"
,
"Fit by multiple function"
,
bins
,
0.7
,
1.3
);
hEtot
->
GetXaxis
()
->
CenterTitle
();
hEtot
->
GetXaxis
()
->
SetTitle
(
"E [MeV]"
);
hEtot
->
GetYaxis
()
->
CenterTitle
();
hEtot
->
GetYaxis
()
->
SetTitle
(
"Events"
);
tr
->
Draw
(
"E >> hEtot"
,
""
,
""
);
// Get the parameters from the fit
g1
->
GetParameters
(
&
par
[
0
]);
g2
->
GetParameters
(
&
par
[
3
]);
// Use the parameters on the sum
total
->
SetParameters
(
par
);
hEtot
->
Fit
(
total
,
"R+"
);
TCanvas
*
c2
=
new
TCanvas
(
"name2"
,
"title of canvas 2"
);
c2
->
Divide
(
2
,
2
);
c2
->
cd
(
1
);
TH1F
*
hEDecomposition
=
new
TH1F
(
*
hE
);
hEDecomposition
->
Draw
();
Double_t
parTotal
[
6
];
total
->
GetParameters
(
&
parTotal
[
0
]);
TF1
*
gLow
=
new
TF1
(
"mLow"
,
"gaus"
,
0.8
,
1.2
);
TF1
*
gHigh
=
new
TF1
(
"mHigh"
,
"gaus"
,
1.0
,
1.3
);
gHigh
->
SetLineColor
(
kGreen
);
gLow
->
SetParameter
(
0
,
parTotal
[
0
]);
gLow
->
SetParameter
(
1
,
parTotal
[
1
]);
gLow
->
SetParameter
(
2
,
parTotal
[
2
]);
gHigh
->
SetParameter
(
0
,
parTotal
[
3
]);
gHigh
->
SetParameter
(
1
,
parTotal
[
4
]);
gHigh
->
SetParameter
(
2
,
parTotal
[
5
]);
gLow
->
Draw
(
"same"
);
gHigh
->
Draw
(
"same"
);
c2
->
cd
(
2
);
hEtot
->
Draw
();
gHigh
->
Draw
(
"same"
);
c2
->
cd
(
3
);
TH1F
*
hInput
=
new
TH1F
(
*
hEDecomposition
);
hInput
->
SetName
(
"hInput"
);
tr
->
Draw
(
"Egamma >> hInput"
,
""
);
c2
->
cd
(
4
);
// TH1F *hEtotZoom = new TH1F(*hEtot);
TH1F
*
hEtotZoom
=
(
TH1F
*
)
hEtot
->
Clone
();
hEtotZoom
->
SetName
(
"hEtotZoom"
);
// hEtotZoom->
hEtotZoom
->
GetXaxis
()
->
SetRangeUser
(
1.04
,
1.18
);
hEtotZoom
->
Draw
();
// total->Draw("same");
gHigh
->
Draw
(
"same"
);
Double_t
maxSingle
=
gHigh
->
GetMaximumX
(
1.08
,
1.14
);
Double_t
maxTotal
=
total
->
GetMaximumX
(
1.08
,
1.14
);
// cout << maxSingle << endl;
TLine
*
l1
=
new
TLine
(
maxSingle
,
100.
,
maxSingle
,
800.
);
l1
->
SetLineWidth
(
2
);
l1
->
SetLineColor
(
gHigh
->
GetLineColor
());
l1
->
Draw
(
""
);
TLine
*
l2
=
new
TLine
(
maxTotal
,
100.
,
maxTotal
,
800.
);
l2
->
SetLineWidth
(
2
);
l2
->
SetLineColor
(
total
->
GetLineColor
());
l2
->
Draw
(
""
);
return
;
// gStyle->ToggleEditor();
TFile
*
fr
=
new
TFile
(
"simeventsNew.root"
);
TTree
*
tr
=
(
TTree
*
)
fr
->
Get
(
"simevents"
);
TCanvas
*
c1
=
new
TCanvas
(
"name1"
,
"title of canvas 1"
);
c1
->
Divide
(
2
,
2
);
c1
->
cd
(
3
);
// fr.cd();
TH1F
*
hEfitSep
=
new
TH1F
(
"hEfitSep"
,
"Fit by two functions"
,
200
,
0.7
,
1.3
);
...
...
@@ -97,109 +217,10 @@ void fittingBetter()
c1
->
Update
();
gStyle
->
ToggleEditor
();
//
gStyle->ToggleEditor();
return
;
TCanvas
*
c2
=
new
TCanvas
(
"name2"
,
"title of canvas 2"
);
c2
->
Divide
(
2
,
2
);
c2
->
cd
(
1
);
tr
->
Draw
(
"E"
,
"E>0.95"
);
TH1F
*
h
=
(
TH1F
*
)
gPad
->
GetPrimitive
(
"htemp"
);
c2
->
cd
(
2
);
// fr.cd();
TH1F
*
hE
=
new
TH1F
(
"hE"
,
"histogram title"
,
100
,
0.95
,
1.4
);
hE
->
Draw
();
tr
->
Draw
(
"E >> hE"
,
""
,
""
);
TF1
*
g1
=
new
TF1
(
"m1"
,
"gaus"
,
1.
,
1.15
);
TF1
*
g2
=
new
TF1
(
"m2"
,
"gaus"
,
1.2
,
1.3
);
// The total is the sum of the three, each has 3 parameters
TF1
*
total
=
new
TF1
(
"mstotal"
,
"gaus(0)+gaus(3)"
,
1.
,
1.3
);
Double_t
par
[
6
];
// Fit each function and add it to the list of functions
hE
->
Fit
(
g1
,
"R"
);
hE
->
Fit
(
g2
,
"R+"
);
c2
->
cd
(
3
);
TH1F
*
hEtot
=
new
TH1F
(
"hEtot"
,
"histogram title"
,
100
,
0.95
,
1.4
);
hEtot
->
Draw
();
tr
->
Draw
(
"E >> hEtot"
,
""
,
""
);
// Get the parameters from the fit
g1
->
GetParameters
(
&
par
[
0
]);
g2
->
GetParameters
(
&
par
[
3
]);
// Use the parameters on the sum
total
->
SetParameters
(
par
);
hEtot
->
Fit
(
total
,
"R+"
);
TCanvas
*
c3
=
new
TCanvas
(
"name3"
,
"title of canvas 3"
);
c3
->
Divide
(
2
,
2
);
c3
->
cd
(
1
);
// tr1->Draw("E", "E>0.95");
// TH1F *h = (TH1F*)gPad->GetPrimitive("htemp");
c3
->
cd
(
2
);
// fr.cd();
TH1F
*
hE1
=
new
TH1F
(
"hE1"
,
"histogram title"
,
100
,
0.95
,
1.4
);
hE1
->
Draw
();
// tr1->Draw("E >> hE1", "", "");
TF1
*
g11
=
new
TF1
(
"m11"
,
"gaus"
,
1.
,
1.15
);
TF1
*
g21
=
new
TF1
(
"m21"
,
"gaus"
,
1.2
,
1.3
);
// The total is the sum of the three, each has 3 parameters
TF1
*
total1
=
new
TF1
(
"mstotal1"
,
"gaus(0)+gaus(3)"
,
1.
,
1.3
);
Double_t
par1
[
6
];
// Fit each function and add it to the list of functions
hE1
->
Fit
(
g11
,
"R"
);
hE1
->
Fit
(
g21
,
"R+"
);
c3
->
cd
(
3
);
TH1F
*
hEtot1
=
new
TH1F
(
"hEtot1"
,
"histogram title"
,
100
,
0.95
,
1.4
);
hEtot1
->
Draw
();
// tr1->Draw("E >> hEtot1", "", "");
// Get the parameters from the fit
g11
->
GetParameters
(
&
par1
[
0
]);
g21
->
GetParameters
(
&
par1
[
3
]);
// Use the parameters on the sum
total1
->
SetParameters
(
par1
);
hEtot1
->
Fit
(
total1
,
"R+"
);
c3
->
cd
(
4
);
TH1F
*
hEtot11
=
new
TH1F
(
"hEtot11"
,
"histogram title"
,
100
,
0.95
,
1.4
);
// tr1->Draw("E >> hEtot11", "", "");
Double_t
par12
[
6
];
total1
->
GetParameters
(
&
par12
[
0
]);
TF1
*
gLow
=
new
TF1
(
"mLow"
,
"gaus"
,
0.95
,
1.2
);
TF1
*
gHigh
=
new
TF1
(
"mHigh"
,
"gaus"
,
1.0
,
1.4
);
gHigh
->
SetLineColor
(
kGreen
);
gLow
->
SetParameter
(
0
,
par12
[
0
]);
gLow
->
SetParameter
(
1
,
par12
[
1
]);
gLow
->
SetParameter
(
2
,
par12
[
2
]);
gHigh
->
SetParameter
(
0
,
par12
[
3
]);
gHigh
->
SetParameter
(
1
,
par12
[
4
]);
gHigh
->
SetParameter
(
2
,
par12
[
5
]);
gLow
->
Draw
(
"same"
);
gHigh
->
Draw
(
"same"
);
}
rootlogon.C
0 → 100644
View file @
cf40581b
void
rootlogon
()
{
Info
(
"rootlogon.c"
,
"This settings are used to make large canvases"
);
// return;
//gStyle choice
// gROOT->SetStyle("Classic");
// gROOT->SetStyle("Plain");
// gROOT->SetStyle("Bold");
// gROOT->SetStyle("Video");
// gROOT->SetStyle("Pub");
gROOT
->
SetStyle
(
"Modern"
);
gStyle
->
SetTitleSize
(
0
.
06
,
"X"
);
gStyle
->
SetTitleOffset
(
0
.
74
,
"X"
);
gStyle
->
SetTitleSize
(
0
.
06
,
"Y"
);
gStyle
->
SetTitleOffset
(
0
.
85
,
"Y"
);
gStyle
->
SetPadTopMargin
(
0
.
04
);
gStyle
->
SetPadBottomMargin
(
0
.
13
);
gStyle
->
SetPadLeftMargin
(
0
.
13
);
gStyle
->
SetPadRightMargin
(
0
.
03
);
gStyle
->
SetOptStat
(
"n"
);
// gStyle->SetTitle
return
;
gStyle
->
SetOptStat
(
"n"
);
gStyle
->
SetOptStat
(
"ne"
);
// gStyle->SetOptStat("");
//canvas size and position
//one panel pictures
// gStyle->SetCanvasDefW(900);
// gStyle->SetCanvasDefH(600);
// gStyle->SetCanvasDefX(800);
// gStyle->SetCanvasDefY(300);
gStyle
->
SetCanvasDefH
(
1091
);
gStyle
->
SetCanvasDefW
(
1200
);
gStyle
->
SetCanvasDefX
(
540
);
gStyle
->
SetCanvasDefY
(
0
);
//marker attributes
gStyle
->
SetMarkerStyle
(
20
);
gStyle
->
SetMarkerSize
(
0
.
1
);
gStyle
->
SetMarkerColor
(
1
);
//line attributes
gStyle
->
SetHistLineWidth
(
1
);
// gStyle->SetHistLineWidth(2);
// gStyle->SetHistLineWidth(3);
gStyle
->
SetTitleBorderSize
(
0
);
return
;
gStyle
->
SetTitleXSize
(
0
.
06
);
gStyle
->
SetTitleYSize
(
0
.
06
);
return
;
gStyle
->
SetTitleFont
(
132
,
"X"
);
gStyle
->
SetTitleFont
(
132
,
"Y"
);
gStyle
->
SetLabelFont
(
132
,
"X"
);
gStyle
->
SetLabelFont
(
132
,
"Y"
);
gStyle
->
SetPadTopMargin
(
0
.
04
);
gStyle
->
SetPadBottomMargin
(
0
.
13
);
gStyle
->
SetPadLeftMargin
(
0
.
13
);
gStyle
->
SetPadRightMargin
(
0
.
03
);
// gStyle->SetTitleOffset(1.3, "Y");
// gStyle->SetLabelSize(0.05, "X");
// gStyle->SetLabelSize(0.05, "Y");
// gStyle->SetTitleSize(0.06, "X");
// gStyle->SetTitleSize(0.06, "Y");
return
;
//parameters used for pictures in EXON paper
// gStyle->SetStatBorderSize(0);
// gStyle->SetTitleBorderSize(0);
// gStyle->SetTitleAlign(12);
// gStyle->SetTitleX(0.83);
// gStyle->SetTitleY(0.85);
gStyle
->
SetTitleX
(
0
.
83
);
//for Fig2
gStyle
->
SetTitleY
(
0
.
9
);
//for Fig2
gStyle
->
SetTitleFontSize
(
0
.
08
);
// gStyle->SetTitleFillColor(0);
// gStyle->SetLineWidth(1);
// gStyle->SetHistLineWidth(1);
gStyle
->
SetHistLineWidth
(
3
);
gStyle
->
SetPadTopMargin
(
0
.
05
);
gStyle
->
SetPadBottomMargin
(
0
.
13
);
gStyle
->
SetPadLeftMargin
(
0
.
14
);
gStyle
->
SetPadRightMargin
(
0
.
05
);
gStyle
->
SetTitleOffset
(
1
.
3
,
"Y"
);
gStyle
->
SetLabelSize
(
0
.
05
,
"X"
);
gStyle
->
SetLabelSize
(
0
.
05
,
"Y"
);
gStyle
->
SetTitleSize
(
0
.
06
,
"X"
);
gStyle
->
SetTitleSize
(
0
.
06
,
"Y"
);
// gStyle->SetAxisColor(1);
gStyle
->
SetLabelColor
(
1
,
"X"
);
gStyle
->
SetLabelColor
(
1
,
"Y"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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