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

Functions

None processFile (str fin, bool noCharm=True)
 
None run ()
 
None run1GeV ()
 
None run4Charm ()
 
None run4Charm1GeV ()
 
None run4beauty ()
 
None finalResult ()
 

Variables

str path = "/eos/experiment/ship/data/Mbias/background-prod-2018/"
 
list charmExtern = [4332, 4232, 4132, 4232, 4122, 431, 411, 421, 15]
 
list neutrinos = [12, 14, 16]
 
float weightMbias = 768.75
 
float weightMbias1GeV = 27778.0
 
float weightCharm = 326.0
 
float weightCharm1GeV = 4895.24
 
float weightBeauty = 9.37
 
dict h = {}
 
ROOT PDG = ROOT.TDatabasePDG.Instance()
 
idnu idw = idnu
 
int idhnu = 1000 + idw
 
ROOT name = PDG.GetParticle(idw).GetName()
 
ROOT title = name + " momentum (GeV)"
 
int key = idhnu
 

Function Documentation

◆ finalResult()

None extractNeutrinosAndUpdateWeight.finalResult ( )

Definition at line 134 of file extractNeutrinosAndUpdateWeight.py.

134def finalResult() -> None:
135 h10 = {}
136 ut.readHists(h10, "pythia8_Geant4_10.0_c0-67000_nu.root")
137 h1 = {}
138 ut.readHists(h1, "pythia8_Geant4_1.0_c0-19000_nu.root")
139 c10 = {}
140 ut.readHists(c10, "pythia8_Geant4_charm_10.0_nu.root")
141 c1 = {}
142 ut.readHists(c1, "pythia8_Geant4_charm_1.0_nu.root")
143 cmd = "hadd pythia8_Geant4_10.0_withCharm_nu.root pythia8_Geant4_10.0_c0-67000_nu.root pythia8_Geant4_charm_10.0_nu.root"
144 os.system(cmd)
145 cmd = (
146 "hadd pythia8_Geant4_1.0_withCharm_nu.root pythia8_Geant4_1.0_c0-19000_nu.root pythia8_Geant4_charm_1.0_nu.root"
147 )
148 os.system(cmd)

◆ processFile()

None extractNeutrinosAndUpdateWeight.processFile ( str  fin,
bool   noCharm = True 
)

Definition at line 54 of file extractNeutrinosAndUpdateWeight.py.

54def processFile(fin: str, noCharm: bool = True) -> None:
55 f = ROOT.TFile.Open(os.environ["EOSSHIP"] + path + fin)
56 print("opened file ", fin)
57 sTree = f.Get("cbmsim")
58 for n in range(sTree.GetEntries()):
59 sTree.GetEntry(n)
60 for v in sTree.vetoPoint:
61 nu = v.GetTrackID()
62 t = sTree.MCTrack[nu]
63 pdgCode = t.GetPdgCode()
64 if abs(pdgCode) not in neutrinos:
65 continue
66 moID = abs(sTree.MCTrack[t.GetMotherId()].GetPdgCode())
67 if moID in charmExtern and noCharm:
68 continue # take heavy flavours from separate production
69 idhnu = abs(pdgCode) + 1000
70 if pdgCode < 0:
71 idhnu += 1000
72 l10ptot = ROOT.TMath.Min(ROOT.TMath.Max(ROOT.TMath.Log10(t.GetP()), -0.3), 1.69999)
73 l10pt = ROOT.TMath.Min(ROOT.TMath.Max(ROOT.TMath.Log10(t.GetPt()), -2.0), 0.4999)
74 key = idhnu
75 h[key].Fill(t.GetP(), weight)
76 key = idhnu + 100
77 h[key].Fill(l10ptot, l10pt, weight)
78 key = idhnu + 200
79 h[key].Fill(l10ptot, l10pt, weight)
80
81

◆ run()

None extractNeutrinosAndUpdateWeight.run ( )

Definition at line 82 of file extractNeutrinosAndUpdateWeight.py.

82def run() -> None:
83 tmp = "pythia8_Geant4_10.0_cXX.root"
84 global weight
85 weight = weightMbias
86 for run in range(0, 67000, 1000):
87 processFile(tmp.replace("XX", str(run)))
88 ut.writeHists(h, "pythia8_Geant4_10.0_c0-67000_nu.root")
89
90

◆ run1GeV()

None extractNeutrinosAndUpdateWeight.run1GeV ( )

Definition at line 91 of file extractNeutrinosAndUpdateWeight.py.

91def run1GeV() -> None:
92 tmp = "pythia8_Geant4_1.0_cXX.root"
93 global weight
94 weight = weightMbias1GeV
95 for run in range(0, 19000, 1000):
96 processFile(tmp.replace("XX", str(run)))
97 ut.writeHists(h, "pythia8_Geant4_1.0_c0-19000_nu.root")
98
99

