IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Pranav Sampathkumar
corsika
Commits
cf7fcffa
Commit
cf7fcffa
authored
3 years ago
by
Matthieu Carrere
Committed by
Maximilian Reininghaus
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Vertical_EAS - Move modules and initializations before shower's loop
parent
d0e4d802
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/vertical_EAS.cpp
+130
-129
130 additions, 129 deletions
examples/vertical_EAS.cpp
with
130 additions
and
129 deletions
examples/vertical_EAS.cpp
+
130
−
129
View file @
cf7fcffa
...
...
@@ -93,8 +93,7 @@ using MyExtraEnv = MediumPropertyModel<UniformMagneticField<T>>;
// argv : 1.number of nucleons, 2.number of protons,
// 3.total energy in GeV, 4.number of showers,
// 5.output directory
// 6.seed (0 by default to generate random values for all)
// 5.seed (0 by default to generate random values for all)
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -112,15 +111,10 @@ int main(int argc, char** argv) {
}
feenableexcept
(
FE_INVALID
);
string
output_dir
=
""
;
int
seed
=
0
;
int
number_showers
=
std
::
stoi
(
std
::
string
(
argv
[
4
]));
if
(
argc
>
5
)
{
output_dir
=
argv
[
5
];
if
(
output_dir
.
back
()
!=
'/'
&&
output_dir
!=
""
)
output_dir
+=
'/'
;
}
if
(
argc
>
6
)
{
seed
=
std
::
stoi
(
std
::
string
(
argv
[
6
]));
}
if
(
argc
>
5
)
{
seed
=
std
::
stoi
(
std
::
string
(
argv
[
5
]));
}
// initialize random number sequence(s)
registerRandomStreams
(
seed
);
...
...
@@ -163,17 +157,131 @@ int main(int argc, char** argv) {
fmt
::
ptr
(
env
.
getUniverse
()
->
getContainingNode
(
Point
(
rootCS
,
{
constants
::
EarthRadius
::
Mean
+
2
_km
,
0
_m
,
0
_m
}))));
// pre-setup particle stack
unsigned
short
const
A
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
Code
beamCode
;
HEPEnergyType
mass
;
unsigned
short
Z
=
0
;
if
(
A
>
0
)
{
beamCode
=
Code
::
Nucleus
;
Z
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
mass
=
get_nucleus_mass
(
A
,
Z
);
}
else
{
int
pdg
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
beamCode
=
convert_from_PDG
(
PDGCode
(
pdg
));
mass
=
get_mass
(
beamCode
);
}
HEPEnergyType
const
E0
=
1
_GeV
*
std
::
stof
(
std
::
string
(
argv
[
3
]));
double
theta
=
20.
;
double
phi
=
180.
;
auto
const
thetaRad
=
theta
/
180.
*
M_PI
;
auto
const
phiRad
=
phi
/
180.
*
M_PI
;
auto
elab2plab
=
[](
HEPEnergyType
Elab
,
HEPMassType
m
)
{
return
sqrt
((
Elab
-
m
)
*
(
Elab
+
m
));
};
HEPMomentumType
P0
=
elab2plab
(
E0
,
mass
);
auto
momentumComponents
=
[](
double
theta
,
double
phi
,
HEPMomentumType
ptot
)
{
return
std
::
make_tuple
(
ptot
*
sin
(
theta
)
*
cos
(
phi
),
ptot
*
sin
(
theta
)
*
sin
(
phi
),
-
ptot
*
cos
(
theta
));
};
auto
const
[
px
,
py
,
pz
]
=
momentumComponents
(
thetaRad
,
phiRad
,
P0
);
auto
plab
=
MomentumVector
(
rootCS
,
{
px
,
py
,
pz
});
cout
<<
"input particle: "
<<
beamCode
<<
endl
;
cout
<<
"input angles: theta="
<<
theta
<<
",phi="
<<
phi
<<
endl
;
cout
<<
"input momentum: "
<<
plab
.
getComponents
()
/
1
_GeV
<<
", norm = "
<<
plab
.
getNorm
()
<<
endl
;
auto
const
observationHeight
=
0
_km
+
builder
.
getEarthRadius
();
auto
const
injectionHeight
=
111.75
_km
+
builder
.
getEarthRadius
();
auto
const
t
=
-
observationHeight
*
cos
(
thetaRad
)
+
sqrt
(
-
static_pow
<
2
>
(
sin
(
thetaRad
)
*
observationHeight
)
+
static_pow
<
2
>
(
injectionHeight
));
Point
const
showerCore
{
rootCS
,
0
_m
,
0
_m
,
observationHeight
};
Point
const
injectionPos
=
showerCore
+
DirectionVector
{
rootCS
,
{
-
sin
(
thetaRad
)
*
cos
(
phiRad
),
-
sin
(
thetaRad
)
*
sin
(
phiRad
),
cos
(
thetaRad
)}}
*
t
;
std
::
cout
<<
"point of injection: "
<<
injectionPos
.
getCoordinates
()
<<
std
::
endl
;
// we make the axis much longer than the inj-core distance since the
// profile will go beyond the core, depending on zenith angle
std
::
cout
<<
"shower axis length: "
<<
(
showerCore
-
injectionPos
).
getNorm
()
*
1.5
<<
std
::
endl
;
ShowerAxis
const
showerAxis
{
injectionPos
,
(
showerCore
-
injectionPos
)
*
1.5
,
env
};
// setup processes, decays and interactions
// corsika::qgsjetII::Interaction qgsjet;
corsika
::
sibyll
::
Interaction
sibyll
;
InteractionCounter
sibyllCounted
(
sibyll
);
corsika
::
sibyll
::
NuclearInteraction
sibyllNuc
(
sibyll
,
env
);
InteractionCounter
sibyllNucCounted
(
sibyllNuc
);
corsika
::
pythia8
::
Decay
decayPythia
;
// use sibyll decay routine for decays of particles unknown to pythia
corsika
::
sibyll
::
Decay
decaySibyll
{{
Code
::
N1440Plus
,
Code
::
N1440MinusBar
,
Code
::
N1440_0
,
Code
::
N1440_0Bar
,
Code
::
N1710Plus
,
Code
::
N1710MinusBar
,
Code
::
N1710_0
,
Code
::
N1710_0Bar
,
Code
::
Pi1300Plus
,
Code
::
Pi1300Minus
,
Code
::
Pi1300_0
,
Code
::
KStar0_1430_0
,
Code
::
KStar0_1430_0Bar
,
Code
::
KStar0_1430_Plus
,
Code
::
KStar0_1430_MinusBar
,
}};
decaySibyll
.
printDecayConfig
();
ParticleCut
cut
{
60
_GeV
,
60
_GeV
,
60
_GeV
,
60
_GeV
,
true
};
corsika
::
proposal
::
Interaction
emCascade
(
env
);
corsika
::
proposal
::
ContinuousProcess
emContinuous
(
env
);
InteractionCounter
emCascadeCounted
(
emCascade
);
OnShellCheck
reset_particle_mass
(
1.e-3
,
1.e-1
,
false
);
LongitudinalProfile
longprof
{
showerAxis
};
Plane
const
obsPlane
(
showerCore
,
DirectionVector
(
rootCS
,
{
0.
,
0.
,
1.
}));
corsika
::
urqmd
::
UrQMD
urqmd
;
InteractionCounter
urqmdCounted
{
urqmd
};
StackInspector
<
setup
::
Stack
>
stackInspect
(
50000
,
false
,
E0
);
// assemble all processes into an ordered process list
struct
EnergySwitch
{
HEPEnergyType
cutE_
;
EnergySwitch
(
HEPEnergyType
cutE
)
:
cutE_
(
cutE
)
{}
bool
operator
()(
const
Particle
&
p
)
{
return
(
p
.
getEnergy
()
<
cutE_
);
}
};
auto
hadronSequence
=
make_select
(
EnergySwitch
(
55
_GeV
),
urqmdCounted
,
make_sequence
(
sibyllNucCounted
,
sibyllCounted
));
auto
decaySequence
=
make_sequence
(
decayPythia
,
decaySibyll
);
for
(
int
i_shower
=
1
;
i_shower
<
number_showers
+
1
;
i_shower
++
)
{
// directory for outputs
string
labHist_dir
=
output_dir
+
"inthist_lab_verticalEAS_"
+
to_string
(
i_shower
)
+
".npz"
;
string
cMSHist_dir
=
output_dir
+
"inthist_cms_verticalEAS_"
+
to_string
(
i_shower
)
+
".npz"
;
string
longprof_dir
=
output_dir
+
"longprof_verticalEAS_"
+
to_string
(
i_shower
)
+
".txt"
;
string
tracks_dir
=
output_dir
+
"tracks_"
+
to_string
(
i_shower
)
+
".dat"
;
string
particles_dir
=
output_dir
+
"particles_"
+
to_string
(
i_shower
)
+
".dat"
;
string
const
labHist_file
=
"inthist_lab_verticalEAS_"
+
to_string
(
i_shower
)
+
".npz"
;
string
const
cMSHist_file
=
"inthist_cms_verticalEAS_"
+
to_string
(
i_shower
)
+
".npz"
;
string
const
longprof_file
=
"longprof_verticalEAS_"
+
to_string
(
i_shower
)
+
".txt"
;
string
const
tracks_file
=
"tracks_"
+
to_string
(
i_shower
)
+
".dat"
;
string
const
particles_file
=
"particles_"
+
to_string
(
i_shower
)
+
".dat"
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"Shower "
<<
i_shower
<<
"/"
<<
number_showers
<<
std
::
endl
;
...
...
@@ -181,48 +289,6 @@ int main(int argc, char** argv) {
// setup particle stack, and add primary particle
setup
::
Stack
stack
;
stack
.
clear
();
unsigned
short
const
A
=
std
::
stoi
(
std
::
string
(
argv
[
1
]));
Code
beamCode
;
HEPEnergyType
mass
;
unsigned
short
Z
=
0
;
if
(
A
>
0
)
{
beamCode
=
Code
::
Nucleus
;
Z
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
mass
=
get_nucleus_mass
(
A
,
Z
);
}
else
{
int
pdg
=
std
::
stoi
(
std
::
string
(
argv
[
2
]));
beamCode
=
convert_from_PDG
(
PDGCode
(
pdg
));
mass
=
get_mass
(
beamCode
);
}
HEPEnergyType
const
E0
=
1
_GeV
*
std
::
stof
(
std
::
string
(
argv
[
3
]));
double
theta
=
0.
;
auto
const
thetaRad
=
theta
/
180.
*
M_PI
;
auto
elab2plab
=
[](
HEPEnergyType
Elab
,
HEPMassType
m
)
{
return
sqrt
((
Elab
-
m
)
*
(
Elab
+
m
));
};
HEPMomentumType
P0
=
elab2plab
(
E0
,
mass
);
auto
momentumComponents
=
[](
double
thetaRad
,
HEPMomentumType
ptot
)
{
return
std
::
make_tuple
(
ptot
*
sin
(
thetaRad
),
0
_eV
,
-
ptot
*
cos
(
thetaRad
));
};
auto
const
[
px
,
py
,
pz
]
=
momentumComponents
(
thetaRad
,
P0
);
auto
plab
=
MomentumVector
(
rootCS
,
{
px
,
py
,
pz
});
cout
<<
"input particle: "
<<
beamCode
<<
endl
;
cout
<<
"input angles: theta="
<<
theta
<<
endl
;
cout
<<
"input momentum: "
<<
plab
.
getComponents
()
/
1
_GeV
<<
", norm = "
<<
plab
.
getNorm
()
<<
endl
;
auto
const
observationHeight
=
0
_km
+
builder
.
getEarthRadius
();
auto
const
injectionHeight
=
111.75
_km
+
builder
.
getEarthRadius
();
auto
const
t
=
-
observationHeight
*
cos
(
thetaRad
)
+
sqrt
(
-
static_pow
<
2
>
(
sin
(
thetaRad
)
*
observationHeight
)
+
static_pow
<
2
>
(
injectionHeight
));
Point
const
showerCore
{
rootCS
,
0
_m
,
0
_m
,
observationHeight
};
Point
const
injectionPos
=
showerCore
+
DirectionVector
{
rootCS
,
{
-
sin
(
thetaRad
),
0
,
cos
(
thetaRad
)}}
*
t
;
std
::
cout
<<
"point of injection: "
<<
injectionPos
.
getCoordinates
()
<<
std
::
endl
;
if
(
A
>
1
)
{
stack
.
addParticle
(
std
::
make_tuple
(
beamCode
,
E0
,
plab
,
injectionPos
,
0
_ns
,
A
,
Z
));
...
...
@@ -242,75 +308,10 @@ int main(int argc, char** argv) {
}
}
// we make the axis much longer than the inj-core distance since the
// profile will go beyond the core, depending on zenith angle
std
::
cout
<<
"shower axis length: "
<<
(
showerCore
-
injectionPos
).
getNorm
()
*
1.5
<<
std
::
endl
;
ShowerAxis
const
showerAxis
{
injectionPos
,
(
showerCore
-
injectionPos
)
*
1.5
,
env
};
// setup processes, decays and interactions
// corsika::qgsjetII::Interaction qgsjet;
corsika
::
sibyll
::
Interaction
sibyll
;
InteractionCounter
sibyllCounted
(
sibyll
);
corsika
::
sibyll
::
NuclearInteraction
sibyllNuc
(
sibyll
,
env
);
InteractionCounter
sibyllNucCounted
(
sibyllNuc
);
corsika
::
pythia8
::
Decay
decayPythia
;
// use sibyll decay routine for decays of particles unknown to pythia
corsika
::
sibyll
::
Decay
decaySibyll
{{
Code
::
N1440Plus
,
Code
::
N1440MinusBar
,
Code
::
N1440_0
,
Code
::
N1440_0Bar
,
Code
::
N1710Plus
,
Code
::
N1710MinusBar
,
Code
::
N1710_0
,
Code
::
N1710_0Bar
,
Code
::
Pi1300Plus
,
Code
::
Pi1300Minus
,
Code
::
Pi1300_0
,
Code
::
KStar0_1430_0
,
Code
::
KStar0_1430_0Bar
,
Code
::
KStar0_1430_Plus
,
Code
::
KStar0_1430_MinusBar
,
}};
decaySibyll
.
printDecayConfig
();
ParticleCut
cut
{
60
_GeV
,
60
_GeV
,
60
_GeV
,
60
_GeV
,
true
};
corsika
::
proposal
::
Interaction
emCascade
(
env
);
corsika
::
proposal
::
ContinuousProcess
emContinuous
(
env
);
InteractionCounter
emCascadeCounted
(
emCascade
);
OnShellCheck
reset_particle_mass
(
1.e-3
,
1.e-1
,
false
);
TrackWriter
trackWriter
(
tracks_dir
);
LongitudinalProfile
longprof
{
showerAxis
};
Plane
const
obsPlane
(
showerCore
,
DirectionVector
(
rootCS
,
{
0.
,
0.
,
1.
}));
TrackWriter
trackWriter
(
tracks_file
);
ObservationPlane
observationLevel
(
obsPlane
,
DirectionVector
(
rootCS
,
{
1.
,
0.
,
0.
}),
particles_dir
);
corsika
::
urqmd
::
UrQMD
urqmd
;
InteractionCounter
urqmdCounted
{
urqmd
};
StackInspector
<
setup
::
Stack
>
stackInspect
(
50000
,
false
,
E0
);
// assemble all processes into an ordered process list
struct
EnergySwitch
{
HEPEnergyType
cutE_
;
EnergySwitch
(
HEPEnergyType
cutE
)
:
cutE_
(
cutE
)
{}
bool
operator
()(
const
Particle
&
p
)
{
return
(
p
.
getEnergy
()
<
cutE_
);
}
};
auto
hadronSequence
=
make_select
(
EnergySwitch
(
55
_GeV
),
urqmdCounted
,
make_sequence
(
sibyllNucCounted
,
sibyllCounted
));
auto
decaySequence
=
make_sequence
(
decayPythia
,
decaySibyll
);
particles_file
);
auto
sequence
=
make_sequence
(
stackInspect
,
hadronSequence
,
reset_particle_mass
,
decaySequence
,
emContinuous
,
cut
,
trackWriter
,
observationLevel
,
longprof
);
...
...
@@ -339,8 +340,8 @@ int main(int argc, char** argv) {
auto
const
hists
=
sibyllCounted
.
getHistogram
()
+
sibyllNucCounted
.
getHistogram
()
+
urqmdCounted
.
getHistogram
();
save_hist
(
hists
.
labHist
(),
labHist_
dir
,
true
);
save_hist
(
hists
.
CMSHist
(),
cMSHist_
dir
,
true
);
longprof
.
save
(
longprof_
dir
);
save_hist
(
hists
.
labHist
(),
labHist_
file
,
true
);
save_hist
(
hists
.
CMSHist
(),
cMSHist_
file
,
true
);
longprof
.
save
(
longprof_
file
);
}
}
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