diff --git a/Processes/Sibyll/ParticleConversion.h b/Processes/Sibyll/ParticleConversion.h index 06f07d2d7060765612246435d27692a8293bc02a..3cc31817212d4bb12606dd99ae88f5a31264e888 100644 --- a/Processes/Sibyll/ParticleConversion.h +++ b/Processes/Sibyll/ParticleConversion.h @@ -22,11 +22,23 @@ namespace corsika::process::sibyll { enum class SibyllCode : int8_t; using SibyllCodeIntType = std::underlying_type<SibyllCode>::type; + /** + These are the possible projectile for which Sibyll knows the cross section + */ + enum class SibyllXSClass : int8_t { + CannotInteract = 0, + Baryon = 1, + Pion = 2, + Kaon = 3, + }; + using SibyllXSClassIntType = std::underlying_type<SibyllXSClass>::type; + + #include <corsika/process/sibyll/Generated.inc> SibyllCode constexpr ConvertToSibyll(corsika::particles::Code pCode) { - return static_cast<SibyllCode>( - corsika2sibyll[static_cast<corsika::particles::CodeIntType>(pCode)]); + return + corsika2sibyll[static_cast<corsika::particles::CodeIntType>(pCode)]; } corsika::particles::Code constexpr ConvertFromSibyll(SibyllCode pCode) { @@ -45,7 +57,7 @@ namespace corsika::process::sibyll { } int constexpr GetSibyllXSCode(corsika::particles::Code pCode) { - return corsika2sibyllXStype[static_cast<corsika::particles::CodeIntType>(pCode)]; + return static_cast<SibyllXSClassIntType>(corsika2sibyllXStype[static_cast<corsika::particles::CodeIntType>(pCode)]); } bool constexpr CanInteract(corsika::particles::Code pCode) { diff --git a/Processes/Sibyll/code_generator.py b/Processes/Sibyll/code_generator.py index d2ca87c6f221bf169ad080a5dd06295016e025e4..7044c95e01df1c5507f8b1dd45b89d4634189ffa 100755 --- a/Processes/Sibyll/code_generator.py +++ b/Processes/Sibyll/code_generator.py @@ -13,65 +13,83 @@ import pickle, sys, itertools -# loads the pickled particle_db (which is an OrderedDict) def load_particledb(filename): + ''' + loads the pickled particle_db (which is an OrderedDict) + ''' with open(filename, "rb") as f: particle_db = pickle.load(f) return particle_db -# def read_sibyll_codes(filename, particle_db): + ''' + reads to sibyll codes data file + + For particls known to sibyll, add 'sibyll_code' and 'sibyll_xsType' to particle_db + ''' with open(filename) as f: for line in f: line = line.strip() - if line[0] == '#': + if len(line)==0 or line[0] == '#': continue identifier, sib_code, canInteractFlag, xsType = line.split() try: particle_db[identifier]["sibyll_code"] = int(sib_code) - particle_db[identifier]["sibyll_xsType"] = int(xsType) + particle_db[identifier]["sibyll_xsType"] = xsType except KeyError as e: raise Exception("Identifier '{:s}' not found in particle_db".format(identifier)) -# generates the enum to access sibyll particles by readable names def generate_sibyll_enum(particle_db): + ''' + generates the enum to access sibyll particles by readable names + ''' output = "enum class SibyllCode : int8_t {\n" for identifier, pData in particle_db.items(): - if pData.get('sibyll_code') != None: + if 'sibyll_code' in pData: output += " {:s} = {:d},\n".format(identifier, pData['sibyll_code']) output += "};\n" return output -# generates the look-up table to convert corsika codes to sibyll codes def generate_corsika2sibyll(particle_db): - string = "std::array<SibyllCodeIntType, {:d}> constexpr corsika2sibyll = {{\n".format(len(particle_db)) + ''' + generates the look-up table to convert corsika codes to sibyll codes + ''' + string = "std::array<SibyllCode, {:d}> constexpr corsika2sibyll = {{\n".format(len(particle_db)) for identifier, pData in particle_db.items(): - sibCode = pData.get("sibyll_code", 0) - string += " {:d}, // {:s}\n".format(sibCode, identifier if sibCode else identifier + " (not implemented in SIBYLL)") + if 'sibyll_code' in pData: + string += " SibyllCode::{:s}, \n".format(identifier) + else: + string += " SibyllCode::Unknown, // {:s}\n".format(identifier + ' not implemented in SIBYLL') string += "};\n" return string -# generates the look-up table to convert corsika codes to sibyll codes def generate_corsika2sibyll_xsType(particle_db): - string = "std::array<int, {:d}> constexpr corsika2sibyllXStype = {{\n".format(len(particle_db)) + ''' + generates the look-up table to convert corsika codes to sibyll codes + ''' + string = "std::array<SibyllXSClass, {:d}> constexpr corsika2sibyllXStype = {{\n".format(len(particle_db)) for identifier, pData in particle_db.items(): - sibCodeXS = pData.get("sibyll_xsType", 0) - string += " {:d}, // {:s}\n".format(sibCodeXS, identifier if sibCodeXS else identifier + " (not implemented in SIBYLL)") + if 'sibyll_xsType' in pData: + string += " SibyllXSClass::{:s}, // {:s}\n".format(pData['sibyll_xsType'], identifier) + else: + string += " SibyllXSClass::CannotInteract, // {:s}\n".format(identifier + ' not implemented in SIBYLL') string += "};\n" return string -# generates the look-up table to convert sibyll codes to corsika codes def generate_sibyll2corsika(particle_db) : + ''' + generates the look-up table to convert sibyll codes to corsika codes + ''' string = "" minID = 0 diff --git a/Processes/Sibyll/sibyll_codes.dat b/Processes/Sibyll/sibyll_codes.dat index 5dc248b4d73db6cedb5324f4dcf83971d47c308d..8392957f20f1ca8544713ec49b32801a196df6f1 100644 --- a/Processes/Sibyll/sibyll_codes.dat +++ b/Processes/Sibyll/sibyll_codes.dat @@ -1,126 +1,132 @@ # input file for particle conversion to/from SIBYLL # the format of this file is: "corsika-identifier" "sibyll-id" "can-interact-in-sibyll" "cross-section-type" -Electron 3 0 0 -Positron 2 0 0 -NuE 15 0 0 -NuEBar 16 0 0 -MuMinus 5 0 0 -MuPlus 4 0 0 -NuMu 17 0 0 -NuMuBar 18 0 0 -TauMinus 91 0 0 -TauPlus 90 0 0 -NuTau 92 0 0 -NuTauBar 93 0 0 -Gamma 1 0 0 -Pi0 6 1 2 -# rho0 could interact but sibyll has no cross section/interaction length. was used for gamma had int -Rho0 27 0 0 -K0Long 11 1 3 -K0 21 0 3 -K0Bar 22 0 3 -PiPlus 7 1 2 -PiMinus 8 1 2 -RhoPlus 25 0 0 -RhoMinus 26 0 0 -Eta 23 0 0 -EtaPrime 24 0 0 -Pi1300Plus 62 0 0 -Pi1300Minus 63 0 0 -Pi1300_0 61 0 0 -Omega 32 0 0 -K0Short 12 1 3 -KStar0 30 0 0 -KStar0Bar 31 0 0 -KPlus 9 1 3 -KMinus 10 1 3 -KStarPlus 28 0 0 -KStarMinus 29 0 0 -KStar0_1430_0 66 0 0 -KStar0_1430_0Bar 67 0 0 -KStar0_1430_Plus 64 0 0 -KStar0_1430_MinusBar 65 0 0 -DPlus 59 1 3 -DMinus 60 1 3 -DStarPlus 78 0 0 -DStarMinus 79 0 0 -D0 71 1 3 -D0Bar 72 1 3 -DStar0 80 0 0 -DStar0Bar 81 0 0 -DsPlus 74 1 3 -DsMinus 75 1 3 -DStarSPlus 76 0 0 -DStarSMinus 77 0 0 -EtaC 73 0 0 -Neutron 14 1 1 -AntiNeutron -14 1 1 -Delta0 42 0 0 -Delta0Bar -42 0 0 -DeltaMinus 43 0 0 -DeltaPlusBar -43 0 0 -Proton 13 1 1 -AntiProton -13 1 1 -N1440Plus 51 0 0 -N1440MinusBar -51 0 0 -N1440_0 52 0 0 -N1440_0Bar -52 0 0 -N1710Plus 53 0 0 -N1710MinusBar -53 0 0 -N1710_0 54 0 0 -N1710_0Bar -54 0 0 -DeltaPlus 41 0 0 -DeltaMinusBar -41 0 0 -DeltaPlusPlus 40 0 0 -DeltaMinusMinusBar -40 0 0 -SigmaMinus 36 1 1 -SigmaPlusBar -36 1 1 -SigmaStarMinus 46 0 0 -SigmaStarPlusBar -46 0 0 -SigmaStarPlus 44 0 0 -SigmaStarMinusBar -44 0 0 -SigmaStar0 45 0 0 -SigmaStar0Bar -45 0 0 -Lambda0 39 1 1 -Lambda0Bar -39 1 1 -Sigma0 35 1 1 -Sigma0Bar -35 1 1 -SigmaPlus 34 1 1 -SigmaMinusBar -34 1 1 -XiMinus 38 1 1 -XiPlusBar -38 1 1 -Xi0 37 1 1 -Xi0Bar -37 1 1 -XiStarMinus 48 0 0 -XiStarPlusBar -48 0 0 -XiStar0 47 0 0 -XiStar0Bar -47 0 0 -OmegaMinus 49 0 0 -OmegaPlusBar -49 0 0 -SigmaC0 86 0 0 -SigmaC0Bar -86 0 0 -SigmaStarC0 96 0 0 -SigmaStarC0Bar -96 0 0 -LambdaCPlus 89 1 1 -LambdaCMinusBar -89 1 1 -XiC0 88 1 1 -XiC0Bar -88 1 1 -SigmaCPlus 85 0 0 -SigmaCMinusBar -85 0 0 -SigmaStarCPlus 95 0 0 -SigmaStarCMinusBar -95 0 0 -SigmaCPlusPlus 84 0 0 -SigmaCMinusMinusBar -84 0 0 -SigmaStarCPlusPlus 94 0 0 -SigmaStarCMinusMinusBar -94 0 0 -XiCPlus 87 1 1 -XiCMinusBar -87 1 1 -XiStarCPlus 97 0 0 -XiStarCMinusBar -97 0 0 -XiStarC0 98 0 0 -XiStarC0Bar -98 0 0 -OmegaC0 99 0 0 -OmegaC0Bar -99 0 0 -Jpsi 83 0 0 -Phi 33 0 0 -Unknown 0 0 0 + +# The unknown particle is to handle all particles that are not known to SIBYLL. +# It is important that sibyll-id does not overlap with any existing sibyll particle! +# Be careful +Unknown 0 0 CannotInteract + +# Here is the list of particles known to sibyll +Electron 3 0 CannotInteract +Positron 2 0 CannotInteract +NuE 15 0 CannotInteract +NuEBar 16 0 CannotInteract +MuMinus 5 0 CannotInteract +MuPlus 4 0 CannotInteract +NuMu 17 0 CannotInteract +NuMuBar 18 0 CannotInteract +TauMinus 91 0 CannotInteract +TauPlus 90 0 CannotInteract +NuTau 92 0 CannotInteract +NuTauBar 93 0 CannotInteract +Gamma 1 0 CannotInteract +Pi0 6 1 Pion +# rho0 could interact but sibyll has no cross section/interaction length. was used for gamma had int +Rho0 27 0 CannotInteract +K0Long 11 1 Kaon +K0 21 0 Kaon +K0Bar 22 0 Kaon +PiPlus 7 1 Pion +PiMinus 8 1 Pion +RhoPlus 25 0 CannotInteract +RhoMinus 26 0 CannotInteract +Eta 23 0 CannotInteract +EtaPrime 24 0 CannotInteract +Pi1300Plus 62 0 CannotInteract +Pi1300Minus 63 0 CannotInteract +Pi1300_0 61 0 CannotInteract +Omega 32 0 CannotInteract +K0Short 12 1 Kaon +KStar0 30 0 CannotInteract +KStar0Bar 31 0 CannotInteract +KPlus 9 1 Kaon +KMinus 10 1 Kaon +KStarPlus 28 0 CannotInteract +KStarMinus 29 0 CannotInteract +KStar0_1430_0 66 0 CannotInteract +KStar0_1430_0Bar 67 0 CannotInteract +KStar0_1430_Plus 64 0 CannotInteract +KStar0_1430_MinusBar 65 0 CannotInteract +DPlus 59 1 Kaon +DMinus 60 1 Kaon +DStarPlus 78 0 CannotInteract +DStarMinus 79 0 CannotInteract +D0 71 1 Kaon +D0Bar 72 1 Kaon +DStar0 80 0 CannotInteract +DStar0Bar 81 0 CannotInteract +DsPlus 74 1 Kaon +DsMinus 75 1 Kaon +DStarSPlus 76 0 CannotInteract +DStarSMinus 77 0 CannotInteract +EtaC 73 0 CannotInteract +Neutron 14 1 Baryon +AntiNeutron -14 1 Baryon +Delta0 42 0 CannotInteract +Delta0Bar -42 0 CannotInteract +DeltaMinus 43 0 CannotInteract +DeltaPlusBar -43 0 CannotInteract +Proton 13 1 Baryon +AntiProton -13 1 Baryon +N1440Plus 51 0 CannotInteract +N1440MinusBar -51 0 CannotInteract +N1440_0 52 0 CannotInteract +N1440_0Bar -52 0 CannotInteract +N1710Plus 53 0 CannotInteract +N1710MinusBar -53 0 CannotInteract +N1710_0 54 0 CannotInteract +N1710_0Bar -54 0 CannotInteract +DeltaPlus 41 0 CannotInteract +DeltaMinusBar -41 0 CannotInteract +DeltaPlusPlus 40 0 CannotInteract +DeltaMinusMinusBar -40 0 CannotInteract +SigmaMinus 36 1 Baryon +SigmaPlusBar -36 1 Baryon +SigmaStarMinus 46 0 CannotInteract +SigmaStarPlusBar -46 0 CannotInteract +SigmaStarPlus 44 0 CannotInteract +SigmaStarMinusBar -44 0 CannotInteract +SigmaStar0 45 0 CannotInteract +SigmaStar0Bar -45 0 CannotInteract +Lambda0 39 1 Baryon +Lambda0Bar -39 1 Baryon +Sigma0 35 1 Baryon +Sigma0Bar -35 1 Baryon +SigmaPlus 34 1 Baryon +SigmaMinusBar -34 1 Baryon +XiMinus 38 1 Baryon +XiPlusBar -38 1 Baryon +Xi0 37 1 Baryon +Xi0Bar -37 1 Baryon +XiStarMinus 48 0 CannotInteract +XiStarPlusBar -48 0 CannotInteract +XiStar0 47 0 CannotInteract +XiStar0Bar -47 0 CannotInteract +OmegaMinus 49 0 CannotInteract +OmegaPlusBar -49 0 CannotInteract +SigmaC0 86 0 CannotInteract +SigmaC0Bar -86 0 CannotInteract +SigmaStarC0 96 0 CannotInteract +SigmaStarC0Bar -96 0 CannotInteract +LambdaCPlus 89 1 Baryon +LambdaCMinusBar -89 1 Baryon +XiC0 88 1 Baryon +XiC0Bar -88 1 Baryon +SigmaCPlus 85 0 CannotInteract +SigmaCMinusBar -85 0 CannotInteract +SigmaStarCPlus 95 0 CannotInteract +SigmaStarCMinusBar -95 0 CannotInteract +SigmaCPlusPlus 84 0 CannotInteract +SigmaCMinusMinusBar -84 0 CannotInteract +SigmaStarCPlusPlus 94 0 CannotInteract +SigmaStarCMinusMinusBar -94 0 CannotInteract +XiCPlus 87 1 Baryon +XiCMinusBar -87 1 Baryon +XiStarCPlus 97 0 CannotInteract +XiStarCMinusBar -97 0 CannotInteract +XiStarC0 98 0 CannotInteract +XiStarC0Bar -98 0 CannotInteract +OmegaC0 99 0 CannotInteract +OmegaC0Bar -99 0 CannotInteract +Jpsi 83 0 CannotInteract +Phi 33 0 CannotInteract