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
c6a35928
Commit
c6a35928
authored
6 years ago
by
ralfulrich
Browse files
Options
Downloads
Patches
Plain Diff
fixed the canInteract, knownby flags for sibyll, and added the xs-type code
parent
59304d3d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Processes/Sibyll/ParticleConversion.h
+4
-0
4 additions, 0 deletions
Processes/Sibyll/ParticleConversion.h
Processes/Sibyll/code_generator.py
+26
-7
26 additions, 7 deletions
Processes/Sibyll/code_generator.py
Processes/Sibyll/testSibyll.cc
+16
-8
16 additions, 8 deletions
Processes/Sibyll/testSibyll.cc
with
46 additions
and
15 deletions
Processes/Sibyll/ParticleConversion.h
+
4
−
0
View file @
c6a35928
...
...
@@ -45,6 +45,10 @@ namespace corsika::process::sibyll {
int
ConvertToSibyllRaw
(
corsika
::
particles
::
Code
pCode
){
return
(
int
)
static_cast
<
corsika
::
process
::
sibyll
::
SibyllCodeIntType
>
(
corsika
::
process
::
sibyll
::
ConvertToSibyll
(
pCode
)
);
}
int
GetSibyllXSCode
(
corsika
::
particles
::
Code
pCode
)
{
return
corsika2sibyllXStype
[
static_cast
<
corsika
::
particles
::
CodeIntType
>
(
pCode
)];
}
}
// namespace corsika::process::sibyll
...
...
This diff is collapsed.
Click to expand it.
Processes/Sibyll/code_generator.py
+
26
−
7
View file @
c6a35928
...
...
@@ -32,7 +32,7 @@ def read_sibyll_codes(filename, pythia_db):
try
:
pythia_db
[
identifier
][
"
sibyll_code
"
]
=
int
(
sib_code
)
pythia_db
[
identifier
][
"
sibyll_canInteract
"
]
=
int
(
canInteractFlag
)
pythia_db
[
identifier
][
"
xsType
"
]
=
int
(
xsType
)
pythia_db
[
identifier
][
"
sibyll_
xsType
"
]
=
int
(
xsType
)
except
KeyError
as
e
:
raise
Exception
(
"
Identifier
'
{:s}
'
not found in pythia_db
"
.
format
(
identifier
))
...
...
@@ -52,7 +52,7 @@ 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
))
string
=
"
std::array<SibyllCodeIntType, {:d}> constexpr corsika2sibyll = {{
\n
"
.
format
(
len
(
pythia_db
))
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)
"
)
...
...
@@ -61,13 +61,27 @@ def generate_corsika2sibyll(pythia_db):
# generates the look-up table to convert corsika codes to sibyll codes
def
generate_corsika2sibyll_xsType
(
pythia_db
):
string
=
"
std::array<int, {:d}> constexpr corsika2sibyllXStype = {{
\n
"
.
format
(
len
(
pythia_db
))
for
identifier
,
pData
in
pythia_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
"
return
string
# generates the look-up table to convert sibyll codes to corsika codes
def
generate_sibyll2corsika
(
pythia_db
)
:
string
=
""
minID
=
0
for
identifier
,
pData
in
pythia_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
pythia_db
.
items
()
:
if
'
sibyll_code
'
in
pData
:
...
...
@@ -75,7 +89,7 @@ def generate_sibyll2corsika(pythia_db) :
pDict
[
sib_code
]
=
identifier
nPart
=
max
(
pDict
.
keys
())
-
min
(
pDict
.
keys
())
+
1
string
=
"
std::array<corsika::particles::Code, {:d}> sibyll2corsika = {{
\n
"
.
format
(
nPart
)
string
+
=
"
std::array<corsika::particles::Code, {:d}> sibyll2corsika = {{
\n
"
.
format
(
nPart
)
for
iPart
in
range
(
nPart
)
:
if
iPart
in
pDict
:
...
...
@@ -85,7 +99,6 @@ def generate_sibyll2corsika(pythia_db) :
string
+=
"
corsika::particles::Code::{:s},
\n
"
.
format
(
identifier
)
string
+=
"
};
\n
"
string
+=
"
SibyllCodeIntType constexpr minSibyll = {:d};
\n
"
.
format
(
minID
)
return
string
...
...
@@ -116,12 +129,15 @@ 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
)
#string = "std::array<bool, {:d}> constexpr corsika2sibyll = {{\n".format(num_particles)
numeric
=
0
for
identifier
,
pData
in
reversed
(
pythia_db
.
items
()):
can
=
0
if
'
sibyll_canInteract
'
in
pData
:
can
=
int
(
pData
[
"
sibyll_canInteract
"
])
&
0x1
numeric
=
(
numeric
<<
1
)
|
can
if
pData
[
'
sibyll_canInteract
'
]
>
0
:
can
=
0x1
numeric
=
(
numeric
<<
1
)
|
can
while
numeric
!=
0
:
low
=
numeric
&
0xFFFFFFFF
...
...
@@ -143,6 +159,8 @@ if __name__ == "__main__":
pythia_db
=
load_pythiadb
(
sys
.
argv
[
1
])
read_sibyll_codes
(
sys
.
argv
[
2
],
pythia_db
)
print
(
str
(
pythia_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
(
pythia_db
),
file
=
f
)
...
...
@@ -150,3 +168,4 @@ if __name__ == "__main__":
print
(
generate_known_particle
(
pythia_db
),
file
=
f
)
print
(
generate_sibyll2corsika
(
pythia_db
),
file
=
f
)
print
(
generate_interacting_particle
(
pythia_db
),
file
=
f
)
print
(
generate_corsika2sibyll_xsType
(
pythia_db
),
file
=
f
)
This diff is collapsed.
Click to expand it.
Processes/Sibyll/testSibyll.cc
+
16
−
8
View file @
c6a35928
...
...
@@ -17,6 +17,8 @@
// cpp file
#include
<catch2/catch.hpp>
#include
<iostream>
using
namespace
std
;
using
namespace
corsika
;
TEST_CASE
(
"Sibyll"
,
"[processes]"
)
{
...
...
@@ -30,23 +32,29 @@ TEST_CASE("Sibyll", "[processes]") {
REQUIRE
(
process
::
sibyll
::
ConvertToSibyll
(
corsika
::
particles
::
Electron
::
GetCode
())
==
process
::
sibyll
::
SibyllCode
::
Electron
);
REQUIRE
(
process
::
sibyll
::
ConvertToSibyllRaw
(
corsika
::
particles
::
Proton
::
GetCode
())
==
13
);
13
);
}
SECTION
(
"
handled
BySibyll"
)
{
SECTION
(
"
Known
BySibyll"
)
{
REQUIRE
(
process
::
sibyll
::
KnownBySibyll
(
corsika
::
particles
::
Electron
::
GetCode
()));
REQUIRE_FALSE
(
process
::
sibyll
::
KnownBySibyll
(
corsika
::
particles
::
XiPrimeC0
::
GetCode
()));
}
SECTION
(
"c
ross-section type
"
)
{
SECTION
(
"c
anInteractInSibyll
"
)
{
REQUIRE
(
process
::
sibyll
::
CanInteract
(
corsika
::
particles
::
Proton
::
GetCode
()));
REQUIRE
(
process
::
sibyll
::
CanInteract
(
corsika
::
particles
::
XiCPlus
::
GetCode
()
));
REQUIRE
(
process
::
sibyll
::
CanInteract
(
corsika
::
particles
::
Code
::
XiCPlus
));
REQUIRE_FALSE
(
process
::
sibyll
::
CanInteract
(
corsika
::
particles
::
Electron
::
GetCode
()));
REQUIRE_FALSE
(
process
::
sibyll
::
CanInteract
(
corsika
::
particles
::
SigmaC0
::
GetCode
()));
REQUIRE_FALSE
(
process
::
sibyll
::
CanInteract
(
corsika
::
particles
::
Electron
::
GetCode
()));
REQUIRE_FALSE
(
process
::
sibyll
::
CanInteract
(
corsika
::
particles
::
SigmaC0
::
GetCode
()));
}
SECTION
(
"cross-section type"
)
{
REQUIRE
(
process
::
sibyll
::
GetSibyllXSCode
(
corsika
::
particles
::
Code
::
Electron
)
==
0
);
REQUIRE
(
process
::
sibyll
::
GetSibyllXSCode
(
corsika
::
particles
::
Code
::
K0Long
)
==
3
);
REQUIRE
(
process
::
sibyll
::
GetSibyllXSCode
(
corsika
::
particles
::
Code
::
SigmaPlus
)
==
1
);
REQUIRE
(
process
::
sibyll
::
GetSibyllXSCode
(
corsika
::
particles
::
Code
::
PiMinus
)
==
2
);
}
}
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