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
Snippets
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
Antonio Augusto Alves Junior
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
No related tags found
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 @@
...
@@ -20,8 +20,8 @@
namespace
corsika
::
process
::
sibyll
{
namespace
corsika
::
process
::
sibyll
{
enum
class
Code
:
int8_t
;
enum
class
Sibyll
Code
:
int8_t
;
using
SibyllCodeIntType
=
std
::
underlying_type
<
Code
>::
type
;
using
SibyllCodeIntType
=
std
::
underlying_type
<
Sibyll
Code
>::
type
;
#include
<corsika/process/sibyll/Generated.inc>
#include
<corsika/process/sibyll/Generated.inc>
...
@@ -33,12 +33,12 @@ namespace corsika::process::sibyll {
...
@@ -33,12 +33,12 @@ namespace corsika::process::sibyll {
return
canInteract
[
static_cast
<
corsika
::
particles
::
CodeIntType
>
(
pCode
)];
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));
//~ 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
];
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):
...
@@ -27,21 +27,23 @@ def read_sibyll_codes(filename, pythia_db):
for
line
in
f
:
for
line
in
f
:
line
=
line
.
strip
()
line
=
line
.
strip
()
if
line
[
0
]
==
'
#
'
:
if
line
[
0
]
==
'
#
'
:
continue
continue
identifier
,
sib_code
=
line
.
split
()
identifier
,
sib_code
,
canInteractFlag
=
line
.
split
()
try
:
try
:
pythia_db
[
identifier
][
"
sibyll_code
"
]
=
int
(
sib_code
)
pythia_db
[
identifier
][
"
sibyll_code
"
]
=
int
(
sib_code
)
pythia_db
[
identifier
][
"
sibyll_canInteract
"
]
=
int
(
canInteractFlag
)
except
KeyError
as
e
:
except
KeyError
as
e
:
raise
Exception
(
"
Identifier
'
{:s}
'
not found in pythia_db
"
.
format
(
identifier
))
raise
Exception
(
"
Identifier
'
{:s}
'
not found in pythia_db
"
.
format
(
identifier
))
# generates the enum to access sibyll particles by readable names
# generates the enum to access sibyll particles by readable names
def
generate_sibyll_enum
(
pythia_db
):
def
generate_sibyll_enum
(
pythia_db
):
output
=
"
enum class Code : int8_t {
\n
"
output
=
"
enum class
Sibyll
Code : int8_t {
\n
"
for
identifier
,
d
in
pythia_db
.
items
():
for
identifier
,
pData
in
pythia_db
.
items
():
if
d
.
get
(
'
sibyll_code
'
)
!=
None
:
if
pData
.
get
(
'
sibyll_code
'
)
!=
None
:
output
+=
"
{:s} = {:d},
\n
"
.
format
(
identifier
,
d
[
'
sibyll_code
'
])
output
+=
"
{:s} = {:d},
\n
"
.
format
(
identifier
,
pData
[
'
sibyll_code
'
])
output
+=
"
};
\n
"
output
+=
"
};
\n
"
return
output
return
output
...
@@ -50,8 +52,8 @@ def generate_sibyll_enum(pythia_db):
...
@@ -50,8 +52,8 @@ def generate_sibyll_enum(pythia_db):
# generates the look-up table to convert corsika codes to sibyll codes
# generates the look-up table to convert corsika codes to sibyll codes
def
generate_corsika2sibyll
(
pythia_db
):
def
generate_corsika2sibyll
(
pythia_db
):
string
=
"
std::array<SibyllCodeIntType, {:d}> constexpr corsika2sibyll = {{
"
.
format
(
len
(
pythia_db
))
string
=
"
std::array<SibyllCodeIntType, {:d}> constexpr corsika2sibyll = {{
"
.
format
(
len
(
pythia_db
))
for
identifier
,
d
in
pythia_db
.
items
():
for
identifier
,
pData
in
pythia_db
.
items
():
sibCode
=
d
.
get
(
"
sibyll_code
"
,
0
)
sibCode
=
pData
.
get
(
"
sibyll_code
"
,
0
)
string
+=
"
{:d}, // {:s}
\n
"
.
format
(
sibCode
,
identifier
if
sibCode
else
identifier
+
"
(not implemented in SIBYLL)
"
)
string
+=
"
{:d}, // {:s}
\n
"
.
format
(
sibCode
,
identifier
if
sibCode
else
identifier
+
"
(not implemented in SIBYLL)
"
)
string
+=
"
};
\n
"
string
+=
"
};
\n
"
return
string
return
string
...
@@ -88,14 +90,14 @@ def generate_sibyll2corsika(pythia_db) :
...
@@ -88,14 +90,14 @@ def generate_sibyll2corsika(pythia_db) :
# generates the bitset for the flag whether Sibyll knows the particle
# 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_particles
=
len
(
pythia_db
)
num_bytes
=
num_particles
//
32
+
1
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
numeric
=
0
for
identifier
,
d
in
reversed
(
pythia_db
.
items
()):
for
identifier
,
pData
in
reversed
(
pythia_db
.
items
()):
handledBySibyll
=
int
(
"
sibyll_code
"
in
d
)
&
0x1
handledBySibyll
=
int
(
"
sibyll_code
"
in
pData
)
&
0x1
numeric
=
(
numeric
<<
1
)
|
handledBySibyll
numeric
=
(
numeric
<<
1
)
|
handledBySibyll
while
numeric
!=
0
:
while
numeric
!=
0
:
...
@@ -105,6 +107,28 @@ def generate_handles_particle(pythia_db):
...
@@ -105,6 +107,28 @@ def generate_handles_particle(pythia_db):
string
+=
"
}}};
\n
"
string
+=
"
}}};
\n
"
return
string
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__":
...
@@ -122,5 +146,5 @@ if __name__ == "__main__":
print
(
"
// this file is automatically generated
\n
// edit at your own risk!
\n
"
,
file
=
f
)
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_sibyll_enum
(
pythia_db
),
file
=
f
)
print
(
generate_corsika2sibyll
(
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
)
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