◆ run4beauty()

None extractNeutrinosAndUpdateWeight.run4beauty ( )

Definition at line 120 of file extractNeutrinosAndUpdateWeight.py.

120def run4beauty() -> None:
121 global weight
122 weight = weightBeauty
123 fname = "pythia8_Geant4_beauty_5336B_10.0.root"
124 rc = processFile(fname, False)
125 if rc == 0:
126 fmu = fname.replace(".root", "_mu.root")
127 rc = os.system("xrdcp " + fmu + " $EOSSHIP/eos/experiment/ship/data/Mbias/background-prod-2018/" + fmu)
128 if rc != 0:
129 print("copy to EOS failed, stop", fmu)
130 else:
131 rc = os.system("rm " + fmu)
132
133

◆ run4Charm()

None extractNeutrinosAndUpdateWeight.run4Charm ( )

Definition at line 100 of file extractNeutrinosAndUpdateWeight.py.

100def run4Charm() -> None:
101 tmp = "pythia8_Geant4_charm_XX-YY_10.0.root"
102 global weight
103 weight = weightCharm
104 for cycle in [0, 1, 2]:
105 for run in range(0, 100, 20):
106 crun = run + cycle * 1000
107 fname = tmp.replace("XX", str(crun)).replace("YY", str(crun + 19))
108 processFile(fname, False)
109 ut.writeHists(h, "pythia8_Geant4_charm_10.0_nu.root")
110
111

◆ run4Charm1GeV()

None extractNeutrinosAndUpdateWeight.run4Charm1GeV ( )

Definition at line 112 of file extractNeutrinosAndUpdateWeight.py.

112def run4Charm1GeV() -> None:
113 fname = "pythia8_Geant4_charm_0-19_1.0.root" # renamed pythia8_Geant4_charm_XX-YY_10.0.root
114 global weight
115 weight = weightCharm1GeV
116 processFile(fname, False)
117 ut.writeHists(h, "pythia8_Geant4_charm_1.0_nu.root")
118
119

Variable Documentation

◆ charmExtern

list extractNeutrinosAndUpdateWeight.charmExtern = [4332, 4232, 4132, 4232, 4122, 431, 411, 421, 15]

Definition at line 14 of file extractNeutrinosAndUpdateWeight.py.

◆ h

dict extractNeutrinosAndUpdateWeight.h = {}

Definition at line 32 of file extractNeutrinosAndUpdateWeight.py.

◆ idhnu

int extractNeutrinosAndUpdateWeight.idhnu = 1000 + idw

Definition at line 38 of file extractNeutrinosAndUpdateWeight.py.

◆ idw

idnu extractNeutrinosAndUpdateWeight.idw = idnu

Definition at line 37 of file extractNeutrinosAndUpdateWeight.py.

◆ key

int extractNeutrinosAndUpdateWeight.key = idhnu

Definition at line 44 of file extractNeutrinosAndUpdateWeight.py.

◆ name

ROOT extractNeutrinosAndUpdateWeight.name = PDG.GetParticle(idw).GetName()

Definition at line 42 of file extractNeutrinosAndUpdateWeight.py.

◆ neutrinos

list extractNeutrinosAndUpdateWeight.neutrinos = [12, 14, 16]

Definition at line 15 of file extractNeutrinosAndUpdateWeight.py.

◆ path

str extractNeutrinosAndUpdateWeight.path = "/eos/experiment/ship/data/Mbias/background-prod-2018/"

Definition at line 9 of file extractNeutrinosAndUpdateWeight.py.

◆ PDG

ROOT extractNeutrinosAndUpdateWeight.PDG = ROOT.TDatabasePDG.Instance()

Definition at line 33 of file extractNeutrinosAndUpdateWeight.py.

◆ title

ROOT extractNeutrinosAndUpdateWeight.title = name + " momentum (GeV)"

Definition at line 43 of file extractNeutrinosAndUpdateWeight.py.

◆ weightBeauty

float extractNeutrinosAndUpdateWeight.weightBeauty = 9.37

Definition at line 29 of file extractNeutrinosAndUpdateWeight.py.

◆ weightCharm

float extractNeutrinosAndUpdateWeight.weightCharm = 326.0

Definition at line 24 of file extractNeutrinosAndUpdateWeight.py.

◆ weightCharm1GeV

float extractNeutrinosAndUpdateWeight.weightCharm1GeV = 4895.24

Definition at line 26 of file extractNeutrinosAndUpdateWeight.py.

◆ weightMbias

float extractNeutrinosAndUpdateWeight.weightMbias = 768.75

Definition at line 18 of file extractNeutrinosAndUpdateWeight.py.

◆ weightMbias1GeV

float extractNeutrinosAndUpdateWeight.weightMbias1GeV = 27778.0

Definition at line 20 of file extractNeutrinosAndUpdateWeight.py.