12ROOT.gRandom.SetSeed(0)
13theSeed = ROOT.gRandom.GetSeed()
15if theSeed > 900000000:
16 theSeed = theSeed % 900000000
17ROOT.gRandom.SetSeed(theSeed)
18ROOT.gSystem.Load(
"libpythia8")
20from argparse
import ArgumentParser
22parser = ArgumentParser()
23parser.add_argument(
"-b",
"--heartbeat", dest=
"heartbeat", type=int, help=
"progress report", default=10000)
24parser.add_argument(
"-n",
"--pot", dest=
"NPoT", type=int, help=
"protons on target", default=1000000)
25parser.add_argument(
"-r",
"--run", dest=
"run", type=int, help=
"production sequence number", default=0)
26parser.add_argument(
"-M",
"--Emin", dest=
"Emin", type=float, help=
"cutOff", default=1.0)
27parser.add_argument(
"-E",
"--Beam", dest=
"fMom", type=float, help=
"beam momentum", default=400.0)
28parser.add_argument(
"-J",
"--Jpsi-mainly", action=
"store_true", dest=
"JpsiMainly", default=
False)
29parser.add_argument(
"-Y",
"--DrellYan", action=
"store_true", dest=
"DrellYan", default=
False)
30parser.add_argument(
"-P",
"--PhotonCollision", action=
"store_true", dest=
"PhotonCollision", default=
False)
31parser.add_argument(
"-C",
"--charm", action=
"store_true", dest=
"charm", default=
False)
32parser.add_argument(
"-X",
"--PDFpSet", dest=
"PDFpSet", type=str, help=
"PDF pSet to use", default=
"13")
33parser.add_argument(
"-u",
"--uOnly", action=
"store_true", dest=
"uOnly", default=
False)
37options = parser.parse_args()
38print(
"start IGNOREIGNOREIGNOREIGNOREIGNOREIGNOREIGNOREIGNOREIGNORE")
39X = ROOT.FixedTargetGenerator()
40print(
"end IGNOREIGNOREIGNOREIGNOREIGNOREIGNOREIGNOREIGNOREIGNORE")
43def yBeam(Mproton: float = 0.938272081, pbeam: float = 400.0):
44 Ebeam = ROOT.TMath.Sqrt(pbeam**2 + Mproton**2)
45 betaCM = pbeam / (Ebeam + Mproton)
46 y_beam = 0.5 * ROOT.TMath.Log((1 + betaCM) / (1 - betaCM))
50generators = {
"p": ROOT.Pythia8.Pythia(),
"n": ROOT.Pythia8.Pythia()}
51generators[
"p"].settings.mode(
"Beams:idB", 2212)
52generators[
"n"].settings.mode(
"Beams:idB", 2112)
55 ut.bookHist(h,
"xsec_" + g,
" total cross section", 1, 0.0, 1.0)
56 ut.bookHist(h,
"M_" + g,
" N mu+mu-;M [GeV/c^{2}];y_{CM}", 500, 0.0, 10.0, 120, -3.0, 3.0, 100, 0.0, 5.0)
57 ut.bookHist(h,
"cosCS_" + g,
" N cosCS;cosCS;y_{CM}", 100, -1.0, 1.0, 120, -3.0, 3.0, 100, 0.0, 5.0)
58 ut.bookHist(h,
"cosCSJpsi_" + g,
" N cosCS 2.9<M<4.5;cosCS;y_{CM}", 100, -1.0, 1.0, 120, -3.0, 3.0, 100, 0.0, 5.0)
59 generators[g].settings.mode(
"Next:numberCount", options.heartbeat)
60 generators[g].settings.mode(
"Beams:idA", 2212)
61 generators[g].settings.mode(
"Beams:frameType", 2)
62 generators[g].settings.parm(
"Beams:eA", options.fMom)
63 generators[g].settings.parm(
"Beams:eB", 0.0)
64 generators[g].readString(
"PDF:pSet = " + options.PDFpSet)
66 generators[g].readString(
"WeakSingleBoson:ffbar2gmZ = on")
68 generators[g].readString(
"23:onMode = off")
69 generators[g].readString(
"23:onIfAll = 13 13")
70 generators[g].readString(
"23:mMin = " +
str(options.Emin))
71 generators[g].readString(
"PhaseSpace:mHatMin = " +
str(options.Emin))
73 generators[g].readString(
"PartonLevel:FSR = on")
74 elif options.JpsiMainly:
76 generators[g].readString(
"Onia:all(3S1) = on")
78 generators[g].readString(
"443:onMode = off")
79 generators[g].readString(
"443:onIfAll = 13 13")
80 generators[g].readString(
"553:onMode = off")
81 generators[g].readString(
"553:onIfAll = 13 13")
82 elif options.PhotonCollision:
83 generators[g].readString(
"PhotonCollision:gmgm2mumu = on")
84 generators[g].readString(
"PhaseSpace:mHatMin = " +
str(options.Emin))
86 generators[g].readString(
"HardQCD:hardccbar = on")
88 generators[g].readString(
"SoftQCD:inelastic = on")
91rc = generators[
"p"].next()
92processes = generators[
"p"].info.codesHard()
99 + generators[
"p"].info.nameProc(processes[0])
101hname = hname.replace(
"*",
"star")
102hname = hname.replace(
"->",
"to")
103hname = hname.replace(
"/",
"")
105f = ROOT.TFile(
"ntuple-" + hname +
".root",
"RECREATE")
106signal = ROOT.TNtuple(
"ntuple",
"ntuple",
"M:P:Pt:y:p1x:p1y:p1z:p2x:p2y:p2z:cosCS")
108timer = ROOT.TStopwatch()
111ntagged = {
"p": 0,
"n": 0}
113for n
in range(
int(options.NPoT)):
118 for ii
in range(1, len(py.event)):
119 if options.DrellYan
and py.event[ii].id() != 23:
121 if options.PhotonCollision
and py.event[ii].id() != 22:
123 for m
in py.event.daughterList(ii):
124 if abs(py.event[m].id()) == 13:
130 Zstar = py.event[nmu[ks[0]]]
131 rc = h[
"M_" + g].Fill(Zstar.m(), py.event[nmu[ks[0]]].y() - ybeam, py.event[nmu[ks[0]]].pT())
134 d0 = py.event.daughterList(ii)[0]
135 d1 = py.event.daughterList(ii)[1]
136 if py.event[d0].id() < 0:
138 nantilep = py.event[d1]
141 nantilep = py.event[d0]
142 P1pl = nlep.e() + nlep.pz()
143 P2pl = nantilep.e() + nantilep.pz()
144 P1mi = nlep.e() - nlep.pz()
145 P2mi = nantilep.e() - nantilep.pz()
146 A = P1pl * P2mi - P2pl * P1mi
148 Zstar.pz() / abs(Zstar.pz()) * 1.0 / Zstar.m() / ROOT.TMath.Sqrt(Zstar.m2() + Zstar.pT() ** 2) * A
150 rc = h[
"cosCS_" + g].Fill(cosCS, Zstar.y() - ybeam, py.event[nmu[ks[0]]].pT())
151 if Zstar.m() > 2.9
and Zstar.m() < 4.5:
152 rc = h[
"cosCSJpsi_" + g].Fill(cosCS, py.event[nmu[ks[0]]].y() - ybeam, py.event[nmu[ks[0]]].pT())
166 if options.PhotonCollision:
170 M[k] = ROOT.TLorentzVector(py.event[m].px(), py.event[m].
py(), py.event[m].pz(), py.event[m].e())
173 rc = h[
"M_" + g].Fill(G.M(), G.Rapidity() - ybeam, G.Pt())
176print(
">>>> proton statistics, ntagged=", ntagged[
"p"])
177generators[
"p"].stat()
178print(
">>>> neutron statistics, ntagged=", ntagged[
"n"])
179generators[
"n"].stat()
182rtime = timer.RealTime()
183ctime = timer.CpuTime()
184print(
"run ", options.run,
" PoT ", options.NPoT,
" Real time ", rtime,
" s, CPU time ", ctime,
"s")
187 sigma = generators[g].info.sigmaGen(processes[0])
188 h[
"xsec_" + g].SetBinContent(1, sigma)
189ut.writeHists(h, hname +
".root")
192def na50(online: bool =
True) ->
None:
195 processes = generators[g].info.codesHard()
196 name = generators[g].info.nameProc(processes[0])
197 sigma = generators[g].info.sigmaGen(processes[0])
200 sigma = h[
"xsec_" + g].GetBinContent(1)
201 yax = h[
"M_" + g].GetYaxis()
202 xax = h[
"M_" + g].GetXaxis()
203 Mmin = xax.FindBin(2.9)
204 Mmax = xax.FindBin(4.5)
205 Ymin = yax.FindBin(-0.425)
206 Ymax = yax.FindBin(0.575)
207 h[
"MA"] = h[
"M_" + g].ProjectionX(
"MA")
208 h[
"M"] = h[
"M_" + g].ProjectionX(
"M", Ymin, Ymax)
209 print(
"generator sigma mumu-ratio in-mass-range in-y-range")
211 "%s %s %6.2F nbarn, %5.2F, %5.2G, %5.2F "
216 float(h[
"MA"].GetEntries()) / options.NPoT,
217 h[
"MA"].Integral(Mmin, Mmax) /
float(h[
"MA"].GetEntries()),
218 h[
"M"].GetEntries() /
float(h[
"MA"].GetEntries()),
221 fraction = h[
"M"].Integral(Mmin, Mmax) / options.NPoT
223 print(f
"cross section a la NA50 for : {g} {0.5 * fraction * sigma * 1e9:5.2F} pb")
227 processes = generators[g].info.codesHard()
228 name = generators[g].info.nameProc(processes[0])
229 sigma = generators[g].info.sigmaGen(processes[0])
232 sigma = h[
"xsec_" + g].GetBinContent(1)
233 yax = h[
"cosCSJpsi_" + g].GetYaxis()
234 xax = h[
"cosCSJpsi_" + g].GetXaxis()
235 Mmin = xax.FindBin(-0.5)
236 Mmax = xax.FindBin(0.5)
237 Ymin = yax.FindBin(-0.425)
238 Ymax = yax.FindBin(0.575)
239 h[
"MA"] = h[
"cosCSJpsi_" + g].ProjectionX(
"MA")
240 h[
"M"] = h[
"cosCSJpsi_" + g].ProjectionX(
"M", Ymin, Ymax)
241 print(
"generator sigma mumu-in-mass-range% cosCS in-y-range")
243 "%s %s %6.2F nbarn, %5.2F, %5.2F, %5.2F "
248 float(h[
"MA"].GetEntries()) / options.NPoT * 100.0,
249 h[
"MA"].Integral(Mmin, Mmax) /
float(h[
"MA"].GetEntries()),
250 h[
"M"].GetEntries() /
float(h[
"MA"].GetEntries()),
253 fraction = h[
"M"].Integral(Mmin, Mmax) / options.NPoT
255 print(
"cross section a la NA50, -0.5<cosCS<0.5: %5.2F pb" % (fraction * sigma * 1e9))
263 processes = generators[g].info.codesHard()
264 name = generators[g].info.nameProc(processes[0])
265 sigma = generators[g].info.sigmaGen(processes[0])
266 yax = h[
"M_" + g].GetYaxis()
267 xax = h[
"M_" + g].GetXaxis()
268 Mmin = xax.FindBin(0.0)
269 Mmax = xax.FindBin(5.0)
270 Ymin = yax.FindBin(0.3)
271 Ymax = yax.FindBin(3.0)
272 h[
"MA"] = h[
"M_" + g].ProjectionX(
"MA")
273 h[
"M"] = h[
"M_" + g].ProjectionX(
"M", Ymin, Ymax)
278 float(h[
"MA"].GetEntries()) / options.NPoT,
279 h[
"MA"].Integral(Mmin, Mmax) /
float(h[
"MA"].GetEntries()),
280 h[
"M"].GetEntries() /
float(h[
"MA"].GetEntries()),
282 fraction[g] = h[
"M"].Integral(Mmin, Mmax) / options.NPoT
283 meanFraction = (fraction[
"p"] * P_Mo + fraction[
"n"] * (Z_Mo - P_Mo)) / Z_Mo * sigma
284 print(
"cross section a la muflux: %5.2F pb" % (0.5 * meanFraction * 1e9))
288 generators[g].settings.listAll()
def yBeam(float Mproton=0.938272081, float pbeam=400.0)
None na50(bool online=True)