FairShip
Loading...
Searching...
No Matches
readDecayTable Namespace Reference

Functions

 PDGcode (particle)
 load (conffile=os.path.expandvars("$FAIRSHIP/python/DecaySelection.conf"), verbose=True)
 addHNLdecayChannels (P8Gen, hnl, conffile=os.path.expandvars("$FAIRSHIP/python/DecaySelection.conf"), verbose=True)
 addDarkPhotondecayChannels (P8gen, mDP, DP, conffile=os.path.expandvars("$FAIRSHIP/python/darkphotonDecaySelection.conf"), verbose=True)

Variables

 configuredDecays = load()

Detailed Description

# ==================================================================
#   Python module
#
#   This module provides methods to read a configuration file
#   storing on/off (yes/no) flags for the HNL decay channels
#   and to pass the configured decay table to a Pythia8 generator.
#
#   Created: 30/12/2014 Elena Graverini (elena.graverini@cern.ch)
#
# ==================================================================

Function Documentation

◆ addDarkPhotondecayChannels()

readDecayTable.addDarkPhotondecayChannels ( P8gen,
mDP,
DP,
conffile = os.path.expandvars("$FAIRSHIP/python/darkphotonDecaySelection.conf"),
verbose = True )
Configures the DP decay table in Pythia8

Inputs:
- P8gen: an instance of ROOT.HNLPythia8Generator()
- conffile: a file listing the channels one wishes to activate

Definition at line 84 of file readDecayTable.py.

86):
87 """
88 Configures the DP decay table in Pythia8
89
90 Inputs:
91 - P8gen: an instance of ROOT.HNLPythia8Generator()
92 - conffile: a file listing the channels one wishes to activate
93 """
94 isResonant = P8gen.GetDPId() == 4900023 # or P8gen.IsPbrem())
95 # First fetch the list of kinematically allowed decays
96 allowed = DP.allowedChannels()
97 # Then fetch the list of desired channels to activate
98 wanted = load(conffile=conffile, verbose=verbose)
99 # Add decay channels
100 for dec in allowed:
101 print("channel allowed:", dec)
102 if dec not in wanted:
103 raise ValueError(f"addDarkPhotondecayChannels: channel not configured (add it to the conf file): {dec}")
104 print("channel wanted:", dec)
105
106 if allowed[dec] == "yes" and wanted[dec] == "yes":
107 BR = DP.findBranchingRatio(dec)
108
109 meMode = 0
110 if isResonant:
111 meMode = 103
112 if "hadrons" in dec:
113 # P8gen.SetDecayToHadrons()
114 print("debug readdecay table hadrons BR ", BR)
115 # Taking decays from pythia8 Z->qqbar
116 dpid = P8gen.GetDPId()
117 if mDP < 3.0:
118 P8gen.SetParameters(f"{dpid}:addChannel = 1 {0.167 * BR:.12} {meMode} 1 -1")
119 P8gen.SetParameters(f"{dpid}:addChannel = 1 {0.666 * BR:.12} {meMode} 2 -2")
120 P8gen.SetParameters(f"{dpid}:addChannel = 1 {0.167 * BR:.12} {meMode} 3 -3")
121 if mDP >= 3.0:
122 P8gen.SetParameters(f"{dpid}:addChannel = 1 {0.1 * BR:.12} {meMode} 1 -1")
123 P8gen.SetParameters(f"{dpid}:addChannel = 1 {0.4 * BR:.12} {meMode} 2 -2")
124 P8gen.SetParameters(f"{dpid}:addChannel = 1 {0.1 * BR:.12} {meMode} 3 -3")
125 P8gen.SetParameters(f"{dpid}:addChannel = 1 {0.4 * BR:.12} {meMode} 4 -4")
126 else:
127 particles = list(dec.replace("->", " ").split())
128 children = particles[1:]
129 childrenCodes = [PDGcode(p) for p in children]
130 codes = " ".join(str(code) for code in childrenCodes)
131 P8gen.SetParameters(f"{P8gen.GetDPId()}:addChannel = 1 {BR:.12} {meMode} {codes}")
132 print("debug readdecay table ", particles, children, BR)
133
134

