FairShip
Loading...
Searching...
No Matches
ana_ShipMuon Namespace Reference

Functions

 origin (sTree, it)
None makeProd ()
 detMap ()
None fitSingleGauss (x, ba=None, be=None)
None bookHist (detName)
None BigEventLoop ()
None executeOneFile (fn, output=None, pid=None)
None makePlots (int nstations)
None AnaEventLoop ()
None muDISntuple (fn)
None analyzeConcrete ()
None rareEventEmulsion (str fname="rareEmulsion.txt")
None extractRareEvents (single=None)
None extractMuCloseByEvents (single=None)
None MergeRareEvents (list[str]|None runs=None)
None persistency ()
None reDraw (fn)
None printAndCopy (str|None prefix=None)
None drawBoth (str tag, hn)
None debugGeoTracks (sTree)
None eventsWithStrawPoints (i)
None eventsWithEntryPoints (i)
None depEnergy (sTree)
None originOfMuon (TextIOWrapper fout, int n, fn, nEvents)
None pers ()
 makeNicePrintout (list[str]|None x=None)
None readAndMergeHistos (prods)

Variables

bool local = False
bool parallel = True
 output = mp.Queue()
list processes = []
list prefixes = []
 makeProd("muon812",10,False,True) # –< 831 copied back, done 16.3.2015 makeProd("muon822",10,True,True) makeProd("muon821",10,True,True) makeProd("muon822",10,True,True)
int withChain = 0
str pref = "muon"
 xx = os.path.abspath(".").lower()
str prefix = pref + prefix
str testdir = "."
str path = ""
 fgeo = None
 sGeo = None
 inputFile = None
 tmp = inputFile.split(".")
 dy = float(tmp[1] + "." + tmp[2])
 inputFile1 = inputFile.replace("_D.", ".")
 inputFile2 = inputFile
 PDG = ROOT.TDatabasePDG.Instance()
 ShipGeo = geometry_config.create_config(Yheight=dy)
 run = ROOT.FairRunSim()
 modules = shipDet_conf.configure(run, ShipGeo)
bool otherPhysList = False
bool noField = False
bool passive = False
 top = sGeo.GetTopVolume()
 muon = top.GetNode("MuonDetector_1")
 mvol = muon.GetVolume()
 zmuon = muon.GetMatrix().GetTranslation()[2]
tuple totl = (zmuon + mvol.GetShape().GetDZ()) / u.m
float ztarget = -100.0
list fchain = []
list fchainRec = []
 q1 = inputFile1 in os.listdir(path + prefix + str(i))
 q2 = inputFile2 in os.listdir(path + prefix + str(i))
 recFile1 = inputFile1.replace(".root", "_rec.root")
 recFile2 = inputFile2.replace(".root", "_rec.root")
 r1 = recFile1 in os.listdir(path + prefix + str(i))
 r2 = recFile2 in os.listdir(path + prefix + str(i))
str fname = path + prefix + str(i) + "/" + inputFile
 recFile = inputFile.replace(".root", "_rec.root")
dict h = {}
dict histlist = {}
dict txt = {}
dict labels = {}
 logVols = detMap()
dict histlistAll
dict hLiSc = {1: {}}
dict hMuon = {}
 mom = ROOT.TVector3()
 pos = ROOT.TVector3()

Function Documentation

◆ AnaEventLoop()

None ana_ShipMuon.AnaEventLoop ( )

Definition at line 944 of file ana_ShipMuon.py.

944def AnaEventLoop() -> None:
945 fout = open("rareEvents.txt", "w") # noqa: SIM115
946 for fn in fchainRec:
947 f = ROOT.TFile(fn)
948 if not f.FindObjectAny("cbmsim"):
949 print("skip file ", f.GetName())
950 continue
951 sTree = f.Get("cbmsim")
952 sTree.GetEvent(0)
953 if sTree.GetBranch("GeoTracks"):
954 sTree.SetBranchStatus("GeoTracks", 0)
955 nEvents = sTree.GetEntries()
956 for n in range(nEvents):
957 sTree.GetEntry(n)
958 if n == 0:
959 print("now at event ", n, f.GetName())
960 if len(sTree.MCTrack) > 1:
961 wg = sTree.MCTrack[1].GetWeight() # also works for neutrinos
962 else:
963 wg = sTree.MCTrack[0].GetWeight() # also works for neutrinos
964 i = -1
965 for atrack in sTree.FitTracks:
966 i += 1
967 fitStatus = atrack.getFitStatus()
968 if not fitStatus.isFitConverged():
969 continue
970 nmeas = atrack.getNumPoints()
971 chi2 = fitStatus.getChi2() / nmeas
972 fittedState = atrack.getFittedState()
973 P = fittedState.getMomMag()
974 fout.write("rare event with track %i, %s, %8.2F \n" % (n, f.GetName(), wg))
975 originOfMuon(fout, n, f.GetName(), nEvents)
976 fout.write("reco %i,%5.3F,%8.2F \n" % (nmeas, chi2, P))
977 mcPartKey = sTree.fitTrack2MC[i]
978 mcPart = sTree.MCTrack[mcPartKey]
979 for ahit in sTree.strawtubesPoint:
980 if ahit.GetTrackID() == mcPartKey:
981 fout.write(
982 "P when making hit %i, %8.2F \n"
983 % (
984 ahit.PdgCode(),
985 ROOT.TMath.Sqrt(ahit.GetPx() ** 2 + ahit.GetPy() ** 2 + ahit.GetPz() ** 2) / u.GeV,
986 )
987 )
988 break
989 if not mcPart:
990 continue
991 Ptruth = mcPart.GetP()
992 fout.write("Ptruth %i %8.2F \n" % (mcPart.GetPdgCode(), Ptruth / u.GeV))
993
994
995#

◆ analyzeConcrete()

None ana_ShipMuon.analyzeConcrete ( )

Definition at line 1032 of file ana_ShipMuon.py.

