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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIC
benchmarks
detector_benchmarks
Commits
ad9312c6
Commit
ad9312c6
authored
Jun 28, 2021
by
Marshall Scott
Browse files
Options
Downloads
Patches
Plain Diff
Rebasing
parent
6ca90009
Branches
Branches containing commit
No related tags found
1 merge request
!51
Resolve "Fix Pi0 benchmark"
This commit is part of merge request
!51
. Comments created here will be created in the context of that merge request.
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
benchmarks/barrel_ecal/scripts/emcal_barrel_pi0_analysis.cxx
+65
-86
65 additions, 86 deletions
benchmarks/barrel_ecal/scripts/emcal_barrel_pi0_analysis.cxx
with
65 additions
and
86 deletions
benchmarks/barrel_ecal/scripts/emcal_barrel_pi0_analysis.cxx
+
65
−
86
Edit
View file @
ad9312c6
...
@@ -13,6 +13,9 @@
...
@@ -13,6 +13,9 @@
#include
"mt.h"
#include
"mt.h"
#include
"util.h"
#include
"util.h"
R__LOAD_LIBRARY
(
libfmt
.
so
)
#include
"fmt/core.h"
#include
"TCanvas.h"
#include
"TCanvas.h"
#include
"TStyle.h"
#include
"TStyle.h"
#include
"TMath.h"
#include
"TMath.h"
...
@@ -28,6 +31,7 @@ using json = nlohmann::json;
...
@@ -28,6 +31,7 @@ using json = nlohmann::json;
void
emcal_barrel_pi0_analysis
(
const
char
*
input_fname
=
"sim_output/sim_emcal_barrel_pi0.root"
)
void
emcal_barrel_pi0_analysis
(
const
char
*
input_fname
=
"sim_output/sim_emcal_barrel_pi0.root"
)
{
{
//input_fname = "../sim_output/sim_emcal_barrel_pi0.root";
// Setting for graphs
// Setting for graphs
gROOT
->
SetStyle
(
"Plain"
);
gROOT
->
SetStyle
(
"Plain"
);
gStyle
->
SetOptFit
(
1
);
gStyle
->
SetOptFit
(
1
);
...
@@ -39,40 +43,20 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
...
@@ -39,40 +43,20 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
gStyle
->
SetPadLeftMargin
(
0.14
);
gStyle
->
SetPadLeftMargin
(
0.14
);
gStyle
->
SetPadRightMargin
(
0.14
);
gStyle
->
SetPadRightMargin
(
0.14
);
//Tests
ROOT
::
EnableImplicitMT
();
std
::
string
test_tag
=
"Barrel_emcal_pi0"
;
ROOT
::
RDataFrame
d0
(
"events"
,
input_fname
);
//TODO: Change test_tag to something else
std:
string
detector
=
"Barrel_emcal"
;
// Energy resolution in the barrel region(-1 < eta < 1)
// Taken from : Initial considerations for EMCal of the EIC detector by A. Bazilevsky
// sigma_E / E = 12% / E^0.5 convoluted with 2%
// sigma_E / E = [ (0.12/E^0.5)^2 + 0.02^2]^0.5, with E in [GeV]
double
thrown_energy
=
5
;
// Current thrown energy, will need to grab from json file
double
resolutionTarget
=
TMath
::
Sqrt
(
0.12
*
0.12
/
thrown_energy
+
0.02
*
0.02
);
eic
::
util
::
Test
pi0_energy_resolution
{
{{
"name"
,
fmt
::
format
(
"{}_energy_resolution"
,
test_tag
)},
{
"title"
,
"Pion0 Energy resolution"
},
{
"description"
,
fmt
::
format
(
"Pion0 energy resolution with {}, estimated using a Gaussian fit."
,
detector
)},
{
"quantity"
,
"resolution (in %)"
},
{
"target"
,
std
::
to_string
(
resolutionTarget
)}}};
// Sampling Fraction grabbed from json file
// Note that this value is derived from electrons
json
j
;
json
j
;
std
::
ifstream
prev_steps_ifstream
(
"results/emcal_barrel_calibration.json"
);
std
::
ifstream
prev_steps_ifstream
(
"results/emcal_barrel_calibration.json"
);
prev_steps_ifstream
>>
j
;
prev_steps_ifstream
>>
j
;
ROOT
::
EnableImplicitMT
();
ROOT
::
RDataFrame
d0
(
"events"
,
input_fname
);
// Sampling Fraction
double
samp_frac
=
j
[
"electron"
][
"sampling_fraction"
];
double
samp_frac
=
j
[
"electron"
][
"sampling_fraction"
];
// Thrown Energy [GeV]
// Thrown Energy [GeV]
//double meanE = 5; // Calculated later
auto
Ethr
=
[](
std
::
vector
<
dd4pod
::
Geant4ParticleData
>
const
&
input
)
{
auto
Ethr
=
[](
std
::
vector
<
dd4pod
::
Geant4ParticleData
>
const
&
input
)
{
std
::
vector
<
double
>
result
;
return
TMath
::
Sqrt
(
input
[
2
].
psx
*
input
[
2
].
psx
+
input
[
2
].
psy
*
input
[
2
].
psy
+
input
[
2
].
psz
*
input
[
2
].
psz
+
input
[
2
].
mass
*
input
[
2
].
mass
);
result
.
push_back
(
TMath
::
Sqrt
(
input
[
2
].
psx
*
input
[
2
].
psx
+
input
[
2
].
psy
*
input
[
2
].
psy
+
input
[
2
].
psz
*
input
[
2
].
psz
+
input
[
2
].
mass
*
input
[
2
].
mass
));
return
result
;
};
};
// Number of hits
// Number of hits
...
@@ -80,45 +64,26 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
...
@@ -80,45 +64,26 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
// Energy deposition [GeV]
// Energy deposition [GeV]
auto
Esim
=
[](
const
std
::
vector
<
dd4pod
::
CalorimeterHitData
>&
evt
)
{
auto
Esim
=
[](
const
std
::
vector
<
dd4pod
::
CalorimeterHitData
>&
evt
)
{
std
::
vector
<
double
>
result
;
auto
total_edep
=
0.0
;
auto
total_edep
=
0.0
;
for
(
const
auto
&
i
:
evt
)
for
(
const
auto
&
i
:
evt
)
{
total_edep
+=
i
.
energyDeposit
;
total_edep
+=
i
.
energyDeposit
;
result
.
push_back
(
total_edep
);
}
return
result
;
return
total_edep
;
};
};
// Sampling fraction = Esampling / Ethrown
// Sampling fraction = Esampling / Ethrown
auto
fsam
=
[](
const
std
::
vector
<
double
>&
sampled
,
const
std
::
vector
<
double
>&
thrown
)
{
auto
fsam
=
[](
const
double
&
sampled
,
const
double
&
thrown
)
{
std
::
vector
<
double
>
result
;
return
sampled
/
thrown
;
auto
it_sam
=
sampled
.
cbegin
();
auto
it_thr
=
thrown
.
cbegin
();
for
(;
it_sam
!=
sampled
.
end
()
&&
it_thr
!=
thrown
.
end
();
++
it_sam
,
++
it_thr
)
{
result
.
push_back
(
*
it_sam
/
*
it_thr
);
}
return
result
;
};
};
// Energy Resolution = Esampling/Sampling_fraction - Ethrown
// Energy Resolution = Esampling/Sampling_fraction - Ethrown
auto
eResol
=
[
samp_frac
](
const
std
::
vector
<
double
>&
sampled
,
const
std
::
vector
<
double
>&
thrown
)
{
auto
eResol
=
[
&
](
const
double
&
sampled
,
const
double
&
thrown
){
std
::
vector
<
double
>
result
;
return
sampled
/
samp_frac
-
thrown
;
auto
it_sam
=
sampled
.
cbegin
();
auto
it_thr
=
thrown
.
cbegin
();
for
(;
it_sam
!=
sampled
.
end
()
&&
it_thr
!=
thrown
.
end
();
++
it_sam
,
++
it_thr
)
{
result
.
push_back
(
*
it_sam
/
samp_frac
-
*
it_thr
);
}
return
result
;
};
};
// Relative Energy Resolution = (Esampling/Sampling fraction - Ethrown)/Ethrown
// Relative Energy Resolution = (Esampling/Sampling fraction - Ethrown)/Ethrown
auto
eResol_rel
=
[
samp_frac
](
const
std
::
vector
<
double
>&
sampled
,
const
std
::
vector
<
double
>&
thrown
)
{
auto
eResol_rel
=
[
&
](
const
double
&
sampled
,
const
double
&
thrown
){
std
::
vector
<
double
>
result
;
return
(
sampled
/
samp_frac
-
thrown
)
/
thrown
;
auto
it_sam
=
sampled
.
cbegin
();
auto
it_thr
=
thrown
.
cbegin
();
for
(;
it_sam
!=
sampled
.
end
()
&&
it_thr
!=
thrown
.
end
();
++
it_sam
,
++
it_thr
)
{
result
.
push_back
((
*
it_sam
/
samp_frac
-
*
it_thr
)
/
*
it_thr
);
}
return
result
;
};
};
// Returns the pdgID of the particle
// Returns the pdgID of the particle
...
@@ -138,6 +103,8 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
...
@@ -138,6 +103,8 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
.
Define
(
"fsam"
,
fsam
,
{
"Esim"
,
"Ethr"
})
.
Define
(
"fsam"
,
fsam
,
{
"Esim"
,
"Ethr"
})
.
Define
(
"pid"
,
getpid
,
{
"mcparticles"
})
.
Define
(
"pid"
,
getpid
,
{
"mcparticles"
})
.
Define
(
"dau"
,
getdau
,
{
"mcparticles"
})
.
Define
(
"dau"
,
getdau
,
{
"mcparticles"
})
.
Define
(
"dE"
,
eResol
,
{
"Esim"
,
"Ethr"
})
.
Define
(
"dE_rel"
,
eResol_rel
,
{
"Esim"
,
"Ethr"
})
;
;
// Define Histograms
// Define Histograms
...
@@ -148,12 +115,9 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
...
@@ -148,12 +115,9 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
auto
hpid
=
d1
.
Histo1D
({
"hpid"
,
"PID; PID; Count"
,
100
,
-
220
,
220
},
"pid"
);
auto
hpid
=
d1
.
Histo1D
({
"hpid"
,
"PID; PID; Count"
,
100
,
-
220
,
220
},
"pid"
);
auto
hdau
=
d1
.
Histo1D
({
"hdau"
,
"Number of Daughters; Number of Daughters; Count"
,
10
,
0
,
10
},
"dau"
);
auto
hdau
=
d1
.
Histo1D
({
"hdau"
,
"Number of Daughters; Number of Daughters; Count"
,
10
,
0
,
10
},
"dau"
);
//
Set s
ampling
F
raction, ideally this will be taken from a json file
//
Gather S
ampling
f
raction
and mean Energy
, ideally this will be taken from a json file
samp_frac
=
hfsam
->
GetMean
();
samp_frac
=
hfsam
->
GetMean
();
const
double
meanE
=
hEthr
->
GetMean
();
auto
d2
=
d1
.
Define
(
"dE"
,
eResol
,
{
"Esim"
,
"Ethr"
})
.
Define
(
"dE_rel"
,
eResol_rel
,
{
"Esim"
,
"Ethr"
})
;
// Event Counts
// Event Counts
auto
nevents_thrown
=
d1
.
Count
();
auto
nevents_thrown
=
d1
.
Count
();
...
@@ -218,29 +182,46 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
...
@@ -218,29 +182,46 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
c6
->
SaveAs
(
"results/emcal_barrel_pi0_dau.pdf"
);
c6
->
SaveAs
(
"results/emcal_barrel_pi0_dau.pdf"
);
// Energy Resolution Calculation
// Energy Resolution Calculation
auto
hdE
=
d2
.
Histo1D
({
"hdE"
,
"dE; dE[GeV]; Events"
,
100
,
-
3.0
,
3.0
},
"dE"
);
std
::
string
test_tag
=
"Barrel_emcal_pi0"
;
// TODO: Change test_tag to something else
auto
hdE_rel
=
d2
.
Histo1D
({
"hdE_rel"
,
"dE Relative; dE Relative; Events"
,
100
,
-
3.0
,
3.0
},
"dE_rel"
);
std
:
string
detEle
=
"Barrel_emcal"
;
hdE
->
Fit
(
"gaus"
,
""
,
""
,
-
3.0
,
3.0
);
double
*
res
=
hdE
->
GetFunction
(
"gaus"
)
->
GetParameters
();
// Energy resolution in the barrel region (-1 < eta < 1)
double
sigmaOverE
=
res
[
2
]
/
thrown_energy
;
// Taken from : Initial considerations for EMCal of the EIC detector by A. Bazilevsky
// sigma_E / E = 12% / E^0.5 convoluted with 2%
// sigma_E / E = [ (0.12/E^0.5)^2 + 0.02^2]^0.5, with E in [GeV]
double
resolutionTarget
=
TMath
::
Sqrt
(
0.12
*
0.12
/
meanE
+
0.02
*
0.02
);
eic
::
util
::
Test
pi0_energy_resolution
{
{{
"name"
,
fmt
::
format
(
"{}_energy_resolution"
,
test_tag
)},
{
"title"
,
"Pi0 Energy resolution"
},
{
"description"
,
fmt
::
format
(
"Pi0 energy resolution for {}, estimated using a Gaussian fit."
,
detEle
)},
{
"quantity"
,
"resolution (in %)"
},
{
"target"
,
std
::
to_string
(
resolutionTarget
)}}
};
// Histograms and Fitting
auto
hdE
=
d1
.
Histo1D
({
"hdE"
,
"dE; dE[GeV]; Events"
,
100
,
-
3.0
,
3.0
},
"dE"
);
auto
hdE_rel
=
d1
.
Histo1D
({
"hdE_rel"
,
"dE Relative; dE Relative; Events"
,
100
,
-
3.0
,
3.0
},
"dE_rel"
);
auto
hdEcopy
=
hdE
->
DrawCopy
();
hdEcopy
->
Fit
(
"gaus"
,
""
,
""
,
-
3.0
,
3.0
);
double
*
res
=
hdEcopy
->
GetFunction
(
"gaus"
)
->
GetParameters
();
double
sigmaOverE
=
res
[
2
]
/
meanE
;
// Pass/Fail
// Pass/Fail
if
(
sigmaOverE
<=
resolutionTarget
)
{
sigmaOverE
<=
resolutionTarget
?
pi0_energy_resolution
.
pass
(
sigmaOverE
)
:
pi0_energy_resolution
.
fail
(
sigmaOverE
);
pi0_energy_resolution
.
pass
(
sigmaOverE
);
std
::
printf
(
"Energy Resolution is %f
\n
"
,
res
[
2
]);
}
else
{
pi0_energy_resolution
.
fail
(
sigmaOverE
);
}
//std::printf("Energy Resolution is %f\n", res[2]);
// Energy Resolution Histogram Plotting
// Energy Resolution Histogram Plotting
auto
*
cdE
=
new
TCanvas
(
"cdE"
,
"cdE"
,
700
,
500
);
auto
*
cdE
=
new
TCanvas
(
"cdE"
,
"cdE"
,
700
,
500
);
cdE
->
SetLogy
(
1
);
cdE
->
SetLogy
(
1
);
hdE
->
GetYaxis
()
->
SetTitleOffset
(
1.4
);
hdE
copy
->
GetYaxis
()
->
SetTitleOffset
(
1.4
);
hdE
->
SetLineWidth
(
2
);
hdE
copy
->
SetLineWidth
(
2
);
hdE
->
SetLineColor
(
kBlue
);
hdE
copy
->
SetLineColor
(
kBlue
);
hdE
->
GetFunction
(
"gaus"
)
->
SetLineWidth
(
2
);
hdE
copy
->
GetFunction
(
"gaus"
)
->
SetLineWidth
(
2
);
hdE
->
GetFunction
(
"gaus"
)
->
SetLineColor
(
kRed
);
hdE
copy
->
GetFunction
(
"gaus"
)
->
SetLineColor
(
kRed
);
hdE
->
DrawClone
();
hdE
copy
->
DrawClone
();
cdE
->
SaveAs
(
"results/emcal_barrel_pi0_dE.png"
);
cdE
->
SaveAs
(
"results/emcal_barrel_pi0_dE.png"
);
cdE
->
SaveAs
(
"results/emcal_barrel_pi0_dE.pdf"
);
cdE
->
SaveAs
(
"results/emcal_barrel_pi0_dE.pdf"
);
...
@@ -252,7 +233,5 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
...
@@ -252,7 +233,5 @@ void emcal_barrel_pi0_analysis(const char* input_fname = "sim_output/sim_emcal_b
cdE_rel
->
SaveAs
(
"results/emcal_barrel_pi0_dE_rel.png"
);
cdE_rel
->
SaveAs
(
"results/emcal_barrel_pi0_dE_rel.png"
);
cdE_rel
->
SaveAs
(
"results/emcal_barrel_pi0_dE_rel.pdf"
);
cdE_rel
->
SaveAs
(
"results/emcal_barrel_pi0_dE_rel.pdf"
);
eic
::
util
::
write_test
({
pi0_energy_resolution
},
fmt
::
format
(
"{}_pi0.json"
,
detector
));
eic
::
util
::
write_test
({
pi0_energy_resolution
},
fmt
::
format
(
"results/{}_pi0.json"
,
detEle
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment