SND@LHC Software
Loading...
Searching...
No Matches
pythia8_conf Namespace Reference

Functions

 configurerpvsusy (P8gen, mass, couplings, sfermionmass, benchmark, inclusive, deepCopy=False, debug=True)
 
 configure (P8gen, mass, production_couplings, decay_couplings, process_selection, deepCopy=False, debug=True)
 
 add_hnl (P8gen, mass, decay_couplings)
 
 setup_pythia_inclusive (P8gen)
 

Function Documentation

◆ add_hnl()

pythia8_conf.add_hnl (   P8gen,
  mass,
  decay_couplings 
)

Definition at line 272 of file pythia8_conf.py.

272def add_hnl(P8gen, mass, decay_couplings):
273 "Adds the HNL to Pythia and ROOT"
274 hnl_instance = hnl.HNL(mass, decay_couplings, debug=True)
275 ctau = hnl_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
276 print("HNL ctau {}".format(ctau))
277 P8gen.SetParameters("9900015:new = N2 N2 2 0 0 {:.12} 0.0 0.0 0.0 {:.12} 0 1 0 1 0".format(mass, ctau/u.mm))
278 P8gen.SetParameters("9900015:isResonance = false")
279 # Configuring decay modes...
280 readDecayTable.addHNLdecayChannels(P8gen, hnl_instance, conffile=os.path.expandvars('$FAIRSHIP/python/DecaySelection.conf'), verbose=False)
281 # Finish HNL setup...
282 P8gen.SetParameters("9900015:mayDecay = on")
283 P8gen.SetHNLId(9900015)
284 # also add to PDG
285 gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
286 addHNLtoROOT(pid=9900015,m=mass,g=gamma)
287
addHNLdecayChannels(P8Gen, hnl, conffile=os.path.expandvars(' $FAIRSHIP/python/DecaySelection.conf'), verbose=True)

◆ configure()

pythia8_conf.configure (   P8gen,
  mass,
  production_couplings,
  decay_couplings,
  process_selection,
  deepCopy = False,
  debug = True 
)
This function configures a HNLPythia8Generator instance for SHiP usage.

Definition at line 131 of file pythia8_conf.py.