1032def analyzeConcrete() -> None:
1033 h["fout"] = ROOT.TFile("muConcrete.root", "recreate")
1034 h["ntuple"] = ROOT.TNtuple("muons", "muon flux concrete", "id:px:py:pz:x:y:z:w")
1035 for m in ["", "mu", "V0"]:
1036 ut.bookHist(h, "conc_hitz" + m, "concrete hit z " + m, 100, -100.0, 100.0)
1037 ut.bookHist(h, "conc_hitzP" + m, "concrete hit z vs P" + m, 100, -100.0, 100.0, 100, 0.0, 25.0)
1038 ut.bookHist(h, "conc_hity" + m, "concrete hit y " + m, 100, -15.0, 15.0)
1039 ut.bookHist(h, "conc_p" + m, "concrete hit p " + m, 1000, 0.0, 400.0)
1040 ut.bookHist(h, "conc_pt" + m, "concrete hit pt " + m, 100, 0.0, 20.0)
1041 ut.bookHist(h, "conc_hitzy" + m, "concrete hit zy " + m, 100, -100.0, 100.0, 100, -15.0, 15.0)
1042 top = sGeo.GetTopVolume()
1043 magn = top.GetNode("magyoke_1")
1044 z0 = magn.GetMatrix().GetTranslation()[2] / u.m
1045 for fn in fchain:
1046 f = ROOT.TFile(fn)
1047 if not f.FindObjectAny("cbmsim"):
1048 print("skip file ", f.GetName())
1049 continue
1050 sTree = f.Get("cbmsim")
1051 nEvents = sTree.GetEntries()
1052 ROOT.gROOT.cd()
1053 for n in range(nEvents):
1054 sTree.GetEntry(n)
1055 if len(sTree.MCTrack) > 1:
1056 wg = sTree.MCTrack[1].GetWeight()
1057 else:
1058 wg = sTree.MCTrack[0].GetWeight()
1059 for ahit in sTree.vetoPoint:
1060 detID = ahit.GetDetectorID()
1061 if logVols[detID] != "rockD":
1062 continue
1063 m = ""
1064 pid = ahit.PdgCode()
1065 if abs(pid) == 13:
1066 m = "mu"
1067 P = ROOT.TMath.Sqrt(ahit.GetPx() ** 2 + ahit.GetPy() ** 2 + ahit.GetPz() ** 2)
1068 if abs(pid) == 13 and 3 / u.GeV < P:
1069 m = "V0"
1070 h["ntuple"].Fill(
1071 float(pid),
1072 float(ahit.GetPx() / u.GeV),
1073 float(ahit.GetPy() / u.GeV),
1074 float(ahit.GetPz() / u.GeV),
1075 float(ahit.GetX() / u.m),
1076 float(ahit.GetY() / u.m),
1077 float(ahit.GetZ() / u.m),
1078 float(wg),
1079 )
1080 h["conc_hitz" + m].Fill(ahit.GetZ() / u.m - z0, wg)
1081 h["conc_hity" + m].Fill(ahit.GetY() / u.m, wg)
1082 h["conc_p" + m].Fill(P / u.GeV, wg)
1083 h["conc_hitzP" + m].Fill(ahit.GetZ() / u.m, P / u.GeV, wg)
1084 Pt = ROOT.TMath.Sqrt(ahit.GetPx() ** 2 + ahit.GetPy() ** 2)
1085 h["conc_pt" + m].Fill(Pt / u.GeV, wg)
1086 h["conc_hitzy" + m].Fill(ahit.GetZ() / u.m - z0, ahit.GetY() / u.m, wg)
1087 #
1088 # start = [ahit.GetX()/u.m,ahit.GetY()/u.m,ahit.GetZ()/u.m]
1089 # direc = [-ahit.GetPx()/P,-ahit.GetPy()/P,-ahit.GetPz()/P]
1090 # t = - start[0]/direc[0]
1091
1092 ut.bookCanvas(h, key="ResultsV0", title="muons hitting concrete, p>3GeV", nx=1000, ny=600, cx=2, cy=2)
1093 ut.bookCanvas(h, key="Resultsmu", title="muons hitting concrete", nx=1000, ny=600, cx=2, cy=2)
1094 ut.bookCanvas(h, key="Results", title="hitting concrete", nx=1000, ny=600, cx=2, cy=2)
1095 for m in ["", "mu", "V0"]:
1096 tc = h["Results" + m].cd(1)
1097 h["conc_hity" + m].Draw()
1098 tc = h["Results" + m].cd(2)
1099 h["conc_hitz" + m].Draw()
1100 tc = h["Results" + m].cd(3)
1101 tc.SetLogy(1)
1102 h["conc_pt" + m].Draw()
1103 tc = h["Results" + m].cd(4)
1104 tc.SetLogy(1)
1105 h["conc_p" + m].Draw()
1106 h["fout"].cd()
1107 h["ntuple"].Write()
1108
1109

◆ BigEventLoop()

None ana_ShipMuon.BigEventLoop ( )

Definition at line 591 of file ana_ShipMuon.py.

591def BigEventLoop() -> None:
592 pid = 1
593 for fn in fchain:
594 if os.path.islink(fn):
595 rfn = os.path.realpath(fn).split("eos")[1]
596 fn = ROOT.gSystem.Getenv("EOSSHIP") + "/eos/" + rfn
597 elif not os.path.isfile(fn):
598 raise RuntimeError("Don't know what to do with " + fn)
599 if parallel:
600 # process files parallel instead of sequential
601 processes.append(mp.Process(target=executeOneFile, args=(fn, output, pid)))
602 pid += 1
603 else:
604 processes.append(fn)
605 # Run processes
606 n = 0
607 for p in processes:
608 if isinstance(p, mp.Process):
609 p.start()
610 n += 1
611 else:
612 executeOneFile(p)
613 if parallel:
614 # Exit the completed processes
615 for p in processes:
616 if isinstance(p, mp.Process):
617 p.join()
618 # clean histos before reading in the new ones
619 for x in h:
620 h[x].Reset()
621 print("now, collect the output")
622 pid = 1
623 for p in processes:
624 ut.readHists(h, "tmpHists_" + str(pid) + ".root")
625 pid += 1
626 # compactify liquid scintillator
627 for mu in ["", "_mu", "_muV0"]:
628 for x in ["", "_E", "_P", "_LP", "_OP", "_id", "_mul", "_evmul", "_origin", "_originmu"]:
629 for k in [1, 2, 3, 5]:
630 first = True
631 for j in hLiSc[k]:
632 detName = hLiSc[k][j]
633 tag = detName + mu + x
634 newh = detName[0:2] + "LiSc" + mu + x
635 if tag not in h:
636 continue
637 if first:
638 h[newh] = h[tag].Clone(newh)
639 h[newh].SetTitle(h[tag].GetTitle().split("_")[0])
640 first = False
641 else:
642 h[newh].Add(h[tag])
643 # compactify muon stations
644 for mu in ["", "_mu", "_muV0"]:
645 for x in ["", "_E", "_P", "_LP", "_OP", "_id", "_mul", "_evmul", "_origin", "_originmu"]:
646 first = True
647 for j in hMuon:
648 detName = hMuon[j]
649 tag = detName + mu + x
650 newh = "muondet" + mu + x
651 if first:
652 h[newh] = h[tag].Clone(newh)
653 h[newh].SetTitle(h[tag].GetTitle().split(" ")[0] + " " + newh)
654 first = False
655 else:
656 h[newh].Add(h[tag])
657
658 # make list of hists with entries
659 k = 1
660 for x in histlistAll:
661 if histlistAll[x] in h:
662 histlist[k] = histlistAll[x]
663 # make cumulative histograms
664 for c in ["", "_E", "_P", "_LP", "_OP", "_id", "_mul", "_evmul", "_origin", "_originmu"]:
665 h[histlist[k] + "_mu" + c].Add(h[histlist[k] + "_muV0" + c])
666 h[histlist[k] + c].Add(h[histlist[k] + "_mu" + c])
667 h[histlist[k] + c].SetMinimum(0.0)
668 h[histlist[k] + "_mu" + c].SetMinimum(0.0)
669 h[histlist[k] + "_muV0" + c].SetMinimum(0.0)
670 k += 1
671 nstations = len(histlist)
672 makePlots(nstations)
673
674

◆ bookHist()

None ana_ShipMuon.bookHist ( detName)

Definition at line 519 of file ana_ShipMuon.py.

519def bookHist(detName) -> None:
520 for mu in ["", "_mu", "_muV0"]:
521 tag = detName + mu
522 if detName.find("LS") < 0:
523 ut.bookHist(h, tag, "x/y " + detName, 100, -3.0, 3.0, 100, -6.0, 6.0)
524 else:
525 ut.bookHist(h, tag, "z phi " + detName, 100, -50.0, 50.0, 100, -1.0, 1.0)
526 ut.bookHist(h, tag + "_E", "deposited energy MeV " + detName, 100, 0.0, 2.0)
527 ut.bookHist(h, tag + "_P", "particle mom GeV " + detName, 500, 0.0, 50.0)
528 ut.bookHist(h, tag + "_LP", "particle mom GeV " + detName, 100, 0.0, 1.0)
529 ut.bookHist(h, tag + "_OP", "original particle mom GeV " + detName, 400, 0.0, 400.0)
530 ut.bookHist(h, tag + "_id", "particle id " + detName, 5001, -2499.5, 2499.5)
531 ut.bookHist(h, tag + "_mul", "multiplicity of hits/tracks " + detName, 100, -0.5, 99.5)
532 ut.bookHist(h, tag + "_evmul", "multiplicity of hits/event " + detName, 100, -0.5, 9999.5)
533 ut.bookHist(h, tag + "_origin", "r vs z", 100, ztarget, totl, 100, 0.0, 12.0)
534 ut.bookHist(h, tag + "_originmu", "r vs z", 100, ztarget, totl, 100, 0.0, 12.0)
535
536

