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
c23ca28b
Commit
c23ca28b
authored
6 years ago
by
ralfulrich
Browse files
Options
Downloads
Patches
Plain Diff
added can-interact array
parent
86cf0814
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Processes/Sibyll/ParticleConversion.h
+5
-5
5 additions, 5 deletions
Processes/Sibyll/ParticleConversion.h
Processes/Sibyll/code_generator.py
+37
-13
37 additions, 13 deletions
Processes/Sibyll/code_generator.py
with
42 additions
and
18 deletions
Processes/Sibyll/ParticleConversion.h
+
5
−
5
View file @
c23ca28b
...
...
@@ -20,8 +20,8 @@
namespace
corsika
::
process
::
sibyll
{
enum
class
Code
:
int8_t
;
using
SibyllCodeIntType
=
std
::
underlying_type
<
Code
>::
type
;
enum
class
Sibyll
Code
:
int8_t
;
using
SibyllCodeIntType
=
std
::
underlying_type
<
Sibyll
Code
>::
type
;
#include
<corsika/process/sibyll/Generated.inc>
...
...
@@ -33,12 +33,12 @@ namespace corsika::process::sibyll {
return
canInteract
[
static_cast
<
corsika
::
particles
::
CodeIntType
>
(
pCode
)];
}
Code
constexpr
ConvertToSibyll
(
corsika
::
particles
::
Code
pCode
)
{
Sibyll
Code
constexpr
ConvertToSibyll
(
corsika
::
particles
::
Code
pCode
)
{
//~ assert(handledBySibyll(pCode));
return
static_cast
<
Code
>
(
corsika2sibyll
[
static_cast
<
corsika
::
particles
::
CodeIntType
>
(
pCode
)]);
return
static_cast
<
Sibyll
Code
>
(
corsika2sibyll
[
static_cast
<
corsika
::
particles
::
CodeIntType
>
(
pCode
)]);
}
corsika
::
particles
::
Code
constexpr
ConvertFromSibyll
(
Code
pCode
)
{
corsika
::
particles
::
Code
constexpr
ConvertFromSibyll
(
Sibyll
Code
pCode
)
{
return
sibyll2corsika
[
static_cast
<
SibyllCodeIntType
>
(
pCode
)
-
minSibyll
];
}
...
...
This diff is collapsed.
Click to expand it.
Processes/Sibyll/code_generator.py
+
37
−
13
View file @
c23ca28b
...
...
@@ -27,21 +27,23 @@ def read_sibyll_codes(filename, pythia_db):
for
line
in
f
:
line
=
line
.
strip
()
if
line
[
0
]
==
'
#
'
:
continue
identifier
,
sib_code
=
line
.
split
()
continue
identifier
,
sib_code
,
canInteractFlag
=
line
.
split
()
try
:
pythia_db
[
identifier
][
"
sibyll_code
"
]
=
int
(
sib_code
)
pythia_db
[
identifier
][
"
sibyll_canInteract
"
]
=
int
(
canInteractFlag
)
except
KeyError
as
e
:
raise
Exception
(
"
Identifier
'
{:s}
'
not found in pythia_db
"
.
format
(
identifier
))
# generates the enum to access sibyll particles by readable names
def
generate_sibyll_enum
(
pythia_db
):
output
=
"
enum class Code : int8_t {
\n
"
for
identifier
,
d
in
pythia_db
.
items
():
if
d
.
get
(
'
sibyll_code
'
)
!=
None
:
output
+=
"
{:s} = {:d},
\n
"
.
format
(
identifier
,
d
[
'
sibyll_code
'
])
output
=
"
enum class
Sibyll
Code : int8_t {
\n
"
for
identifier
,
pData
in
pythia_db
.
items
():
if
pData
.
get
(
'
sibyll_code
'
)
!=
None
:
output
+=
"
{:s} = {:d},
\n
"
.
format
(
identifier
,
pData
[
'
sibyll_code
'
])
output
+=
"
};
\n
"
return
output
...
...
@@ -50,8 +52,8 @@ def generate_sibyll_enum(pythia_db):
# generates the look-up table to convert corsika codes to sibyll codes
def
generate_corsika2sibyll
(
pythia_db
):
string
=
"
std::array<SibyllCodeIntType, {:d}> constexpr corsika2sibyll = {{
"
.
format
(
len
(
pythia_db
))
for
identifier
,
d
in
pythia_db
.
items
():
sibCode
=
d
.
get
(
"
sibyll_code
"
,
0
)
for
identifier
,
pData
in
pythia_db
.
items
():
sibCode
=
pData
.
get
(
"
sibyll_code
"
,
0
)
string
+=
"
{:d}, // {:s}
\n
"
.
format
(
sibCode
,
identifier
if
sibCode
else
identifier
+
"
(not implemented in SIBYLL)
"
)
string
+=
"
};
\n
"
return
string
...
...
@@ -88,14 +90,14 @@ def generate_sibyll2corsika(pythia_db) :
# generates the bitset for the flag whether Sibyll knows the particle
def
generate_
handles
_particle
(
pythia_db
):
def
generate_
known
_particle
(
pythia_db
):
num_particles
=
len
(
pythia_db
)
num_bytes
=
num_particles
//
32
+
1
string
=
"
Bitset2::bitset2<{:d}> constexpr
handleable
{{ std::array<uint32_t, {:d}>{{{{
\n
"
.
format
(
num_particles
,
num_bytes
)
string
=
"
Bitset2::bitset2<{:d}> constexpr
isKnown
{{ std::array<uint32_t, {:d}>{{{{
\n
"
.
format
(
num_particles
,
num_bytes
)
numeric
=
0
for
identifier
,
d
in
reversed
(
pythia_db
.
items
()):
handledBySibyll
=
int
(
"
sibyll_code
"
in
d
)
&
0x1
for
identifier
,
pData
in
reversed
(
pythia_db
.
items
()):
handledBySibyll
=
int
(
"
sibyll_code
"
in
pData
)
&
0x1
numeric
=
(
numeric
<<
1
)
|
handledBySibyll
while
numeric
!=
0
:
...
...
@@ -105,6 +107,28 @@ def generate_handles_particle(pythia_db):
string
+=
"
}}};
\n
"
return
string
# generates the bitset for the flag whether Sibyll can use particle as projectile
def
generate_interacting_particle
(
pythia_db
):
num_particles
=
len
(
pythia_db
)
num_bytes
=
num_particles
//
32
+
1
string
=
"
Bitset2::bitset2<{:d}> constexpr canInteract{{ std::array<uint32_t, {:d}>{{{{
\n
"
.
format
(
num_particles
,
num_bytes
)
numeric
=
0
for
identifier
,
pData
in
reversed
(
pythia_db
.
items
()):
if
'
sibyll_canInteract
'
in
pData
:
can
=
int
(
pData
[
"
sibyll_canInteract
"
])
&
0x1
numeric
=
(
numeric
<<
1
)
|
can
while
numeric
!=
0
:
low
=
numeric
&
0xFFFFFFFF
numeric
=
numeric
>>
32
string
+=
"
0x{:0x},
\n
"
.
format
(
low
)
string
+=
"
}}};
\n
"
return
string
...
...
@@ -122,5 +146,5 @@ if __name__ == "__main__":
print
(
"
// this file is automatically generated
\n
// edit at your own risk!
\n
"
,
file
=
f
)
print
(
generate_sibyll_enum
(
pythia_db
),
file
=
f
)
print
(
generate_corsika2sibyll
(
pythia_db
),
file
=
f
)
print
(
generate_
handles
_particle
(
pythia_db
),
file
=
f
)
print
(
generate_
known
_particle
(
pythia_db
),
file
=
f
)
print
(
generate_sibyll2corsika
(
pythia_db
),
file
=
f
)
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