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
989f9ef2
Commit
989f9ef2
authored
6 years ago
by
ralfulrich
Browse files
Options
Downloads
Patches
Plain Diff
fix dependency
parent
d6148eba
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/CMakeLists.txt
+2
-2
2 additions, 2 deletions
Processes/Sibyll/CMakeLists.txt
Processes/Sibyll/code_generator.py
+35
-35
35 additions, 35 deletions
Processes/Sibyll/code_generator.py
with
37 additions
and
37 deletions
Processes/Sibyll/CMakeLists.txt
+
2
−
2
View file @
989f9ef2
add_custom_command
(
OUTPUT
${
PROJECT_BINARY_DIR
}
/Processes/Sibyll/Generated.inc
COMMAND
${
PROJECT_SOURCE_DIR
}
/Processes/Sibyll/code_generator.py
${
PROJECT_BINARY_DIR
}
/Framework/Particles/p
ythia
_db.pkl
${
PROJECT_BINARY_DIR
}
/Framework/Particles/p
article
_db.pkl
${
PROJECT_SOURCE_DIR
}
/Processes/Sibyll/sibyll_codes.dat
DEPENDS code_generator.py
sibyll_codes.dat
${
PROJECT_BINARY_DIR
}
/Framework/Particles/p
ythia
_db.pkl
${
PROJECT_BINARY_DIR
}
/Framework/Particles/p
article
_db.pkl
WORKING_DIRECTORY
${
PROJECT_BINARY_DIR
}
/Processes/Sibyll/
COMMENT
"Generate conversion tables for particle codes SIBYLL <-> CORSIKA"
...
...
This diff is collapsed.
Click to expand it.
Processes/Sibyll/code_generator.py
+
35
−
35
View file @
989f9ef2
...
...
@@ -13,16 +13,16 @@ import pickle, sys, itertools
# loads the pickled p
ythia
_db (which is an OrderedDict)
def
load_p
ythia
db
(
filename
):
# loads the pickled p
article
_db (which is an OrderedDict)
def
load_p
article
db
(
filename
):
with
open
(
filename
,
"
rb
"
)
as
f
:
p
ythia
_db
=
pickle
.
load
(
f
)
return
p
ythia
_db
p
article
_db
=
pickle
.
load
(
f
)
return
p
article
_db
#
def
read_sibyll_codes
(
filename
,
p
ythia
_db
):
def
read_sibyll_codes
(
filename
,
p
article
_db
):
with
open
(
filename
)
as
f
:
for
line
in
f
:
line
=
line
.
strip
()
...
...
@@ -30,19 +30,19 @@ def read_sibyll_codes(filename, pythia_db):
continue
identifier
,
sib_code
,
canInteractFlag
,
xsType
=
line
.
split
()
try
:
p
ythia
_db
[
identifier
][
"
sibyll_code
"
]
=
int
(
sib_code
)
p
ythia
_db
[
identifier
][
"
sibyll_canInteract
"
]
=
int
(
canInteractFlag
)
p
ythia
_db
[
identifier
][
"
sibyll_xsType
"
]
=
int
(
xsType
)
p
article
_db
[
identifier
][
"
sibyll_code
"
]
=
int
(
sib_code
)
p
article
_db
[
identifier
][
"
sibyll_canInteract
"
]
=
int
(
canInteractFlag
)
p
article
_db
[
identifier
][
"
sibyll_xsType
"
]
=
int
(
xsType
)
except
KeyError
as
e
:
raise
Exception
(
"
Identifier
'
{:s}
'
not found in p
ythia
_db
"
.
format
(
identifier
))
raise
Exception
(
"
Identifier
'
{:s}
'
not found in p
article
_db
"
.
format
(
identifier
))
# generates the enum to access sibyll particles by readable names
def
generate_sibyll_enum
(
p
ythia
_db
):
def
generate_sibyll_enum
(
p
article
_db
):
output
=
"
enum class SibyllCode : int8_t {
\n
"
for
identifier
,
pData
in
p
ythia
_db
.
items
():
for
identifier
,
pData
in
p
article
_db
.
items
():
if
pData
.
get
(
'
sibyll_code
'
)
!=
None
:
output
+=
"
{:s} = {:d},
\n
"
.
format
(
identifier
,
pData
[
'
sibyll_code
'
])
output
+=
"
};
\n
"
...
...
@@ -51,9 +51,9 @@ def generate_sibyll_enum(pythia_db):
# generates the look-up table to convert corsika codes to sibyll codes
def
generate_corsika2sibyll
(
p
ythia
_db
):
string
=
"
std::array<SibyllCodeIntType, {:d}> constexpr corsika2sibyll = {{
\n
"
.
format
(
len
(
p
ythia
_db
))
for
identifier
,
pData
in
p
ythia
_db
.
items
():
def
generate_corsika2sibyll
(
p
article
_db
):
string
=
"
std::array<SibyllCodeIntType, {:d}> constexpr corsika2sibyll = {{
\n
"
.
format
(
len
(
p
article
_db
))
for
identifier
,
pData
in
p
article
_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
"
...
...
@@ -62,9 +62,9 @@ def generate_corsika2sibyll(pythia_db):
# generates the look-up table to convert corsika codes to sibyll codes
def
generate_corsika2sibyll_xsType
(
p
ythia
_db
):
string
=
"
std::array<int, {:d}> constexpr corsika2sibyllXStype = {{
\n
"
.
format
(
len
(
p
ythia
_db
))
for
identifier
,
pData
in
p
ythia
_db
.
items
():
def
generate_corsika2sibyll_xsType
(
p
article
_db
):
string
=
"
std::array<int, {:d}> constexpr corsika2sibyllXStype = {{
\n
"
.
format
(
len
(
p
article
_db
))
for
identifier
,
pData
in
p
article
_db
.
items
():
sibCodeXS
=
pData
.
get
(
"
sibyll_xsType
"
,
-
1
)
string
+=
"
{:d}, // {:s}
\n
"
.
format
(
sibCodeXS
,
identifier
if
sibCodeXS
else
identifier
+
"
(not implemented in SIBYLL)
"
)
string
+=
"
};
\n
"
...
...
@@ -72,18 +72,18 @@ def generate_corsika2sibyll_xsType(pythia_db):
# generates the look-up table to convert sibyll codes to corsika codes
def
generate_sibyll2corsika
(
p
ythia
_db
)
:
def
generate_sibyll2corsika
(
p
article
_db
)
:
string
=
""
minID
=
0
for
identifier
,
pData
in
p
ythia
_db
.
items
()
:
for
identifier
,
pData
in
p
article
_db
.
items
()
:
if
'
sibyll_code
'
in
pData
:
minID
=
min
(
minID
,
pData
[
'
sibyll_code
'
])
string
+=
"
SibyllCodeIntType constexpr minSibyll = {:d};
\n\n
"
.
format
(
minID
)
pDict
=
{}
for
identifier
,
pData
in
p
ythia
_db
.
items
()
:
for
identifier
,
pData
in
p
article
_db
.
items
()
:
if
'
sibyll_code
'
in
pData
:
sib_code
=
pData
[
'
sibyll_code
'
]
-
minID
pDict
[
sib_code
]
=
identifier
...
...
@@ -104,13 +104,13 @@ def generate_sibyll2corsika(pythia_db) :
# generates the bitset for the flag whether Sibyll knows the particle
def
generate_known_particle
(
p
ythia
_db
):
num_particles
=
len
(
p
ythia
_db
)
def
generate_known_particle
(
p
article
_db
):
num_particles
=
len
(
p
article
_db
)
num_bytes
=
num_particles
//
32
+
1
string
=
"
Bitset2::bitset2<{:d}> constexpr isKnown{{ std::array<uint32_t, {:d}>{{{{
\n
"
.
format
(
num_particles
,
num_bytes
)
numeric
=
0
for
identifier
,
pData
in
reversed
(
p
ythia
_db
.
items
()):
for
identifier
,
pData
in
reversed
(
p
article
_db
.
items
()):
handledBySibyll
=
int
(
"
sibyll_code
"
in
pData
)
&
0x1
numeric
=
(
numeric
<<
1
)
|
handledBySibyll
...
...
@@ -125,14 +125,14 @@ def generate_known_particle(pythia_db):
# generates the bitset for the flag whether Sibyll can use particle as projectile
def
generate_interacting_particle
(
p
ythia
_db
):
num_particles
=
len
(
p
ythia
_db
)
def
generate_interacting_particle
(
p
article
_db
):
num_particles
=
len
(
p
article
_db
)
num_bytes
=
num_particles
//
32
+
1
string
=
"
Bitset2::bitset2<{:d}> constexpr canInteract{{ std::array<uint32_t, {:d}>{{{{
\n
"
.
format
(
num_particles
,
num_bytes
)
#string = "std::array<bool, {:d}> constexpr corsika2sibyll = {{\n".format(num_particles)
numeric
=
0
for
identifier
,
pData
in
reversed
(
p
ythia
_db
.
items
()):
for
identifier
,
pData
in
reversed
(
p
article
_db
.
items
()):
can
=
0
if
'
sibyll_canInteract
'
in
pData
:
if
pData
[
'
sibyll_canInteract
'
]
>
0
:
...
...
@@ -151,19 +151,19 @@ def generate_interacting_particle(pythia_db):
if
__name__
==
"
__main__
"
:
if
len
(
sys
.
argv
)
!=
3
:
print
(
"
usage: {:s} <p
ythia
_db.pkl> <sibyll_codes.dat>
"
.
format
(
sys
.
argv
[
0
]),
file
=
sys
.
stderr
)
print
(
"
usage: {:s} <p
article
_db.pkl> <sibyll_codes.dat>
"
.
format
(
sys
.
argv
[
0
]),
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
print
(
"
code_generator.py for SIBYLL
"
)
p
ythia
_db
=
load_p
ythia
db
(
sys
.
argv
[
1
])
read_sibyll_codes
(
sys
.
argv
[
2
],
p
ythia
_db
)
p
article
_db
=
load_p
article
db
(
sys
.
argv
[
1
])
read_sibyll_codes
(
sys
.
argv
[
2
],
p
article
_db
)
with
open
(
"
Generated.inc
"
,
"
w
"
)
as
f
:
print
(
"
// this file is automatically generated
\n
// edit at your own risk!
\n
"
,
file
=
f
)
print
(
generate_sibyll_enum
(
p
ythia
_db
),
file
=
f
)
print
(
generate_corsika2sibyll
(
p
ythia
_db
),
file
=
f
)
print
(
generate_known_particle
(
p
ythia
_db
),
file
=
f
)
print
(
generate_sibyll2corsika
(
p
ythia
_db
),
file
=
f
)
print
(
generate_interacting_particle
(
p
ythia
_db
),
file
=
f
)
print
(
generate_corsika2sibyll_xsType
(
p
ythia
_db
),
file
=
f
)
print
(
generate_sibyll_enum
(
p
article
_db
),
file
=
f
)
print
(
generate_corsika2sibyll
(
p
article
_db
),
file
=
f
)
print
(
generate_known_particle
(
p
article
_db
),
file
=
f
)
print
(
generate_sibyll2corsika
(
p
article
_db
),
file
=
f
)
print
(
generate_interacting_particle
(
p
article
_db
),
file
=
f
)
print
(
generate_corsika2sibyll_xsType
(
p
article
_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