◆ debugGeoTracks()

None ana_ShipMuon.debugGeoTracks ( sTree)

Definition at line 1311 of file ana_ShipMuon.py.

1311def debugGeoTracks(sTree) -> None:
1312 for i in range(sTree.GetEntries()):
1313 sTree.GetEntry(i)
1314 n = 0
1315 for gt in sTree.GeoTracks:
1316 print(
1317 i, n, gt.GetFirstPoint()[2], gt.GetLastPoint()[2], gt.GetParticle().GetPdgCode(), gt.GetParticle().P()
1318 )
1319 n += 1
1320
1321

◆ depEnergy()

None ana_ShipMuon.depEnergy ( sTree)

Definition at line 1359 of file ana_ShipMuon.py.

1359def depEnergy(sTree) -> None:
1360 for n in range(sTree.GetEntries()):
1361 sTree.GetEntry(n)
1362 for ahit in sTree.strawtubesPoint:
1363 dE = ahit.GetEnergyLoss() / u.keV
1364 ahit.Momentum(mom)
1365 pa = ut.get_particle(ahit.PdgCode())
1366 mpa = pa.Mass()
1367 E = ROOT.TMath.Sqrt(mom.Mag2() + mpa**2)
1368 ekin = E - mpa
1369 h["dE"].Fill(dE, ekin / u.MeV)
1370 h["dE"].SetXTitle("keV")
1371 h["dE"].SetYTitle("MeV")
1372
1373

◆ detMap()

ana_ShipMuon.detMap ( )

Definition at line 479 of file ana_ShipMuon.py.

479def detMap():
480 sGeo = ROOT.gGeoManager
481 detList = {}
482 for v in sGeo.GetListOfVolumes():
483 nm = v.GetName()
484 i = sGeo.FindVolumeFast(nm).GetNumber()
485 detList[i] = nm
486 return detList
487
488

◆ drawBoth()

None ana_ShipMuon.drawBoth ( str tag,
hn )

Definition at line 1300 of file ana_ShipMuon.py.

1300def drawBoth(tag: str, hn) -> None:
1301 n1 = h[hn + "_mu" + tag].GetMaximum()
1302 n2 = h[hn + tag].GetMaximum()
1303 if n1 > n2:
1304 h[hn + tag].SetMaximum(n1)
1305 h[hn + "_mu" + tag].SetLineColor(4)
1306 h[hn + tag].SetLineColor(3)
1307 h[hn + "_mu" + tag].Draw()
1308 h[hn + tag].Draw("same")
1309
1310

◆ eventsWithEntryPoints()

None ana_ShipMuon.eventsWithEntryPoints ( i)

Definition at line 1341 of file ana_ShipMuon.py.

1341def eventsWithEntryPoints(i) -> None:
1342 f = ROOT.TFile.Open(fchain[i])
1343 sTree = f.Get("cbmsim")
1344 mom = ROOT.TVector3()
1345 for i in range(sTree.GetEntries()):
1346 sTree.GetEntry(i)
1347 np = 0
1348 for vp in sTree.vetoPoint:
1349 detName = logVols[vp.GetDetectorID()]
1350 if detName == "VetoTimeDet":
1351 np += 0 # ??
1352 vp.Momentum(mom)
1353 print(i, detName, vp.PdgCode())
1354 mom.Print()
1355 print("-----------------------")
1356 f.Close()
1357
1358

◆ eventsWithStrawPoints()

None ana_ShipMuon.eventsWithStrawPoints ( i)

Definition at line 1322 of file ana_ShipMuon.py.

1322def eventsWithStrawPoints(i) -> None:
1323 f = ROOT.TFile.Open(fchain[i])
1324 sTree = f.Get("cbmsim")
1325 mom = ROOT.TVector3()
1326 for i in range(sTree.GetEntries()):
1327 sTree.GetEntry(i)
1328 nS = len(sTree.strawtubesPoint)
1329 if nS > 0:
1330 mu = sTree.MCTrack[0]
1331 mu.GetMomentum(mom)
1332 print(i, nS)
1333 mom.Print()
1334 sp = sTree.strawtubesPoint[(max(0, nS - 3))]
1335 sp.Momentum(mom)
1336 mom.Print()
1337 print("-----------------------")
1338 f.Close()
1339
1340

◆ executeOneFile()

None ana_ShipMuon.executeOneFile ( fn,
output = None,
pid = None )

Definition at line 675 of file ana_ShipMuon.py.

