14 parser = argparse.ArgumentParser(description=
'Script to create flux maps.')
17 help=
'''Simulation results to use as input. '''
18 '''Supports retrieving files from EOS via the XRootD protocol.''')
22 default=
'flux_map.root',
23 help=
'''File to write the flux maps to. '''
24 '''Will be recreated if it already exists.''')
25 args = parser.parse_args()
26 f = r.TFile.Open(args.outputfile,
'recreate')
33 for nplane
in range(0, 23):
34 ut.bookHist(h,
'NuTauMu_all_{}'.format(nplane),
35 'Rpc_{};x[cm];y[cm]'.format(
36 nplane), 100, -300, +300, 100, -300,
38 ut.bookHist(h,
'NuTauMu_mu_{}'.format(nplane),
39 'Rpc_{};x[cm];y[cm]'.format(
40 nplane), 100, -300, +300, 100, -300,
42 for suffix, title
in [(
'mu',
'#mu#pm hits'), (
'all',
'All hits')]:
43 ut.bookHist(h,
'muon_tiles_{}'.format(suffix),
44 '{};x[cm];y[cm]'.format(title), 200, -1000, +1000, 90,
46 ut.bookHist(h,
'muon_bars_x_{}'.format(suffix),
47 '{};x[cm];y[cm]'.format(title), 2, -300, +300, 240, -600,
49 ut.bookHist(h,
'muon_bars_y_{}'.format(suffix),
50 '{};x[cm];y[cm]'.format(title), 120, -300, +300, 4, -600,
52 ut.bookHist(h,
'timing_{}'.format(suffix),
53 '{};x[cm];y[cm]'.format(title), 3, -252, +252, 167, -501,
55 ut.bookHist(h,
'TargetTracker_{}'.format(suffix),
56 '{};x[cm];y[cm]'.format(title), 120, -60, 60, 120, -60,
58 ut.bookHist(h,
'TargetTracker_yvsz_{}'.format(suffix),
59 '{};z[cm];y[cm]'.format(
60 title), 400, -3300, -2900, 120, -60,
62 ut.bookHist(h,
'TargetTracker_xvsz_{}'.format(suffix),
63 '{};z[cm];x[cm]'.format(
64 title), 400, -3300, -2900, 120, -60,
66 ut.bookHist(h,
'NuTauMu_{}'.format(suffix),
67 '{};x[cm];y[cm]'.format(title), 100, -300, +300, 100, -300,
69 ut.bookHist(h,
'NuTauMu_yvsz_{}'.format(suffix),
70 '{};z[cm];y[cm]'.format(
71 title), 200, -2680, -2480, 600, -300,
73 ut.bookHist(h,
'NuTauMu_xvsz_{}'.format(suffix),
74 '{};z[cm];x[cm]'.format(
75 title), 200, -2680, -2480, 600, -300,
77 ut.bookHist(h,
'ECAL_TP_{}'.format(suffix),
78 '{};x[cm];y[cm]'.format(title), 167, -501, +501, 334,
80 ut.bookHist(h,
'ECAL_Alt_{}'.format(suffix),
81 '{};x[cm];y[cm]'.format(title), 50, -500, +500, 100, -1000,
83 ut.bookHist(h,
'SBT_Liquid_{}'.format(suffix),
84 '{};z[cm];#phi'.format(title), 100, -3000, +3000, 100,
85 -r.TMath.Pi(), r.TMath.Pi())
86 ut.bookHist(h,
'SBT_Plastic_{}'.format(suffix),
87 '{};z[cm];#phi'.format(title), 100, -3000, +3000, 100,
88 -r.TMath.Pi(), r.TMath.Pi())
89 for station
in range(1, 5):
90 ut.bookHist(h,
'T{}_{}'.format(station, suffix),
91 '{};x[cm];y[cm]'.format(title), 10, -250, +250, 20,
94 ut.bookHist(h,
'NuTauMu_mu_p',
'#mu#pm;p[GeV];', 100, 0, maxp)
95 ut.bookHist(h,
'NuTauMu_mu_pt',
'#mu#pm;p_t[GeV];', 100, 0,
97 ut.bookHist(h,
'NuTauMu_mu_ppt',
'#mu#pm;p[GeV];p_t[GeV];',
98 100, 0, maxp, 100, 0, maxpt)
99 ut.bookHist(h,
'NuTauMu_all_p',
'#mu#pm;p[GeV];', 100, 0, maxp)
100 ut.bookHist(h,
'NuTauMu_all_pt',
'#mu#pm;p_t[GeV];', 100, 0,
102 ut.bookHist(h,
'NuTauMu_all_ppt',
'#mu#pm;p[GeV];p_t[GeV];',
103 100, 0, maxp, 100, 0, maxpt)
105 for suffix
in [
'',
'_original']:
106 ut.bookHist(h,
'mu_p{}'.format(suffix),
'#mu#pm;p[GeV];', 100, 0, maxp)
107 ut.bookHist(h,
'mu_pt{}'.format(suffix),
'#mu#pm;p_t[GeV];', 100, 0,
109 ut.bookHist(h,
'mu_ppt{}'.format(suffix),
'#mu#pm;p[GeV];p_t[GeV];',
110 100, 0, maxp, 100, 0, maxpt)
111 ut.bookHist(h,
'ECAL_TP_e',
'e#pm with E#geq 250 MeV;x[cm];y[cm]', 167,
112 -501, +501, 334, -1002, 1002)
113 ut.bookHist(h,
'ECAL_Alt_e',
'e#pm with E#geq 250 MeV;x[cm];y[cm]', 50,
114 -500, +500, 100, -1000, 1000)
115 ut.bookHist(h,
'ECAL_TP_gamma',
'#gamma;x[cm];y[cm]', 167, -501, +501, 334,
117 ut.bookHist(h,
'ECAL_Alt_gamma',
'#gamma;x[cm];y[cm]', 50, -500, +500, 100,
119 ut.bookHist(h,
'ECAL_e_E',
'e#pm;E[GeV/c^{2}];', 100, 0, 1)
120 ut.bookHist(h,
'ECAL_gamma_E',
'#gamma;E[GeV/c^{2}];', 100, 0, 1)
121 ch = r.TChain(
'cbmsim')
122 ch.Add(args.inputfile)
128 log.info(
'{}/{}'.format(i, n))
131 for hit
in event.strawtubesPoint:
133 if not hit.GetEnergyLoss() > 0:
135 trid = hit.GetTrackID()
137 weight = event.MCTrack[trid].GetWeight()
144 pt = np.hypot(px, py)
147 assert pid
not in [12, -12, 14, -14, 16, -16]
148 detector_ID = hit.GetDetectorID()
149 station = detector_ID // 10000000
150 h[
'T{}_all'.format(station)].Fill(x, y, weight)
154 h[
'T{}_mu'.format(station)].Fill(x, y, weight)
155 h[
'mu_p'].Fill(P, weight)
156 h[
'mu_pt'].Fill(pt, weight)
157 h[
'mu_ppt'].Fill(P, pt, weight)
158 for hit
in event.EcalPoint:
160 if not hit.GetEnergyLoss() > 0:
162 trid = hit.GetTrackID()
164 weight = event.MCTrack[trid].GetWeight()
170 pt = np.hypot(px, py)
173 if pid
in [12, -12, 14, -14, 16, -16]:
175 h[
'ECAL_TP_all'].Fill(x, y, weight)
176 h[
'ECAL_Alt_all'].Fill(x, y, weight)
180 h[
'mu_p'].Fill(P, weight)
181 h[
'mu_pt'].Fill(pt, weight)
182 h[
'mu_ppt'].Fill(P, pt, weight)
183 h[
'ECAL_TP_mu'].Fill(x, y, weight)
184 h[
'ECAL_Alt_mu'].Fill(x, y, weight)
186 Esq = px ** 2 + py ** 2 + pz ** 2 + 0.000511 ** 2
187 h[
'ECAL_e_E'].Fill(np.sqrt(Esq), weight)
188 h[
'ECAL_TP_e'].Fill(x, y, weight)
189 h[
'ECAL_Alt_e'].Fill(x, y, weight)
191 Esq = px ** 2 + py ** 2 + pz ** 2
192 h[
'ECAL_gamma_E'].Fill(np.sqrt(Esq), weight)
193 h[
'ECAL_TP_gamma'].Fill(x, y, weight)
194 h[
'ECAL_Alt_gamma'].Fill(x, y, weight)
195 for hit
in event.TTPoint:
197 if not hit.GetEnergyLoss() > 0:
199 trid = hit.GetTrackID()
201 detID = hit.GetDetectorID()
202 weight = event.MCTrack[trid].GetWeight()
209 pt = np.hypot(px, py)
212 assert pid
not in [12, -12, 14, -14, 16, -16]
214 h[
'TargetTracker_all'].Fill(x, y, weight)
215 h[
'TargetTracker_xvsz_all'].Fill(z, x, weight)
216 h[
'TargetTracker_yvsz_all'].Fill(z, y, weight)
220 h[
'mu_p'].Fill(P, weight)
221 h[
'mu_pt'].Fill(pt, weight)
222 h[
'mu_ppt'].Fill(P, pt, weight)
224 h[
'TargetTracker_mu'].Fill(x, y, weight)
225 h[
'TargetTracker_xvsz_mu'].Fill(z, x, weight)
226 h[
'TargetTracker_yvsz_mu'].Fill(z, y, weight)
227 for hit
in event.ShipRpcPoint:
229 if not hit.GetEnergyLoss() > 0:
231 trid = hit.GetTrackID()
233 detID = hit.GetDetectorID()
234 nplane = detID - 10000
235 weight = event.MCTrack[trid].GetWeight()
242 pt = np.hypot(px, py)
245 assert pid
not in [12, -12, 14, -14, 16, -16]
246 h[
'NuTauMu_all'].Fill(x, y, weight)
248 h[
'NuTauMu_all_{}'.format(nplane)].Fill(x, y, weight)
249 h[
'NuTauMu_xvsz_all'].Fill(z, x, weight)
250 h[
'NuTauMu_yvsz_all'].Fill(z, y, weight)
252 h[
'NuTauMu_all_p'].Fill(P, weight)
253 h[
'NuTauMu_all_pt'].Fill(pt, weight)
254 h[
'NuTauMu_all_ppt'].Fill(P, pt, weight)
258 h[
'mu_p'].Fill(P, weight)
259 h[
'mu_pt'].Fill(pt, weight)
260 h[
'mu_ppt'].Fill(P, pt, weight)
261 h[
'NuTauMu_mu'].Fill(x, y, weight)
264 h[
'NuTauMu_mu_{}'.format(nplane)].Fill(x, y, weight)
266 h[
'NuTauMu_mu_p'].Fill(P, weight)
267 h[
'NuTauMu_mu_pt'].Fill(pt, weight)
268 h[
'NuTauMu_mu_ppt'].Fill(P, pt, weight)
269 h[
'NuTauMu_xvsz_mu'].Fill(z, x, weight)
270 h[
'NuTauMu_yvsz_mu'].Fill(z, y, weight)
271 for hit
in event.TimeDetPoint:
273 if not hit.GetEnergyLoss() > 0:
275 trid = hit.GetTrackID()
277 weight = event.MCTrack[trid].GetWeight()
284 pt = np.hypot(px, py)
287 assert pid
not in [12, -12, 14, -14, 16, -16]
288 h[
'timing_all'].Fill(x, y, weight)
292 h[
'mu_p'].Fill(P, weight)
293 h[
'mu_pt'].Fill(pt, weight)
294 h[
'mu_ppt'].Fill(P, pt, weight)
295 h[
'timing_mu'].Fill(x, y, weight)
296 for hit
in event.muonPoint:
298 if not hit.GetEnergyLoss() > 0:
300 trid = hit.GetTrackID()
302 weight = event.MCTrack[trid].GetWeight()
308 pt = np.hypot(px, py)
311 assert pid
not in [12, -12, 14, -14, 16, -16]
312 h[
'muon_tiles_all'].Fill(x, y, weight)
313 h[
'muon_bars_x_all'].Fill(x, y, weight)
314 h[
'muon_bars_y_all'].Fill(x, y, weight)
318 h[
'mu_p'].Fill(P, weight)
319 h[
'mu_pt'].Fill(pt, weight)
320 h[
'mu_ppt'].Fill(P, pt, weight)
321 h[
'muon_tiles_mu'].Fill(x, y, weight)
322 h[
'muon_bars_y_mu'].Fill(x, y, weight)
323 h[
'muon_bars_x_mu'].Fill(x, y, weight)
324 for hit
in event.vetoPoint:
326 if not hit.GetEnergyLoss() > 0:
328 trid = hit.GetTrackID()
330 weight = event.MCTrack[trid].GetWeight()
337 pt = np.hypot(px, py)
340 detector_ID = hit.GetDetectorID()
341 assert pid
not in [12, -12, 14, -14, 16, -16]
342 phi = r.TMath.ATan2(y, x)
343 if 99999 < detector_ID < 999999:
344 h[
'SBT_Liquid_all'].Fill(z, phi, weight)
348 h[
'mu_p'].Fill(P, weight)
349 h[
'mu_pt'].Fill(pt, weight)
350 h[
'mu_ppt'].Fill(P, pt, weight)
351 h[
'SBT_Liquid_mu'].Fill(z, phi, weight)
353 elif detector_ID > 999999:
354 h[
'SBT_Plastic_all'].Fill(z, phi, weight)
358 h[
'mu_p'].Fill(P, weight)
359 h[
'mu_pt'].Fill(pt, weight)
360 h[
'mu_ppt'].Fill(P, pt, weight)
361 h[
'SBT_Plastic_mu'].Fill(z, phi, weight)
363 log.warn(
'Unidentified vetoPoint.')
365 original_muon = event.MCTrack[muonid]
366 weight = original_muon.GetWeight()
367 h[
'mu_p_original'].Fill(original_muon.GetP(), weight)
368 h[
'mu_pt_original'].Fill(original_muon.GetPt(), weight)
369 h[
'mu_ppt_original'].Fill(original_muon.GetP(),
370 original_muon.GetPt(), weight)
373 log.info(
'Event loop done')
375 classname = h[key].Class().GetName()
376 if 'TH' in classname
or 'TP' in classname: