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

Functions

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

Variables

ROOT pdg = ROOT.TDatabasePDG.Instance()
 
def 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()

def 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 89 of file readDecayTable.py.

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

◆ addHNLdecayChannels()

def 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 55 of file readDecayTable.py.

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

◆ load()

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

Definition at line 35 of file readDecayTable.py.

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

◆ PDGcode()

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

Definition at line 26 of file readDecayTable.py.

26def PDGcode(particle):
27 """
28 Read particle ID from PDG database
29 """
30 particle = PDGname(particle)
31 tPart = pdg.GetParticle(particle)
32 return int(tPart.PdgCode())
33
34

Variable Documentation

◆ configuredDecays

def readDecayTable.configuredDecays = load()

Definition at line 142 of file readDecayTable.py.

◆ pdg

ROOT readDecayTable.pdg = ROOT.TDatabasePDG.Instance()

Definition at line 23 of file readDecayTable.py.