13def configurerpvsusy(P8gen, mass, couplings, sfermionmass, benchmark, inclusive, deepCopy=False, debug=True):
16 pythia_log=open(
'pythia8_conf.txt',
'w')
19 os.path.expandvars(
"$FAIRSHIP/shipgen/branchingratiosrpvsusybench{}.dat".format(benchmark)))
22 if deepCopy: P8gen.UseDeepCopy()
23 pdg = ROOT.TDatabasePDG.Instance()
32 P8gen.SetParameters(
"HardQCD::hardccbar = on")
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")
41 rpvsusy_instance.AddChannelsToPythia(P8gen)
44 P8gen.SetParameters(
"9900015:mayDecay = on")
45 P8gen.SetHNLId(9900015)
47 gamma = u.hbarc / float(ctau)
48 addHNLtoROOT(pid=9900015,m=mass,g=gamma)
50 charmhistograms = [
'd_mu',
'ds_mu']
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")
63 P8gen.SetParameters(
"431:addChannel 1 {:.12} 0 -13 9900015"\
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))
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")
74 P8gen.SetParameters(
"411:addChannel 1 {:.12} 0 -13 9900015"\
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))
83 P8gen.SetParameters(
"HardQCD::hardbbbar = on")
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")
90 rpvsusy_instance.AddChannelsToPythia(P8gen)
92 P8gen.SetParameters(
"9900015:mayDecay = on")
93 P8gen.SetHNLId(9900015)
95 gamma = u.hbarc / float(ctau)
96 addHNLtoROOT(pid=9900015,m=mass,g=gamma)
98 beautyhistograms = [
'b_mu',
'b_tau',
'b0_nu_mu',
'b0_nu_tau']
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")
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"\
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")
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"\
128 if debug: pythia_log.close()
131def configure(P8gen, mass, production_couplings, decay_couplings, process_selection,
132 deepCopy=False, debug=True):
134 This function configures a HNLPythia8Generator instance for SHiP usage.
137 if process_selection ==
True:
138 process_selection =
'inclusive'
142 pythia_log=open(
'pythia8_conf.txt',
'w')
145 fairship_root = os.environ[
'FAIRSHIP']
149 if deepCopy: P8gen.UseDeepCopy()
150 pdg = ROOT.TDatabasePDG.Instance()
151 P8gen.SetParameters(
"Next:numberCount = 0")
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']
166 if process_selection==
'inclusive':
172 if process_selection==
'c':
174 selection = data[
'selections'][
'c']
175 for cmd
in selection[
'parameters']:
176 P8gen.SetParameters(cmd)
177 add_hnl(P8gen, mass, decay_couplings)
183 c_particles = selection[
'particles']
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]
203 primary_decays = [(ch[
'id'], [
get_br(histograms, ch, mass, production_couplings)])
204 for ch
in c_channels]
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
216 for ch
in c_channels:
217 add_channel(P8gen, ch, histograms, mass, production_couplings, 1/max_total_br)
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))
228 for ch
in tau_channels:
230 add_tau_channel(P8gen, ch, histograms, mass, production_couplings, 1/(total_tau_br
or 1))
241 if process_selection
in [
'b',
'bc']:
243 selection = data[
'selections'][process_selection]
244 for cmd
in selection[
'parameters']:
245 P8gen.SetParameters(cmd)
246 add_hnl(P8gen, mass, decay_couplings)
249 particles = selection[
'particles']
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]
263 add_channel(P8gen, ch, histograms, mass, production_couplings, 1/max_total_br)
270 if debug: pythia_log.close()
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")
282 P8gen.SetParameters(
"9900015:mayDecay = on")
283 P8gen.SetHNLId(9900015)
285 gamma = u.hbarc / float(ctau)
286 addHNLtoROOT(pid=9900015,m=mass,g=gamma)