5ROOT.gRandom.SetSeed(theSeed)
6ROOT.gSystem.Load(
"libpythia8")
11ROOT.gInterpreter.Declare(
'''
12const Pythia8::Info& generator_info(Pythia8::Pythia& pythia) {
17nudict = {12:
"nue", -12:
"anue", 14:
"numu", -14:
"anumu", 16:
"nutau", -16:
"anutau"}
19from argparse
import ArgumentParser
20parser = ArgumentParser()
21parser.add_argument(
"-f",
"--nuflavour", action=
'append', type=int, dest=
'nu_flavour', help=
"neutrino flavour", default=
None)
22parser.add_argument(
"-b",
"--heartbeat", dest=
"heartbeat", type=int, help=
"progress report", default=10000)
23parser.add_argument(
"-n",
"--pot", dest=
"Np", type=int, help=
"proton collisions", default=1000000)
24parser.add_argument(
"-Ecm",
"--energyCM", dest=
"eCM", type=float, help=
"center of mass energy [GeV]", default=13000.)
25parser.add_argument(
'-C',
'--charm', action=
'store_true', dest=
'charm',help=
"ccbar production", default=
False)
26parser.add_argument(
'-B',
'--beauty', action=
'store_true', dest=
'beauty',help=
"bbbar production", default=
False)
27parser.add_argument(
'-H',
'--hard', action=
'store_true', dest=
'hard',help=
"all hard processes", default=
False)
28parser.add_argument(
'-X',
'--PDFpSet',dest=
"PDFpSet", type=str, help=
"PDF pSet to use", default=
"13")
29parser.add_argument(
'-EtaMin',dest=
"eta_min", type=float, help=
"minimum eta for neutrino to pass", default=6.)
30parser.add_argument(
'-EtaMax',dest=
"eta_max", type=float, help=
"maximum eta for neutrino to pass", default=10.)
36options = parser.parse_args()
37X=ROOT.Pythia8Generator()
40L=len(options.nu_flavour)
42 if i==L-1: nunames +=nudict[options.nu_flavour[i]]
43 else: nunames +=nudict[options.nu_flavour[i]]+
'_'
46generator = ROOT.Pythia8.Pythia()
47generator.settings.mode(
"Next:numberCount",options.heartbeat)
48generator.settings.mode(
"Beams:idA", 2212)
49generator.settings.mode(
"Beams:idB", 2212)
50generator.readString(
"Beams:eCM = "+
str(options.eCM));
55generator.readString(
"PDF:pSet = "+options.PDFpSet)
58 generator.readString(
"HardQCD:hardccbar = on")
61 generator.readString(
"HardQCD:hardbbbar = on")
64 generator.readString(
"HardQCD:all = on")
67 generator.readString(
"SoftQCD:inelastic = on")
72hname =
'pythia8_'+tag+
'_PDFpset'+options.PDFpSet+
'_'+nunames
73hname = hname.replace(
'*',
'star')
74hname = hname.replace(
'->',
'to')
75hname = hname.replace(
'/',
'')
77fout = ROOT.TFile(hname+
".root",
"RECREATE")
78dTree = ROOT.TTree(
'NuTree', nunames)
79dAnc = ROOT.TClonesArray(
"TParticle")
83dAncstrBranch = dTree.Branch(
"Ancstr",dAnc,32000,-1)
85evtId = array(
'i', [0])
86dEvtId = dTree.Branch(
"EvtId", evtId,
"evtId/I")
88timer = ROOT.TStopwatch()
93for n
in range(
int(options.Np)):
95 for ii
in range(1,py.event.size()):
97 if py.event[ii].isFinal()
and py.event[ii].id()
in options.nu_flavour:
100 if (eta > options.eta_min
and eta < options.eta_max)
or (eta < -options.eta_min
and eta > -options.eta_max):
102 neut = ROOT.TParticle(evt.id(), evt.status(),
103 evt.mother1(),evt.mother2(),0,0,
104 evt.px(),evt.py(),evt.pz(),evt.e(),
105 evt.xProd(),evt.yProd(),evt.zProd(),evt.tProd())
108 gm = py.event[ii].mother1()
112 anc = ROOT.TParticle(evtM.id(),evtM.status(),
113 evtM.mother1(),evtM.mother2(),evtM.daughter1(),evtM.daughter2(),
114 evtM.px(),evtM.py(),evtM.pz(),evtM.e(),
115 evtM.xProd(),evtM.yProd(),evtM.zProd(),evtM.tProd())
116 nAnc = dAnc.GetEntries()
117 if dAnc.GetSize() == nAnc: dAnc.Expand(nAnc+10)
119 gm = py.event[gm].mother1()
128rtime = timer.RealTime()
129ctime = timer.CpuTime()
131info = ROOT.generator_info(generator)
132processes = info.codesHard()
134 totalXsec+=info.sigmaGen(p)
137IntLumi = options.Np / totalXsec * 1E-12
139print(
"Saving to output %s neutrino flavour(s) having PDG ID(s)"%(nunames), options.nu_flavour)
140print(
"simulated events = %i, equivalent to integrated luminosity of %5.2G fb-1. Real time %6.1Fs, CPU time %6.1Fs"%(options.Np,IntLumi,rtime,ctime))
143print(
"corresponding to effective luminosity (folded with neutrino CC cross section at 100GeV) of %5.2G fb-1."%(IntLumi/4.8E-12))
147 generator.settings.listAll()