CORSIKA
@c8_version@
The framework to simulate particle cascades for astroparticle physics
ParticleConversion.hpp
1
/*
2
* (c) Copyright 2023 CORSIKA Project, corsika-project@lists.kit.edu
3
*
4
* This software is distributed under the terms of the GNU General Public
5
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6
* the license.
7
*/
8
9
#pragma once
10
11
#include <array>
12
#include <cstdint>
13
#include <type_traits>
14
#include <vector>
15
16
#include <
corsika/framework/core/ParticleProperties.hpp
>
17
#include <fmt/core.h>
18
19
#include <string>
20
21
namespace
corsika::fluka
{
22
23
enum class
FLUKACode : int;
24
using FLUKACodeIntType = std::underlying_type<FLUKACode>::type;
25
26
#include <corsika/modules/fluka/Generated.inc>
27
28
FLUKACode constexpr convertToFluka(Code const c8id) {
29
if
(
is_nucleus
(c8id)) {
30
throw
std::runtime_error{
"nucleus conversion to FLUKA not implemented"
};
31
}
32
33
FLUKACode
const
flukaID = corsika2fluka[
static_cast<
corsika::CodeIntType
>
(c8id)];
34
if
(flukaID == FLUKACode::Unknown) {
35
throw
std::runtime_error{
36
fmt::format(
"no correspondig FLUKA id for {}"
,
get_name
(c8id)).c_str()};
37
}
38
39
return
flukaID;
40
}
41
42
int
constexpr convertToFlukaRaw(Code
const
code) {
43
return
static_cast<
FLUKACodeIntType
>
(convertToFluka(code));
44
}
45
46
bool
const
canInteract(Code
const
code) {
47
if
(
is_nucleus
(code))
return
false
;
// nuclei support not yet implemented
48
return
flukaCanInteract[
static_cast<
CodeIntType
>
(code)];
49
}
50
}
// namespace corsika::fluka
corsika::get_name
std::string_view constexpr get_name(Code const)
name of the particle as string
corsika::fluka
Definition:
InteractionModel.hpp:23
corsika::is_nucleus
bool constexpr is_nucleus(Code const)
Checks if Code corresponds to a nucleus.
ParticleProperties.hpp
Interface to particle properties.
corsika
modules
fluka
ParticleConversion.hpp
Generated by
1.8.13