IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue 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
Air Shower Physics
corsika
Commits
240772f7
Commit
240772f7
authored
4 years ago
by
Maximilian Reininghaus
Committed by
Ralf Ulrich
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactored InteractionCounter
parent
95c5c804
No related branches found
No related tags found
1 merge request
!189
Interaction histogram
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Documentation/Examples/vertical_EAS.cc
+16
-11
16 additions, 11 deletions
Documentation/Examples/vertical_EAS.cc
Processes/InteractionCounter/InteractionCounter.h
+36
-17
36 additions, 17 deletions
Processes/InteractionCounter/InteractionCounter.h
with
52 additions
and
28 deletions
Documentation/Examples/vertical_EAS.cc
+
16
−
11
View file @
240772f7
...
...
@@ -157,7 +157,7 @@ int main(int argc, char** argv) {
process
::
sibyll
::
Interaction
sibyll
;
process
::
interaction_counter
::
InteractionCounter
sibyllCounted
(
sibyll
);
process
::
sibyll
::
NuclearInteraction
sibyllNuc
(
sibyll
,
env
);
process
::
interaction_counter
::
InteractionCounter
sibyllNucCounted
(
sibyllNuc
);
...
...
@@ -202,14 +202,14 @@ int main(int argc, char** argv) {
process
::
switch_process
::
SwitchProcess
switchProcess
(
urqmd
,
sibyllSequence
,
55
_GeV
);
auto
decaySequence
=
decayPythia
<<
decaySibyll
;
auto
sequence
=
switchProcess
<<
decaySequence
<<
eLoss
<<
cut
<<
observationLevel
;
// << trackWriter;
// << trackWriter;
// define air shower object, run simulation
tracking_line
::
TrackingLine
tracking
;
cascade
::
Cascade
EAS
(
env
,
tracking
,
sequence
,
stack
);
EAS
.
Init
();
// EAS.SetNodes();
// EAS.forceInteraction();
// EAS.SetNodes();
// EAS.forceInteraction();
EAS
.
Run
();
eLoss
.
PrintProfile
();
// print longitudinal profile
...
...
@@ -221,13 +221,18 @@ int main(int argc, char** argv) {
<<
"relative difference (%): "
<<
(
Efinal
/
E0
-
1
)
*
100
<<
endl
;
cout
<<
"total dEdX energy (GeV): "
<<
eLoss
.
GetTotal
()
/
1
_GeV
<<
endl
<<
"relative difference (%): "
<<
eLoss
.
GetTotal
()
/
E0
*
100
<<
endl
;
auto
const
cms_hists
=
*
std
::
get
<
0
>
(
sibyllCounted
.
CMSHists
())
+
*
std
::
get
<
0
>
(
sibyllNucCounted
.
CMSHists
());
auto
const
lab_hists
=
*
std
::
get
<
0
>
(
sibyllCounted
.
labHists
())
+
*
std
::
get
<
0
>
(
sibyllNucCounted
.
labHists
());
process
::
interaction_counter
::
saveHist
(
cms_hists
,
*
std
::
get
<
1
>
(
sibyllNucCounted
.
CMSHists
()),
"intcount_hist_cms.txt"
,
"center-of-mass system"
);
process
::
interaction_counter
::
saveHist
(
lab_hists
,
*
std
::
get
<
1
>
(
sibyllNucCounted
.
labHists
()),
"intcount_hist_lab.txt"
,
"lab system"
);
auto
const
cms_hists
=
*
std
::
get
<
0
>
(
sibyllCounted
.
CMSHists
())
+
*
std
::
get
<
0
>
(
sibyllNucCounted
.
CMSHists
());
auto
const
lab_hists
=
*
std
::
get
<
0
>
(
sibyllCounted
.
labHists
())
+
*
std
::
get
<
0
>
(
sibyllNucCounted
.
labHists
());
process
::
interaction_counter
::
saveHist
(
cms_hists
,
*
std
::
get
<
1
>
(
sibyllNucCounted
.
CMSHists
()),
"intcount_hist_cms.txt"
,
"center-of-mass system"
);
process
::
interaction_counter
::
saveHist
(
lab_hists
,
*
std
::
get
<
1
>
(
sibyllNucCounted
.
labHists
()),
"intcount_hist_lab.txt"
,
"lab system"
);
std
::
ofstream
finish
(
"finished"
);
finish
<<
"run completed without error"
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
Processes/InteractionCounter/InteractionCounter.h
+
36
−
17
View file @
240772f7
...
...
@@ -134,16 +134,23 @@ namespace corsika::process::interaction_counter {
}
};
template
<
typename
T1
,
typename
T2
>
static
void
saveHist
(
T1
const
&
hist
,
T2
const
&
histMap
,
std
::
string
const
&
filename
,
template
<
typename
T1
>
static
void
saveHist
(
T1
const
&
hist
,
std
::
string
const
&
filename
,
std
::
string
const
&
comment
=
""
)
{
std
::
ofstream
file
;
file
.
open
(
filename
);
saveHist
(
hist
,
file
,
comment
);
}
template
<
typename
T1
>
static
void
saveHist
(
T1
const
&
hist
,
std
::
ofstream
&
file
,
std
::
string
const
&
comment
=
""
)
{
auto
const
&
energy_axis
=
hist
.
axis
(
1
);
std
::
ofstream
myfile
;
myfile
.
open
(
filename
);
myfile
<<
"# interaction count histogram ("
<<
comment
<<
")"
<<
std
::
endl
<<
"# "
<<
energy_axis
.
size
()
<<
" bins between "
<<
energy_axis
.
bin
(
0
).
lower
()
<<
" and "
<<
energy_axis
.
bin
(
energy_axis
.
size
()
-
1
).
upper
()
<<
" GeV"
<<
std
::
endl
;
file
<<
"# interaction count histogram ("
<<
comment
<<
")"
<<
std
::
endl
<<
"# "
<<
energy_axis
.
size
()
<<
" bins between "
<<
energy_axis
.
bin
(
0
).
lower
()
<<
" and "
<<
energy_axis
.
bin
(
energy_axis
.
size
()
-
1
).
upper
()
<<
" GeV"
<<
std
::
endl
;
for
(
particles
::
CodeIntType
p
=
0
;
p
<
static_cast
<
particles
::
CodeIntType
>
(
particles
::
Code
::
LastParticle
);
++
p
)
{
...
...
@@ -151,22 +158,34 @@ namespace corsika::process::interaction_counter {
if
(
auto
pdg
=
static_cast
<
particles
::
PDGCodeType
>
(
particles
::
GetPDG
(
static_cast
<
particles
::
Code
>
(
p
)));
pdg
<
1'000'000'000l
)
{
my
file
<<
"# "
<<
static_cast
<
particles
::
Code
>
(
p
)
<<
std
::
endl
;
my
file
<<
pdg
;
for
(
int
i
=
0
;
i
<
energy_axis
.
size
();
++
i
)
{
my
file
<<
' '
<<
hist
.
at
(
p
,
i
);
}
my
file
<<
std
::
endl
;
file
<<
"# "
<<
static_cast
<
particles
::
Code
>
(
p
)
<<
std
::
endl
;
file
<<
pdg
;
for
(
int
i
=
0
;
i
<
energy_axis
.
size
();
++
i
)
{
file
<<
' '
<<
hist
.
at
(
p
,
i
);
}
file
<<
std
::
endl
;
}
}
}
myfile
<<
"# nuclei"
<<
std
::
endl
;
template
<
typename
THistogramMap
>
static
void
saveHistMap
(
THistogramMap
const
&
histMap
,
std
::
ofstream
&
file
)
{
file
<<
"# nuclei"
<<
std
::
endl
;
for
(
auto
const
&
[
pdg
,
hist
]
:
histMap
)
{
auto
const
num_ebins_nucl
=
hist
.
axis
(
0
).
size
();
assert
(
energy_axis
.
size
()
==
num_ebins_nucl
);
my
file
<<
pdg
<<
" "
;
for
(
int
i
=
0
;
i
<
num_ebins_nucl
;
++
i
)
{
my
file
<<
' '
<<
hist
.
at
(
i
);
}
my
file
<<
std
::
endl
;
file
<<
pdg
<<
' '
;
for
(
int
i
=
0
;
i
<
num_ebins_nucl
;
++
i
)
{
file
<<
' '
<<
hist
.
at
(
i
);
}
file
<<
std
::
endl
;
}
}
template
<
typename
T1
,
typename
T2
>
static
void
saveHist
(
T1
const
&
hist
,
T2
const
&
histMap
,
std
::
string
const
&
filename
,
std
::
string
const
&
comment
=
""
)
{
std
::
ofstream
file
;
file
.
open
(
filename
);
saveHist
(
hist
,
file
,
comment
);
saveHistMap
(
histMap
,
file
);
}
}
// namespace corsika::process::interaction_counter
#endif
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