4 @file FPGATrackSimPlotHits.py
5 @author Riley Xu - riley.xu@cern.ch
7 @brief Plots the hits from a specific event
9 FPGATrackSimPlotHits.py input_wrapper event
16 ROOT.gStyle.SetOptStat(00000000)
17 ROOT.gROOT.ForceStyle();
22 print(
"Plotting event " +
str(event) +
" from file " + filename)
24 f = ROOT.TFile(sys.argv[1],
"READ")
25 c = ROOT.TCanvas(
"c1",
"c1",1200,900)
28 t = f.Get(
"FPGATrackSimEventTree")
29 if event >= t.GetEntries():
30 raise IndexError(
"Bad entry " +
str(event))
33 hits = t.FPGATrackSimEventInputHeader.hits()
35 coords = np.empty((nhits, 3))
36 colors = np.empty(nhits, dtype=int)
37 styles = np.empty(nhits, dtype=int)
38 for i
in range(nhits):
40 coords[i] = (h.getX(), h.getY(), h.getZ())
41 colors[i] = 1 + h.getLayerDisk() % 9
44 styles[i] = ROOT.kCircle
if h.getSide()
else ROOT.kMultiply
46 rs = np.sqrt(np.power(coords[:, 0], 2) + np.power(coords[:, 1], 2))
49 g = ROOT.TGraph(nhits, coords[:, 2].astype(
"float"), rs)
51 g.GetXaxis().SetTitle(
"z (mm)")
52 g.GetYaxis().SetTitle(
"r (mm)")
57 for i
in range(nhits):
61 m = ROOT.TMarker(x, y, styles[i])
62 m.SetMarkerColor(colors[i])
67 g2 = ROOT.TGraph(nhits, coords[:, 0].astype(
"float"), coords[:, 1].astype(
"float"))
69 g2.GetXaxis().SetTitle(
"x (mm)")
70 g2.GetYaxis().SetTitle(
"y (mm)")
75 for i
in range(nhits):
79 m = ROOT.TMarker(x, y, styles[i])
80 m.SetMarkerColor(colors[i])
85 offline = t.FPGATrackSimEventInputHeader.optional().getOfflineClusters()
87 off_coords = np.empty((noff, 3))
88 off_colors = np.empty(noff, dtype=int)
89 off_styles = np.empty(noff, dtype=int)
91 h = offline[i].getClusterEquiv()
92 off_coords[i] = (h.getX(), h.getY(), h.getZ())
93 off_colors[i] = 1 + h.getLayerDisk() % 9
94 if off_colors[i] == 5:
96 off_styles[i] = ROOT.kCircle
if h.getSide()
else ROOT.kMultiply
98 off_rs = np.sqrt(np.power(off_coords[:, 0], 2) + np.power(off_coords[:, 1], 2))
102 off_g = ROOT.TGraph(noff, off_coords[:, 2].astype(
"float"), off_rs)
103 off_g.SetTitle(
"offline r vs z")
104 off_g.GetXaxis().SetTitle(
"z (mm)")
105 off_g.GetYaxis().SetTitle(
"r (mm)")
106 off_g.SetMarkerColor(0)
110 for i
in range(noff):
113 off_g.GetPoint(i, x, y)
114 m = ROOT.TMarker(x, y, off_styles[i])
115 m.SetMarkerColor(off_colors[i])
117 off_g._markers.append(m)
120 off_g2 = ROOT.TGraph(noff, off_coords[:, 0].astype(
"float"), off_coords[:, 1].astype(
"float"))
121 off_g2.SetTitle(
"offline y vs x")
122 off_g2.GetXaxis().SetTitle(
"x (mm)")
123 off_g2.GetYaxis().SetTitle(
"y (mm)")
124 off_g2.SetMarkerColor(0)
128 for i
in range(noff):
131 off_g2.GetPoint(i, x, y)
132 m = ROOT.TMarker(x, y, off_styles[i])
133 m.SetMarkerColor(off_colors[i])
135 off_g2._markers.append(m)
137 c.Print(
"Event_" +
str(event) +
".png")
139 if __name__ ==
"__main__":
140 plot(sys.argv[1],
int(sys.argv[2]))