132 deepCopy=False, debug=True):
133 """
134 This function configures a HNLPythia8Generator instance for SHiP usage.
135 """
136
137 if process_selection == True: # For backward compatibility
138 process_selection = 'inclusive'
139
140 # Wrap the Pythia8 object into a class logging all of its method calls
141 if debug:
142 pythia_log=open('pythia8_conf.txt','w')
143 P8gen = MethodLogger(P8gen, sink=pythia_log)
144
145 fairship_root = os.environ['FAIRSHIP']
146 histograms = make_interpolators(fairship_root + '/shipgen/branchingratios.dat')
147 P8gen.UseRandom3() # TRandom1 or TRandom3 ?
148 P8gen.SetMom(400) # beam momentum in GeV
149 if deepCopy: P8gen.UseDeepCopy()
150 pdg = ROOT.TDatabasePDG.Instance()
151 P8gen.SetParameters("Next:numberCount = 0")
152 # let strange particle decay in Geant4
153 make_particles_stable(P8gen, above_lifetime=1)
154
155 # Load particle & decay data
156 # ==========================
157
158 datafile = fairship_root + '/python/hnl_production.yaml'
159 with open(datafile, 'rU') as f:
160 data = yaml.load(f, Loader=yaml.FullLoader)
161 all_channels = data['channels']
162
163 # Inclusive
164 # =========
165
166 if process_selection=='inclusive':
167 setup_pythia_inclusive(P8gen)
168
169 # Charm decays only (with secondary production from tau)
170 # ======================================================
171
172 if process_selection=='c':
173
174 selection = data['selections']['c']
175 for cmd in selection['parameters']:
176 P8gen.SetParameters(cmd)
177 add_hnl(P8gen, mass, decay_couplings)
178
179 # Add new charmed particles
180 # -------------------------
181
182 # Select all charmed particles (+ tau lepton)
183 c_particles = selection['particles']
184 tau_id = 15 # tau- Monte-Carlo ID
185 add_particles(P8gen, c_particles + [tau_id], data)
186
187 # Add HNL production channels from charmed particles
188 # --------------------------------------------------
189
190 # Find charm and tau decays to HNLs
191 c_channels = [ch for ch in all_channels if ch['id'] in c_particles]
192 tau_channels = [ch for ch in all_channels if ch['id'] == tau_id]
193 # Standard model process: tau+ production from D_s+ decay
194 ds_id = 431 # D_s+ Monte-Carlo ID
195 ds_tau_br = 0.0548 # SM branching ratio Br(D_s+ -> tau+ nu_tau) (source: PDG 2018)
196
197 # Compute the branching ratio scaling factor, taking into account
198 # secondary production from tau
199 # Decay chains are encoded as follows:
200 # [(top level id A, [br A -> B, br B -> C, ...]), ...]
201
202 # Most charm particles directly decay to HNLs
203 primary_decays = [(ch['id'], [get_br(histograms, ch, mass, production_couplings)])
204 for ch in c_channels]
205 # The D_s+ can indirectly produce a HNL by first producing a tau+
206 secondary_decays = [(ds_id, [ds_tau_br, get_br(histograms, ch, mass, production_couplings)])
207 for ch in tau_channels]
208 all_decays = primary_decays + secondary_decays
209
210 # Compute maximum total branching ratio (to rescale all BRs)
211 max_total_br = compute_max_total_br(all_decays)
212 exit_if_zero_br(max_total_br, process_selection, mass)
213 print_scale_factor(1/max_total_br)
214
215 # Add charm decays
216 for ch in c_channels:
217 add_channel(P8gen, ch, histograms, mass, production_couplings, 1/max_total_br)
218 # Add tau production from D_s+
219 # We can freely rescale Br(Ds -> tau) and Br(tau -> N X...) as long as
220 # Br(Ds -> tau -> N X...) remains the same.
221 # Here, we set Br(tau -> N) to unity to make event generation more efficient.
222 # The implicit assumption here is that we will disregard the tau during the analysis.
223 total_tau_br = sum(branching_ratios[1] for (_, branching_ratios) in secondary_decays)
224 assert(ds_tau_br*total_tau_br <= max_total_br + 1e-12)
225 P8gen.SetParameters("431:addChannel 1 {:.12} 0 -15 16"\
226 .format(ds_tau_br*total_tau_br/max_total_br))
227 # Add secondary HNL production from tau
228 for ch in tau_channels:
229 # Rescale branching ratios only if some are non-zero. Otherwise leave them at zero.
230 add_tau_channel(P8gen, ch, histograms, mass, production_couplings, 1/(total_tau_br or 1))
231
232 # Add dummy channels in place of SM processes
233 fill_missing_channels(P8gen, max_total_br, all_decays)
234
235 # List channels to confirm that Pythia has been properly set up
236 P8gen.List(9900015)
237
238 # B/Bc decays only
239 # ================
240
241 if process_selection in ['b', 'bc']:
242
243 selection = data['selections'][process_selection]
244 for cmd in selection['parameters']:
245 P8gen.SetParameters(cmd)
246 add_hnl(P8gen, mass, decay_couplings)
247
248 # Add particles
249 particles = selection['particles']
250 add_particles(P8gen, particles, data)
251
252 # Find all decay channels
253 channels = [ch for ch in all_channels if ch['id'] in particles]
254 decays = [(ch['id'], [get_br(histograms, ch, mass, production_couplings)]) for ch in channels]
255
256 # Compute scaling factor
257 max_total_br = compute_max_total_br(decays)
258 exit_if_zero_br(max_total_br, process_selection, mass)
259 print_scale_factor(1/max_total_br)
260
261 # Add beauty decays
262 for ch in channels:
263 add_channel(P8gen, ch, histograms, mass, production_couplings, 1/max_total_br)
264
265 # Add dummy channels in place of SM processes
266 fill_missing_channels(P8gen, max_total_br, decays)
267
268 P8gen.List(9900015)
269
270 if debug: pythia_log.close()
271

