예제 #1
0
def add_hnl(P8gen, mass, decay_couplings):
    "Adds the HNL to Pythia and ROOT"
    hnl_instance = hnl.HNL(mass, decay_couplings, debug=True)
    ctau = hnl_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
    print("HNL ctau {}".format(ctau))
    P8gen.SetParameters("9900015:new = N2 N2 2 0 0 " + str(mass) +
                        " 0.0 0.0 0.0 " + str(ctau / u.mm) +
                        "  0   1   0   1   0")
    P8gen.SetParameters("9900015:isResonance = false")
    # Configuring decay modes...
    readDecayTable.addHNLdecayChannels(
        P8gen,
        hnl_instance,
        conffile=os.path.expandvars('$FAIRSHIP/python/DecaySelection.conf'),
        verbose=False)
    # Finish HNL setup...
    P8gen.SetParameters("9900015:mayDecay = on")
    P8gen.SetHNLId(9900015)
    # also add to PDG
    gamma = u.hbarc / float(
        ctau
    )  #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
    addHNLtoROOT(pid=9900015, m=mass, g=gamma)
예제 #2
0
def configure(P8gen, mass, couplings, inclusive, deepCopy=False):
    # configure pythia8 for Ship usage
    P8gen.UseRandom3() # TRandom1 or TRandom3 ?
    P8gen.SetMom(400)  # beam momentum in GeV 
    if deepCopy: P8gen.UseDeepCopy()
    pdg = ROOT.TDatabasePDG.Instance()
    # pythia stuff not known to ROOT
    pdg.AddParticle('system','system', 0., False, 0., 0., 'XXX', 90)
    pdg.AddParticle('p_diffr+','p_diffr+', 0., False, 0., 0., 'XXX', 9902210)
    # let strange particle decay in Geant4
    ## the following does not work because need to have N2 decaying
    #P8gen.SetParameters("ParticleDecays:limitTau0 = on")
    #P8gen.SetParameters("ParticleDecays:tau0Max = 1")
    # explicitly make KS and KL stable
    P8gen.SetParameters("130:mayDecay  = off")
    P8gen.SetParameters("310:mayDecay  = off")
    P8gen.SetParameters("3122:mayDecay = off")
    if inclusive=="True":
        P8gen.SetParameters("SoftQCD:inelastic = on")
        P8gen.SetParameters("PhotonCollision:gmgm2mumu = on")
        P8gen.SetParameters("PromptPhoton:all = on")
        P8gen.SetParameters("WeakBosonExchange:all = on")
    if inclusive=="c":
        P8gen.SetParameters("HardQCD::hardccbar  = on")
        # add HNL
        #ctau = 5.4E+06 # for tests use 5.4E+03  # nominal ctau = 54 km = 5.4E+06 cm = 5.4E+07 mm
        #mass = 1.0 # GeV
        hnl_instance = hnl.HNL(mass, couplings, debug=True)
        ctau = hnl_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
        P8gen.SetParameters("9900015:new = N2 N2 2 0 0 "+str(mass)+" 0.0 0.0 0.0 "+str(ctau/u.mm)+"  0   1   0   1   0") 
        P8gen.SetParameters("9900015:isResonance = false")
        # Configuring decay modes...
        readDecayTable.addHNLdecayChannels(P8gen, hnl_instance, conffile=os.path.expandvars('$FAIRSHIP/python/DecaySelection.conf'), verbose=True)
        # Finish HNL setup...
        P8gen.SetParameters("9900015:mayDecay = on")
        P8gen.SetHNLId(9900015)
        # also add to PDG
        gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
        addHNLtoROOT(pid=9900015,m=mass,g=gamma)
        # 12 14 16 neutrinos replace with N2
        #overwrite Xi_c0 decays
        P8gen.SetParameters("4132:new  Xi_c0            Xi_cbar0    2   0   0    2.47088    0.00000    0.00000    0.00000  3.36000e-02   0   1   0   1   0")
        P8gen.SetParameters("4132:addChannel      1   0.0200000   22      -11       9900015        3     3101")
        P8gen.SetParameters("4132:addChannel      1   0.0050000   22      -11       9900015        3     3103")
        P8gen.SetParameters("4132:addChannel      1   0.0200000   22      -13       9900015        3     3101")
        P8gen.SetParameters("4132:addChannel      1   0.0050000   22      -13       9900015        3     3103")
        #overwrite D0 decays
        P8gen.SetParameters("421:new  D0  Dbar0    1   0   0    1.86486    0.00000    0.00000    0.00000  1.22900e-01   0   1   0   1   0")
        P8gen.SetParameters("421:addChannel      1   0.0034000   22      -11       9900015     -211")
        P8gen.SetParameters("421:addChannel      1   0.0022000   22      -11       9900015     -213")
        P8gen.SetParameters("421:addChannel      1   0.0350000   22      -11       9900015     -321")
        P8gen.SetParameters("421:addChannel      1   0.0225000   22      -11       9900015     -323")
        P8gen.SetParameters("421:addChannel      1   0.0015000   22      -11       9900015     -325")
        P8gen.SetParameters("421:addChannel      1   0.0014000   22      -11       9900015   -10323")
        P8gen.SetParameters("421:addChannel      1   0.0034000   22      -13       9900015     -211")
        P8gen.SetParameters("421:addChannel      1   0.0022000   22      -13       9900015     -213")
        P8gen.SetParameters("421:addChannel      1   0.0340000   22      -13       9900015     -321")
        P8gen.SetParameters("421:addChannel      1   0.0214000   22      -13       9900015     -323")
        P8gen.SetParameters("421:addChannel      1   0.0015000   22      -13       9900015     -325")
        P8gen.SetParameters("421:addChannel      1   0.0014000   22      -13       9900015   -10323")
        P8gen.SetParameters("421:addChannel      1   0.0011000   22      -11       9900015      311     -211")
        P8gen.SetParameters("421:addChannel      1   0.0006000   22      -11       9900015     -321      111")
        P8gen.SetParameters("421:addChannel      1   0.0011000   22      -13       9900015      311     -211")
        P8gen.SetParameters("421:addChannel      1   0.0006000   22      -13       9900015     -321      111")
        #overwrite tau- decays
        P8gen.SetParameters("15:new  tau-  tau+    2   -3   0    1.77682    0.00000    0.00000    0.00000  8.71100e-02   0   1   0   1   0")
        P8gen.SetParameters("15:addChannel      1   0.1076825 1521       9900015     -211")
        P8gen.SetParameters("15:addChannel      1   0.0069601 1521       9900015     -321")
        P8gen.SetParameters("15:addChannel      1   0.1772832 1531       9900015       11      -12")
        P8gen.SetParameters("15:addChannel      1   0.1731072 1531       9900015       13      -14")
        P8gen.SetParameters("15:addChannel      1   0.2537447 1532       9900015      111     -211")
        P8gen.SetParameters("15:addChannel      1   0.0015809 1532       9900015      311     -321")
        P8gen.SetParameters("15:addChannel      1   0.0001511 1532       9900015      221     -321")
        P8gen.SetParameters("15:addChannel      1   0.0083521 1533       9900015     -211     -311")
        P8gen.SetParameters("15:addChannel      1   0.0042655 1533       9900015      111     -321")
        P8gen.SetParameters("15:addChannel      1   0.0924697 1541       9900015      111      111     -211")
        P8gen.SetParameters("15:addChannel      1   0.0925691 1541       9900015     -211     -211      211")
        P8gen.SetParameters("15:addChannel      1   0.0039772 1542       9900015      111     -211     -311")
        P8gen.SetParameters("15:addChannel      1   0.0034701 1542       9900015     -211      211     -321")
        P8gen.SetParameters("15:addChannel      1   0.0014318 1542       9900015     -211     -321      321")
        P8gen.SetParameters("15:addChannel      1   0.0015809 1542       9900015      111      311     -321")
        P8gen.SetParameters("15:addChannel      1   0.0011932 1542       9900015      130     -211      310")
        P8gen.SetParameters("15:addChannel      1   0.0006463 1542       9900015      111      111     -321")
        P8gen.SetParameters("15:addChannel      1   0.0002386 1542       9900015      130      130     -211")
        P8gen.SetParameters("15:addChannel      1   0.0002386 1542       9900015     -211      310      310")
        P8gen.SetParameters("15:addChannel      1   0.0013821 1543       9900015      111     -211      221")
        P8gen.SetParameters("15:addChannel      1   0.0017520 1544       9900015       22      111     -211")
        P8gen.SetParameters("15:addChannel      1   0.0459365 1551       9900015      111     -211     -211      211")
        P8gen.SetParameters("15:addChannel      1   0.0104401 1551       9900015      111      111      111     -211")
        P8gen.SetParameters("15:addChannel      1   0.0049069 1561       9900015      111      111     -211     -211      211")
        P8gen.SetParameters("15:addChannel      1   0.0009515 1561       9900015      111      111      111      111     -211")
        P8gen.SetParameters("15:addChannel      1   0.0008342 1561       9900015     -211     -211     -211      211      211")
        P8gen.SetParameters("15:addChannel      1   0.0001631    0       9900015     -211     -211      211      221")
        P8gen.SetParameters("15:addChannel      1   0.0001491    0       9900015      111      111     -211      221")
        P8gen.SetParameters("15:addChannel      1   0.0001392    0       9900015      111      111     -211      223")
        P8gen.SetParameters("15:addChannel      1   0.0001193    0       9900015     -211     -211      211      223")
        P8gen.SetParameters("15:addChannel      1   0.0004077    0       9900015      223     -321")
        P8gen.SetParameters("15:addChannel      1   0.0004773    0       9900015      111      111      111     -321")
        P8gen.SetParameters("15:addChannel      1   0.0003052    0       9900015      111     -211      211     -321")
        P8gen.SetParameters("15:addChannel      1   0.0002784    0       9900015      221     -323")
        P8gen.SetParameters("15:addChannel      1   0.0002366    0       9900015      111      111     -211     -311")
        P8gen.SetParameters("15:addChannel      1   0.0002237    0       9900015     -211     -211      211     -311")
        P8gen.SetParameters("15:addChannel      1   0.0002953    0       9900015      111     -211     -311      311")
        P8gen.SetParameters("15:addChannel      1   0.0000590    0       9900015      111     -211     -321      321")
        #overwrite D_s+ decays
        P8gen.SetParameters("431:new  D_s+  D_s-    1   3   0    1.96849    0.00000    0.00000    0.00000  1.49900e-01   0   1   0   1   0")
        P8gen.SetParameters("431:addChannel      1   0.0061600    0      -13       9900015")
        P8gen.SetParameters("431:addChannel      1   0.0640000    0      -15       9900015")
        P8gen.SetParameters("431:addChannel      1   0.0307000   22      -11       9900015      221")
        P8gen.SetParameters("431:addChannel      1   0.0027000   22      -11       9900015      311")
        P8gen.SetParameters("431:addChannel      1   0.0010000   22      -11       9900015     -313")
        P8gen.SetParameters("431:addChannel      1   0.0106000   22      -11       9900015      331")
        P8gen.SetParameters("431:addChannel      1   0.0242000   22      -11       9900015      333")
        P8gen.SetParameters("431:addChannel      1   0.0307000   22      -13       9900015      221")
        P8gen.SetParameters("431:addChannel      1   0.0027000   22      -13       9900015      311")
        P8gen.SetParameters("431:addChannel      1   0.0010000   22      -13       9900015     -313")
        P8gen.SetParameters("431:addChannel      1   0.0106000   22      -13       9900015      331")
        P8gen.SetParameters("431:addChannel      1   0.0242000   22      -13       9900015      333")
        #overwrite Lambda_c+ decays
        P8gen.SetParameters("4122:new  Lambda_c+   Lambda_cbar-    2   3   0    2.28646    0.00000    0.00000    0.00000  5.99000e-02   0   1   0   1   0")
        P8gen.SetParameters("4122:addChannel      1   0.0030000   22      -11       9900015     2112")
        P8gen.SetParameters("4122:addChannel      1   0.0020000   22      -11       9900015     2114")
        P8gen.SetParameters("4122:addChannel      1   0.0180000   22      -11       9900015     3122")
        P8gen.SetParameters("4122:addChannel      1   0.0050000   22      -11       9900015     3212")
        P8gen.SetParameters("4122:addChannel      1   0.0050000   22      -11       9900015     3214")
        P8gen.SetParameters("4122:addChannel      1   0.0030000   22      -13       9900015     2112")
        P8gen.SetParameters("4122:addChannel      1   0.0020000   22      -13       9900015     2114")
        P8gen.SetParameters("4122:addChannel      1   0.0180000   22      -13       9900015     3122")
        P8gen.SetParameters("4122:addChannel      1   0.0050000   22      -13       9900015     3212")
        P8gen.SetParameters("4122:addChannel      1   0.0050000   22      -13       9900015     3214")
        P8gen.SetParameters("4122:addChannel      1   0.0060000   22      -11       9900015     2112      111")
        P8gen.SetParameters("4122:addChannel      1   0.0060000   22      -11       9900015     2212     -211")
        P8gen.SetParameters("4122:addChannel      1   0.0060000   22      -13       9900015     2112      111")
        P8gen.SetParameters("4122:addChannel      1   0.0060000   22      -13       9900015     2212     -211")
        #overwrite D+ decays
        P8gen.SetParameters("411:new  D+ D-    1   3   0    1.86962    0.00000    0.00000    0.00000  3.11800e-01   0   1   0   1   0")
        P8gen.SetParameters("411:addChannel      1   0.0004000    0      -13       9900015")
        P8gen.SetParameters("411:addChannel      1   0.0010000    0      -15       9900015")
        P8gen.SetParameters("411:addChannel      1   0.0043000   22      -11       9900015      111")
        P8gen.SetParameters("411:addChannel      1   0.0028000   22      -11       9900015      113")
        P8gen.SetParameters("411:addChannel      1   0.0026000   22      -11       9900015      221")
        P8gen.SetParameters("411:addChannel      1   0.0028000   22      -11       9900015      223")
        P8gen.SetParameters("411:addChannel      1   0.0900000   22      -11       9900015      311")
        P8gen.SetParameters("411:addChannel      1   0.0554000   22      -11       9900015     -313")
        P8gen.SetParameters("411:addChannel      1   0.0038000   22      -11       9900015     -315")
        P8gen.SetParameters("411:addChannel      1   0.0005000   22      -11       9900015      331")
        P8gen.SetParameters("411:addChannel      1   0.0036000   22      -11       9900015   -10313")
        P8gen.SetParameters("411:addChannel      1   0.0043000   22      -13       9900015      111")
        P8gen.SetParameters("411:addChannel      1   0.0028000   22      -13       9900015      113")
        P8gen.SetParameters("411:addChannel      1   0.0026000   22      -13       9900015      221")
        P8gen.SetParameters("411:addChannel      1   0.0028000   22      -13       9900015      223")
        P8gen.SetParameters("411:addChannel      1   0.0874000   22      -13       9900015      311")
        P8gen.SetParameters("411:addChannel      1   0.0533000   22      -13       9900015     -313")
        P8gen.SetParameters("411:addChannel      1   0.0038000   22      -13       9900015     -315")
        P8gen.SetParameters("411:addChannel      1   0.0005000   22      -13       9900015      331")
        P8gen.SetParameters("411:addChannel      1   0.0036000   22      -13       9900015   -10313")
        P8gen.SetParameters("411:addChannel      1   0.0014000   22      -11       9900015      311      111")
        P8gen.SetParameters("411:addChannel      1   0.0027000   22      -11       9900015     -321      211")
        P8gen.SetParameters("411:addChannel      1   0.0014000   22      -13       9900015      311      111")
        P8gen.SetParameters("411:addChannel      1   0.0027000   22      -13       9900015     -321      211")
        P8gen.List(9900015)
    if inclusive=="b":
        P8gen.SetParameters("HardQCD::hardbbbar  = on")
        # P8gen.SetParameters("PDF:hardLHAPDFset = cteq5l.LHgrid")
        # P8gen.SetParameters("BeamRemnants:primordialKThard = 1.0")
        # add HNL
        #ctau = 5.4E+06 # for tests use 5.4E+03  # nominal ctau = 54 km = 5.4E+06 cm = 5.4E+07 mm
        #mass = 1.0 # GeV
        hnl_instance = hnl.HNL(mass, couplings, debug=True)
        ctau = hnl_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
        P8gen.SetParameters("9900015:new = N2 N2 2 0 0 "+str(mass)+" 0.0 0.0 0.0 "+str(ctau/u.mm)+"  0   1   0   1   0") 
        P8gen.SetParameters("9900015:isResonance = false")
        # Configuring decay modes...
        readDecayTable.addHNLdecayChannels(P8gen, hnl_instance, conffile=os.path.expandvars('$FAIRSHIP/python/DecaySelection.conf'), verbose=True)
        # Finish HNL setup...
        P8gen.SetParameters("9900015:mayDecay = on")
        P8gen.SetHNLId(9900015)
        # also add to PDG
        gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
        addHNLtoROOT(pid=9900015,m=mass,g=gamma)
        # 12 14 16 neutrinos replace with N2
        #overwrite Lambda_b0 decays
        P8gen.SetParameters("5122:new  Lambda_b0        Lambda_bbar0    2   0   0    5.61940    0.00000    0.00000    0.00000  3.69000e-01   0   1   0   1   0")
        P8gen.SetParameters("5122:addChannel      1   0.0546000   22      9900015       11     4122")
        P8gen.SetParameters("5122:addChannel      1   0.0096000   22      9900015       11     4124")
        P8gen.SetParameters("5122:addChannel      1   0.0128000   22      9900015       11    14122")
        P8gen.SetParameters("5122:addChannel      1   0.0546000   22      9900015       13     4122")
        P8gen.SetParameters("5122:addChannel      1   0.0096000   22      9900015       13     4124")
        P8gen.SetParameters("5122:addChannel      1   0.0128000   22      9900015       13    14122")
        P8gen.SetParameters("5122:addChannel      1   0.0172000   22      9900015       15     4122")
        P8gen.SetParameters("5122:addChannel      1   0.0032000   22      9900015       15     4124")
        P8gen.SetParameters("5122:addChannel      1   0.0043000   22      9900015       15    14122")
        #overwrite B+ decays
        P8gen.SetParameters("521:new  B+               B-    1   3   0    5.27925    0.00000    0.00000    0.00000  4.91100e-01   0   1   0   1   0")
        P8gen.SetParameters("521:addChannel      1   0.0000930    0       9900015      -15")
        P8gen.SetParameters("521:addChannel      1   0.0000720   22       9900015      -11      111")
        P8gen.SetParameters("521:addChannel      1   0.0001450   22       9900015      -11      113")
        P8gen.SetParameters("521:addChannel      1   0.0000840   22       9900015      -11      221")
        P8gen.SetParameters("521:addChannel      1   0.0001450   22       9900015      -11      223")
        P8gen.SetParameters("521:addChannel      1   0.0000840   22       9900015      -11      331")
        P8gen.SetParameters("521:addChannel      1   0.0224000   22       9900015      -11     -421")
        P8gen.SetParameters("521:addChannel      1   0.0617000   22       9900015      -11     -423")
        P8gen.SetParameters("521:addChannel      1   0.0030000   22       9900015      -11     -425")
        P8gen.SetParameters("521:addChannel      1   0.0049000   22       9900015      -11   -10421")
        P8gen.SetParameters("521:addChannel      1   0.0056000   22       9900015      -11   -10423")
        P8gen.SetParameters("521:addChannel      1   0.0090000   22       9900015      -11   -20423")
        P8gen.SetParameters("521:addChannel      1   0.0000720   22       9900015      -13      111")
        P8gen.SetParameters("521:addChannel      1   0.0001450   22       9900015      -13      113")
        P8gen.SetParameters("521:addChannel      1   0.0000840   22       9900015      -13      221")
        P8gen.SetParameters("521:addChannel      1   0.0001450   22       9900015      -13      223")
        P8gen.SetParameters("521:addChannel      1   0.0000840   22       9900015      -13      331")
        P8gen.SetParameters("521:addChannel      1   0.0224000   22       9900015      -13     -421")
        P8gen.SetParameters("521:addChannel      1   0.0617000   22       9900015      -13     -423")
        P8gen.SetParameters("521:addChannel      1   0.0030000   22       9900015      -13     -425")
        P8gen.SetParameters("521:addChannel      1   0.0049000   22       9900015      -13   -10421")
        P8gen.SetParameters("521:addChannel      1   0.0056000   22       9900015      -13   -10423")
        P8gen.SetParameters("521:addChannel      1   0.0090000   22       9900015      -13   -20423")
        P8gen.SetParameters("521:addChannel      1   0.0000300   22       9900015      -15      111")
        P8gen.SetParameters("521:addChannel      1   0.0000420   22       9900015      -15      113")
        P8gen.SetParameters("521:addChannel      1   0.0000120   22       9900015      -15      221")
        P8gen.SetParameters("521:addChannel      1   0.0000420   22       9900015      -15      223")
        P8gen.SetParameters("521:addChannel      1   0.0000200   22       9900015      -15      225")
        P8gen.SetParameters("521:addChannel      1   0.0000180   22       9900015      -15      331")
        P8gen.SetParameters("521:addChannel      1   0.0000200   22       9900015      -15      335")
        P8gen.SetParameters("521:addChannel      1   0.0070000   22       9900015      -15     -421")
        P8gen.SetParameters("521:addChannel      1   0.0160000   22       9900015      -15     -423")
        P8gen.SetParameters("521:addChannel      1   0.0020000   22       9900015      -15     -425")
        P8gen.SetParameters("521:addChannel      1   0.0000270   22       9900015      -15    10113")
        P8gen.SetParameters("521:addChannel      1   0.0000020   22       9900015      -15    10221")
        P8gen.SetParameters("521:addChannel      1   0.0000130   22       9900015      -15    10223")
        P8gen.SetParameters("521:addChannel      1   0.0000130   22       9900015      -15    10333")
        P8gen.SetParameters("521:addChannel      1   0.0013000   22       9900015      -15   -10421")
        P8gen.SetParameters("521:addChannel      1   0.0013000   22       9900015      -15   -10423")
        P8gen.SetParameters("521:addChannel      1   0.0000460   22       9900015      -15    20113")
        P8gen.SetParameters("521:addChannel      1   0.0000230   22       9900015      -15    20223")
        P8gen.SetParameters("521:addChannel      1   0.0000230   22       9900015      -15    20333")
        P8gen.SetParameters("521:addChannel      1   0.0020000   22       9900015      -15   -20423")
        P8gen.SetParameters("521:addChannel      1   0.0000040   22       9900015      -15  9000111")
        P8gen.SetParameters("521:addChannel      1   0.0000020   22       9900015      -15  9010221")
        P8gen.SetParameters("521:addChannel      1   0.0019000   22       9900015      -11     -411      211")
        P8gen.SetParameters("521:addChannel      1   0.0006000   22       9900015      -11     -413      211")
        P8gen.SetParameters("521:addChannel      1   0.0010000   22       9900015      -11     -421      111")
        P8gen.SetParameters("521:addChannel      1   0.0003000   22       9900015      -11     -423      111")
        P8gen.SetParameters("521:addChannel      1   0.0019000   22       9900015      -13     -411      211")
        P8gen.SetParameters("521:addChannel      1   0.0006000   22       9900015      -13     -413      211")
        P8gen.SetParameters("521:addChannel      1   0.0010000   22       9900015      -13     -421      111")
        P8gen.SetParameters("521:addChannel      1   0.0003000   22       9900015      -13     -423      111")
        P8gen.SetParameters("521:addChannel      2   0.0019480   22       9900015      -11        2       -2")
        P8gen.SetParameters("521:addChannel      2   0.0019480   22       9900015      -13        2       -2")
        P8gen.SetParameters("521:addChannel      3   0.0019480   22       9900015      -11       -2        2")
        P8gen.SetParameters("521:addChannel      3   0.0019480   22       9900015      -13       -2        2")
        #overwrite Xi_b- decays
        P8gen.SetParameters("5132:new  Xi_b- Xi_b+    2   -3   0    5.79110    0.00000    0.00000    0.00000  3.64000e-01   0   1   0   1   0")
        P8gen.SetParameters("5132:addChannel      1   0.1080010   22      9900015       11        4     3101")
        P8gen.SetParameters("5132:addChannel      1   0.0020000   22      9900015       11        2     3101")
        P8gen.SetParameters("5132:addChannel      1   0.1080000   22      9900015       13        4     3101")
        P8gen.SetParameters("5132:addChannel      1   0.0020000   22      9900015       13        2     3101")
        P8gen.SetParameters("5132:addChannel      1   0.0250000   22      9900015       15        4     3101")
        P8gen.SetParameters("5132:addChannel      1   0.0010000   22      9900015       15        4     3101")
        #overwrite Xi_b0 decays
        P8gen.SetParameters("5232:new  Xi_b0  Xi_b0_bar    2   0   0    5.78800    0.00000    0.00000    0.00000  3.64000e-01   0   1   0   1   0")
        P8gen.SetParameters("5232:addChannel      1   0.1080010   22      9900015       11        4     3201")
        P8gen.SetParameters("5232:addChannel      1   0.0020000   22      9900015       11        2     3201")
        P8gen.SetParameters("5232:addChannel      1   0.1080000   22      9900015       13        4     3201")
        P8gen.SetParameters("5232:addChannel      1   0.0020000   22      9900015       13        2     3201")
        P8gen.SetParameters("5232:addChannel      1   0.0250000   22      9900015       15        4     3201")
        P8gen.SetParameters("5232:addChannel      1   0.0010000   22      9900015       15        4     3201")
        #overwrite B_s0 decays
        P8gen.SetParameters("531:new  B_s0             B_sbar0    1   0   0    5.36677    0.00000    0.00000    0.00000  4.39000e-01   0   1   0   1   0")
        P8gen.SetParameters("531:addChannel      1   0.0002000   22       9900015      -11     -321")
        P8gen.SetParameters("531:addChannel      1   0.0003000   22       9900015      -11     -323")
        P8gen.SetParameters("531:addChannel      1   0.0210000   22       9900015      -11     -431")
        P8gen.SetParameters("531:addChannel      1   0.0490000   22       9900015      -11     -433")
        P8gen.SetParameters("531:addChannel      1   0.0070000   22       9900015      -11     -435")
        P8gen.SetParameters("531:addChannel      1   0.0003000   22       9900015      -11   -10323")
        P8gen.SetParameters("531:addChannel      1   0.0040000   22       9900015      -11   -10431")
        P8gen.SetParameters("531:addChannel      1   0.0070000   22       9900015      -11   -10433")
        P8gen.SetParameters("531:addChannel      1   0.0002000   22       9900015      -11   -20323")
        P8gen.SetParameters("531:addChannel      1   0.0040000   22       9900015      -11   -20433")
        P8gen.SetParameters("531:addChannel      1   0.0002000   22       9900015      -13     -321")
        P8gen.SetParameters("531:addChannel      1   0.0003000   22       9900015      -13     -323")
        P8gen.SetParameters("531:addChannel      1   0.0210000   22       9900015      -13     -431")
        P8gen.SetParameters("531:addChannel      1   0.0490000   22       9900015      -13     -433")
        P8gen.SetParameters("531:addChannel      1   0.0070000   22       9900015      -13     -435")
        P8gen.SetParameters("531:addChannel      1   0.0003000   22       9900015      -13   -10323")
        P8gen.SetParameters("531:addChannel      1   0.0040000   22       9900015      -13   -10431")
        P8gen.SetParameters("531:addChannel      1   0.0070000   22       9900015      -13   -10433")
        P8gen.SetParameters("531:addChannel      1   0.0002000   22       9900015      -13   -20323")
        P8gen.SetParameters("531:addChannel      1   0.0040000   22       9900015      -13   -20433")
        P8gen.SetParameters("531:addChannel      1   0.0080000   22       9900015      -15     -431")
        P8gen.SetParameters("531:addChannel      1   0.0160000   22       9900015      -15     -433")
        P8gen.SetParameters("531:addChannel      1   0.0028000   22       9900015      -15     -435")
        P8gen.SetParameters("531:addChannel      1   0.0018000   22       9900015      -15   -10431")
        P8gen.SetParameters("531:addChannel      1   0.0028000   22       9900015      -15   -10433")
        P8gen.SetParameters("531:addChannel      1   0.0018000   22       9900015      -15   -20433")
        #overwrite B_c+ decays
        P8gen.SetParameters("541:new  B_c+             B_c-    1   3   0    6.27700    0.00000    0.00000    0.00000  1.38000e-01   0   1   0   1   0")
        P8gen.SetParameters("541:addChannel      1   0.0160000    0       9900015      -15")
        P8gen.SetParameters("541:addChannel      1   0.0034000   22      -11       9900015      511")
        P8gen.SetParameters("541:addChannel      1   0.0058000   22      -11       9900015      513")
        P8gen.SetParameters("541:addChannel      1   0.0403000   22      -11       9900015      531")
        P8gen.SetParameters("541:addChannel      1   0.0506000   22      -11       9900015      533")
        P8gen.SetParameters("541:addChannel      1   0.0000400   22       9900015      -11      421")
        P8gen.SetParameters("541:addChannel      1   0.0001800   22       9900015      -11      423")
        P8gen.SetParameters("541:addChannel      1   0.0075000   22       9900015      -11      441")
        P8gen.SetParameters("541:addChannel      1   0.0190000   22       9900015      -11      443")
        P8gen.SetParameters("541:addChannel      1   0.0002000   22       9900015      -11   100441")
        P8gen.SetParameters("541:addChannel      1   0.0009400   22       9900015      -11   100443")
        P8gen.SetParameters("541:addChannel      1   0.0034000   22      -13       9900015      511")
        P8gen.SetParameters("541:addChannel      1   0.0058000   22      -13       9900015      513")
        P8gen.SetParameters("541:addChannel      1   0.0403000   22      -13       9900015      531")
        P8gen.SetParameters("541:addChannel      1   0.0506000   22      -13       9900015      533")
        P8gen.SetParameters("541:addChannel      1   0.0000400   22       9900015      -13      421")
        P8gen.SetParameters("541:addChannel      1   0.0001800   22       9900015      -13      423")
        P8gen.SetParameters("541:addChannel      1   0.0075000   22       9900015      -13      441")
        P8gen.SetParameters("541:addChannel      1   0.0190000   22       9900015      -13      443")
        P8gen.SetParameters("541:addChannel      1   0.0002000   22       9900015      -13   100441")
        P8gen.SetParameters("541:addChannel      1   0.0009400   22       9900015      -13   100443")
        P8gen.SetParameters("541:addChannel      1   0.0000200   22       9900015      -15      421")
        P8gen.SetParameters("541:addChannel      1   0.0000800   22       9900015      -15      423")
        P8gen.SetParameters("541:addChannel      1   0.0023000   22       9900015      -15      441")
        P8gen.SetParameters("541:addChannel      1   0.0048000   22       9900015      -15      443")
        P8gen.SetParameters("541:addChannel      1   0.0000160   22       9900015      -15   100441")
        P8gen.SetParameters("541:addChannel      1   0.0000800   22       9900015      -15   100443")
        #overwrite B0 decays
        P8gen.SetParameters("511:new  B0  Bbar0    1   0   0    5.27958    0.00000    0.00000    0.00000  4.58700e-01   0   1   0   1   0")
        P8gen.SetParameters("511:addChannel      1   0.0001330   22       9900015      -11     -211")
        P8gen.SetParameters("511:addChannel      1   0.0002690   22       9900015      -11     -213")
        P8gen.SetParameters("511:addChannel      1   0.0207000   22       9900015      -11     -411")
        P8gen.SetParameters("511:addChannel      1   0.0570000   22       9900015      -11     -413")
        P8gen.SetParameters("511:addChannel      1   0.0023000   22       9900015      -11     -415")
        P8gen.SetParameters("511:addChannel      1   0.0045000   22       9900015      -11   -10411")
        P8gen.SetParameters("511:addChannel      1   0.0052000   22       9900015      -11   -10413")
        P8gen.SetParameters("511:addChannel      1   0.0083000   22       9900015      -11   -20413")
        P8gen.SetParameters("511:addChannel      1   0.0001330   22       9900015      -13     -211")
        P8gen.SetParameters("511:addChannel      1   0.0002690   22       9900015      -13     -213")
        P8gen.SetParameters("511:addChannel      1   0.0207000   22       9900015      -13     -411")
        P8gen.SetParameters("511:addChannel      1   0.0570000   22       9900015      -13     -413")
        P8gen.SetParameters("511:addChannel      1   0.0023000   22       9900015      -13     -415")
        P8gen.SetParameters("511:addChannel      1   0.0045000   22       9900015      -13   -10411")
        P8gen.SetParameters("511:addChannel      1   0.0052000   22       9900015      -13   -10413")
        P8gen.SetParameters("511:addChannel      1   0.0083000   22       9900015      -13   -20413")
        P8gen.SetParameters("511:addChannel      1   0.0000600   22       9900015      -15     -211")
        P8gen.SetParameters("511:addChannel      1   0.0000830   22       9900015      -15     -213")
        P8gen.SetParameters("511:addChannel      1   0.0000080   22       9900015      -15     -215")
        P8gen.SetParameters("511:addChannel      1   0.0070000   22       9900015      -15     -411")
        P8gen.SetParameters("511:addChannel      1   0.0160000   22       9900015      -15     -413")
        P8gen.SetParameters("511:addChannel      1   0.0020000   22       9900015      -15     -415")
        P8gen.SetParameters("511:addChannel      1   0.0000080   22       9900015      -15   -10213")
        P8gen.SetParameters("511:addChannel      1   0.0013000   22       9900015      -15   -10411")
        P8gen.SetParameters("511:addChannel      1   0.0013000   22       9900015      -15   -10413")
        P8gen.SetParameters("511:addChannel      1   0.0000900   22       9900015      -15   -20213")
        P8gen.SetParameters("511:addChannel      1   0.0020000   22       9900015      -15   -20413")
        P8gen.SetParameters("511:addChannel      1   0.0000080   22       9900015      -15 -9000211")
        P8gen.SetParameters("511:addChannel      1   0.0010000   22       9900015      -11     -411      111")
        P8gen.SetParameters("511:addChannel      1   0.0003000   22       9900015      -11     -413      111")
        P8gen.SetParameters("511:addChannel      1   0.0020000   22       9900015      -11     -421     -211")
        P8gen.SetParameters("511:addChannel      1   0.0007000   22       9900015      -11     -423     -211")
        P8gen.SetParameters("511:addChannel      1   0.0010000   22       9900015      -13     -411      111")
        P8gen.SetParameters("511:addChannel      1   0.0003000   22       9900015      -13     -413      111")
        P8gen.SetParameters("511:addChannel      1   0.0020000   22       9900015      -13     -421     -211")
        P8gen.SetParameters("511:addChannel      1   0.0007000   22       9900015      -13     -423     -211")
        P8gen.SetParameters("511:addChannel      2   0.0018920   22       9900015      -11        1       -2")
        P8gen.SetParameters("511:addChannel      2   0.0018920   22       9900015      -13        1       -2")
        P8gen.SetParameters("511:addChannel      3   0.0018920   22       9900015      -11       -2        1")
        P8gen.SetParameters("511:addChannel      3   0.0018920   22       9900015      -13       -2        1")
        P8gen.List(9900015)
