20 """Fill BKLM histograms of values from RawKLMs, KLMDigits, BKLMHit1ds, and BKLMHit2ds;
21 (optionally) draw event displays from these data-objects."""
38 BKLM_MAXSTRIP_BIT = 15
40 BKLM_STRIP_MASK = 0x3f
42 BKLM_PLANE_MASK = (1 << BKLM_PLANE_BIT)
44 BKLM_LAYER_MASK = (15 << BKLM_LAYER_BIT)
46 BKLM_SECTOR_MASK = (7 << BKLM_SECTOR_BIT)
48 BKLM_SECTION_MASK = (1 << BKLM_SECTION_BIT)
50 BKLM_MAXSTRIP_MASK = (63 << BKLM_MAXSTRIP_BIT)
52 BKLM_MODULEID_MASK = (BKLM_SECTION_MASK | BKLM_SECTOR_MASK | BKLM_LAYER_MASK)
54 def __init__(self, exp, run, histName, pdfName):
58 exp (str): formatted experiment number
59 run (str): formatter run number
60 histName (str): path name of the output histogram ROOT file
61 pdfName (str): path name of the output histogram PDF file
62 eventPdfName (str): path name of the output event-display PDF file
63 maxDisplays (int): max # of events displays to write
64 minRPCHits (int): min # of RPC BKLMHit2ds in any sector for event display
77 """Create and return a ROOT TGraph
80 x[] (real): x coordinates
81 y[] (real): y coordinates
84 for i
in range(0, len(x)):
85 graph.SetPoint(i, x[i], y[i])
91 """Create and return a ROOT TLatex with the following properties:
92 size = 0.04, color = red, alignment = middle centre, angle = 90 degrees
95 x (real): x coordinate
96 y (real): y coordinate
97 s (str): character string
99 text = ROOT.TLatex(x, y, s)
100 text.SetTextSize(0.04)
102 text.SetTextAlign(22)
103 text.SetTextAngle(90)
107 """Handle job initialization: create histograms"""
109 expRun =
'e{0:02d}r{1}: '.format(int(self.
expexp), int(self.
runrun))
118 expRun +
'tt_ctime relative to triggertime;' +
119 'tt_ctime - triggertime (ns)',
123 expRun +
'RawKLM lane;Lane (scint: 1..7, RPC: 8..20)',
127 expRun +
'RawKLM word count (N/channel)',
131 expRun +
'RawKLM word count (1/channel)',
135 'PerChannelMultiplicity',
136 expRun +
'Per-channel multiplicity (N/channel > 1);' +
137 'Per-channel multiplicity;' +
138 '(Lane #) * 2 + (Axis #)',
139 30, -0.5, 29.5, 42, -0.5, 41.5)
142 'RPCLaneAxisOccupancy',
143 expRun +
'Lane/axis occupancy of RPC channels (1/channel);' +
144 'Sector # (always 0);' +
145 '(Lane #) * 2 + (Axis #)',
146 3, -1.5, 1.5, 42, -0.5, 41.5)
149 'ScintLaneAxisOccupancy',
150 expRun +
'Lane/axis occupancy of scint channels (1/channel);' +
151 'Sector # (always 0);' +
152 '(Lane #) * 2 + (Axis #)',
153 3, -1.5, 1.5, 42, -0.5, 41.5)
157 expRun +
'Channel occupancy for axis 0;lane;channel',
158 42, -0.25, 20.75, 128, -0.25, 63.75)
160 expRun +
'Channel occupancy for axis 1;lane;channel',
161 42, -0.25, 20.75, 128, -0.25, 63.75)
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], [0, 0], [0, 0], [0, 0],
166 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
167 for lane
in range(0, 21):
168 nChannels = 64
if (lane > 2)
else 128
169 label =
'ChannelOccupancy_A0L{0}'.format(lane)
170 title =
'{0}Channel occupancy for axis 0 lane {1};channel'.format(expRun, lane)
171 self.
hist_ChannelOccupancyALhist_ChannelOccupancyAL[lane][0] = ROOT.TH1F(label, title, nChannels, -0.5, nChannels - 0.5)
172 label =
'ChannelOccupancy_A1L{0}'.format(lane)
173 title =
'{0}Channel occupancy for axis 1 lane {1};channel'.format(expRun, lane)
174 self.
hist_ChannelOccupancyALhist_ChannelOccupancyAL[lane][1] = ROOT.TH1F(label, title, nChannels, -0.5, nChannels - 0.5)
177 expRun +
'RPC TDC lowest-order bits;' +
178 'Sector # (always 0);' +
179 'TDC % 4 (ns) [should be 0]',
180 3, -1.5, 1.5, 8, -0.25, 3.75)
183 expRun +
'RPC tdc relative to event trigtime;tdc - triggerTime (ns)',
187 expRun +
'RPC tdc relative to event ctime;tdc - trigCtime (ns)',
190 self.
hist_RPCTimePerLayerA0hist_RPCTimePerLayerA0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
191 for lane
in range(0, 21):
192 label =
'RPCTimeA0L{0:02d}'.format(lane)
193 title =
'{0}RPC axis 0 lane {1} time relative to trigtime;t - triggerTime (ns)'.format(expRun, lane)
196 self.
hist_RPCTimePerLayerA1hist_RPCTimePerLayerA1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
197 for lane
in range(0, 21):
198 label =
'RPCTimeA1L{0:02d}'.format(lane)
199 title =
'{0}RPC axis 1 lane {1} time relative to trigtime;t - triggerTime (ns)'.format(expRun, lane)
202 self.
hist_RPCTime2PerLayerA0hist_RPCTime2PerLayerA0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
203 for lane
in range(0, 21):
204 label =
'RPCTime2A0L{0:02d}'.format(lane)
205 title =
'{0}RPC axis 0 lane {1} time relative to trigCtime;t - trigCtime (ns)'.format(expRun, lane)
208 self.
hist_RPCTime2PerLayerA1hist_RPCTime2PerLayerA1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
209 for lane
in range(0, 21):
210 label =
'RPCTime2A1L{0:02d}'.format(lane)
211 title =
'{0}RPC axis 1 lane {1} time relative to trigCtime;t - trigCtime (ns)'.format(expRun, lane)
214 self.
hist_RPCTdcRangehist_RPCTdcRange = ROOT.TH1F(
'RPCTdcRange', expRun +
'RPC TDC-range in event;TDCMax - TDCMin (ns)', 512, -0.5, 2047.5)
217 expRun +
'RPC revotime-range in event;revotimeMax - revotimeMin (ns)',
221 expRun +
'RPC TDC vs revotime;tdc (ns);revotime - minRevotime',
222 64, 767.5, 1023.5, 10, -0.5, 159.5)
226 expRun +
'RPC TDC vs revotime;' +
227 'tdc - dt(index) (ns);' +
228 'revotime - minRevotime',
229 64, 767.5, 1023.5, 10, -0.5, 159.5)
232 expRun +
'RPC TDC vs hit index;tdc (ns);Hit index',
233 64, 767.5, 1023.5, 60, -0.5, 59.5)
236 expRun +
'RPC TDC vs hit index;tdc - dt(index) (ns);Hit index',
237 64, 767.5, 1023.5, 60, -0.5, 59.5)
240 'ScintTimeLowBitsBySector',
241 expRun +
'Scint TDC lowest-order bits;' +
242 'Sector # (always 0);' +
244 3, -1.5, 1.5, 8, -0.25, 3.75)
247 expRun +
'Scint tdc distribution;tdc - triggerTime (ns)',
251 expRun +
'Scint ctime distribution;ctime - triggerCtime (ns)',
255 expRun +
'Scint ctime distribution;ctime - triggerTime (ns)',
259 'ScintCtimeRange', expRun +
'Scint ctime-range in event;ctimeMax - ctimeMin (ns)', 128, -0.5, 8191.5)
262 """Handle job termination: draw histograms, close output files"""
264 canvas = ROOT.TCanvas(
"canvas", self.
pdfNamepdfName, 1600, 1600)
265 title =
'{0}['.format(self.
pdfNamepdfName)
268 canvas.GetPad(0).SetGrid(1, 1)
269 canvas.GetPad(0).Update()
280 canvas.GetPad(0).SetGrid(1, 1)
281 canvas.GetPad(1).SetGrid(1, 1)
282 canvas.GetPad(2).SetGrid(1, 1)
283 for sectorFB
in range(0, 1):
289 for lane
in range(0, 21):
305 canvas.Print(self.
pdfNamepdfName,
"Title:{0}".format(self.
hist_RPCTimehist_RPCTime.GetName()))
306 for lane
in range(0, 21):
310 for lane
in range(0, 21):
323 canvas.Print(self.
pdfNamepdfName,
"Title:{0}".format(self.
hist_jRPCtdchist_jRPCtdc.GetName()))
336 pdfNameLast =
'{0}]'.format(self.
pdfNamepdfName)
337 canvas.Print(pdfNameLast,
"Title:{0}".format(self.
hist_ScintCtimeRangehist_ScintCtimeRange.GetName()))
343 """Handle begin of run: print diagnostic message"""
344 print(
'beginRun', self.
runrun)
347 """Handle end of run: print diagnostic message"""
348 print(
'endRun', self.
runrun)
350 def event(self, eventHits, tt_ctime, raw_time):
351 """Process one event: fill histograms"""
355 countAllMultihit = 2 * n + 1
if (n > 0)
else 0
357 channelMultiplicity = {}
363 minScintCtime = 99999
366 for j
in range(0, n):
372 flag = 1
if (lane > 2)
else 2
374 isScint = (flag == 2)
375 laneAxisChannel = (((lane << 1) + axis) << 7) + channel
376 if laneAxisChannel
not in channelMultiplicity:
377 countAll = countAll + 2
378 channelMultiplicity[laneAxisChannel] = 0
379 channelMultiplicity[laneAxisChannel] = channelMultiplicity[laneAxisChannel] + 1
383 for j
in range(0, n):
391 flag = 1
if (lane > 2)
else 2
393 isScint = (flag == 2)
394 laneAxisChannel = (((lane << 1) + axis) << 7) + channel
395 laneAxis = axis
if ((lane < 1)
or (lane > 20))
else ((lane << 1) + axis)
396 if laneAxisChannel
in channelMultiplicity:
397 if channelMultiplicity[laneAxisChannel] > 1:
400 t = (tdc - raw_time) & 0x03ff
401 t2 = (tdc - tt_ctime) & 0x03ff
402 ct = ((ctime << 3) - tt_ctime) & 0x3ff
408 if ctime < minRPCCtime:
410 if ctime > maxRPCCtime:
429 if ctime < minScintCtime:
430 minScintCtime = ctime
431 if ctime > maxScintCtime:
432 maxScintCtime = ctime
437 self.
hist_ScintCtime0hist_ScintCtime0.Fill(((ctime << 3) - raw_time) & 0x3ff)
445 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