675def executeOneFile(fn, output=None, pid=None) -> None:
676 f = ROOT.TFile.Open(fn)
677 sTree = f.Get("cbmsim")
678 nEvents = sTree.GetEntries()
679 if sTree.GetBranch("GeoTracks"):
680 sTree.SetBranchStatus("GeoTracks", 0)
681 sTree.GetEntry(0)
682 hitContainers = [
683 sTree.vetoPoint,
684 sTree.muonPoint,
685 sTree.EcalPointLite,
686 sTree.strawtubesPoint,
687 sTree.ShipRpcPoint,
688 sTree.TargetPoint,
689 ]
690 ntot = 0
691 for n in range(nEvents):
692 sTree.GetEntry(n)
693 theMuon = sTree.MCTrack[0]
694 if len(sTree.MCTrack) > 1:
695 w = sTree.MCTrack[1].GetWeight() # also works for neutrinos
696 else:
697 print("should not happen with new files", n, fn)
698 w = sTree.MCTrack[0].GetWeight() # also works for neutrinos
699 if w == 0:
700 w = 1.0
701 h["weight"].Fill(w)
702 h["muonP"].Fill(theMuon.GetP() / u.GeV, w)
703 ntot += 1
704 if ntot % 10000 == 0:
705 print("read event", f.GetName(), n)
706 hitmult = {}
707 esum = 0
708 for mcp in sTree.MCTrack:
709 if mcp.GetMotherId() == 0: # mother is original muon
710 E = mcp.GetEnergy()
711 if mcp.GetPdgCode() == 11:
712 h["deltaElec"].Fill(E, w)
713 esum += E
714 h["secondaries"].Fill(E, w)
715 h["prop_deltaElec"].Fill(
716 esum / sTree.MCTrack[0].GetP(), w
717 ) # until energy is really made persistent GetEnergy()
718 for c in hitContainers:
719 for ahit in c:
720 if not ahit.GetEnergyLoss() > 0:
721 continue
722 detID = ahit.GetDetectorID()
723 if ahit.GetName() == "strawtubesPoint":
724 detName = "strawstation_" + str(ahit.GetStationNumber())
725 x = ahit.GetX()
726 y = ahit.GetY()
727 E = ahit.GetEnergyLoss()
728 else:
729 if detID not in logVols:
730 detName = c.GetName().replace("Points", "")
731 if detName not in histlistAll.values():
732 print(detID, detName, c.GetName())
733 else:
734 detName = logVols[detID]
735 x = ahit.GetX()
736 y = ahit.GetY()
737 ahit.GetZ()
738 E = ahit.GetEnergyLoss()
739 if detName not in h:
740 bookHist(detName)
741 mu = ""
742 pdgID = -2
743 if "PdgCode" in dir(ahit):
744 pdgID = ahit.PdgCode()
745 trackID = ahit.GetTrackID()
746 phit = -100.0
747 mom = ROOT.TVector3()
748 aTrack = None
749 if not trackID < 0:
750 aTrack = sTree.MCTrack[trackID]
751 pdgID = aTrack.GetPdgCode()
752 aTrack.GetMomentum(mom) # ! this is not momentum of particle at Calorimeter place
753 phit = mom.Mag() / u.GeV
754 if abs(pdgID) == 13:
755 mu = "_mu"
756 if phit > 3 and abs(pdgID) == 13:
757 mu = "_muV0"
758 detName = detName + mu
759 if detName.find("LS") < 0:
760 h[detName].Fill(x / u.m, y / u.m, w)
761 else:
762 h[detName].Fill(ahit.GetZ() / u.m, ROOT.TMath.ATan2(y, x) / ROOT.TMath.Pi(), w)
763 h[detName + "_E"].Fill(E / u.MeV, w)
764 if detName not in hitmult:
765 hitmult[detName] = {-1: 0}
766 if trackID not in hitmult[detName]:
767 hitmult[detName][trackID] = 0
768 hitmult[detName][trackID] += 1
769 hitmult[detName][-1] += 1
770 h[detName + "_id"].Fill(pdgID, w)
771 h[detName + "_P"].Fill(phit, w)
772 h[detName + "_LP"].Fill(phit, w)
773 if aTrack is not None:
774 r = ROOT.TMath.Sqrt(aTrack.GetStartX() ** 2 + aTrack.GetStartY() ** 2) / u.m
775 h["origin"].Fill(aTrack.GetStartZ() / u.m, r, w)
776 h[detName + "_origin"].Fill(aTrack.GetStartZ() / u.m, r, w)
777 if abs(pdgID) == 13:
778 h[detName + "_originmu"].Fill(aTrack.GetStartZ() / u.m, r, w)
779 h["borigin"].Fill(aTrack.GetStartZ() / u.m, r, w)
780 aTrack.GetMomentum(mom)
781 h[detName + "_OP"].Fill(mom.Mag() / u.GeV, w)
782 rz_inter = -1.0, 0.0
783 if trackID > 0:
784 rz_inter = origin(sTree, trackID)
785 h["porigin"].Fill(
786 aTrack.GetStartZ() / u.m,
787 ROOT.TMath.Sqrt(aTrack.GetStartX() ** 2 + aTrack.GetStartY() ** 2) / u.m,
788 w,
789 )
790 h["mu-inter"].Fill(rz_inter[1] / u.m, rz_inter[0] / u.m, w)
791 for detName in hitmult:
792 h[detName + "_evmul"].Fill(hitmult[detName][-1], w)
793 for tr in hitmult[detName]:
794 h[detName + "_mul"].Fill(hitmult[detName][tr], w)
795 if output:
796 ut.writeHists(h, "tmpHists_" + str(pid) + ".root")
797 output.put("ok")
798 f.Close()
799
800
801#

◆ extractMuCloseByEvents()

None ana_ShipMuon.extractMuCloseByEvents ( single = None)

Definition at line 1203 of file ana_ShipMuon.py.

1203def extractMuCloseByEvents(single=None) -> None:
1204 mom = ROOT.TVector3()
1205 pos = ROOT.TVector3()
1206 # Goliath magnet has been removed from geometry
1207 goliath_node = top.GetNode("volGoliath_1")
1208 if goliath_node:
1209 golmx = goliath_node.GetMatrix()
1210 zGol = golmx.GetTranslation()[2]
1211 else:
1212 zGol = -9999.0 # No Goliath, accept all z positions
1213 for fn in fchainRec:
1214 if single:
1215 if fn.find(str(single)) < 0:
1216 continue
1217 f = ROOT.TFile(fn)
1218 if not f.FindObjectAny("cbmsim"):
1219 print("skip file ", f.GetName())
1220 continue
1221 sTree = f.Get("cbmsim")
1222 nEvents = sTree.GetEntries()
1223 raref = ROOT.TFile(fn.replace(".root", "_clby.root"), "recreate")
1224 newTree = sTree.CloneTree(0)
1225 for n in range(nEvents):
1226 sTree.GetEntry(n)
1227 if n == 0:
1228 print("now at event ", n, f.GetName())
1229 # look for muons p>3 hitting something
1230 n = 0
1231 for c in [sTree.vetoPoint, sTree.strawtubesPoint, sTree.ShipRpcPoint]:
1232 for ahit in c:
1233 if abs(ahit.PdgCode()) != 13:
1234 continue
1235 ahit.Momentum(mom)
1236 if mom.Mag() < 3.0:
1237 continue
1238 ahit.Position(pos)
1239 if pos.z() < zGol:
1240 continue
1241 n += 1
1242 if n > 0:
1243 newTree.Fill()
1244 # print 'filled newTree',rc
1245 sTree.Clear()
1246 newTree.AutoSave()
1247 print(" --> events saved:", newTree.GetEntries())
1248 f.Close()
1249 raref.Close()
1250
1251
1252#

◆ extractRareEvents()

None ana_ShipMuon.extractRareEvents ( single = None)

Definition at line 1166 of file ana_ShipMuon.py.

1166def extractRareEvents(single=None) -> None:
1167 for fn in fchainRec:
1168 if single:
1169 if fn.find(str(single)) < 0:
1170 continue
1171 f = ROOT.TFile(fn)
1172 if not f.FindObjectAny("cbmsim"):
1173 print("skip file ", f.GetName())
1174 continue
1175 sTree = f.Get("cbmsim")
1176 nEvents = sTree.GetEntries()
1177 raref = ROOT.TFile(fn.replace(".root", "_rare.root"), "recreate")
1178 newTree = sTree.CloneTree(0)
1179 for n in range(nEvents):
1180 sTree.GetEntry(n)
1181 if n == 0:
1182 print("now at event ", n, f.GetName())
1183 # count fitted tracks which have converged and nDF>20:
1184 n = 0
1185 for fT in sTree.FitTracks:
1186 fst = fT.getFitStatus()
1187 if not fst.isFitConverged():
1188 continue
1189 if fst.getNdf() < 20:
1190 continue
1191 n += 1
1192 if n > 0:
1193 rc = newTree.Fill()
1194 print("filled newTree", rc)
1195 sTree.Clear()
1196 newTree.AutoSave()
1197 print(" --> events saved:", newTree.GetEntries())
1198 f.Close()
1199 raref.Close()
1200
1201
1202#

◆ fitSingleGauss()

None ana_ShipMuon.fitSingleGauss ( x,
ba = None,
be = None )

Definition at line 489 of file ana_ShipMuon.py.

489def fitSingleGauss(x, ba=None, be=None) -> None:
490 name = "myGauss_" + x
491 myGauss = h[x].GetListOfFunctions().FindObject(name)
492 if not myGauss:
493 if not ba:
494 ba = h[x].GetBinCenter(1)
495 if not be:
496 be = h[x].GetBinCenter(h[x].GetNbinsX())
497 bw = h[x].GetBinWidth(1)
498 mean = h[x].GetMean()
499 sigma = h[x].GetRMS()
500 norm = h[x].GetEntries() * 0.3
501 myGauss = ROOT.TF1(name, "[0]*" + str(bw) + "/([2]*sqrt(2*pi))*exp(-0.5*((x-[1])/[2])**2)+[3]", 4)
502 myGauss.SetParameter(0, norm)
503 myGauss.SetParameter(1, mean)
504 myGauss.SetParameter(2, sigma)
505 myGauss.SetParameter(3, 1.0)
506 myGauss.SetParName(0, "Signal")
507 myGauss.SetParName(1, "Mean")
508 myGauss.SetParName(2, "Sigma")
509 h[x].Fit(myGauss, "", "", ba, be)
510
511