예제 #3
0
def configure(P8gen, mass, couplings, inclusive, deepCopy=False):
    # configure pythia8 for Ship usage
    debug=True
    if debug: cf=open('pythia8_conf.txt','w')
    h=readFromAscii()
    P8gen.UseRandom3() # TRandom1 or TRandom3 ?
    P8gen.SetMom(400)  # beam momentum in GeV 
    if deepCopy: P8gen.UseDeepCopy()
    pdg = ROOT.TDatabasePDG.Instance()
    # let strange particle decay in Geant4
    p8 = P8gen.getPythiaInstance()
    n=1
    while n!=0:
     n = p8.particleData.nextId(n)
     p = p8.particleData.particleDataEntryPtr(n)
     if p.tau0()>1: 
      command = str(n)+":mayDecay = false"
      p8.readString(command)
      print "Pythia8 configuration: Made %s stable for Pythia, should decay in Geant4"%(p.name())
    if inclusive=="True":
        P8gen.SetParameters("SoftQCD:inelastic = on")
        P8gen.SetParameters("PhotonCollision:gmgm2mumu = on")
        P8gen.SetParameters("PromptPhoton:all = on")
        P8gen.SetParameters("WeakBosonExchange:all = on")
    if inclusive=="c":
        P8gen.SetParameters("HardQCD::hardccbar  = on")
	if debug: cf.write('P8gen.SetParameters("HardQCD::hardccbar  = on")\n')
        # add HNL
        #ctau = 5.4E+06 # for tests use 5.4E+03  # nominal ctau = 54 km = 5.4E+06 cm = 5.4E+07 mm
        #mass = 1.0 # GeV
        hnl_instance = hnl.HNL(mass, couplings, debug=True)
        ctau = hnl_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
        print "HNL ctau",ctau
        P8gen.SetParameters("9900015:new = N2 N2 2 0 0 "+str(mass)+" 0.0 0.0 0.0 "+str(ctau/u.mm)+"  0   1   0   1   0") 
        if debug: cf.write('P8gen.SetParameters("9900015:new = N2 N2 2 0 0 '+str(mass)+' 0.0 0.0 0.0 '+str(ctau/u.mm)+'  0   1   0   1   0") \n')
        P8gen.SetParameters("9900015:isResonance = false")
        if debug: cf.write('P8gen.SetParameters("9900015:isResonance = false")\n')
	P8gen.SetParameters("Next:numberCount    =  0")
        if debug: cf.write('P8gen.SetParameters("Next:numberCount    =  0")\n')
        # Configuring decay modes...
        readDecayTable.addHNLdecayChannels(P8gen, hnl_instance, conffile=os.path.expandvars('$FAIRSHIP/python/DecaySelection.conf'), verbose=False)
        # Finish HNL setup...
        P8gen.SetParameters("9900015:mayDecay = on")
	if debug: cf.write('P8gen.SetParameters("9900015:mayDecay = on")\n')
        P8gen.SetHNLId(9900015)
	if debug: cf.write('P8gen.SetHNLId(9900015)\n')
        # also add to PDG
        gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
        addHNLtoROOT(pid=9900015,m=mass,g=gamma)
        # 12 14 16 neutrinos replace with N2
        charmhistograms = ['ds_e','d_e','d0_K-_e','d0_K*-_e','d_K0_e','lambdac_Lambda0_e','xic0_Xi-_e','ds_mu','d_mu','d0_K-_mu','d_K0_mu','d0_K*-_mu','lambdac_Lambda0_mu','xic0_Xi-_mu','d_tau','ds_tau']
        tauhistograms= ['tau_nu_e_bar_e','tau_nu_mu_bar_mu','tau_nu_tau_e','tau_nu_tau_mu','tau_pi-','tau_K-','tau_rho-']
        totaltauBR=gettotalbr(h,tauhistograms,mass,couplings,0.)
        maxsumBR=getmaxsumbr(h,charmhistograms,mass,couplings,totaltauBR)
        if maxsumBR==0.:
           print "No phase space for HNL from c at this mass:",mass,". Quitting."
           sys.exit()
        totalBR=gettotalbr(h,charmhistograms,mass,couplings,totaltauBR)
        #overwrite Xi_c0 decays
        P8gen.SetParameters("4132:new  Xi_c0            Xi_cbar0    2   0   0    2.47088    0.00000    0.00000    0.00000  3.36000e-02   0   1   0   1   0")
        channels = [ {'id':'4132','decay':'xic0_Xi-_e',   'coupling':0,'idlepton':-11,'idhadron':-3312},\
                     {'id':'4132','decay':'xic0_Xi-_mu',  'coupling':1,'idlepton':-11,'idhadron':-3312}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite D0 decays
        P8gen.SetParameters("421:new  D0  Dbar0    1   0   0    1.86486    0.00000    0.00000    0.00000  1.22900e-01   0   1   0   1   0")
        channels = [ {'id':'421','decay':'d0_K-_e',   'coupling':0,'idlepton':-11,'idhadron':-321},\
                     {'id':'421','decay':'d0_K*-_e',  'coupling':0,'idlepton':-11,'idhadron':-323},\
                     {'id':'421','decay':'d0_K-_mu',  'coupling':1,'idlepton':-13,'idhadron':-321},\
                     {'id':'421','decay':'d0_K*-_mu', 'coupling':1,'idlepton':-13,'idhadron':-323}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite tau- decays
        P8gen.SetParameters("15:new  tau-  tau+    2   -3   0    1.77682    0.00000    0.00000    0.00000  8.71100e-02   0   1   0   1   0")
        channels = [ {'id':'15','decay':'tau_pi-', 'coupling':2,'idhadron':-211},\
                     {'id':'15','decay':'tau_K-',  'coupling':2,'idhadron':-321},\
                     {'id':'15','decay':'tau_rho-',  'coupling':2,'idhadron':-213},\
                     {'id':'15','decay':'tau__nu_e_bar_e',  'coupling':2,'idlepton':11,'idhadron':-12},\
                     {'id':'15','decay':'tau_nu_tau_e',     'coupling':2,'idlepton':11,'idhadron':-16},\
                     {'id':'15','decay':'tau_nu_mu_bar_mu',     'coupling':2,'idlepton':13,'idhadron':-14},\
                     {'id':'15','decay':'tau_nu_tau_mu',     'coupling':2,'idlepton':13,'idhadron':-16}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite D_s+ decays
        P8gen.SetParameters("431:new  D_s+  D_s-    1   3   0    1.96849    0.00000    0.00000    0.00000  1.49900e-01   0   1   0   1   0")
        channels = [ {'id':'431','decay':'ds_mu', 'coupling':1,'idlepton':-13},\
                     {'id':'411','decay':'ds_e',  'coupling':0,'idlepton':-11},\
                     {'id':'411','decay':'ds_tau','coupling':2,'idlepton':-15}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite Lambda_c+ decays
        P8gen.SetParameters("4122:new  Lambda_c+   Lambda_cbar-    2   3   0    2.28646    0.00000    0.00000    0.00000  5.99000e-02   0   1   0   1   0")
        channels = [ {'id':'4122','decay':'lambdac_Lambda0_e', 'coupling':0,'idlepton':-11,'idhadron':3122},\
                     {'id':'4122','decay':'lambdac_Lambda0_mu', 'coupling':1,'idlepton':-13,'idhadron':3122}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite D+ decays
        P8gen.SetParameters("411:new  D+ D-    1   3   0    1.86962    0.00000    0.00000    0.00000  3.11800e-01   0   1   0   1   0")
        channels = [ {'id':'411','decay':'d_mu', 'coupling':1,'idlepton':-13},\
                     {'id':'411','decay':'d_e',  'coupling':0,'idlepton':-11},\
                     {'id':'411','decay':'d_tau','coupling':2,'idlepton':-15},\
                     {'id':'411','decay':'d_K0_e','coupling':0,'idlepton':-11,'idhadron':311},\
                     {'id':'411','decay':'d_K0_mu','coupling':1,'idlepton':-13,'idhadron':311}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)
        P8gen.List(9900015)
	if debug: cf.write('P8gen.List(9900015)\n')
    if inclusive=="b":
        P8gen.SetParameters("HardQCD::hardbbbar  = on")
	if debug: cf.write('P8gen.SetParameters("HardQCD::hardbbbar  = on")\n')
        # add HNL
        #ctau = 5.4E+06 # for tests use 5.4E+03  # nominal ctau = 54 km = 5.4E+06 cm = 5.4E+07 mm
        #mass = 1.0 # GeV
        hnl_instance = hnl.HNL(mass, couplings, debug=True)
        ctau = hnl_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
        P8gen.SetParameters("9900015:new = N2 N2 2 0 0 "+str(mass)+" 0.0 0.0 0.0 "+str(ctau/u.mm)+"  0   1   0   1   0") 
	if debug: cf.write('P8gen.SetParameters("9900015:new = N2 N2 2 0 0 '+str(mass)+' 0.0 0.0 0.0 '+str(ctau/u.mm)+'  0   1   0   1   0")\n')
        P8gen.SetParameters("9900015:isResonance = false")
	if debug: cf.write('P8gen.SetParameters("9900015:isResonance = false"\n')
        # Configuring decay modes...
        readDecayTable.addHNLdecayChannels(P8gen, hnl_instance, conffile=os.path.expandvars('$FAIRSHIP/python/DecaySelection.conf'), verbose=True)
        # Finish HNL setup...
        P8gen.SetParameters("9900015:mayDecay = on")
	if debug: cf.write('P8gen.SetParameters("9900015:mayDecay = on")\n')
        P8gen.SetHNLId(9900015)
	if debug: cf.write('P8gen.SetHNLId(9900015)\n')
        # also add to PDG
        gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
        addHNLtoROOT(pid=9900015,m=mass,g=gamma)
        # 12 14 16 neutrinos replace with N2
        beautyhistograms = ['bc_tau','b_D*0_bar_tau','bs_D_s-_tau','b_tau','lambdab_Lambda_c+_tau','Xib_Xi_c+_tau',\
                            'Omega_b-_tau','b0_D*-_tau','bs_D*_s-_tau','b_D0_bar_tau','b0_D-_tau','b_e','bc_e','b_D*0_bar_e',\
                            'b_D0_bar_e','b0_D*-_e','b0_D-_e','bs_D_s-_e','bs_D*_s-_e','bc_B_s0_e','bc_B0_e','bc_B*0_e','bc_B*_s0_e',\
                            'lambdab_Lambda_c+_e','Xib_Xi_c+_e','Omega_b-_e','b_mu','bc_mu','b_D*0_bar_mu','b_D0_bar_mu','b0_D-_mu',\
                            'b0_D*-_mu','bs_D_s-_mu','bs_D*_s-_mu','bc_B_s0_mu','bc_B0_mu','bc_B*0_mu','bc_B*_s0_mu','lambdab_Lambda_c+_mu','Xib_Xi_c+_mu','Omega_b-_mu','b_mu']
# disable Bc until production is sorted out
        tmp = []
        for x in beautyhistograms:
           if  x[:2]=='bc': continue
           tmp.append(x)
        beautyhistograms = tmp
        maxsumBR=getmaxsumbr(h,beautyhistograms,mass,couplings,0.)
        if maxsumBR==0.:
           print "No phase space for HNL from b at this mass:",mass,". Quitting."
           sys.exit()
        totalBR=gettotalbr(h,beautyhistograms,mass,couplings,0.)
        #overwrite Lambda_b0 decays
        P8gen.SetParameters("5122:new  Lambda_b0        Lambda_bbar0    2   0   0    5.61940    0.00000    0.00000    0.00000  3.69000e-01   0   1   0   1   0")
        channels = [ {'id':'5122','decay':'lambdab_Lambda_c+_e','coupling':0,'idlepton':11,'idhadron':4122},\
                     {'id':'5122','decay':'lambdab_Lambda_c+_mu','coupling':1,'idlepton':13,'idhadron':4122},\
                     {'id':'5122','decay':'lambdab_Lambda_c+_tau','coupling':2,'idlepton':15,'idhadron':4122}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite B+ decays
        P8gen.SetParameters("521:new  B+               B-    1   3   0    5.27925    0.00000    0.00000    0.00000  4.91100e-01   0   1   0   1   0")
        channels = [ {'id':'521','decay':'b_tau','coupling':2,'idlepton':-15},\
                     {'id':'521','decay':'b_mu', 'coupling':1,'idlepton':-13},\
                     {'id':'521','decay':'b_e',  'coupling':0,'idlepton':-11},\
                     {'id':'521','decay':'b_D0_bar_e',   'coupling':0,'idlepton':-11,'idhadron':-421},\
                     {'id':'521','decay':'b_D*0_bar_e',  'coupling':0,'idlepton':-11,'idhadron':-423},\
                     {'id':'521','decay':'b_D0_bar_mu',   'coupling':1,'idlepton':-13,'idhadron':-421},\
                     {'id':'521','decay':'b_D*0_bar_mu',  'coupling':1,'idlepton':-13,'idhadron':-423},\
                     {'id':'521','decay':'b_D0_bar_tau',   'coupling':2,'idlepton':-15,'idhadron':-421},\
                     {'id':'521','decay':'b_D*0_bar_tau',  'coupling':2,'idlepton':-15,'idhadron':-423}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite Xi_b0 decays
        P8gen.SetParameters("5232:new  Xi_b0            Xi_bbar0    2   0   0    5.78800    0.00000    0.00000    0.00000  3.64000e-01   0   1   0   1   0")
        channels = [ {'id':'5232','decay':'Xib_Xi_c+_tau','coupling':2,'idlepton':-15},\
                     {'id':'5232','decay':'Xib_Xi_c+_mu','coupling':1,'idlepton':-13},\
                     {'id':'5232','decay':'Xib_Xi_c+_e','coupling':0,'idlepton':-11}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite B_s0 decays
        P8gen.SetParameters("531:new  B_s0             B_sbar0    1   0   0    5.36677    0.00000    0.00000    0.00000  4.39000e-01   0   1   0   1   0")
        channels = [ {'id':'531','decay':'bs_D_s-_e',   'coupling':0,'idlepton':-11,'idhadron':-431},\
                     {'id':'531','decay':'bs_D*_s-_e',  'coupling':0,'idlepton':-11,'idhadron':-433},\
                     {'id':'531','decay':'bs_D_s-_mu',  'coupling':1,'idlepton':-13,'idhadron':-431},\
                     {'id':'531','decay':'bs_D*_s-_mu', 'coupling':1,'idlepton':-13,'idhadron':-433},\
                     {'id':'531','decay':'bs_D_s-_tau', 'coupling':2,'idlepton':-15,'idhadron':-431},\
                     {'id':'531','decay':'bs_D*_s-_tau','coupling':2,'idlepton':-15,'idhadron':-433}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite Omega_b- decays
        P8gen.SetParameters("5332:new  Omega_b-         Omega_bbar+    2   -3   0    6.07000    0.00000    0.00000    0.00000  3.64000e-01   0   1   0   1   0")
        channels = [ {'id':'5332','decay':'Omega_b-_tau','coupling':2,'idlepton':-15},\
                     {'id':'5332','decay':'Omega_b-_mu','coupling':1,'idlepton':-13},\
                     {'id':'5332','decay':'Omega_b-_e','coupling':0,'idlepton':-11}]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite B_c+ decays
        P8gen.SetParameters("541:new  B_c+             B_c-    1   3   0    6.27700    0.00000    0.00000    0.00000  1.38000e-01   0   1   0   1   0")
        channels = [ {'id':'541','decay':'bc_tau','coupling':2,'idlepton':-15},\
                     {'id':'541','decay':'bc_e',  'coupling':0,'idlepton':-11},\
                     {'id':'541','decay':'bc_mu', 'coupling':1,'idlepton':-13},\
                     {'id':'541','decay':'bc_B0_e',    'coupling':0,'idlepton':-11,'idhadron':511},\
                     {'id':'541','decay':'bc_B*0_e',   'coupling':0,'idlepton':-11,'idhadron':513},\
                     {'id':'541','decay':'bc_B_s0_e',  'coupling':0,'idlepton':-11,'idhadron':531},\
                     {'id':'541','decay':'bc_B*_s0_e', 'coupling':0,'idlepton':-11,'idhadron':533},\
                     {'id':'541','decay':'bc_B0_mu',   'coupling':1,'idlepton':-13,'idhadron':511},\
                     {'id':'541','decay':'bc_B*0_mu',  'coupling':1,'idlepton':-13,'idhadron':513},\
                     {'id':'541','decay':'bc_B_s0_mu', 'coupling':1,'idlepton':-13,'idhadron':531},\
                     {'id':'541','decay':'bc_B*_s0_mu','coupling':1,'idlepton':-13,'idhadron':533} ]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        #overwrite B0 decays
        P8gen.SetParameters("511:new  B0  Bbar0    1   0   0    5.27958    0.00000    0.00000    0.00000  4.58700e-01   0   1   0   1   0")
        channels = [ {'id':'511','decay':'b0_D-_e',   'coupling':0,'idlepton':-11,'idhadron':-411},\
                     {'id':'511','decay':'b0_D*-_e',  'coupling':0,'idlepton':-11,'idhadron':-413},\
                     {'id':'511','decay':'b0_D-_mu',  'coupling':1,'idlepton':-13,'idhadron':-411},\
                     {'id':'511','decay':'b0_D*-_mu', 'coupling':1,'idlepton':-13,'idhadron':-413},\
                     {'id':'511','decay':'b0_D-_tau', 'coupling':2,'idlepton':-15,'idhadron':-411},\
                     {'id':'511','decay':'b0_D*-_tau','coupling':2,'idlepton':-15,'idhadron':-413} ]
        setChannels(P8gen,h,channels,mass,couplings,maxsumBR)

        P8gen.List(9900015)
        if debug: cf.write('P8gen.List(9900015)\n')
    if debug: cf.close()
예제 #4
0
def configure(P8gen, mass, couplings, inclusive, deepCopy=False):
    # configure pythia8 for Ship usage
    debug=True
    if debug: cf=open('pythia8_conf.txt','w')
    h=readFromAscii()
    P8gen.UseRandom3() # TRandom1 or TRandom3 ?
    P8gen.SetMom(400)  # beam momentum in GeV 
    if deepCopy: P8gen.UseDeepCopy()
    pdg = ROOT.TDatabasePDG.Instance()
    # let strange particle decay in Geant4
    ## the following does not work because need to have N2 decaying
    #P8gen.SetParameters("ParticleDecays:limitTau0 = on")
    #P8gen.SetParameters("ParticleDecays:tau0Max = 1")
    # explicitly make KS and KL stable
    P8gen.SetParameters("130:mayDecay  = off")
    if debug: cf.write('P8gen.SetParameters("130:mayDecay  = off")\n')
    P8gen.SetParameters("310:mayDecay  = off")
    if debug: cf.write('P8gen.SetParameters("310:mayDecay  = off")\n')
    P8gen.SetParameters("3122:mayDecay = off")
    if debug: cf.write('P8gen.SetParameters("3122:mayDecay = off")\n')
    P8gen.SetParameters("3222:mayDecay = off")
    if inclusive=="True":
        P8gen.SetParameters("SoftQCD:inelastic = on")
        P8gen.SetParameters("PhotonCollision:gmgm2mumu = on")
        P8gen.SetParameters("PromptPhoton:all = on")
        P8gen.SetParameters("WeakBosonExchange:all = on")
    if inclusive=="c":
        P8gen.SetParameters("HardQCD::hardccbar  = on")
	if debug: cf.write('P8gen.SetParameters("HardQCD::hardccbar  = on")\n')
        # add HNL
        #ctau = 5.4E+06 # for tests use 5.4E+03  # nominal ctau = 54 km = 5.4E+06 cm = 5.4E+07 mm
        #mass = 1.0 # GeV
        hnl_instance = hnl.HNL(mass, couplings, debug=True)
        ctau = hnl_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
        P8gen.SetParameters("9900015:new = N2 N2 2 0 0 "+str(mass)+" 0.0 0.0 0.0 "+str(ctau/u.mm)+"  0   1   0   1   0") 
        if debug: cf.write('P8gen.SetParameters("9900015:new = N2 N2 2 0 0 '+str(mass)+' 0.0 0.0 0.0 '+str(ctau/u.mm)+'  0   1   0   1   0") \n')
        P8gen.SetParameters("9900015:isResonance = false")
        if debug: cf.write('P8gen.SetParameters("9900015:isResonance = false")\n')
	P8gen.SetParameters("Next:numberCount    =  0")
        if debug: cf.write('P8gen.SetParameters("Next:numberCount    =  0")\n')
        # Configuring decay modes...
        readDecayTable.addHNLdecayChannels(P8gen, hnl_instance, conffile=os.path.expandvars('$FAIRSHIP/python/DecaySelection.conf'), verbose=True)
        # Finish HNL setup...
        P8gen.SetParameters("9900015:mayDecay = on")
	if debug: cf.write('P8gen.SetParameters("9900015:mayDecay = on")\n')
        P8gen.SetHNLId(9900015)
	if debug: cf.write('P8gen.SetHNLId(9900015)\n')
        # also add to PDG
        gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
        addHNLtoROOT(pid=9900015,m=mass,g=gamma)
        # 12 14 16 neutrinos replace with N2
        charmhistograms = ['ds_e','d_e','d0_K-_e','d0_K*-_e','d_K0_e','lambdac_Lambda0_e','xic0_Xi-_e','ds_mu','d_mu','d0_K-_mu','d_K0_mu','d0_K*-_mu','lambdac_Lambda0_mu','xic0_Xi-_mu','d_tau','ds_tau']
        tauhistograms= ['tau_nu_e_bar_e','tau_nu_mu_bar_mu','tau_nu_tau_e','tau_nu_tau_mu','tau_pi-','tau_K-','tau_rho-']
        totaltauBR=gettotalbr(h,tauhistograms,mass,couplings,0.)
        maxsumBR=getmaxsumbr(h,charmhistograms,mass,couplings,totaltauBR)
        if maxsumBR==0.:
           print "No phase space for HNL from c at this mass:",mass,". Quitting."
           sys.exit()
        totalBR=gettotalbr(h,charmhistograms,mass,couplings,totaltauBR)
        #overwrite Xi_c0 decays
        P8gen.SetParameters("4132:new  Xi_c0            Xi_cbar0    2   0   0    2.47088    0.00000    0.00000    0.00000  3.36000e-02   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("4132:new Xi_c0  Xi_cbar0     2 0 0 2.47088 0.00000 0.00000 0.00000 3.36000e-02 0 1 0 1 0")\n')
        sumBR=0.
        if getbr(h,'xic0_Xi-_e',mass,couplings[0])>0.:
           P8gen.SetParameters("4132:addChannel      1  "+str(getbr(h,'xic0_Xi-_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015 3312")
	   if debug: cf.write('P8gen.SetParameters("4132:addChannel      1  '+str(getbr(h,'xic0_Xi-_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015 3312")\n')
           sumBR+=float(getbr(h,'xic0_Xi-_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'xic0_Xi-_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("4132:addChannel      1  "+str(getbr(h,'xic0_Xi-_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015 3312")
	   if debug: cf.write('P8gen.SetParameters("4132:addChannel      1  '+str(getbr(h,'xic0_Xi-_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015 3312")\n')
           sumBR+=float(getbr(h,'xic0_Xi-_mu',mass,couplings[1])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("4132:addChannel      1   "+str(1.-sumBR)+"    0       22      22")
	   if debug: cf.write('P8gen.SetParameters("4132:addChannel      1  '+str(1.-sumBR)+'    0       22      22")\n')
        #overwrite D0 decays
        P8gen.SetParameters("421:new  D0  Dbar0    1   0   0    1.86486    0.00000    0.00000    0.00000  1.22900e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("421:new D0      Dbar0         1 0 0 1.86486 0.00000 0.00000 0.00000 1.22900e-01  1 0 1 0")\n')
        sumBR=0.
        if getbr(h,'d0_K-_e',mass,couplings[0])>0.:
           P8gen.SetParameters("421:addChannel      1  "+str(getbr(h,'d0_K-_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015     -321")
	   if debug: cf.write('P8gen.SetParameters("421:addChannel       1  '+str(getbr(h,'d0_K-_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015     -321")\n')
           sumBR+=float(getbr(h,'d0_K-_e',mass,couplings[0])/maxsumBR)  
        if getbr(h,'d0_K*-_e',mass,couplings[0])>0.:
           P8gen.SetParameters("421:addChannel      1  "+str(getbr(h,'d0_K*-_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015     -323")
	   if debug: cf.write('P8gen.SetParameters("421:addChannel       1  '+str(getbr(h,'d0_K*-_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015     -323")\n')
           sumBR+=float(getbr(h,'d0_K*-_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'d0_K-_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("421:addChannel      1  "+str(getbr(h,'d0_K-_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015     -321")
	   if debug: cf.write('P8gen.SetParameters("421:addChannel       1  '+str(getbr(h,'d0_K-_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015     -321")\n')
           sumBR+=float(getbr(h,'d0_K-_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'d0_K*-_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("421:addChannel      1  "+str(getbr(h,'d0_K*-_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015     -323")
	   if debug: cf.write('P8gen.SetParameters("421:addChannel       1  '+str(getbr(h,'d0_K*-_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015     -323")\n')
           sumBR+=float(getbr(h,'d0_K*-_mu',mass,couplings[1])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("421:addChannel      1   "+str(1.-sumBR)+"    0       22      22")
           if debug: cf.write('P8gen.SetParameters("421:addChannel       1  '+str(1.-sumBR)+'    0       22      22")\n')

        #overwrite tau- decays
        P8gen.SetParameters("15:new  tau-  tau+    2   -3   0    1.77682    0.00000    0.00000    0.00000  8.71100e-02   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("15:new  tau-     tau+         2 -3 0 1.77682 0.00000 0.00000 0.00000 8.71100e-02 0 1 0 1 0")\n')
        sumBR=0.
        if getbr(h,'tau_pi-',mass,couplings[2])>0.:
           P8gen.SetParameters("15:addChannel      1  "+str(getbr(h,'tau_pi-',mass,couplings[2])/maxsumBR)+" 1521       9900015     -211")
	   if debug: cf.write('P8gen.SetParameters("15:addChannel        1  '+str(getbr(h,'tau_pi-',mass,couplings[2])/maxsumBR)+' 1521       9900015     -211")\n')
           sumBR+=float(getbr(h,'tau_pi-',mass,couplings[2])/maxsumBR) 
        if getbr(h,'tau_K-',mass,couplings[2])>0.:
           P8gen.SetParameters("15:addChannel      1  "+str(getbr(h,'tau_K-',mass,couplings[2])/maxsumBR)+" 1521       9900015     -321")
	   if debug: cf.write('P8gen.SetParameters("15:addChannel        1  '+str(getbr(h,'tau_K-',mass,couplings[2])/maxsumBR)+' 1521       9900015     -321")\n')
           sumBR+=float(getbr(h,'tau_K-',mass,couplings[2])/maxsumBR) 
        if getbr(h,'tau_rho-',mass,couplings[2])>0.:
           P8gen.SetParameters("15:addChannel      1  "+str(getbr(h,'tau_rho-',mass,couplings[2])/maxsumBR)+" 1521       9900015     -213")
	   if debug: cf.write('P8gen.SetParameters("15:addChannel        1  '+str(getbr(h,'tau_rho-',mass,couplings[2])/maxsumBR)+' 1521       9900015     -213")\n')
           sumBR+=float(getbr(h,'tau_rho-',mass,couplings[2])/maxsumBR) 
        if getbr(h,'tau_nu_e_bar_e',mass,couplings[2])>0.:
           P8gen.SetParameters("15:addChannel      1  "+str(getbr(h,'tau_nu_e_bar_e',mass,couplings[2])/maxsumBR)+" 1531       9900015       11      -12")
	   if debug: cf.write('P8gen.SetParameters("15:addChannel        1  '+str(getbr(h,'tau_nu_e_bar_e',mass,couplings[2])/maxsumBR)+' 1531       9900015       11      -12")\n')
           sumBR+=float(getbr(h,'tau_nu_e_bar_e',mass,couplings[2])/maxsumBR) 
        if getbr(h,'tau_nu_tau_e',mass,couplings[2])>0.:
           P8gen.SetParameters("15:addChannel      1  "+str(getbr(h,'tau_nu_tau_e',mass,couplings[2])/maxsumBR)+" 1531       9900015       11      -16")
	   if debug: cf.write('P8gen.SetParameters("15:addChannel        1  '+str(getbr(h,'tau_nu_tau_e',mass,couplings[2])/maxsumBR)+' 1531       9900015       11      -16")\n')
           sumBR+=float(getbr(h,'tau_nu_tau_e',mass,couplings[2])/maxsumBR) 
        if getbr(h,'tau_nu_mu_bar_mu',mass,couplings[2])>0.:
           P8gen.SetParameters("15:addChannel      1  "+str(getbr(h,'tau_nu_mu_bar_mu',mass,couplings[2])/maxsumBR)+" 1531       9900015       13      -14")
	   if debug: cf.write('P8gen.SetParameters("15:addChannel        1  '+str(getbr(h,'tau_nu_mu_bar_mu',mass,couplings[2])/maxsumBR)+' 1531       9900015       13      -14")\n')
           sumBR+=float(getbr(h,'tau_nu_mu_bar_mu',mass,couplings[2])/maxsumBR) 
        if getbr(h,'tau_nu_tau_mu',mass,couplings[2])>0.:
           P8gen.SetParameters("15:addChannel      1  "+str(getbr(h,'tau_nu_tau_mu',mass,couplings[2])/maxsumBR)+" 1531       9900015       13      -16")
	   if debug: cf.write('P8gen.SetParameters("15:addChannel        1  '+str(getbr(h,'tau_nu_tau_mu',mass,couplings[2])/maxsumBR)+' 1531       9900015       13      -16")\n')
           sumBR+=float(getbr(h,'tau_nu_tau_mu',mass,couplings[2])/maxsumBR) 

        #overwrite D_s+ decays
        P8gen.SetParameters("431:new  D_s+  D_s-    1   3   0    1.96849    0.00000    0.00000    0.00000  1.49900e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("431:new  D_s+      D_s-        1 3 0 1.96849 0.00000 0.00000 0.00000 1.49900e-01 0 1 0 1 0")\n')
        sumBR=0.
        if getbr(h,'ds_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("431:addChannel      1  "+str(getbr(h,'ds_mu',mass,couplings[1])/maxsumBR)+"    0      -13       9900015")
	   if debug: cf.write('P8gen.SetParameters("431:addChannel       1  '+str(getbr(h,'ds_mu',mass,couplings[1])/maxsumBR)+'    0      -13       9900015")\n')
           sumBR+=float(getbr(h,'ds_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'ds_e',mass,couplings[1])>0.:
           P8gen.SetParameters("431:addChannel      1  "+str(getbr(h,'ds_e',mass,couplings[0])/maxsumBR)+"    0      -11       9900015")
	   if debug: cf.write('P8gen.SetParameters("431:addChannel       1  '+str(getbr(h,'ds_e',mass,couplings[0])/maxsumBR)+'    0      -11       9900015")\n')
           sumBR+=float(getbr(h,'ds_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'ds_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("431:addChannel      1  "+str(getbr(h,'ds_tau',mass,couplings[2])/maxsumBR)+"    0      -15       9900015")
	   if debug: cf.write('P8gen.SetParameters("431:addChannel       1  '+str(getbr(h,'ds_tau',mass,couplings[2])/maxsumBR)+'    0      -15       9900015")\n')
           sumBR+=float(getbr(h,'ds_tau',mass,couplings[2])/maxsumBR) 
        P8gen.SetParameters("431:addChannel      1  "+str(totaltauBR/maxsumBR)+"    0      -15       16")
	if debug: cf.write('P8gen.SetParameters("431:addChannel       1  '+str(totaltauBR/maxsumBR)+'    0      -15       16")\n')
        sumBR+=float(totaltauBR/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("431:addChannel      1   "+str(1.-sumBR)+"    0       22      -11")
	   if debug: cf.write('P8gen.SetParameters("431:addChannel       1  '+str(1.-sumBR)+'    0       22      22")\n')
        #overwrite Lambda_c+ decays
        P8gen.SetParameters("4122:new  Lambda_c+   Lambda_cbar-    2   3   0    2.28646    0.00000    0.00000    0.00000  5.99000e-02   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("4122:new Lambda_c+ Lambda_cbar- 2 3 0 2.28646 0.00000 0.00000 0.00000 5.99000e-02 0 1 0 1 0")\n')
        sumBR=0
        if getbr(h,'lambdac_Lambda0_e',mass,couplings[0])>0.:
           P8gen.SetParameters("4122:addChannel      1  "+str(getbr(h,'lambdac_Lambda0_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015     3122")
	   if debug: cf.write('P8gen.SetParameters("4122:addChannel      1  '+str(getbr(h,'lambdac_Lambda0_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015     3122")\n')
           sumBR+=float(getbr(h,'lambdac_Lambda0_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'lambdac_Lambda0_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("4122:addChannel      1  "+str(getbr(h,'lambdac_Lambda0_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015     3122")
	   if debug: cf.write('P8gen.SetParameters("4122:addChannel      1  '+str(getbr(h,'lambdac_Lambda0_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015     3122")\n')
           sumBR+=float(getbr(h,'lambdac_Lambda0_mu',mass,couplings[1])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("4122:addChannel      1   "+str(1.-sumBR)+"    0       22      -11")
	   if debug: cf.write('P8gen.SetParameters("4122:addChannel      1  '+str(1.-sumBR)+'    0       22      22")\n')

        #overwrite D+ decays
        P8gen.SetParameters("411:new  D+ D-    1   3   0    1.86962    0.00000    0.00000    0.00000  3.11800e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("411:new D+          D-        1 3 0 1.86962 0.00000 0.00000 0.00000 3.11800e-01 0 1 0 1 0")\n')
        sumBR=0.
        if getbr(h,'d_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("411:addChannel      1  "+str(getbr(h,'d_mu',mass,couplings[1])/maxsumBR)+"    0      -13       9900015")
	   if debug: cf.write('P8gen.SetParameters("411:addChannel       1  '+str(getbr(h,'d_mu',mass,couplings[1])/maxsumBR)+'    0      -13       9900015")\n')
           sumBR+=float(getbr(h,'d_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'d_e',mass,couplings[1])>0.:
           P8gen.SetParameters("411:addChannel      1  "+str(getbr(h,'d_e',mass,couplings[0])/maxsumBR)+"    0      -11       9900015")
	   if debug: cf.write('P8gen.SetParameters("411:addChannel       1  '+str(getbr(h,'d_e',mass,couplings[0])/maxsumBR)+'    0      -11       9900015")\n')
           sumBR+=float(getbr(h,'d_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'d_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("411:addChannel      1  "+str(getbr(h,'d_tau',mass,couplings[2])/maxsumBR)+"    0      -15       9900015")
	   if debug: cf.write('P8gen.SetParameters("411:addChannel       1  '+str(getbr(h,'d_tau',mass,couplings[2])/maxsumBR)+'    0      -15       9900015")\n')
           sumBR+=float(getbr(h,'d_tau',mass,couplings[2])/maxsumBR) 
        if getbr(h,'d_K0_e',mass,couplings[0])>0.:
           P8gen.SetParameters("411:addChannel      1  "+str(getbr(h,'d_K0_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015      311")
	   if debug: cf.write('P8gen.SetParameters("411:addChannel       1  '+str(getbr(h,'d_K0_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015      311")\n')
           sumBR+=float(getbr(h,'d_K0_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'d_K0_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("411:addChannel      1  "+str(getbr(h,'d_K0_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015      311")
	   if debug: cf.write('P8gen.SetParameters("411:addChannel       1  '+str(getbr(h,'d_K0_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015      311")\n')
           sumBR+=float(getbr(h,'d_K0_mu',mass,couplings[1])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("411:addChannel      1   "+str(1.-sumBR)+"    0       22      -11")
	   if debug: cf.write('P8gen.SetParameters("411:addChannel       1  '+str(1.-sumBR)+'    0       22      22")\n')
        P8gen.List(9900015)
	if debug: cf.write('P8gen.List(9900015)\n')
    if inclusive=="b":
        P8gen.SetParameters("HardQCD::hardbbbar  = on")
	if debug: cf.write('P8gen.SetParameters("HardQCD::hardbbbar  = on")\n')
        # add HNL
        #ctau = 5.4E+06 # for tests use 5.4E+03  # nominal ctau = 54 km = 5.4E+06 cm = 5.4E+07 mm
        #mass = 1.0 # GeV
        hnl_instance = hnl.HNL(mass, couplings, debug=True)
        ctau = hnl_instance.computeNLifetime(system="FairShip") * u.c_light * u.cm
        P8gen.SetParameters("9900015:new = N2 N2 2 0 0 "+str(mass)+" 0.0 0.0 0.0 "+str(ctau/u.mm)+"  0   1   0   1   0") 
	if debug: cf.write('P8gen.SetParameters("9900015:new = N2 N2 2 0 0 '+str(mass)+' 0.0 0.0 0.0 '+str(ctau/u.mm)+'  0   1   0   1   0")\n')
        P8gen.SetParameters("9900015:isResonance = false")
	if debug: cf.write('P8gen.SetParameters("9900015:isResonance = false"\n')
        # Configuring decay modes...
        readDecayTable.addHNLdecayChannels(P8gen, hnl_instance, conffile=os.path.expandvars('$FAIRSHIP/python/DecaySelection.conf'), verbose=True)
        # Finish HNL setup...
        P8gen.SetParameters("9900015:mayDecay = on")
	if debug: cf.write('P8gen.SetParameters("9900015:mayDecay = on")\n')
        P8gen.SetHNLId(9900015)
	if debug: cf.write('P8gen.SetHNLId(9900015)\n')
        # also add to PDG
        gamma = u.hbarc / float(ctau) #197.3269631e-16 / float(ctau) # hbar*c = 197 MeV*fm = 197e-16 GeV*cm
        addHNLtoROOT(pid=9900015,m=mass,g=gamma)
        # 12 14 16 neutrinos replace with N2
        beautyhistograms = ['bc_tau','b_D*0_bar_tau','bs_D_s-_tau','b_tau','lambdab_Lambda_c+_tau','Xib_Xi_c+_tau','Omega_b-_tau','b0_D*-_tau','bs_D*_s-_tau','b_D0_bar_tau','b0_D-_tau','b_e','bc_e','b_D*0_bar_e','b_D0_bar_e','b0_D*-_e','b0_D-_e','bs_D_s-_e','bs_D*_s-_e','bc_B_s0_e','bc_B0_e','bc_B*0_e','bc_B*_s0_e','lambdab_Lambda_c+_e','Xib_Xi_c+_e','Omega_b-_e','b_mu','bc_mu','b_D*0_bar_mu','b_D0_bar_mu','b0_D-_mu','b0_D*-_mu','bs_D_s-_mu','bs_D*_s-_mu','bc_B_s0_mu','bc_B0_mu','bc_B*0_mu','bc_B*_s0_mu','lambdab_Lambda_c+_mu','Xib_Xi_c+_mu','Omega_b-_mu','b_mu',] 
        maxsumBR=getmaxsumbr(h,beautyhistograms,mass,couplings,0.)
        if maxsumBR==0.:
           print "No phase space for HNL from b at this mass:",mass,". Quitting."
           sys.exit()
        totalBR=gettotalbr(h,beautyhistograms,mass,couplings,0.)
        #overwrite Lambda_b0 decays
        P8gen.SetParameters("5122:new  Lambda_b0        Lambda_bbar0    2   0   0    5.61940    0.00000    0.00000    0.00000  3.69000e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("5122:new  Lambda_b0        Lambda_bbar0    2   0   0    5.61940    0.00000    0.00000    0.00000  3.69000e-01   0   1   0   1   0")\n')
        sumBR=0.
        if getbr(h,'lambdab_Lambda_c+_e',mass,couplings[0])>0.:
           P8gen.SetParameters("5122:addChannel      1  "+str(getbr(h,'lambdab_Lambda_c+_e',mass,couplings[0])/maxsumBR)+"   22      9900015       11     4122")
	   if debug: cf.write('P8gen.SetParameters("5122:addChannel      1  '+str(getbr(h,'lambdab_Lambda_c+_e',mass,couplings[0])/maxsumBR)+'   22      9900015       11     4122")\n')
           sumBR+=float(getbr(h,'lambdab_Lambda_c+_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'lambdab_Lambda_c+_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("5122:addChannel      1  "+str(getbr(h,'lambdab_Lambda_c+_mu',mass,couplings[1])/maxsumBR)+"   22      9900015       13     4122")
	   if debug: cf.write('P8gen.SetParameters("5122:addChannel      1  '+str(getbr(h,'lambdab_Lambda_c+_mu',mass,couplings[1])/maxsumBR)+'   22      9900015       13     4122")\n')
           sumBR+=float(getbr(h,'lambdab_Lambda_c+_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'lambdab_Lambda_c+_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("5122:addChannel      1  "+str(getbr(h,'lambdab_Lambda_c+_tau',mass,couplings[2])/maxsumBR)+"   22      9900015       15     4122")
	   if debug: cf.write('P8gen.SetParameters("5122:addChannel      1  '+str(getbr(h,'lambdab_Lambda_c+_tau',mass,couplings[2])/maxsumBR)+'   22      9900015       15     4122")\n')
           sumBR+=float(getbr(h,'lambdab_Lambda_c+_tau',mass,couplings[2])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("5122:addChannel      1   "+str(1.-sumBR)+"    0       22      -11")
	   if debug: cf.write('P8gen.SetParameters("5122:addChannel      1   '+str(1.-sumBR)+'    0       22      22")\n')
        #overwrite B+ decays
        P8gen.SetParameters("521:new  B+               B-    1   3   0    5.27925    0.00000    0.00000    0.00000  4.91100e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("521:new  B+               B-    1   3   0    5.27925    0.00000    0.00000    0.00000  4.91100e-01   0   1   0   1   0")\n')
        sumBR=0.
        if getbr(h,'b_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_tau',mass,couplings[2])/maxsumBR)+"    0       9900015      -15")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_tau',mass,couplings[2])/maxsumBR)+'    0       9900015      -15")\n')
           sumBR+=float(getbr(h,'b_tau',mass,couplings[2])/maxsumBR) 
        if getbr(h,'b_mu',mass,couplings[2])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_mu',mass,couplings[1])/maxsumBR)+"    0       9900015      -13")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_mu',mass,couplings[1])/maxsumBR)+'    0       9900015      -13")\n')
           sumBR+=float(getbr(h,'b_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'b_e',mass,couplings[2])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_e',mass,couplings[0])/maxsumBR)+"    0       9900015      -11")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_e',mass,couplings[0])/maxsumBR)+'    0       9900015      -11")\n')
           sumBR+=float(getbr(h,'b_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'b_D0_bar_e',mass,couplings[0])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_D0_bar_e',mass,couplings[0])/maxsumBR)+"   22       9900015      -11     -421")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_D0_bar_e',mass,couplings[0])/maxsumBR)+'   22       9900015      -11     -421")\n')
           sumBR+=float(getbr(h,'b_D0_bar_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'b_D*0_bar_e',mass,couplings[0])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_D*0_bar_e',mass,couplings[0])/maxsumBR)+"   22       9900015      -11     -423")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_D*0_bar_e',mass,couplings[0])/maxsumBR)+'   22       9900015      -11     -423")\n')
           sumBR+=float(getbr(h,'b_D*0_bar_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'b_D0_bar_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_D0_bar_mu',mass,couplings[1])/maxsumBR)+"   22       9900015      -13     -421")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_D0_bar_mu',mass,couplings[1])/maxsumBR)+'   22       9900015      -13     -421")\n')
           sumBR+=float(getbr(h,'b_D0_bar_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'b_D*0_bar_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_D*0_bar_mu',mass,couplings[1])/maxsumBR)+"   22       9900015      -13     -423")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_D*0_bar_mu',mass,couplings[1])/maxsumBR)+'   22       9900015      -13     -423")\n')
           sumBR+=float(getbr(h,'b_D*0_bar_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'b_D0_bar_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_D0_bar_tau',mass,couplings[2])/maxsumBR)+"   22       9900015      -15     -421")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_D0_bar_tau',mass,couplings[2])/maxsumBR)+'   22       9900015      -15     -421")\n')
           sumBR+=float(getbr(h,'b_D0_bar_tau',mass,couplings[2])/maxsumBR) 
        if getbr(h,'b_D*0_bar_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("521:addChannel      1  "+str(getbr(h,'b_D*0_bar_tau',mass,couplings[2])/maxsumBR)+"   22       9900015      -15     -423")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1  '+str(getbr(h,'b_D*0_bar_tau',mass,couplings[2])/maxsumBR)+'   22       9900015      -15     -423")\n')
           sumBR+=float(getbr(h,'b_D*0_bar_tau',mass,couplings[2])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("521:addChannel      1   "+str(1.-sumBR)+"    0       22      22")
	   if debug: cf.write('P8gen.SetParameters("521:addChannel      1   '+str(1.-sumBR)+'    0       22      22")\n')
        #overwrite Xi_b0 decays
        P8gen.SetParameters("5232:new  Xi_b0            Xi_bbar0    2   0   0    5.78800    0.00000    0.00000    0.00000  3.64000e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("5232:new  Xi_b0            Xi_bbar0    2   0   0    5.78800    0.00000    0.00000    0.00000  3.64000e-01   0   1   0   1   0")\n')
        sumBR=0.
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("5232:addChannel      1   "+str(1.-sumBR)+"    0       22      22")
	   if debug: cf.write('P8gen.SetParameters("5232:addChannel      1   '+str(1.-sumBR)+'    0       22      22")\n')

        #overwrite B_s0 decays
        P8gen.SetParameters("531:new  B_s0             B_sbar0    1   0   0    5.36677    0.00000    0.00000    0.00000  4.39000e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("531:new  B_s0             B_sbar0    1   0   0    5.36677    0.00000    0.00000    0.00000  4.39000e-01   0   1   0   1   0")\n')
        sumBR=0.
        if getbr(h,'bs_D_s-_e',mass,couplings[0])>0.:
           P8gen.SetParameters("531:addChannel      1  "+str(getbr(h,'bs_D_s-_e',mass,couplings[0])/maxsumBR)+"   22       9900015      -11     -431")
	   if debug: cf.write('P8gen.SetParameters("531:addChannel      1  '+str(getbr(h,'bs_D_s-_e',mass,couplings[0])/maxsumBR)+'   22       9900015      -11     -431")\n')
           sumBR+=float(getbr(h,'bs_D_s-_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'bs_D*_s-_e',mass,couplings[0])>0.:
           P8gen.SetParameters("531:addChannel      1  "+str(getbr(h,'bs_D*_s-_e',mass,couplings[0])/maxsumBR)+"   22       9900015      -11     -433")
	   if debug: cf.write('P8gen.SetParameters("531:addChannel      1  '+str(getbr(h,'bs_D*_s-_e',mass,couplings[0])/maxsumBR)+'   22       9900015      -11     -433")\n')
           sumBR+=float(getbr(h,'bs_D*_s-_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'bs_D_s-_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("531:addChannel      1  "+str(getbr(h,'bs_D_s-_mu',mass,couplings[1])/maxsumBR)+"   22       9900015      -13     -431")
	   if debug: cf.write('P8gen.SetParameters("531:addChannel      1  '+str(getbr(h,'bs_D_s-_mu',mass,couplings[1])/maxsumBR)+'   22       9900015      -13     -431")\n')
           sumBR+=float(getbr(h,'bs_D_s-_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'bs_D*_s-_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("531:addChannel      1  "+str(getbr(h,'bs_D*_s-_mu',mass,couplings[1])/maxsumBR)+"   22       9900015      -13     -433")
	   if debug: cf.write('P8gen.SetParameters("531:addChannel      1  '+str(getbr(h,'bs_D*_s-_mu',mass,couplings[1])/maxsumBR)+'   22       9900015      -13     -433")\n')
           sumBR+=float(getbr(h,'bs_D*_s-_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'bs_D_s-_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("531:addChannel      1  "+str(getbr(h,'bs_D_s-_tau',mass,couplings[2])/maxsumBR)+"   22       9900015      -15     -431")
	   if debug: cf.write('P8gen.SetParameters("531:addChannel      1  '+str(getbr(h,'bs_D_s-_tau',mass,couplings[2])/maxsumBR)+'   22       9900015      -15     -431")\n')
           sumBR+=float(getbr(h,'bs_D_s-_tau',mass,couplings[2])/maxsumBR) 
        if getbr(h,'bs_D*_s-_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("531:addChannel      1  "+str(getbr(h,'bs_D*_s-_tau',mass,couplings[2])/maxsumBR)+"   22       9900015      -15     -433")
	   if debug: cf.write('P8gen.SetParameters("531:addChannel      1  '+str(getbr(h,'bs_D*_s-_tau',mass,couplings[2])/maxsumBR)+'   22       9900015      -15     -433")\n')
           sumBR+=float(getbr(h,'bs_D*_s-_tau',mass,couplings[2])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("531:addChannel      1   "+str(1.-sumBR)+"    0       22      22")
	   if debug: cf.write('P8gen.SetParameters("531:addChannel      1   '+str(1.-sumBR)+'    0       22      22")\n')

        #overwrite Omega_b- decays
        P8gen.SetParameters("5332:new  Omega_b-         Omega_bbar+    2   -3   0    6.07000    0.00000    0.00000    0.00000  3.64000e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("5332:new  Omega_b-         Omega_bbar+    2   -3   0    6.07000    0.00000    0.00000    0.00000  3.64000e-01   0   1   0   1   0")\n')
        sumBR=0.
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("5332:addChannel      1   "+str(1.-sumBR)+"    0       22      11")
	   if debug: cf.write('P8gen.SetParameters("5332:addChannel      1   '+str(1.-sumBR)+'    0       22      22")\n')

        #overwrite B_c+ decays
        P8gen.SetParameters("541:new  B_c+             B_c-    1   3   0    6.27700    0.00000    0.00000    0.00000  1.38000e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("541:new  B_c+             B_c-    1   3   0    6.27700    0.00000    0.00000    0.00000  1.38000e-01   0   1   0   1   0")\n')
        sumBR=0.
        if getbr(h,'bc_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_tau',mass,couplings[2])/maxsumBR)+"    0       9900015      -15")
	   if debug: cf.write(' P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_tau',mass,couplings[2])/maxsumBR)+'    0       9900015      -15")\n')
           sumBR+=float(getbr(h,'bc_tau',mass,couplings[2])/maxsumBR) 
        if getbr(h,'bc_e',mass,couplings[2])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_e',mass,couplings[0])/maxsumBR)+"    0       9900015      -11")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_e',mass,couplings[0])/maxsumBR)+'    0       9900015      -11")\n')
           sumBR+=float(getbr(h,'bc_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'bc_mu',mass,couplings[2])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_mu',mass,couplings[1])/maxsumBR)+"    0       9900015      -13")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_mu',mass,couplings[1])/maxsumBR)+'    0       9900015      -13")\n')
           sumBR+=float(getbr(h,'bc_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'bc_B0_e',mass,couplings[0])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_B0_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015      511")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_B0_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015      511")\n')
           sumBR+=float(getbr(h,'bc_B0_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'bc_B*0_e',mass,couplings[0])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_B*0_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015      513")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_B*0_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015      513")\n')
           sumBR+=float(getbr(h,'bc_B*0_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'bc_B_s0_e',mass,couplings[0])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_B_s0_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015      531")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_B_s0_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015      531")\n')
           sumBR+=float(getbr(h,'bc_B_s0_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'bc_B*_s0_e',mass,couplings[0])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_B*_s0_e',mass,couplings[0])/maxsumBR)+"   22      -11       9900015      533")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_B*_s0_e',mass,couplings[0])/maxsumBR)+'   22      -11       9900015      533")\n')
           sumBR+=float(getbr(h,'bc_B*_s0_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'bc_B0_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_B0_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015      511")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_B0_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015      511")\n')
           sumBR+=float(getbr(h,'bc_B0_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'bc_B*0_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_B*0_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015      513")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_B*0_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015      513")\n')
           sumBR+=float(getbr(h,'bc_B*0_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'bc_B_s0_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_B_s0_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015      531")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_B_s0_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015      531")\n')
           sumBR+=float(getbr(h,'bc_B_s0_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'bc_B*_s0_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("541:addChannel      1  "+str(getbr(h,'bc_B*_s0_mu',mass,couplings[1])/maxsumBR)+"   22      -13       9900015      533")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1  '+str(getbr(h,'bc_B*_s0_mu',mass,couplings[1])/maxsumBR)+'   22      -13       9900015      533")\n')
           sumBR+=float(getbr(h,'bc_B*_s0_mu',mass,couplings[1])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("541:addChannel      1   "+str(1.-sumBR)+"    0       22      -11")
	   if debug: cf.write('P8gen.SetParameters("541:addChannel      1   '+str(1.-sumBR)+'    0       22      22")\n')

        #overwrite B0 decays
        P8gen.SetParameters("511:new  B0  Bbar0    1   0   0    5.27958    0.00000    0.00000    0.00000  4.58700e-01   0   1   0   1   0")
	if debug: cf.write('P8gen.SetParameters("511:new  B0  Bbar0    1   0   0    5.27958    0.00000    0.00000    0.00000  4.58700e-01   0   1   0   1   0")\n')
        sumBR=0.
        if getbr(h,'b0_D-_e',mass,couplings[0])>0.:
           P8gen.SetParameters("511:addChannel      1  "+str(getbr(h,'b0_D-_e',mass,couplings[0])/maxsumBR)+"   22       9900015      -11     -411")
	   if debug: cf.write('P8gen.SetParameters("511:addChannel      1  '+str(getbr(h,'b0_D-_e',mass,couplings[0])/maxsumBR)+'   22       9900015      -11     -411")\n')
           sumBR+=float(getbr(h,'b0_D-_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'b0_D*-_e',mass,couplings[0])>0.:
           P8gen.SetParameters("511:addChannel      1  "+str(getbr(h,'b0_D*-_e',mass,couplings[0])/maxsumBR)+"   22       9900015      -11     -413")
	   if debug: cf.write('P8gen.SetParameters("511:addChannel      1  '+str(getbr(h,'b0_D*-_e',mass,couplings[0])/maxsumBR)+'   22       9900015      -11     -413")\n')
           sumBR+=float(getbr(h,'b0_D*-_e',mass,couplings[0])/maxsumBR) 
        if getbr(h,'b0_D-_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("511:addChannel      1  "+str(getbr(h,'b0_D-_mu',mass,couplings[1])/maxsumBR)+"   22       9900015      -13     -411")
	   if debug: cf.write('P8gen.SetParameters("511:addChannel      1  '+str(getbr(h,'b0_D-_mu',mass,couplings[1])/maxsumBR)+'   22       9900015      -13     -411")\n')
           sumBR+=float(getbr(h,'b0_D-_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'b0_D*-_mu',mass,couplings[1])>0.:
           P8gen.SetParameters("511:addChannel      1  "+str(getbr(h,'b0_D*-_mu',mass,couplings[1])/maxsumBR)+"   22       9900015      -13     -413")
	   if debug: cf.write('P8gen.SetParameters("511:addChannel      1  '+str(getbr(h,'b0_D*-_mu',mass,couplings[1])/maxsumBR)+'   22       9900015      -13     -413")\n')
           sumBR+=float(getbr(h,'b0_D*-_mu',mass,couplings[1])/maxsumBR) 
        if getbr(h,'b0_D-_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("511:addChannel      1  "+str(getbr(h,'b0_D-_tau',mass,couplings[2])/maxsumBR)+"   22       9900015      -15     -411")
	   if debug: cf.write('P8gen.SetParameters("511:addChannel      1  '+str(getbr(h,'b0_D-_tau',mass,couplings[2])/maxsumBR)+'   22       9900015      -15     -411")\n')
           sumBR+=float(getbr(h,'b0_D-_tau',mass,couplings[2])/maxsumBR) 
        if getbr(h,'b0_D*-_tau',mass,couplings[2])>0.:
           P8gen.SetParameters("511:addChannel      1  "+str(getbr(h,'b0_D*-_tau',mass,couplings[2])/maxsumBR)+"   22       9900015      -15     -413")
	   if debug: cf.write('P8gen.SetParameters("511:addChannel      1  '+str(getbr(h,'b0_D*-_tau',mass,couplings[2])/maxsumBR)+'   22       9900015      -15     -413")\n')
           sumBR+=float(getbr(h,'b0_D*-_tau',mass,couplings[2])/maxsumBR) 
        if sumBR<1. and sumBR>0.:
           P8gen.SetParameters("511:addChannel      1   "+str(1.-sumBR)+"    0       22      22")
	   if debug: cf.write('P8gen.SetParameters("511:addChannel      1   '+str(1.-sumBR)+'    0       22      22")\n')
        P8gen.List(9900015)
        if debug: cf.write('P8gen.List(9900015)\n')
    if debug: cf.close()