◆ addHNLdecayChannels()

readDecayTable.addHNLdecayChannels ( P8Gen,
hnl,
conffile = os.path.expandvars("$FAIRSHIP/python/DecaySelection.conf"),
verbose = True )
Configures the HNL decay table in Pythia8
Inputs:
- P8Gen: an instance of ROOT.HNLPythia8Generator()
- hnl: an instance of hnl.HNL()
- conffile: a file listing the channels one wishes to activate

Definition at line 53 of file readDecayTable.py.

53def addHNLdecayChannels(P8Gen, hnl, conffile=os.path.expandvars("$FAIRSHIP/python/DecaySelection.conf"), verbose=True):
54 """
55 Configures the HNL decay table in Pythia8
56 Inputs:
57 - P8Gen: an instance of ROOT.HNLPythia8Generator()
58 - hnl: an instance of hnl.HNL()
59 - conffile: a file listing the channels one wishes to activate
60 """
61 # First fetch the list of kinematically allowed decays
62 allowed = hnl.allowedChannels()
63 # Then fetch the list of desired channels to activate
64 wanted = load(conffile=conffile, verbose=verbose)
65 # Add decay channels
66 for dec in allowed:
67 if dec not in wanted:
68 raise ValueError(f"addHNLdecayChannels: channel not configured: {dec}")
69 if allowed[dec] == "yes" and wanted[dec] == "yes":
70 particles = list(dec.replace("->", " ").split())
71 children = particles[1:]
72 childrenCodes = [PDGcode(p) for p in children]
73 BR = hnl.findBranchingRatio(dec)
74 # Take care of Majorana modes
75 BR = BR / 2.0
76 codes = " ".join([str(code) for code in childrenCodes])
77 P8Gen.SetParameters(f"9900015:addChannel = 1 {BR:.12} 0 {codes}")
78 # Charge conjugate modes. Self-conjugate daughters (pi0, eta, rho0, ...) keep their code.
79 codes = " ".join([(str(-1 * code) if is_known_particle(-code) else str(code)) for code in childrenCodes])
80 P8Gen.SetParameters(f"9900015:addChannel = 1 {BR:.12} 0 {codes}")
81 # print "debug readdecay table",particles,children,BR
82
83

◆ load()

readDecayTable.load ( conffile = os.path.expandvars("$FAIRSHIP/python/DecaySelection.conf"),
verbose = True )

Definition at line 33 of file readDecayTable.py.

33def load(conffile=os.path.expandvars("$FAIRSHIP/python/DecaySelection.conf"), verbose=True):
34 with open(conffile) as f:
35 reader = csv.reader(f, delimiter=":")
36 configuredDecays = {}
37 for row in reader:
38 if not row:
39 continue # skip empty lines
40 if str(row[0]).strip().startswith("#"):
41 continue # skip comment / header lines
42 channel = str(row[0]).strip()
43 flag = str(row[-1]).partition("#")[0].strip() # skip line comments
44 configuredDecays[channel] = flag
45 if verbose:
46 print("Activated decay channels (plus charge conjugates): ")
47 for channel in configuredDecays:
48 if configuredDecays[channel] == "yes":
49 print("\t" + channel)
50 return configuredDecays
51
52

◆ PDGcode()

readDecayTable.PDGcode ( particle)
Read particle ID from PDG database

Definition at line 24 of file readDecayTable.py.

24def PDGcode(particle):
25 """
26 Read particle ID from PDG database
27 """
28 particle = PDGname(particle)
29 tPart = get_particle(particle)
30 return int(tPart.PdgCode())
31
32

Variable Documentation

◆ configuredDecays

readDecayTable.configuredDecays = load()

Definition at line 136 of file readDecayTable.py.