13ROOT.gROOT.LoadMacro(
"$VMCWORKDIR/gconfig/basiclibs.C")
17fname =
"/eos/experiment/ship/data/Charm/Cascade-parp16-MSTP82-1-MSEL4-76Mpot_1"
24print(
"usage: python $FAIRSHIP/macro/makeDecay.py -f ")
27 opts, args = getopt.getopt(sys.argv[1:],
"f:p:c:", [
"pot=",
"chicc="])
28except getopt.GetoptError:
30 print(
" enter -f: input file with charm hadrons")
31 print(
" for experts: p pot= number of protons on target per spill to normalize on")
32 print(
" : c chicc= ccbar over mbias cross section")
36 fname = a.replace(
".root",
"")
37 if o
in (
"-p",
"--pot"):
39 if o
in (
"-c",
"--chicc"):
44tmp = os.path.abspath(FIN).split(
"/")
45FOUT =
"Decay-" + tmp[len(tmp) - 1]
46if FIN.find(
"eos") < 0:
49 fin = ROOT.TFile.Open(ROOT.gSystem.Getenv(
"EOSSHIP") + FIN)
50sTree = fin.FindObjectAny(
"pythia6")
51nEvents = sTree.GetEntries()
57 hc[
"2"] = fin.Get(
"2")
59 fhin = ROOT.TFile(FIN.replace(
"ntuple",
"hists"))
60 hc[
"2"] = fhin.Get(
"2")
63nrcpot = hc[
"2"].GetBinContent(1) / 2.0
64print(
"Input file: ", FIN,
" with ", nEvents,
" entries, corresponding to nr-pot=", nrcpot)
66print(
"Output ntuples written to: ", FOUT)
68P8gen = ROOT.TPythia8()
70P8.readString(
"ProcessLevel:all = off")
75 n = P8.particleData.nextId(n)
76 p = P8.particleData.particleDataEntryPtr(n)
78 command = str(n) +
":mayDecay = false"
79 P8.readString(command)
80 print(
"Pythia8 configuration: Made %s stable for Pythia, should decay in Geant4", p.name())
85ftup = ROOT.TFile.Open(FOUT,
"RECREATE")
86Ntup = ROOT.TNtuple(
"Decay",
"pythia8 heavy flavour decays",
"id:px:py:pz:E:M:weight:mid:mpx:mpy:mpz:mE:pot:ptGM:pzGM")
91PDG = ROOT.TDatabasePDG.Instance()
92for idnu
in range(12, 18, 2):
94 for idadd
in range(-1, 3, 2):
100 name = PDG.GetParticle(idw).GetName()
101 ut.bookHist(h, str(idhnu), name +
" momentum (GeV)", 400, 0.0, 400.0)
102 ut.bookHist(h, str(idhnu + 100), name +
" log10-p vs log10-pt", 100, -0.3, 1.7, 100, -2.0, 0.5)
103 ut.bookHist(h, str(idhnu + 200), name +
" log10-p vs log10-pt", 25, -0.3, 1.7, 100, -2.0, 0.5)
110for n
in range(nEvents):
111 rc = sTree.GetEvent(n)
114 if not setByHand
and sTree.M > 5:
116 print(
"automatic detection of beauty, configured for beauty")
117 print(
"bb cross section / mbias ", chicc)
119 print(
"cc cross section / mbias ", chicc)
121 print(
"weights: ", nrpotspill,
" p.o.t. per spill")
123 wspill = nrpotspill * chicc / nrcpot
125 pt = ROOT.TMath.Sqrt(sTree.mpx**2 + sTree.mpy**2)
127 if pt < 1.0e-5
and int(sTree.mid) == 2212:
130 idabs = int(abs(sTree.id))
134 P8.event.append(int(sTree.id), 1, 0, 0, sTree.px, sTree.py, sTree.pz, sTree.E, sTree.M, 0.0, 9.0)
137 for n
in range(len(P8.event)):
139 if P8.event[n].isFinal():
141 idabs = int(abs(P8.event[n].id()))
142 if idabs > 11
and idabs < 17:
144 ptGM = ROOT.TMath.Sqrt(sTree.mpx * sTree.mpx + sTree.mpy * sTree.mpy)
163 if idabs == 16
or idabs == 14
or idabs == 12:
167 pt2 = par.px() ** 2 + par.py() ** 2
168 ptot = ROOT.TMath.Sqrt(pt2 + par.pz() ** 2)
169 l10ptot = min(max(ROOT.TMath.Log10(ptot), -0.3), 1.69999)
170 l10pt = min(max(ROOT.TMath.Log10(ROOT.TMath.Sqrt(pt2)), -2.0), 0.4999)
171 h[str(idhnu)].Fill(ptot, wspill)
172 h[str(idhnu + 100)].Fill(l10ptot, l10pt, wspill)
173 h[str(idhnu + 200)].Fill(l10ptot, l10pt, wspill)
175print(
"Now at Ntup.Write() for pot=", pot, nrcpot)
176if (1.0 - pot / nrcpot) < 1.0e-2:
177 print(
"write ntuple, weight/event=", nrpotspill,
"x", chicc,
"/", nrcpot,
"=", wspill)
182 print(
"Neutrino statistics/spill of 5.e15 pot:")
183 for idnu
in range(12, 18, 2):
185 for idadd
in range(-1, 3, 2):
191 print(idhnu, h[str(idhnu)].GetTitle(), (
"%8.3E " % (h[str(idhnu)].Integral())))
193 fDsP6 = 1.0 * nDsprim / ntotprim
196 print(
"fDs of primary proton interactions in P6=", fDsP6,
" should be ", fDs)
199 print(
"*********** WARNING ***********")
200 print(
"number of POT does not agree between ntuple and hists, i.e.:", pot,
"<>", nrcpot)
201 print(
"mu/neutrino ntuple has NOT been written")