◆ makeNicePrintout()

ana_ShipMuon.makeNicePrintout ( list[str] | None x = None)

Definition at line 1421 of file ana_ShipMuon.py.

1421def makeNicePrintout(x: list[str] | None = None):
1422 if x is None:
1423 x = ["rareEvents_61-62.txt", "rareEvents_71-72.txt"]
1424 result: list[dict[str, str | float]] = []
1425 cor = 1.0
1426 for fn in x:
1427 with open(fn) as f:
1428 recTrack: dict[str, str | float] | None = None
1429 if fn == "rareEvents_81-102.txt":
1430 cor = 30.0
1431 for lx in f.readlines():
1432 line = lx.replace("\n", "")
1433 if not line.find("rare event") < 0:
1434 if recTrack:
1435 result.append(recTrack)
1436 tmp = line.split(",")
1437 w = tmp[2].replace(" ", "")
1438 ff = tmp[1].split("/")[0].replace(" ", "")
1439 recTrack = {"w": w, "file": ff}
1440 elif recTrack is None:
1441 # skip anything before the first "rare event" marker
1442 continue
1443 elif not line.find("original") < 0:
1444 tmp = line.split(",")
1445 recTrack["origin"] = tmp[0].split(" ")[2]
1446 recTrack["pytiaid"] = tmp[1].replace(" ", "")
1447 recTrack["o-mom"] = tmp[2].replace(" ", "")
1448 elif not line.find("reco ") < 0:
1449 tmp = line.split(",")
1450 recTrack["nmeas"] = tmp[0].split(" ")[1]
1451 recTrack["chi2"] = tmp[1]
1452 recTrack["p_rec"] = tmp[2].replace(" ", "")
1453 elif not line.find("making") < 0:
1454 tmp = line.split(",")
1455 recTrack["p_hit"] = tmp[1].replace(" ", "")
1456 recTrack["fp_hit"] = float(tmp[1].replace(" ", ""))
1457 elif not line.find("Ptruth") < 0:
1458 tmp = line.split(" ")
1459 recTrack["id_hit"] = tmp[1].replace(" ", "")
1460 # flush the record still being assembled when the file ends
1461 if recTrack:
1462 result.append(recTrack)
1463 # print a table
1464 print(
1465 "%4s %8s %8s %4s %8s %8s %8s %8s %8s %8s "
1466 % ("nr", "origin", "pythiaID", "ID", "p_orig", "p_hit", "chi2", "weight", "file", "cor w")
1467 )
1468 # sort according to p_hit
1469 tmp = sorted(result, key=itemgetter("fp_hit"))
1470 muonrate1 = 0
1471 muonrate2 = 0
1472 muonrate3 = 0
1473 for i in range(len(tmp)):
1474 tr = tmp[i]
1475 corw = float(tr["w"]) / cor
1476 if float(tr["p_hit"]) > 1:
1477 muonrate1 += corw
1478 if float(tr["p_hit"]) > 2:
1479 muonrate2 += corw
1480 if float(tr["p_hit"]) > 3:
1481 muonrate3 += corw
1482 print(
1483 "%4i %8s %8s %4s %8s %8s %8s %8s %8s %8s "
1484 % (
1485 i,
1486 tr["origin"],
1487 tr["pytiaid"],
1488 tr["id_hit"],
1489 tr["o-mom"],
1490 tr["p_hit"],
1491 tr["chi2"],
1492 tr["w"],
1493 tr["file"],
1494 corw,
1495 )
1496 )
1497 print("guestimate for muonrate above 1GeV = ", muonrate1)
1498 print("guestimate for muonrate above 2GeV = ", muonrate2)
1499 print("guestimate for muonrate above 3GeV = ", muonrate3)
1500 # guestimate for muonrate above 1GeV = 56025.4793333
1501 # guestimate for muonrate above 2GeV = 25584.9546667
1502 # guestimate for muonrate above 3GeV = 14792.8113333
1503 return tmp
1504
1505
1506#

◆ makePlots()

None ana_ShipMuon.makePlots ( int nstations)

Definition at line 802 of file ana_ShipMuon.py.

802def makePlots(nstations: int) -> None:
803 cxcy = {
804 1: [2, 1],
805 2: [3, 1],
806 3: [2, 2],
807 4: [3, 2],
808 5: [3, 2],
809 6: [3, 2],
810 7: [3, 3],
811 8: [3, 3],
812 9: [3, 3],
813 10: [4, 3],
814 11: [4, 3],
815 12: [4, 3],
816 13: [5, 3],
817 14: [5, 3],
818 15: [5, 3],
819 }
820 ut.bookCanvas(
821 h,
822 key="ResultsI",
823 title="hit occupancies",
824 nx=1100,
825 ny=600 * cxcy[nstations][1],
826 cx=cxcy[nstations][0],
827 cy=cxcy[nstations][1],
828 )
829 ut.bookCanvas(
830 h,
831 key="ResultsImu",
832 title="hit occupancies",
833 nx=1100,
834 ny=600 * cxcy[nstations][1],
835 cx=cxcy[nstations][0],
836 cy=cxcy[nstations][1],
837 )
838 ut.bookCanvas(
839 h,
840 key="ResultsImuV0",
841 title="hit occupancies",
842 nx=1100,
843 ny=600 * cxcy[nstations][1],
844 cx=cxcy[nstations][0],
845 cy=cxcy[nstations][1],
846 )
847 ut.bookCanvas(
848 h,
849 key="ResultsII",
850 title="deposited energies",
851 nx=1100,
852 ny=600 * cxcy[nstations][1],
853 cx=cxcy[nstations][0],
854 cy=cxcy[nstations][1],
855 )
856 ut.bookCanvas(
857 h,
858 key="ResultsIII",
859 title="track info",
860 nx=1100,
861 ny=600 * cxcy[nstations][1],
862 cx=cxcy[nstations][0],
863 cy=cxcy[nstations][1],
864 )
865 ut.bookCanvas(
866 h,
867 key="ResultsIV",
868 title="track info",
869 nx=1100,
870 ny=600 * cxcy[nstations][1],
871 cx=cxcy[nstations][0],
872 cy=cxcy[nstations][1],
873 )
874 ut.bookCanvas(h, key="ResultsV", title="origin info", nx=600, ny=400, cx=1, cy=1)
875 txt[0] = "occupancy 1sec 5E13pot "
876 h["dummy"].Fill(-1)
877 nSpills = len(prefixes)
878 for i in histlist:
879 tc = h["ResultsI"].cd(i)
880 hn = histlist[i]
881 if hn not in h:
882 continue
883 h[hn].SetStats(0)
884 h[hn].Draw("colz")
885 txt[i] = "%5.2G" % (h[hn].GetSumOfWeights() / nSpills)
886 labels[i] = ROOT.TLatex().DrawLatexNDC(0.15, 0.85, txt[i])
887 #
888 hn = histlist[i] + "_mu"
889 tc = h["ResultsImu"].cd(i)
890 h[hn].SetStats(0)
891 h[hn].Draw("colz")
892 txt[i + 100] = "%5.2G" % (h[hn].GetSumOfWeights() / nSpills)
893 labels[i + 100] = ROOT.TLatex().DrawLatexNDC(0.15, 0.85, txt[i + 100])
894 #
895 hn = histlist[i] + "_muV0"
896 tc = h["ResultsImuV0"].cd(i)
897 h[hn].SetStats(0)
898 h[hn].Draw("colz")
899 txt[i + 200] = "%5.2G" % (h[hn].GetSumOfWeights() / nSpills)
900 labels[i + 200] = ROOT.TLatex().DrawLatexNDC(0.15, 0.85, txt[i + 200])
901 #
902 for i in histlist:
903 tc = h["ResultsII"].cd(i)
904 h[histlist[i] + "_E"].Draw("colz")
905 #
906 for i in histlist:
907 tc = h["ResultsIII"].cd(i)
908 tc.SetLogy(1)
909 hn = histlist[i]
910 drawBoth("_P", hn)
911 hid = h[hn + "_id"]
912 print("particle statistics for " + histlist[i])
913 for k in range(hid.GetNbinsX()):
914 ncont = hid.GetBinContent(k + 1)
915 pid = hid.GetBinCenter(k + 1)
916 if ncont > 0:
917 temp = int(abs(pid) + 0.5) * int(pid / abs(pid))
918 _p = ut.get_particle(temp)
919 nm = _p.GetName()
920 print(f"{nm} :{ncont:5.2g}")
921 hid = h[histlist[i] + "_mu_id"]
922 for k in range(hid.GetNbinsX()):
923 ncont = hid.GetBinContent(k + 1)
924 pid = hid.GetBinCenter(k + 1)
925 if ncont > 0:
926 temp = int(abs(pid) + 0.5) * int(pid / abs(pid))
927 _p = ut.get_particle(temp)
928 nm = _p.GetName()
929 print(f"{nm} :{ncont:5.2g}")
930 #
931 tc = h["ResultsV"].cd(1)
932 h["origin"].SetStats(0)
933 h["origin"].Draw("colz")
934 #
935 for i in histlist:
936 tc = h["ResultsIV"].cd(i)
937 tc.SetLogy(1)
938 hn = histlist[i]
939 drawBoth("_OP", hn)
940 persistency()
941
942
943#

