SND@LHC Software
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

 pdg = ROOT.TDatabasePDG.Instance()
 
 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 79 of file readDecayTable.py.

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

◆ 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 48 of file readDecayTable.py.

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

◆ load()

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

Definition at line 30 of file readDecayTable.py.

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

◆ PDGcode()

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

Definition at line 21 of file readDecayTable.py.

21def PDGcode(particle):
22 """
23 Read particle ID from PDG database
24 """
25 particle = PDGname(particle)
26 tPart = pdg.GetParticle(particle)
27 return int(tPart.PdgCode())
28
29

Variable Documentation

◆ configuredDecays

readDecayTable.configuredDecays = load()

Definition at line 138 of file readDecayTable.py.

◆ pdg

readDecayTable.pdg = ROOT.TDatabasePDG.Instance()

Definition at line 19 of file readDecayTable.py.