Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
detector_benchmarks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIC
benchmarks
detector_benchmarks
Merge requests
!17
Implement detector benchmark for the barrel calorimeter for energy resolution
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Implement detector benchmark for the barrel calorimeter for energy resolution
10-calo-resolution
into
master
Overview
2
Commits
70
Pipelines
0
Changes
9
Merged
Maria Zurek
requested to merge
10-calo-resolution
into
master
4 years ago
Overview
2
Commits
70
Pipelines
0
Changes
9
Expand
0
0
Merge request reports
Compare
master
version 76
3d1cc514
4 years ago
version 75
89ebca07
4 years ago
version 74
d8aca262
4 years ago
version 73
af0e90b6
4 years ago
version 72
d146ab14
4 years ago
version 71
c87450bc
4 years ago
version 70
75dc58ed
4 years ago
version 69
eacc2080
4 years ago
version 68
2387bbbb
4 years ago
version 67
e6bab14e
4 years ago
version 66
0867c4a4
4 years ago
version 65
7d07743d
4 years ago
version 64
e12706f0
4 years ago
version 63
79b61ecb
4 years ago
version 62
f54e9445
4 years ago
version 61
63268e5c
4 years ago
version 60
cd32117f
4 years ago
version 59
39da1a73
4 years ago
version 58
5690d721
4 years ago
version 57
0e30d910
4 years ago
version 56
49cd61a2
4 years ago
version 55
a67f4ca5
4 years ago
version 54
9800aff8
4 years ago
version 53
cb48966f
4 years ago
version 52
16050dae
4 years ago
version 51
5558b7b1
4 years ago
version 50
bb9cb3ec
4 years ago
version 49
14fb531a
4 years ago
version 48
751352fd
4 years ago
version 47
1788b60c
4 years ago
version 46
70a7c329
4 years ago
version 45
978d99c5
4 years ago
version 44
bff20d37
4 years ago
version 43
6b9f78d2
4 years ago
version 42
04771c2c
4 years ago
version 41
3ee5750f
4 years ago
version 40
532a1014
4 years ago
version 39
7045d730
4 years ago
version 38
467a41d3
4 years ago
version 37
d7fff690
4 years ago
version 36
068ba175
4 years ago
version 35
629918a0
4 years ago
version 34
4c13d926
4 years ago
version 33
d28681fa
4 years ago
version 32
f06b9f3c
4 years ago
version 31
bde4e30c
4 years ago
version 30
ff6bf973
4 years ago
version 29
9480e13b
4 years ago
version 28
17a0dbb0
4 years ago
version 27
2f24ec7b
4 years ago
version 26
3bb32215
4 years ago
version 25
065e526f
4 years ago
version 24
a609dfc5
4 years ago
version 23
2f9c4f6c
4 years ago
version 22
75351781
4 years ago
version 21
79fc88af
4 years ago
version 20
c7212619
4 years ago
version 19
aca5cc46
4 years ago
version 18
e3c9d567
4 years ago
version 17
eae2a734
4 years ago
version 16
7ad1b63a
4 years ago
version 15
e7b95fa1
4 years ago
version 14
e663217b
4 years ago
version 13
e2a0a6d3
4 years ago
version 12
fe6164ec
4 years ago
version 11
da3c3664
4 years ago
version 10
b9700d81
4 years ago
version 9
572260b8
4 years ago
version 8
8742d5fb
4 years ago
version 7
bc0d944a
4 years ago
version 6
9ec4f981
4 years ago
version 5
8e1254b6
4 years ago
version 4
a376c4a2
4 years ago
version 3
ecde0c5a
4 years ago
version 2
9995c0aa
4 years ago
version 1
c2cf9eec
4 years ago
master (base)
and
latest version
latest version
6b79b848
70 commits,
4 years ago
version 76
3d1cc514
78 commits,
4 years ago
version 75
89ebca07
77 commits,
4 years ago
version 74
d8aca262
76 commits,
4 years ago
version 73
af0e90b6
75 commits,
4 years ago
version 72
d146ab14
74 commits,
4 years ago
version 71
c87450bc
73 commits,
4 years ago
version 70
75dc58ed
72 commits,
4 years ago
version 69
eacc2080
71 commits,
4 years ago
version 68
2387bbbb
70 commits,
4 years ago
version 67
e6bab14e
69 commits,
4 years ago
version 66
0867c4a4
68 commits,
4 years ago
version 65
7d07743d
67 commits,
4 years ago
version 64
e12706f0
66 commits,
4 years ago
version 63
79b61ecb
65 commits,
4 years ago
version 62
f54e9445
64 commits,
4 years ago
version 61
63268e5c
63 commits,
4 years ago
version 60
cd32117f
62 commits,
4 years ago
version 59
39da1a73
61 commits,
4 years ago
version 58
5690d721
60 commits,
4 years ago
version 57
0e30d910
59 commits,
4 years ago
version 56
49cd61a2
58 commits,
4 years ago
version 55
a67f4ca5
57 commits,
4 years ago
version 54
9800aff8
56 commits,
4 years ago
version 53
cb48966f
55 commits,
4 years ago
version 52
16050dae
54 commits,
4 years ago
version 51
5558b7b1
53 commits,
4 years ago
version 50
bb9cb3ec
52 commits,
4 years ago
version 49
14fb531a
51 commits,
4 years ago
version 48
751352fd
50 commits,
4 years ago
version 47
1788b60c
49 commits,
4 years ago
version 46
70a7c329
48 commits,
4 years ago
version 45
978d99c5
47 commits,
4 years ago
version 44
bff20d37
46 commits,
4 years ago
version 43
6b9f78d2
45 commits,
4 years ago
version 42
04771c2c
44 commits,
4 years ago
version 41
3ee5750f
43 commits,
4 years ago
version 40
532a1014
42 commits,
4 years ago
version 39
7045d730
41 commits,
4 years ago
version 38
467a41d3
40 commits,
4 years ago
version 37
d7fff690
39 commits,
4 years ago
version 36
068ba175
38 commits,
4 years ago
version 35
629918a0
37 commits,
4 years ago
version 34
4c13d926
36 commits,
4 years ago
version 33
d28681fa
35 commits,
4 years ago
version 32
f06b9f3c
34 commits,
4 years ago
version 31
bde4e30c
33 commits,
4 years ago
version 30
ff6bf973
32 commits,
4 years ago
version 29
9480e13b
31 commits,
4 years ago
version 28
17a0dbb0
30 commits,
4 years ago
version 27
2f24ec7b
29 commits,
4 years ago
version 26
3bb32215
28 commits,
4 years ago
version 25
065e526f
27 commits,
4 years ago
version 24
a609dfc5
26 commits,
4 years ago
version 23
2f9c4f6c
25 commits,
4 years ago
version 22
75351781
24 commits,
4 years ago
version 21
79fc88af
23 commits,
4 years ago
version 20
c7212619
22 commits,
4 years ago
version 19
aca5cc46
21 commits,
4 years ago
version 18
e3c9d567
20 commits,
4 years ago
version 17
eae2a734
19 commits,
4 years ago
version 16
7ad1b63a
18 commits,
4 years ago
version 15
e7b95fa1
17 commits,
4 years ago
version 14
e663217b
16 commits,
4 years ago
version 13
e2a0a6d3
15 commits,
4 years ago
version 12
fe6164ec
14 commits,
4 years ago
version 11
da3c3664
13 commits,
4 years ago
version 10
b9700d81
12 commits,
4 years ago
version 9
572260b8
11 commits,
4 years ago
version 8
8742d5fb
10 commits,
4 years ago
version 7
bc0d944a
9 commits,
4 years ago
version 6
9ec4f981
8 commits,
4 years ago
version 5
8e1254b6
7 commits,
4 years ago
version 4
a376c4a2
4 commits,
4 years ago
version 3
ecde0c5a
3 commits,
4 years ago
version 2
9995c0aa
2 commits,
4 years ago
version 1
c2cf9eec
1 commit,
4 years ago
9 files
+
745
−
15
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
9
Search (e.g. *.vue) (Ctrl+P)
benchmarks/barrel_ecal/scripts/emcal_barrel_energy_scan_analysis.cxx
0 → 100644
+
227
−
0
Options
////////////////////////////////////////
// Read reconstruction ROOT output file
// Plot variables
////////////////////////////////////////
#include
"ROOT/RDataFrame.hxx"
#include
<iostream>
#include
<fmt/core.h>
#include
"dd4pod/Geant4ParticleCollection.h"
#include
"dd4pod/CalorimeterHitCollection.h"
#include
"TCanvas.h"
#include
"TStyle.h"
#include
"TMath.h"
#include
"TH1.h"
#include
"TF1.h"
#include
"TH1D.h"
#include
"TGraphErrors.h"
using
ROOT
::
RDataFrame
;
using
namespace
ROOT
::
VecOps
;
void
save_canvas
(
TCanvas
*
c
,
std
::
string
label
)
{
c
->
SaveAs
(
fmt
::
format
(
"results/energy_scan/{}.png"
,
label
).
c_str
());
c
->
SaveAs
(
fmt
::
format
(
"results/energy_scan/{}.pdf"
,
label
).
c_str
());
}
void
save_canvas
(
TCanvas
*
c
,
std
::
string
label
,
double
E
)
{
std
::
string
label_with_E
=
fmt
::
format
(
"{}/{}"
,
E
,
label
);
save_canvas
(
c
,
label_with_E
);
}
void
save_canvas
(
TCanvas
*
c
,
std
::
string
label
,
std
::
string
E_label
)
{
std
::
string
label_with_E
=
fmt
::
format
(
"{}/{}"
,
E_label
,
label
);
save_canvas
(
c
,
label_with_E
);
}
void
save_canvas
(
TCanvas
*
c
,
std
::
string
var_label
,
std
::
string
E_label
,
std
::
string
particle_label
)
{
std
::
string
label_with_E
=
fmt
::
format
(
"{}/emcal_barrel_{}_{}"
,
E_label
,
particle_label
,
var_label
);
save_canvas
(
c
,
label_with_E
);
}
std
::
tuple
<
double
,
double
,
double
,
double
>
extract_sampling_fraction_parameters
(
std
::
string
particle_label
,
std
::
string
E_label
)
{
std
::
string
input_fname
=
fmt
::
format
(
"sim_output/energy_scan/{}/sim_emcal_barrel_{}.root"
,
E_label
,
particle_label
);
ROOT
::
EnableImplicitMT
();
ROOT
::
RDataFrame
d0
(
"events"
,
input_fname
);
// Thrown Energy [GeV]
auto
Ethr
=
[](
std
::
vector
<
dd4pod
::
Geant4ParticleData
>
const
&
input
)
{
auto
p
=
input
[
2
];
auto
energy
=
TMath
::
Sqrt
(
p
.
psx
*
p
.
psx
+
p
.
psy
*
p
.
psy
+
p
.
psz
*
p
.
psz
+
p
.
mass
*
p
.
mass
);
return
energy
;
};
// Number of hits
auto
nhits
=
[]
(
const
std
::
vector
<
dd4pod
::
CalorimeterHitData
>&
evt
)
{
return
(
int
)
evt
.
size
();
};
// Energy deposition [GeV]
auto
Esim
=
[](
const
std
::
vector
<
dd4pod
::
CalorimeterHitData
>&
evt
)
{
auto
total_edep
=
0.0
;
for
(
const
auto
&
i
:
evt
)
total_edep
+=
i
.
energyDeposit
;
return
total_edep
;
};
// Sampling fraction = Esampling / Ethrown
auto
fsam
=
[](
const
double
sampled
,
const
double
thrown
)
{
return
sampled
/
thrown
;
};
// Define variables
auto
d1
=
d0
.
Define
(
"Ethr"
,
Ethr
,
{
"mcparticles"
})
.
Define
(
"nhits"
,
nhits
,
{
"EcalBarrelHits"
})
.
Define
(
"Esim"
,
Esim
,
{
"EcalBarrelHits"
})
.
Define
(
"fsam"
,
fsam
,
{
"Esim"
,
"Ethr"
});
// Define Histograms
auto
hEthr
=
d1
.
Histo1D
(
{
"hEthr"
,
"Thrown Energy; Thrown Energy [GeV]; Events"
,
100
,
0.0
,
25.0
},
"Ethr"
);
auto
hNhits
=
d1
.
Histo1D
({
"hNhits"
,
"Number of hits per events; Number of hits; Events"
,
100
,
0.0
,
2000.0
},
"nhits"
);
auto
hEsim
=
d1
.
Histo1D
(
{
"hEsim"
,
"Energy Deposit; Energy Deposit [GeV]; Events"
,
500
,
0.0
,
0.5
},
"Esim"
);
auto
hfsam
=
d1
.
Histo1D
(
{
"hfsam"
,
"Sampling Fraction; Sampling Fraction; Events"
,
200
,
0.0
,
0.05
},
"fsam"
);
// Event Counts
auto
nevents_thrown
=
d1
.
Count
();
std
::
cout
<<
"Number of Thrown Events: "
<<
(
*
nevents_thrown
)
<<
"
\n
"
;
// Draw Histograms
{
TCanvas
*
c1
=
new
TCanvas
(
"c1"
,
"c1"
,
700
,
500
);
c1
->
SetLogy
(
1
);
auto
h
=
hEthr
->
DrawCopy
();
//h->GetYaxis()->SetTitleOffset(1.4);
h
->
SetLineWidth
(
2
);
h
->
SetLineColor
(
kBlue
);
save_canvas
(
c1
,
"Ethr"
,
E_label
,
particle_label
);
}
{
TCanvas
*
c2
=
new
TCanvas
(
"c2"
,
"c2"
,
700
,
500
);
c2
->
SetLogy
(
1
);
auto
h
=
hNhits
->
DrawCopy
();
//h->GetYaxis()->SetTitleOffset(1.4);
h
->
SetLineWidth
(
2
);
h
->
SetLineColor
(
kBlue
);
save_canvas
(
c2
,
"nhits"
,
E_label
,
particle_label
);
}
{
TCanvas
*
c3
=
new
TCanvas
(
"c3"
,
"c3"
,
700
,
500
);
c3
->
SetLogy
(
1
);
auto
h
=
hEsim
->
DrawCopy
();
//h->GetYaxis()->SetTitleOffset(1.4);
h
->
SetLineWidth
(
2
);
h
->
SetLineColor
(
kBlue
);
double
up_fit
=
h
->
GetMean
()
+
5
*
h
->
GetStdDev
();
double
down_fit
=
h
->
GetMean
()
-
5
*
h
->
GetStdDev
();
h
->
GetXaxis
()
->
SetRangeUser
(
0.
,
up_fit
);
save_canvas
(
c3
,
"Esim"
,
E_label
,
particle_label
);
}
{
TCanvas
*
c4
=
new
TCanvas
(
"c4"
,
"c4"
,
700
,
500
);
//c4->SetLogy(1);
auto
h
=
hfsam
->
DrawCopy
();
//h->GetYaxis()->SetTitleOffset(1.4);
h
->
SetLineWidth
(
2
);
h
->
SetLineColor
(
kBlue
);
double
up_fit
=
h
->
GetMean
()
+
5
*
h
->
GetStdDev
();
double
down_fit
=
h
->
GetMean
()
-
5
*
h
->
GetStdDev
();
h
->
Fit
(
"gaus"
,
""
,
""
,
down_fit
,
up_fit
);
h
->
GetXaxis
()
->
SetRangeUser
(
0.
,
up_fit
);
TF1
*
gaus
=
h
->
GetFunction
(
"gaus"
);
gaus
->
SetLineWidth
(
2
);
gaus
->
SetLineColor
(
kRed
);
double
mean
=
gaus
->
GetParameter
(
1
);
double
sigma
=
gaus
->
GetParameter
(
2
);
double
mean_err
=
gaus
->
GetParError
(
1
);
double
sigma_err
=
gaus
->
GetParError
(
2
);
save_canvas
(
c4
,
"fsam"
,
E_label
,
particle_label
);
return
std
::
make_tuple
(
mean
,
sigma
,
mean_err
,
sigma_err
);
}
}
std
::
vector
<
std
::
string
>
read_scanned_energies
(
std
::
string
input_energies_fname
)
{
std
::
vector
<
std
::
string
>
scanned_energies
;
std
::
string
E_label
;
ifstream
E_file
(
input_energies_fname
);
if
(
E_file
.
is_open
())
{
while
(
E_file
>>
E_label
)
{
scanned_energies
.
push_back
(
E_label
);
}
E_file
.
close
();
return
scanned_energies
;
}
else
{
std
::
cout
<<
"Unable to open file "
<<
input_energies_fname
<<
std
::
endl
;
abort
();
}
}
void
emcal_barrel_energy_scan_analysis
(
std
::
string
particle_label
=
"electron"
)
{
// Setting for graphs
gROOT
->
SetStyle
(
"Plain"
);
gStyle
->
SetOptFit
(
1
);
gStyle
->
SetLineWidth
(
2
);
gStyle
->
SetPadTickX
(
1
);
gStyle
->
SetPadTickY
(
1
);
gStyle
->
SetPadGridX
(
1
);
gStyle
->
SetPadGridY
(
1
);
gStyle
->
SetPadLeftMargin
(
0.14
);
gStyle
->
SetPadRightMargin
(
0.14
);
auto
scanned_energies
=
read_scanned_energies
(
fmt
::
format
(
"sim_output/emcal_barrel_energy_scan_points_{}.txt"
,
particle_label
));
TGraphErrors
gr_fsam
(
scanned_energies
.
size
()
-
1
);
TGraphErrors
gr_fsam_res
(
scanned_energies
.
size
()
-
1
);
for
(
const
auto
&
E_label
:
scanned_energies
)
{
auto
[
fsam
,
fsam_res
,
fsam_err
,
fsam_res_err
]
=
extract_sampling_fraction_parameters
(
particle_label
,
E_label
);
auto
E
=
std
::
stod
(
E_label
);
gr_fsam
.
SetPoint
(
gr_fsam
.
GetN
(),
E
,
100
*
fsam
);
gr_fsam
.
SetPointError
(
gr_fsam
.
GetN
()
-
1
,
0.
,
100
*
fsam_err
);
gr_fsam_res
.
SetPoint
(
gr_fsam_res
.
GetN
(),
E
,
100.0
*
(
fsam_res
/
fsam
));
auto
fsam_res_rel_err
=
100.0
*
(
sqrt
(
pow
((
fsam_res_err
/
fsam
),
2
)
+
pow
((
fsam_err
*
fsam_res
)
/
(
fsam
*
fsam
),
2
)));
gr_fsam_res
.
SetPointError
(
gr_fsam_res
.
GetN
()
-
1
,
0.
,
fsam_res_rel_err
);
}
TCanvas
*
c5
=
new
TCanvas
(
"c5"
,
"c5"
,
700
,
500
);
c5
->
cd
();
gr_fsam
.
SetTitle
(
"Sampling Fraction Scan;True Energy [GeV];Sampling Fraction [%]"
);
gr_fsam
.
SetMarkerStyle
(
20
);
gr_fsam
.
Fit
(
"pol0"
,
""
,
""
,
2.
,
20.
);
gr_fsam
.
Draw
(
"APE"
);
save_canvas
(
c5
,
fmt
::
format
(
"emcal_barrel_{}_fsam_scan"
,
particle_label
));
TCanvas
*
c6
=
new
TCanvas
(
"c6"
,
"c6"
,
700
,
500
);
c6
->
cd
();
TF1
*
func_res
=
new
TF1
(
"func_res"
,
"[0]/sqrt(x) + [1]"
,
0.25
,
20.
);
func_res
->
SetLineWidth
(
2
);
func_res
->
SetLineColor
(
kRed
);
gr_fsam_res
.
SetTitle
(
"Energy Resolution;True Energy [GeV];#Delta E/E [%]"
);
gr_fsam_res
.
SetMarkerStyle
(
20
);
gr_fsam_res
.
Fit
(
func_res
,
"R"
);
gr_fsam_res
.
Draw
(
"APE"
);
save_canvas
(
c6
,
fmt
::
format
(
"emcal_barrel_{}_fsam_scan_res"
,
particle_label
));
}
Loading