◆ makeProd()

None ana_ShipMuon.makeProd ( )

Definition at line 455 of file ana_ShipMuon.py.

455def makeProd() -> None:
456 ntot = 736406
457 ncpu = 4
458 n3 = int(ntot / ncpu)
459 cmd = "python $FAIRSHIP/macro/run_simScript.py --MuonBack -f $SHIPSOFT/data/pythia8_Geant4_onlyMuons.root " # --display"
460 ns = 0
461 prefix = "muon18"
462 for i in range(1, ncpu + 1):
463 d = prefix + str(i)
464 if d not in os.listdir("."):
465 os.system("mkdir " + d)
466 os.chdir("./" + prefix + "1")
467 for i in range(1, ncpu + 1):
468 if i == ncpu:
469 n3 = ntot - i * n3
470 os.system("cp $FAIRSHIP/macro/run_simScript.py .")
471 os.system(cmd + " -n " + str(n3) + " -i " + str(ns) + " > log &")
472 # print " -n "+str(n3)+" -i "+str(ns)
473 ns += n3
474 if i == ncpu:
475 break
476 os.chdir("../" + prefix + str(i + 1))
477
478

◆ MergeRareEvents()

None ana_ShipMuon.MergeRareEvents ( list[str] | None runs = None)

Definition at line 1253 of file ana_ShipMuon.py.

1253def MergeRareEvents(runs: list[str] | None = None) -> None:
1254 if runs is None:
1255 runs = ["61", "62"]
1256 for prefix in runs:
1257 cmd = "$ROOTSYS/bin/hadd rareEvents_" + prefix + ".root -f "
1258 for fn in fchainRec:
1259 if fn.find("muon" + prefix) < 0:
1260 continue
1261 fr = fn.replace(".root", "_rare.root")
1262 cmd = cmd + " " + fr
1263 os.system(cmd)
1264
1265
1266#

◆ muDISntuple()

None ana_ShipMuon.muDISntuple ( fn)

Definition at line 996 of file ana_ShipMuon.py.

996def muDISntuple(fn) -> None:
997 # take as input the rare events
998 fout = ROOT.TFile("muDISVetoCounter.root", "recreate")
999 h["ntuple"] = ROOT.TNtuple("muons", "muon flux VetoCounter", "id:px:py:pz:x:y:z:w")
1000 f = ROOT.TFile(fn)
1001 sTree = f.Get("cbmsim")
1002 nEvents = sTree.GetEntries()
1003 for n in range(nEvents):
1004 sTree.GetEntry(n)
1005 if len(sTree.MCTrack) > 1:
1006 wg = sTree.MCTrack[1].GetWeight()
1007 else:
1008 wg = sTree.MCTrack[0].GetWeight()
1009 for ahit in sTree.vetoPoint:
1010 detID = ahit.GetDetectorID()
1011 if logVols[detID] != "VetoTimeDet":
1012 continue
1013 pid = ahit.PdgCode()
1014 if abs(pid) != 13:
1015 continue
1016 P = ROOT.TMath.Sqrt(ahit.GetPx() ** 2 + ahit.GetPy() ** 2 + ahit.GetPz() ** 2)
1017 if 3 / u.GeV < P:
1018 h["ntuple"].Fill(
1019 float(pid),
1020 float(ahit.GetPx() / u.GeV),
1021 float(ahit.GetPy() / u.GeV),
1022 float(ahit.GetPz() / u.GeV),
1023 float(ahit.GetX() / u.m),
1024 float(ahit.GetY() / u.m),
1025 float(ahit.GetZ() / u.m),
1026 float(wg),
1027 )
1028 fout.cd()
1029 h["ntuple"].Write()
1030
1031

◆ origin()

ana_ShipMuon.origin ( sTree,
it )
Return (r, z) of the ancestor track produced by the primary muon.

Returns the sentinel (-1.0, 0.0) if the mother chain does not end at the
primary muon (track 0).

Definition at line 392 of file ana_ShipMuon.py.

392def origin(sTree, it):
393 """Return (r, z) of the ancestor track produced by the primary muon.
394
395 Returns the sentinel (-1.0, 0.0) if the mother chain does not end at the
396 primary muon (track 0).
397 """
398 at = sTree.MCTrack[it]
399 im = at.GetMotherId()
400 if im > 0:
401 return origin(sTree, im)
402 if im == 0:
403 return ROOT.TMath.Sqrt(at.GetStartX() ** 2 + at.GetStartY() ** 2), at.GetStartZ()
404 # does not come from muon
405 return -1.0, 0.0
406
407

◆ originOfMuon()

None ana_ShipMuon.originOfMuon ( TextIOWrapper fout,
int n,
fn,
nEvents )

Definition at line 1374 of file ana_ShipMuon.py.

1374def originOfMuon(fout: TextIOWrapper, n: int, fn, nEvents) -> None:
1375 # from fn extract Yandex or CERN/cracow
1376 ncpu = 9
1377 x = fn.find("/")
1378 ni = int(fn[x - 1 : x]) - 1
1379 if nEvents < 100000:
1380 fm = "$SHIPSOFT/data/pythia8_Geant4_onlyMuons.root"
1381 else:
1382 fm = "$SHIPSOFT/data/pythia8_Geant4_Yandex_onlyMuons.root"
1383 fmuon = ROOT.TFile(fm)
1384 ntupl = fmuon.Get("pythia8-Geant4")
1385 ntot = ntupl.GetEntries()
1386 n3 = int(ntot / ncpu)
1387 N = n3 * ni + n
1388 ntupl.GetEvent(N)
1389 P = ROOT.TMath.Sqrt(ntupl.pz * ntupl.pz + ntupl.py * ntupl.py + ntupl.px * ntupl.px)
1390 fout.write("original muon %i, %i, %8.2F \n" % (ntupl.parentid, ntupl.pythiaid, P))
1391 fmuon.Close()
1392
1393
1394#
1395# BigEventLoop()
1396# makePlots()
1397# AnaEventLoop()
1398
1399
1400# ShipAna

◆ pers()