◆ configurerpvsusy()

pythia8_conf.configurerpvsusy (   P8gen,
  mass,
  couplings,
  sfermionmass,
  benchmark,
  inclusive,
  deepCopy = False,
  debug = True 
)

Definition at line 13 of file pythia8_conf.py.

13def configurerpvsusy(P8gen, mass, couplings, sfermionmass, benchmark, inclusive, deepCopy=False, debug=True):
14 # configure pythia8 for Ship usage
15 if debug:
16 pythia_log=open('pythia8_conf.txt','w')
17 P8gen = MethodLogger(P8gen, sink=pythia_log)
18 h = make_interpolators(
19 os.path.expandvars("$FAIRSHIP/shipgen/branchingratiosrpvsusybench{}.dat".format(benchmark)))
20 P8gen.UseRandom3()
21 P8gen.SetMom(400) # beam momentum in GeV
22 if deepCopy: P8gen.UseDeepCopy()
23 pdg = ROOT.TDatabasePDG.Instance()
24 # let strange particle decay in Geant4
25 make_particles_stable(P8gen, above_lifetime=1)
26
27 if inclusive=="True":
28 setup_pythia_inclusive(P8gen)
29
30 # generate RPV neutralino from inclusive charm hadrons
31 if inclusive=="c":
32 P8gen.SetParameters("HardQCD::hardccbar = on")
33 # add RPVSUSY
34 rpvsusy_instance = rpvsusy.RPVSUSY(mass, couplings, sfermionmass, benchmark, debug=True)
35 ctau = rpvsusy_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
36 print("RPVSUSY ctau ",ctau)
37 P8gen.SetParameters("9900015:new = N2 N2 2 0 0 {:.12} 0.0 0.0 0.0 {:.12} 0 1 0 1 0".format(mass, ctau/u.mm))
38 P8gen.SetParameters("9900015:isResonance = false")
39 P8gen.SetParameters("Next:numberCount = 0")
40 # Configuring decay modes...
41 rpvsusy_instance.AddChannelsToPythia(P8gen)
42
43 # Finish HNL setup...
44 P8gen.SetParameters("9900015:mayDecay = on")
45 P8gen.SetHNLId(9900015)
46 # also add to PDG
47 gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
48 addHNLtoROOT(pid=9900015,m=mass,g=gamma)
49 # 12 14 16 neutrinos replace with N2
50 charmhistograms = ['d_mu','ds_mu']
51 # no tau decay here to consider
52 totaltauBR = 0.0
53 maxsumBR = getmaxsumbrrpvsusy(h,charmhistograms,mass,couplings)
54 exit_if_zero_br(maxsumBR, inclusive, mass, particle='RPV neutralino')
55 totalBR = gettotalbrrpvsusy(h,charmhistograms,mass,couplings)
56
57
58 #overwrite D_s+ decays
59 P8gen.SetParameters("431:new D_s+ D_s- 1 3 0 1.96849"\
60 " 0.00000 0.00000 0.00000 1.49900e-01 0 1 0 1 0")
61 sumBR=0.
62 if getbr_rpvsusy(h,'ds_mu',mass,couplings[1])>0.:
63 P8gen.SetParameters("431:addChannel 1 {:.12} 0 -13 9900015"\
64 .format(getbr_rpvsusy(h,'ds_mu',mass,couplings[1])/maxsumBR))
65 sumBR+=float(getbr_rpvsusy(h,'ds_mu',mass,couplings[1])/maxsumBR)
66 if sumBR<1. and sumBR>0.:
67 P8gen.SetParameters("431:addChannel 1 {:.12} 0 22 -11".format(1.-sumBR))
68
69 #overwrite D+ decays
70 P8gen.SetParameters("411:new D+ D- 1 3 0 1.86962"\
71 " 0.00000 0.00000 0.00000 3.11800e-01 0 1 0 1 0")
72 sumBR=0.
73 if getbr_rpvsusy(h,'d_mu',mass,couplings[1])>0.:
74 P8gen.SetParameters("411:addChannel 1 {:.12} 0 -13 9900015"\
75 .format(getbr_rpvsusy(h,'d_mu',mass,couplings[1])/maxsumBR))
76 sumBR+=float(getbr_rpvsusy(h,'d_mu',mass,couplings[1])/maxsumBR)
77 if sumBR<1. and sumBR>0.:
78 P8gen.SetParameters("411:addChannel 1 {:.12} 0 22 -11".format(1.-sumBR))
79
80 P8gen.List(9900015)
81
82 if inclusive=="b":
83 P8gen.SetParameters("HardQCD::hardbbbar = on")
84 # add RPVSUSY
85 rpvsusy_instance = rpvsusy.RPVSUSY(mass, couplings, sfermionmass, benchmark, debug=True)
86 ctau = rpvsusy_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
87 P8gen.SetParameters("9900015:new = N2 N2 2 0 0 {:.12} 0.0 0.0 0.0 {:.12} 0 1 0 1 0".format(mass, ctau/u.mm))
88 P8gen.SetParameters("9900015:isResonance = false")
89 # Configuring decay modes...
90 rpvsusy_instance.AddChannelsToPythia(P8gen)
91 # Finish HNL setup...
92 P8gen.SetParameters("9900015:mayDecay = on")
93 P8gen.SetHNLId(9900015)
94 # also add to PDG
95 gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
96 addHNLtoROOT(pid=9900015,m=mass,g=gamma)
97 # 12 14 16 neutrinos replace with N2
98 beautyhistograms = ['b_mu','b_tau','b0_nu_mu','b0_nu_tau']
99 maxsumBR=getmaxsumbrrpvsusy(h,beautyhistograms,mass,couplings)
100 exit_if_zero_br(maxsumBR, inclusive, mass, particle='RPV neutralino')
101 totalBR=gettotalbrrpvsusy(h,beautyhistograms,mass,couplings)
102
103 #overwrite B+ decays
104 P8gen.SetParameters("521:new B+ B- 1 3 0 5.27925"\
105 " 0.00000 0.00000 0.00000 4.91100e-01 0 1 0 1 0")
106 sumBR=0.
107 if getbr_rpvsusy(h,'b_tau',mass,couplings[1])>0.:
108 P8gen.SetParameters("521:addChannel 1 {:.12} 0 9900015 -15"\
109 .format(getbr_rpvsusy(h,'b_tau',mass,couplings[1])/maxsumBR))
110 sumBR+=float(getbr_rpvsusy(h,'b_tau',mass,couplings[1])/maxsumBR)
111 if sumBR<1. and sumBR>0.:
112 P8gen.SetParameters("521:addChannel 1 {:.12} 0 22 22"\
113 .format(1.-sumBR))
114
115 #overwrite B0 decays
116 P8gen.SetParameters("511:new B0 Bbar0 1 0 0 5.27958"\
117 " 0.00000 0.00000 0.00000 4.58700e-01 0 1 0 1 0")
118 sumBR=0.
119 if getbr_rpvsusy(h,'b0_nu_tau',mass,couplings[1])>0.:
120 P8gen.SetParameters("511:addChannel 1 {:.12} 22 9900015 16"\
121 .format(getbr_rpvsusy(h,'b0_nu_tau',mass,couplings[1])/maxsumBR))
122 if sumBR<1. and sumBR>0.:
123 P8gen.SetParameters("511:addChannel 1 {:.12} 0 22 22"\
124 .format(1.-sumBR))
125
126 P8gen.List(9900015)
127
128 if debug: pythia_log.close()
129
130

◆ setup_pythia_inclusive()

pythia8_conf.setup_pythia_inclusive (   P8gen)

Definition at line 288 of file pythia8_conf.py.

288def setup_pythia_inclusive(P8gen):
289 P8gen.SetParameters("SoftQCD:inelastic = on")
290 P8gen.SetParameters("PhotonCollision:gmgm2mumu = on")
291 P8gen.SetParameters("PromptPhoton:all = on")
292 P8gen.SetParameters("WeakBosonExchange:all = on")