19 """Fill BKLM histograms of values from RawKLMs, KLMDigits, BKLMHit1ds, and BKLMHit2ds;
20 (optionally) draw event displays from these data-objects.
"""
37 BKLM_MAXSTRIP_BIT = 15
39 BKLM_STRIP_MASK = 0x3f
41 BKLM_PLANE_MASK = (1 << BKLM_PLANE_BIT)
43 BKLM_LAYER_MASK = (15 << BKLM_LAYER_BIT)
45 BKLM_SECTOR_MASK = (7 << BKLM_SECTOR_BIT)
47 BKLM_SECTION_MASK = (1 << BKLM_SECTION_BIT)
49 BKLM_MAXSTRIP_MASK = (63 << BKLM_MAXSTRIP_BIT)
51 BKLM_MODULEID_MASK = (BKLM_SECTION_MASK | BKLM_SECTOR_MASK | BKLM_LAYER_MASK)
53 def __init__(self, exp, run, histName, pdfName):
57 exp (str): formatted experiment number
58 run (str): formatter run number
59 histName (str): path name of the output histogram ROOT file
60 pdfName (str): path name of the output histogram PDF file
61 eventPdfName (str): path name of the output event-display PDF file
62 maxDisplays (int): max
76 """Create and return a ROOT TGraph
79 x[] (real): x coordinates
80 y[] (real): y coordinates
83 for i
in range(0, len(x)):
84 graph.SetPoint(i, x[i], y[i])
90 """Create and return a ROOT TLatex with the following properties:
91 size = 0.04, color = red, alignment = middle centre, angle = 90 degrees
94 x (real): x coordinate
95 y (real): y coordinate
96 s (str): character string
98 text = ROOT.TLatex(x, y, s)
99 text.SetTextSize(0.04)
101 text.SetTextAlign(22)
102 text.SetTextAngle(90)
106 """Handle job initialization: create histograms"""
108 expRun = f
'e{int(self.exp):02d}r{int(self.run)}: '
117 expRun +
'tt_ctime relative to triggertime;' +
118 'tt_ctime - triggertime (ns)',
122 expRun +
'RawKLM lane;Lane (scint: 1..7, RPC: 8..20)',
126 expRun +
'RawKLM word count (N/channel)',
130 expRun +
'RawKLM word count (1/channel)',
134 'PerChannelMultiplicity',
135 expRun +
'Per-channel multiplicity (N/channel > 1);' +
136 'Per-channel multiplicity;' +
137 '(Lane #) * 2 + (Axis #)',
138 30, -0.5, 29.5, 42, -0.5, 41.5)
141 'RPCLaneAxisOccupancy',
142 expRun +
'Lane/axis occupancy of RPC channels (1/channel);' +
143 'Sector # (always 0);' +
144 '(Lane #) * 2 + (Axis #)',
145 3, -1.5, 1.5, 42, -0.5, 41.5)
148 'ScintLaneAxisOccupancy',
149 expRun +
'Lane/axis occupancy of scint channels (1/channel);' +
150 'Sector # (always 0);' +
151 '(Lane #) * 2 + (Axis #)',
152 3, -1.5, 1.5, 42, -0.5, 41.5)
156 expRun +
'Channel occupancy for axis 0;lane;channel',
157 42, -0.25, 20.75, 128, -0.25, 63.75)
159 expRun +
'Channel occupancy for axis 1;lane;channel',
160 42, -0.25, 20.75, 128, -0.25, 63.75)
163 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
164 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
165 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
166 for lane
in range(0, 21):
167 nChannels = 64
if (lane > 2)
else 128
168 label = f
'ChannelOccupancy_A0L{lane}'
169 title = f
'{expRun}Channel occupancy for axis 0 lane {lane};channel'
171 label = f
'ChannelOccupancy_A1L{lane}'
172 title = f
'{expRun}Channel occupancy for axis 1 lane {lane};channel'
176 expRun +
'RPC TDC lowest-order bits;' +
177 'Sector # (always 0);' +
178 'TDC % 4 (ns) [should be 0]',
179 3, -1.5, 1.5, 8, -0.25, 3.75)
182 expRun +
'RPC tdc relative to event trigtime;tdc - triggerTime (ns)',
186 expRun +
'RPC tdc relative to event ctime;tdc - trigCtime (ns)',
189 self.
hist_RPCTimePerLayerA0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
190 for lane
in range(0, 21):
191 label = f
'RPCTimeA0L{lane:02d}'
192 title = f
'{expRun}RPC axis 0 lane {lane} time relative to trigtime;t - triggerTime (ns)'
195 self.
hist_RPCTimePerLayerA1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
196 for lane
in range(0, 21):
197 label = f
'RPCTimeA1L{lane:02d}'
198 title = f
'{expRun}RPC axis 1 lane {lane} time relative to trigtime;t - triggerTime (ns)'
201 self.
hist_RPCTime2PerLayerA0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
202 for lane
in range(0, 21):
203 label = f
'RPCTime2A0L{lane:02d}'
204 title = f
'{expRun}RPC axis 0 lane {lane} time relative to trigCtime;t - trigCtime (ns)'
207 self.
hist_RPCTime2PerLayerA1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
208 for lane
in range(0, 21):
209 label = f
'RPCTime2A1L{lane:02d}'
210 title = f
'{expRun}RPC axis 1 lane {lane} time relative to trigCtime;t - trigCtime (ns)'
213 self.
hist_RPCTdcRange = ROOT.TH1F(
'RPCTdcRange', expRun +
'RPC TDC-range in event;TDCMax - TDCMin (ns)', 512, -0.5, 2047.5)
216 expRun +
'RPC revotime-range in event;revotimeMax - revotimeMin (ns)',
220 expRun +
'RPC TDC vs revotime;tdc (ns);revotime - minRevotime',
221 64, 767.5, 1023.5, 10, -0.5, 159.5)
225 expRun +
'RPC TDC vs revotime;' +
226 'tdc - dt(index) (ns);' +
227 'revotime - minRevotime',
228 64, 767.5, 1023.5, 10, -0.5, 159.5)
231 expRun +
'RPC TDC vs hit index;tdc (ns);Hit index',
232 64, 767.5, 1023.5, 60, -0.5, 59.5)
235 expRun +
'RPC TDC vs hit index;tdc - dt(index) (ns);Hit index',
236 64, 767.5, 1023.5, 60, -0.5, 59.5)
239 'ScintTimeLowBitsBySector',
240 expRun +
'Scint TDC lowest-order bits;' +
241 'Sector # (always 0);' +
243 3, -1.5, 1.5, 8, -0.25, 3.75)
246 expRun +
'Scint tdc distribution;tdc - triggerTime (ns)',
250 expRun +
'Scint ctime distribution;ctime - triggerCtime (ns)',
254 expRun +
'Scint ctime distribution;ctime - triggerTime (ns)',
258 'ScintCtimeRange', expRun +
'Scint ctime-range in event;ctimeMax - ctimeMin (ns)', 128, -0.5, 8191.5)
261 """Handle job termination: draw histograms, close output files"""
263 canvas = ROOT.TCanvas(
"canvas", self.
pdfName, 1600, 1600)
264 title = f
'{self.pdfName}['
267 canvas.GetPad(0).SetGrid(1, 1)
268 canvas.GetPad(0).Update()
270 canvas.Print(self.
pdfName, f
"Title:{self.hist_rawKLMlane.GetName()}")
272 canvas.Print(self.
pdfName, f
"Title:{self.hist_rawKLMsizeMultihit.GetName()}")
274 canvas.Print(self.
pdfName, f
"Title:{self.hist_rawKLMsize.GetName()}")
276 canvas.Print(self.
pdfName, f
"Title:{self.hist_PerChannelMultiplicity.GetName()}")
279 canvas.GetPad(0).SetGrid(1, 1)
280 canvas.GetPad(1).SetGrid(1, 1)
281 canvas.GetPad(2).SetGrid(1, 1)
282 for sectorFB
in range(0, 1):
287 canvas.Print(self.
pdfName, f
"Title:{self.hist_ChannelOccupancy[0].GetName()}")
288 for lane
in range(0, 21):
296 canvas.Print(self.
pdfName, f
"Title:{self.hist_ChannelOccupancyAL[lane][0].GetName()}")
300 canvas.Print(self.
pdfName, f
"Title:{self.hist_ttc_trigtime.GetName()}")
302 canvas.Print(self.
pdfName, f
"Title:{self.hist_RPCTimeLowBitsBySector.GetName()}")
304 canvas.Print(self.
pdfName, f
"Title:{self.hist_RPCTime.GetName()}")
305 for lane
in range(0, 21):
308 canvas.Print(self.
pdfName, f
"Title:{self.hist_RPCTimePerLayerA0[lane].GetName()}")
309 for lane
in range(0, 21):
312 canvas.Print(self.
pdfName, f
"Title:{self.hist_RPCTimePerLayerA1[lane].GetName()}")
314 canvas.Print(self.
pdfName, f
"Title:{self.hist_RPCTdcRange.GetName()}")
316 canvas.Print(self.
pdfName, f
"Title:{self.hist_RPCRevotimeRange.GetName()}")
318 canvas.Print(self.
pdfName, f
"Title:{self.hist_revotimeRPCtdc.GetName()}")
322 canvas.Print(self.
pdfName, f
"Title:{self.hist_jRPCtdc.GetName()}")
326 canvas.Print(self.
pdfName, f
"Title:{self.hist_ScintTimeLowBitsBySector.GetName()}")
328 canvas.Print(self.
pdfName, f
"Title:{self.hist_ScintTime.GetName()}")
330 canvas.Print(self.
pdfName, f
"Title:{self.hist_ScintCtime.GetName()}")
332 canvas.Print(self.
pdfName, f
"Title:{self.hist_ScintCtime0.GetName()}")
334 canvas.Print(self.
pdfName, f
"Title:{self.hist_ScintCtimeRange.GetName()}")
335 pdfNameLast = f
'{self.pdfName}]'
336 canvas.Print(pdfNameLast, f
"Title:{self.hist_ScintCtimeRange.GetName()}")
342 """Handle begin of run: print diagnostic message"""
343 print(
'beginRun', self.
run)
346 """Handle end of run: print diagnostic message"""
347 print(
'endRun', self.
run)
349 def event(self, eventHits, tt_ctime, raw_time):
350 """Process one event: fill histograms"""
354 countAllMultihit = 2 * n + 1
if (n > 0)
else 0
356 channelMultiplicity = {}
362 minScintCtime = 99999
365 for j
in range(0, n):
371 flag = 1
if (lane > 2)
else 2
373 isScint = (flag == 2)
374 laneAxisChannel = (((lane << 1) + axis) << 7) + channel
375 if laneAxisChannel
not in channelMultiplicity:
376 countAll = countAll + 2
377 channelMultiplicity[laneAxisChannel] = 0
378 channelMultiplicity[laneAxisChannel] = channelMultiplicity[laneAxisChannel] + 1
382 for j
in range(0, n):
390 flag = 1
if (lane > 2)
else 2
392 isScint = (flag == 2)
393 laneAxisChannel = (((lane << 1) + axis) << 7) + channel
394 laneAxis = axis
if ((lane < 1)
or (lane > 20))
else ((lane << 1) + axis)
395 if laneAxisChannel
in channelMultiplicity:
396 if channelMultiplicity[laneAxisChannel] > 1:
399 t = (tdc - raw_time) & 0x03ff
400 t2 = (tdc - tt_ctime) & 0x03ff
401 ct = ((ctime << 3) - tt_ctime) & 0x3ff
407 if ctime < minRPCCtime:
409 if ctime > maxRPCCtime:
428 if ctime < minScintCtime:
429 minScintCtime = ctime
430 if ctime > maxScintCtime:
431 maxScintCtime = ctime
444 if maxScintCtime > 0:
hist_ChannelOccupancyAL
histograms of channel occupancy (1 hit per readout channel), indexed by axis/lane
run
internal copy of run number
hist_PerChannelMultiplicity
scatterplot of multiplicity of entries in one readout channel vs lane/axis
hist_ScintCtimeRange
histogram of scint CTIME range in event
def makeText(self, x, y, s)
hist_rawKLMlane
histogram of the hit's lane
hist_RPCTimePerLayerA0
histograms of RPC TDC value relative to event's trigger time for axis 0, indexed by lane
hist_jRPCtdc
scatterplot of RPC calibrated time vs hit's index
hist_RPCTimePerLayerA1
histograms of RPC TDC value relative to event's trigger time for axis 1, indexed by lane
hist_RPCTdcRange
histogram of RPC TDC range in event
hist_RPCTime2PerLayerA0
histograms of RPC TDC value relative to event's ctime for axis 0, indexed by lane
hist_ScintLaneAxisOccupancy
scatterplot of number of mapped scint hits by lane/axis vs sector, at most one entry per readout chan...
def event(self, eventHits, tt_ctime, raw_time)
hist_rawKLMsizeMultihit
histogram of number of hits, including multiple entries on one readout channel
def makeGraph(self, x, y)
hist_revotimeRPCtdc
scatterplot of RPC REVO9 range vs TDC value in event
hist_ChannelOccupancy
scatterplots of channel occupancy (1 hit per readout channel) for each axis
hist_revotimeRPCtdc2
scatterplot of RPC REVO9 range vs TDC value corrected for DC-processing delay in event
hist_ttc_trigtime
histogram of the tt_ctime relative to triggertime
exp
internal copy of experiment number
def __init__(self, exp, run, histName, pdfName)
hist_RPCRevotimeRange
histogram of RPC REVO9 range in event
hist_RPCTimeLowBitsBySector
scatterplot of RPC TDC low-order bits vs sector (should be 0 since granularity is 4 ns)
hist_RPCTime2
histogram of RPC TDC value relative to event's ctime in event header
hist_ScintCtime
histogram of scint CTIME value relative to event's ctime
hist_RPCTime
histogram of RPC TDC value relative to event's REVO9 trigger time in last word of event
hist_ScintTime
histogram of scint TDC value relative to event's trigger time
pdfName
internal copy of the pathname of the output histogram PDF file
hist_RPCTime2PerLayerA1
histograms of RPC TDC value relative to event's ctime for axis 1, indexed by lane
histogramFile
Output ROOT TFile that will contain the histograms/scatterplots.
hist_ScintTimeLowBitsBySector
scatterplot of scint TDC low-order bits vs sector
histName
internal copy of the pathname of the output histogram ROOT file
hist_RPCLaneAxisOccupancy
scatterplot of number of mapped RPC hits by lane/axis vs sector, at most one entry per readout channe...
hist_ScintCtime0
histogram of scint CTIME value relative to event's trigger time
hist_rawKLMsize
histogram of number of hits, at most one entry per readout channel
hist_jRPCtdc2
scatterplot of RPC calibrated time vs hit's index, corrected for DC-processing delay