None ana_ShipMuon.pers ( )

Definition at line 1401 of file ana_ShipMuon.py.

1401def pers() -> None:
1402 xdisk = "/media/Work/HNL/"
1403 for x in h:
1404 if isinstance(h[x], ROOT.TCanvas):
1405 h[x].Update()
1406 tn = h[x].GetName() + ".png"
1407 h[x].Print(tn)
1408 rpath = os.path.abspath(".").split("/HNL/")[1]
1409 lp = rpath.split("/")
1410 prefix = xdisk
1411 for i in range(len(lp)):
1412 if lp[i] not in os.listdir(prefix):
1413 os.system("mkdir " + prefix + "/" + lp[i])
1414 prefix = prefix + "/" + lp[i]
1415 os.system("cp " + tn + " " + xdisk + rpath)
1416
1417

◆ persistency()

None ana_ShipMuon.persistency ( )

Definition at line 1267 of file ana_ShipMuon.py.

1267def persistency() -> None:
1268 printAndCopy(prefix)
1269 ut.writeHists(h, prefix + ".root", plusCanvas=True)
1270
1271

◆ printAndCopy()

None ana_ShipMuon.printAndCopy ( str | None prefix = None)

Definition at line 1282 of file ana_ShipMuon.py.

1282def printAndCopy(prefix: str | None = None) -> None:
1283 if not prefix:
1284 prefix = (h["tc"].GetName()).replace(".root", "")
1285 for x in ["ResultsI", "ResultsII", "ResultsImu", "ResultsImuV0", "ResultsIII", "ResultsIV", "ResultsV"]:
1286 h[x].Update()
1287 if prefix not in os.listdir("."):
1288 os.mkdir(prefix)
1289 os.chdir(prefix)
1290 h["ResultsI"].Print(prefix + "Back_occ.png")
1291 h["ResultsII"].Print(prefix + "Back_depE.png")
1292 h["ResultsImu"].Print(prefix + "muBack_occ.png")
1293 h["ResultsImuV0"].Print(prefix + "muV0Back_occ.png")
1294 h["ResultsIII"].Print(prefix + "Back_P.png")
1295 h["ResultsIV"].Print(prefix + "Back_OP.png")
1296 h["ResultsV"].Print(prefix + "origin.png")
1297 os.chdir("../")
1298
1299

◆ rareEventEmulsion()

None ana_ShipMuon.rareEventEmulsion ( str fname = "rareEmulsion.txt")

Definition at line 1110 of file ana_ShipMuon.py.

1110def rareEventEmulsion(fname: str = "rareEmulsion.txt") -> None:
1111 fout = open(fname, "w") # noqa: SIM115
1112 for fn in fchainRec:
1113 f = ROOT.TFile(fn)
1114 if not f.FindObjectAny("cbmsim"):
1115 print("skip file ", f.GetName())
1116 continue
1117 sTree = f.Get("cbmsim")
1118 sTree.GetEvent(0)
1119 if sTree.GetBranch("GeoTracks"):
1120 sTree.SetBranchStatus("GeoTracks", 0)
1121 nEvents = sTree.GetEntries()
1122 for n in range(nEvents):
1123 sTree.GetEntry(n)
1124 if n == 0:
1125 print("now at event ", n, f.GetName())
1126 for ahit in sTree.vetoPoint:
1127 detID = ahit.GetDetectorID()
1128 if logVols[detID] != "Emulsion":
1129 continue
1130 ahit.GetX()
1131 ahit.GetY()
1132 ahit.GetZ()
1133 if len(sTree.MCTrack) > 1:
1134 wg = sTree.MCTrack[1].GetWeight() # also works for neutrinos
1135 else:
1136 wg = sTree.MCTrack[0].GetWeight() # also works for neutrinos
1137 fout.write("rare emulsion hit %i, %s, %8.3F, %i \n" % (n, f.GetName(), wg, ahit.PdgCode()))
1138 if ahit.GetPz() / u.GeV > 1.0:
1139 fout.write(
1140 "V,P when making hit %8.3F,%8.3F,%8.3F %8.3F,%8.3F,%8.3F (GeV) \n"
1141 % (
1142 ahit.GetX() / u.m,
1143 ahit.GetY() / u.m,
1144 ahit.GetZ() / u.m,
1145 ahit.GetPx() / u.GeV,
1146 ahit.GetPy() / u.GeV,
1147 ahit.GetPz() / u.GeV,
1148 )
1149 )
1150 else:
1151 fout.write(
1152 "V,P when making hit %8.3F,%8.3F,%8.3F %8.3F,%8.3F,%8.3F (MeV)\n"
1153 % (
1154 ahit.GetX() / u.m,
1155 ahit.GetY() / u.m,
1156 ahit.GetZ() / u.m,
1157 ahit.GetPx() / u.MeV,
1158 ahit.GetPy() / u.MeV,
1159 ahit.GetPz() / u.MeV,
1160 )
1161 )
1162 originOfMuon(fout, n, f.GetName(), nEvents)
1163
1164
1165#

◆ readAndMergeHistos()

None ana_ShipMuon.readAndMergeHistos ( prods)

Definition at line 1507 of file ana_ShipMuon.py.

1507def readAndMergeHistos(prods) -> None:
1508 for p in prods:
1509 x = p
1510 if p.find(".root") < 0:
1511 x = p + ".root"
1512 ut.readHists(h, x)
1513 # make list of hists with entries
1514 k = 1
1515 for x in histlistAll:
1516 if histlistAll[x] in h:
1517 histlist[k] = histlistAll[x]
1518 k += 1
1519 nstations = len(histlist)
1520 print("make plots for ", nstations)
1521 makePlots(nstations)
1522 printAndCopy(prods[0].replace(".root", ""))
1523
1524
1525# python -i $HNL/ana_ShipMuon.py 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829
1526# python -i $HNL/ana_ShipMuon.py 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929
1527# python -i $HNL/ana_ShipMuon.py 1012 1013 1014 1015 1016 1017 1018 1019 1022 1023 1024 1025 1026 1027 1028 1029
1528# python -i $HNL/ana_ShipMuon.py 634 635 636 637 638 639 640 641 642 643
1529# combine all cern-cracow
1530# python -i $HNL/ana_ShipMuon.py 810 811 812 813 814 815 816 817 818 819 910 911 912 913 914 915 916 917 918 919 1012 1013 1014 1015 1016 1017 1018 1019
1531# python -i $HNL/ana_ShipMuon.py 820 821 822 823 824 825 826 827 828 829 920 921 922 923 924 925 926 927 928 929 1022 1023 1024 1025 1026 1027 1028 1029
1532# make muonDIS ntuple: muDISntuple("/media/Data/HNL/muonBackground/rareEvents_81-102.root") -> 'muDISVetoCounter.root'
1533# second step python $FAIRSHIP/muonDIS/makeMuonDIS.py -f muDISVetoCounter.root -n 10 -nDISPerMuon 10000
1534# third step run_simScript.py --MuDIS -n 10 -f muonDis.root
1535# for concrete
1536# analyzeConcrete() -> muConcrete.root

◆ reDraw()

None ana_ShipMuon.reDraw ( fn)

Definition at line 1272 of file ana_ShipMuon.py.

1272def reDraw(fn) -> None:
1273 if fn.find("root") < 0:
1274 fn = fn + ".root"
1275 if "tc" not in h:
1276 h["tc"] = ROOT.TFile(fn)
1277 for x in ["ResultsI", "ResultsII", "ResultsImu", "ResultsImuV0", "ResultsIII", "ResultsIV", "ResultsV"]:
1278 h[x] = h["tc"].FindObjectAny(x)
1279 h[x].Draw()
1280
1281

Variable Documentation

◆ dy

float ana_ShipMuon.dy = float(tmp[1] + "." + tmp[2])

Definition at line 359 of file ana_ShipMuon.py.

◆ fchain

list ana_ShipMuon.fchain = []

Definition at line 419 of file ana_ShipMuon.py.

◆ fchainRec

list ana_ShipMuon.fchainRec = []

Definition at line 420 of file ana_ShipMuon.py.

◆ fgeo

ana_ShipMuon.fgeo = None

Definition at line 345 of file ana_ShipMuon.py.

◆ fname

str ana_ShipMuon.fname = path + prefix + str(i) + "/" + inputFile

Definition at line 442 of file ana_ShipMuon.py.

◆ h

dict ana_ShipMuon.h = {}

Definition at line 512 of file ana_ShipMuon.py.

◆ histlist

dict ana_ShipMuon.histlist = {}

Definition at line 513 of file ana_ShipMuon.py.

◆ histlistAll

dict ana_ShipMuon.histlistAll
Initial value:
1= {
2 1: "strawstation_5",
3 2: "strawstation_1",
4 3: "strawstation_4",
5 4: "Ecal",
6 5: "muondet",
7 6: "VetoTimeDet",
8 7: "T1LiSc",
9 8: "T2LiSc",
10 9: "T3LiSc",
11 10: "T5LiSc",
12 11: "ShipRpc",
13 12: "volHPT",
14 13: "Target",
15 14: "TimeDet",
16 15: "Det2",
17}

Definition at line 552 of file ana_ShipMuon.py.

◆ hLiSc

dict ana_ShipMuon.hLiSc = {1: {}}

Definition at line 569 of file ana_ShipMuon.py.

◆ hMuon

dict ana_ShipMuon.hMuon = {}

Definition at line 581 of file ana_ShipMuon.py.

◆ inputFile

ana_ShipMuon.inputFile = None

Definition at line 347 of file ana_ShipMuon.py.

◆ inputFile1

ana_ShipMuon.inputFile1 = inputFile.replace("_D.", ".")

Definition at line 364 of file ana_ShipMuon.py.

◆ inputFile2

ana_ShipMuon.inputFile2 = inputFile

Definition at line 365 of file ana_ShipMuon.py.

◆ labels

dict ana_ShipMuon.labels = {}

Definition at line 515 of file ana_ShipMuon.py.

◆ local

bool ana_ShipMuon.local = False

Definition at line 13 of file ana_ShipMuon.py.

◆ logVols

ana_ShipMuon.logVols = detMap()

Definition at line 516 of file ana_ShipMuon.py.

◆ modules

ana_ShipMuon.modules = shipDet_conf.configure(run, ShipGeo)

Definition at line 389 of file ana_ShipMuon.py.

◆ mom

ana_ShipMuon.mom = ROOT.TVector3()

Definition at line 587 of file ana_ShipMuon.py.

◆ muon

ana_ShipMuon.muon = top.GetNode("MuonDetector_1")

Definition at line 413 of file ana_ShipMuon.py.

◆ mvol

ana_ShipMuon.mvol = muon.GetVolume()

Definition at line 414 of file ana_ShipMuon.py.

◆ noField

bool ana_ShipMuon.noField = False

Definition at line 409 of file ana_ShipMuon.py.

◆ otherPhysList

bool ana_ShipMuon.otherPhysList = False

Definition at line 408 of file ana_ShipMuon.py.

◆ output

ana_ShipMuon.output = mp.Queue()

Definition at line 20 of file ana_ShipMuon.py.

◆ parallel

bool ana_ShipMuon.parallel = True

Definition at line 17 of file ana_ShipMuon.py.

◆ passive

bool ana_ShipMuon.passive = False

Definition at line 410 of file ana_ShipMuon.py.

◆ path

str ana_ShipMuon.path = ""

Definition at line 340 of file ana_ShipMuon.py.

◆ PDG

ana_ShipMuon.PDG = ROOT.TDatabasePDG.Instance()

Definition at line 373 of file ana_ShipMuon.py.

◆ pos

ana_ShipMuon.pos = ROOT.TVector3()

Definition at line 588 of file ana_ShipMuon.py.

◆ pref

str ana_ShipMuon.pref = "muon"

Definition at line 318 of file ana_ShipMuon.py.

◆ prefix

str ana_ShipMuon.prefix = pref + prefix

Definition at line 333 of file ana_ShipMuon.py.

◆ prefixes

list ana_ShipMuon.prefixes = []

makeProd("muon812",10,False,True) # –< 831 copied back, done 16.3.2015 makeProd("muon822",10,True,True) makeProd("muon821",10,True,True) makeProd("muon822",10,True,True)

makeProd("muon813",10,False,True) # makeProd("muon823",10,True,True)

Definition at line 316 of file ana_ShipMuon.py.

◆ processes

list ana_ShipMuon.processes = []

Definition at line 22 of file ana_ShipMuon.py.

◆ q1

ana_ShipMuon.q1 = inputFile1 in os.listdir(path + prefix + str(i))

Definition at line 430 of file ana_ShipMuon.py.

◆ q2

ana_ShipMuon.q2 = inputFile2 in os.listdir(path + prefix + str(i))

Definition at line 431 of file ana_ShipMuon.py.

◆ r1

ana_ShipMuon.r1 = recFile1 in os.listdir(path + prefix + str(i))

Definition at line 434 of file ana_ShipMuon.py.

◆ r2

ana_ShipMuon.r2 = recFile2 in os.listdir(path + prefix + str(i))

Definition at line 435 of file ana_ShipMuon.py.

◆ recFile

ana_ShipMuon.recFile = inputFile.replace(".root", "_rec.root")

Definition at line 443 of file ana_ShipMuon.py.

◆ recFile1

ana_ShipMuon.recFile1 = inputFile1.replace(".root", "_rec.root")

Definition at line 432 of file ana_ShipMuon.py.

◆ recFile2

ana_ShipMuon.recFile2 = inputFile2.replace(".root", "_rec.root")

Definition at line 433 of file ana_ShipMuon.py.

◆ run

ana_ShipMuon.run = ROOT.FairRunSim()

Definition at line 388 of file ana_ShipMuon.py.

◆ sGeo

ana_ShipMuon.sGeo = None

Definition at line 346 of file ana_ShipMuon.py.

◆ ShipGeo

ana_ShipMuon.ShipGeo = geometry_config.create_config(Yheight=dy)

Definition at line 380 of file ana_ShipMuon.py.

◆ testdir

str ana_ShipMuon.testdir = "."

Definition at line 339 of file ana_ShipMuon.py.

◆ tmp

ana_ShipMuon.tmp = inputFile.split(".")

Definition at line 357 of file ana_ShipMuon.py.

◆ top

ana_ShipMuon.top = sGeo.GetTopVolume()

Definition at line 412 of file ana_ShipMuon.py.

◆ totl

tuple ana_ShipMuon.totl = (zmuon + mvol.GetShape().GetDZ()) / u.m

Definition at line 416 of file ana_ShipMuon.py.

◆ txt

dict ana_ShipMuon.txt = {}

Definition at line 514 of file ana_ShipMuon.py.

◆ withChain

int ana_ShipMuon.withChain = 0

Definition at line 317 of file ana_ShipMuon.py.

◆ xx

ana_ShipMuon.xx = os.path.abspath(".").lower()

Definition at line 319 of file ana_ShipMuon.py.

◆ zmuon

ana_ShipMuon.zmuon = muon.GetMatrix().GetTranslation()[2]

Definition at line 415 of file ana_ShipMuon.py.

◆ ztarget

float ana_ShipMuon.ztarget = -100.0

Definition at line 417 of file ana_ShipMuon.py.