14 from ROOT
import Belle2, TH1F, TH2F, TCanvas, THistPainter, TPad
18 """Fill BKLM histograms of values from RawKLMs, KLMDigits, BKLMHit1ds, and BKLMHit2ds;
19 (optionally) draw event displays from these data-objects."""
36 BKLM_MAXSTRIP_BIT = 15
38 BKLM_STRIP_MASK = 0x3f
40 BKLM_PLANE_MASK = (1 << BKLM_PLANE_BIT)
42 BKLM_LAYER_MASK = (15 << BKLM_LAYER_BIT)
44 BKLM_SECTOR_MASK = (7 << BKLM_SECTOR_BIT)
46 BKLM_SECTION_MASK = (1 << BKLM_SECTION_BIT)
48 BKLM_MAXSTRIP_MASK = (63 << BKLM_MAXSTRIP_BIT)
50 BKLM_MODULEID_MASK = (BKLM_SECTION_MASK | BKLM_SECTOR_MASK | BKLM_LAYER_MASK)
52 def __init__(self, exp, run, histName, pdfName, eventPdfName, verbosity,
53 maxDisplays, minRPCHits, legacyTimes, singleEntry, view):
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 verbosity (int): determines how many histograms are written to the histogram PDF file
63 maxDisplays (int): max # of events displays to write
64 minRPCHits (int): min # of RPC BKLMHit2ds in any sector for event display
65 legacyTimes (bool): true to correct BKLMHit{1,2}d times in legacy reconstruction, False otherwise
66 singleEntry (int): select events with any (0) or exactly one (1) or more than one (2) entries/channel
67 view (int): view event displays using one-dimensional (1) or two-dimensional (2) BKLMHits
100 """Create and return a ROOT TGraph
103 x[] (real): x coordinates
104 y[] (real): y coordinates
106 graph = ROOT.TGraph()
107 for i
in range(0, len(x)):
108 graph.SetPoint(i, x[i], y[i])
109 graph.SetLineColor(2)
110 graph.SetLineWidth(1)
114 """Create and return a ROOT TLatex with the following properties:
115 size = 0.04, color = red, alignment = middle centre, angle = 90 degrees
118 x (real): x coordinate
119 y (real): y coordinate
120 s (str): character string
122 text = ROOT.TLatex(x, y, s)
123 text.SetTextSize(0.04)
125 text.SetTextAlign(22)
126 text.SetTextAngle(90)
130 """Handle job initialization: fill the mapping database, create histograms, open the event-display file"""
132 expRun =
'e{0:02d}r{1}: '.format(int(self.
exp), int(self.
run))
134 self.
hist_XY = ROOT.TH2F(
'XY',
' ;x;y', 10, -345.0, 345.0, 10, -345.0, 345.0)
138 self.
hist_ZY1D[0] = ROOT.TH2F(
'ZY0',
' ;z;y', 10, -200.0, 300.0, 10, -150.0, 350.0)
139 self.
hist_ZY1D[1] = ROOT.TH2F(
'ZY1',
' ;z;y', 10, -200.0, 300.0, 10, -150.0, 350.0)
143 self.
hist_ZY = ROOT.TH2F(
'ZY',
' ;z;y', 10, -345.0, 345.0, 10, -345.0, 345.0)
147 ROOT.gStyle.SetOptStat(10)
151 self.
sectorFBToDC = [11, 15, 2, 6, 10, 14, 3, 7, 9, 13, 0, 4, 8, 12, 1, 5]
153 self.
dcToSectorFB = [10, 14, 2, 6, 11, 15, 3, 7, 12, 8, 4, 0, 13, 9, 5, 1]
168 self.
t0RPC = [[[0, 0, 17, 16, 15, 13, 14, 14, 16, 17, 18, 16, 16, 18, 16],
169 [0, 0, 0, -2, -1, -5, -6, -5, -5, -3, -4, -6, -8, -6, -8],
170 [0, 0, 6, 3, 5, 0, -1, -1, -2, 0, 0, -2, -3, -2, -4],
171 [0, 0, -4, -3, -6, -8, -8, -9, -9, -7, -7, -10, -10, -10, -12],
172 [0, 0, 6, 8, 4, 4, 3, 8, 4, 7, 7, 3, 5, 5, 4],
173 [0, 0, 18, 20, 18, 18, 16, 21, 17, 20, 20, 19, 21, 19, 20],
174 [0, 0, 19, 19, 19, 18, 17, 18, 22, 24, 25, 22, 22, 24, 22],
175 [0, 0, 19, 19, 18, 17, 16, 18, 18, 20, 21, 19, 20, 20, 20],
176 [0, 0, 6, 7, 9, 5, 4, 6, 6, 9, 9, 6, 7, 8, 7],
177 [0, 0, 3, 2, 2, -4, -1, -2, -2, 1, 0, -4, 246, -3, -4],
178 [0, 0, -1, -1, -1, -5, -6, -6, -8, -5, -4, -7, -7, -7, -8],
179 [0, 0, -5, -5, -5, -12, -9, -10, -8, -6, -10, -8, -8, -11, -12],
180 [0, 0, 12, 12, 13, 8, 6, 6, 7, 9, 10, 7, 6, 8, 5],
181 [0, 0, 14, 15, 43, 12, 10, 12, 11, 15, 16, 28, 14, 15, 14],
182 [0, 0, 22, 22, 21, 19, 19, 19, 21, 23, 24, 21, 22, 22, 22],
183 [0, 0, 18, 18, 17, 16, 16, 18, 18, 20, 21, 18, 18, 20, 19]],
184 [[0, 0, 6, 5, 4, 1, 1, 2, 3, 2, 2, -1, 0, 1, -1],
185 [0, 0, -11, -12, -11, -15, -18, -18, -18, -18, -19, -22, -23, -22, -24],
186 [0, 0, -4, -7, -6, -11, -12, -12, -14, -15, -15, -18, -19, -18, -20],
187 [0, 0, -15, -15, -16, -19, -22, -21, -22, -22, -22, -25, -26, -26, -27],
188 [0, 0, -5, -3, -6, -7, -9, -9, -9, -8, -8, -13, -12, -10, -13],
189 [0, 0, 6, 7, 5, 5, 3, 9, 4, 5, 6, 3, 5, 3, 4],
190 [0, 0, 9, 10, 10, 7, 7, 7, 9, 9, 9, 6, 6, 8, 8],
191 [0, 0, 7, 8, 7, 6, 4, 5, 4, 5, 5, 4, 3, 4, 3],
192 [0, 0, -5, -3, -1, -4, -8, -7, -7, -6, -6, -6, -9, -9, -9],
193 [0, 0, -8, -8, -11, -10, -14, -15, -16, -14, -15, -20, -20, -13, -20],
194 [0, 0, -12, -12, -14, -16, -16, -15, -21, -19, -19, -23, -23, -23, -24],
195 [0, 0, -15, -15, -15, -21, -22, -22, -22, -21, -23, -25, -25, -26, -27],
196 [0, 0, 0, 0, 2, -4, -5, -5, -4, -2, -1, -5, -5, -3, -7],
197 [0, 0, 3, 3, 32, 1, 0, -1, -3, 2, 1, 13, -1, 0, -2],
198 [0, 0, 11, 11, 10, 9, 6, 7, 6, 8, 8, 5, 6, 7, 6],
199 [0, 0, 7, 8, 7, 5, 3, 5, 7, 5, 5, 2, 7, 4, 3]]]
202 self.
ct0Scint = [[[5, 7], [-27, -24], [-29, -45], [-27, -32], [3, 6], [34, 35], [48, 44], [33, 38],
203 [4, 7], [-28, -27], [-39, -34], [-36, -33], [2, 5], [25, 30], [46, 49], [41, 31]],
204 [[0, 0], [-32, -32], [-29, -54], [-31, -40], [-1, -1], [29, 27], [41, 41], [28, 28],
205 [-2, -1], [-32, -34], [-38, -45], [-40, -41], [-3, -3], [21, 20], [41, 42], [41, 19]]]
210 ROOT.gStyle.SetOptStat(10)
211 ROOT.gStyle.SetOptFit(111)
216 self.
hist_nDigit = ROOT.TH1F(
'NDigit', expRun +
'# of BKLMDigits', 500, -0.5, 499.5)
218 self.
hist_nRawKLM = ROOT.TH1F(
'NRawKLM', expRun +
'# of RawKLMs', 10, -0.5, 9.5)
220 self.
hist_rawKLMnumEvents = ROOT.TH1F(
'RawKLMnumEvents', expRun +
'RawKLM NumEvents;(should be 1)', 10, -0.5, 9.5)
222 self.
hist_rawKLMnumNodes = ROOT.TH1F(
'RawKLMnumNodes', expRun +
'RawKLM NumNodes;(should be 1)', 10, -0.5, 9.5)
225 expRun +
'RawKLM NodeID;' +
226 'NodeID (bklm: 1..4, eklm:5..8);' +
228 10, -0.5, 9.5, 10, -0.5, 9.5)
231 expRun +
'RawKLM lane vs flag;' +
232 'Flag (1=RPC, 2=Scint);' +
233 'Lane (scint: 1..7, RPC: 8..20)',
234 4, -0.5, 3.5, 21, -0.5, 20.5)
237 expRun +
'RawKLM RPC tdcExtra bits;' +
238 'Sector # (0-7 = backward, 8-15 = forward);' +
239 'tdcExtra [should be 0]',
240 16, -0.5, 15.5, 32, -0.5, 31.5)
243 expRun +
'RawKLM RPC adcExtra bits;' +
244 'Sector # (0-7 = backward, 8-15 = forward);' +
245 'adcExtra [should be 0]',
246 16, -0.5, 15.5, 16, -0.5, 15.5)
249 expRun +
'RawKLM Scint tdcExtra bits;' +
250 'Sector # (0-7 = backward, 8-15 = forward);' +
252 16, -0.5, 15.5, 32, -0.5, 31.5)
255 expRun +
'RawKLM Scint adcExtra bits;' +
256 'Sector # (0-7 = backward, 8-15 = forward);' +
258 16, -0.5, 15.5, 16, -0.5, 15.5)
262 self.
hist_rawKLMsize = ROOT.TH1F(
'rawKLMsize', expRun +
'RawKLM word count (1/channel)', 250, -0.5, 499.5)
267 for sectorFB
in range(0, 16):
271 label =
'rawKLM_S{0:02d}_sizeMultihit'.format(sectorFB)
272 title =
'{0}sector {1} [COPPER {2} finesse {3}] word count (N/channel)'.format(expRun, sectorFB, copper, finesse)
274 label =
'rawKLM_S{0:02d}_size'.format(sectorFB)
275 title =
'{0}sector {1} [COPPER {2} finesse {3}] word count (1/channel)'.format(expRun, sectorFB, copper, finesse)
281 for sectorFB
in range(0, 16):
285 label =
'rawKLM_S{0:02d}_channelMultiplicity'.format(sectorFB)
286 title =
'{0}sector {1} [COPPER {2} finesse {3}] per-channel multiplicity (N/channel > 1);'.format(
287 expRun, sectorFB, copper, finesse) +
'Per-channel multiplicity;(Lane #) * 2 + (Axis #)'
289 label =
'rawKLM_S{0:02d}_channelMultiplicityFine'.format(sectorFB)
290 title =
'{0}sector {1} [COPPER {2} finesse {3}] per-channel multiplicity (N/channel > 1);'.format(
291 expRun, sectorFB, copper, finesse) +
'Per-channel multiplicity;(Lane #) * 256 + (Axis #) * 128 + (Channel #)'
295 'mappedSectorOccupancyMultihit',
296 expRun +
'Sector occupancy of mapped channels (N/channel);' +
297 'Sector # (0-7 = backward, 8-15 = forward)',
301 'unmappedSectorOccupancyMultihit',
302 expRun +
'Sector occupancy of unmapped channels (N/channel);' +
303 'Sector # (0-7 = backward, 8-15 = forward)',
307 'mappedSectorOccupancy',
308 expRun +
'Sector occupancy of mapped channels (1/channel);' +
309 'Sector # (0-7 = backward, 8-15 = forward)',
313 'unmappedSectorOccupancy',
314 expRun +
'Sector occupancy of unmapped channels (1/channel);' +
315 'Sector # (0-7 = backward, 8-15 = forward)',
319 'mappedRPCSectorOccupancy',
320 expRun +
'Sector occupancy of mapped RPC channels (1/channel);' +
321 'Sector # (0-7 = backward, 8-15 = forward)',
325 'mappedRPCLaneAxisOccupancy',
326 expRun +
'Lane/axis occupancy of mapped RPC channels (1/channel);' +
327 'Sector # (0-7 = backward, 8-15 = forward);' +
328 '(Lane #) * 2 + (Axis #)',
329 16, -0.5, 15.5, 42, -0.5, 41.5)
332 'unmappedRPCSectorOccupancy',
333 expRun +
'Sector occupancy of unmapped RPC channels (1/channel);' +
334 'Sector # (0-7 = backward, 8-15 = forward)',
338 'unmappedRPCLaneAxisOccupancy',
339 expRun +
'Lane/axis occupancy of unmapped RPC channels (1/channel);' +
340 'Sector # (0-7 = backward, 8-15 = forward);' +
341 '(Lane #) * 2 + (Axis #)',
342 16, -0.5, 15.5, 42, -0.5, 41.5)
345 'mappedScintSectorOccupancy',
346 expRun +
'Sector occupancy of mapped scint channels (1/channel);' +
347 'Sector # (0-7 = backward, 8-15 = forward)',
351 'mappedScintLaneAxisOccupancy',
352 expRun +
'Lane/axis occupancy of mapped scint channels (1/channel);' +
353 'Sector # (0-7 = backward, 8-15 = forward);' +
354 '(Lane #) * 2 + (Axis #)',
355 16, -0.5, 15.5, 42, -0.5, 41.5)
358 'unmappedScintSectorOccupancy',
359 expRun +
'Sector occupancy of unmapped scint channels (1/channel);' +
360 'Sector # (0-7 = backward, 8-15 = forward)',
364 'unmappedScintLaneAxisOccupancy',
365 expRun +
'Lane/axis occupancy of unmapped scint channels (1/channel);' +
366 'Sector # (0-7 = backward, 8-15 = forward);' +
367 '(Lane #) * 2 + (Axis #)',
368 16, -0.5, 15.5, 42, -0.5, 41.5)
371 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
372 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
375 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
376 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
379 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
380 [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
381 for sectorFB
in range(0, 16):
382 label =
'mappedChannelOccupancy_S{0:02d}ZPrompt'.format(sectorFB)
383 title =
'{0}In-time mapped channel occupancy for sector {1} z hits;lane;channel'.format(expRun, sectorFB)
385 label =
'mappedChannelOccupancy_S{0:02d}ZBkgd'.format(sectorFB)
386 title =
'{0}Out-of-time mapped channel occupancy for sector {1} z hits;lane;channel'.format(expRun, sectorFB)
388 label =
'unmappedChannelOccupancy_S{0:02d}Z'.format(sectorFB)
389 title =
'{0}Unmapped channel occupancy for sector {1} z hits;lane;channel'.format(expRun, sectorFB)
391 label =
'mappedChannelOccupancy_S{0:02d}PhiPrompt'.format(sectorFB)
392 title =
'{0}In-time mapped occupancy for sector {1} phi hits;lane;channel'.format(expRun, sectorFB)
394 label =
'mappedChannelOccupancy_S{0:02d}PhiBkgd'.format(sectorFB)
395 title =
'{0}Out-of-time mapped occupancy for sector {1} phi hits;lane;channel'.format(expRun, sectorFB)
397 label =
'unmappedChannelOccupancy_S{0:02d}Phi'.format(sectorFB)
398 title =
'{0}Unmapped channel occupancy for sector {1} phi hits;lane;channel'.format(expRun, sectorFB)
402 expRun +
'RPC TDC lowest-order bits;' +
403 'Sector # (0-7 = backward, 8-15 = forward);' +
404 'TDC % 4 (ns) [should be 0]',
405 16, -0.5, 15.5, 4, -0.5, 3.5)
408 'mappedRPCTime', expRun +
'RPC mapped-strip time distribution;t - t(trigger) (ns)', 256, -0.5, 1023.5)
411 'mappedRPCTimeCal', expRun +
'RPC mapped-strip time distribution;t - t(trigger) - dt(layer) (ns)', 256, -0.5, 1023.5)
416 for sectorFB
in range(0, 16):
419 for layer
in range(0, 15):
420 label =
'mappedRPCPhiTime_S{0:02d}L{1:02d}'.format(sectorFB, layer)
421 title =
'{0}RPC sector {1} layer {2} phi time distribution;t - t(trigger) (ns)'.format(expRun, sectorFB, layer)
423 label =
'mappedRPCZTime_S{0:02d}L{1:02d}'.format(sectorFB, layer)
424 title =
'{0}RPC sector {1} layer {2} z time distribution;t - t(trigger) (ns)'.format(expRun, sectorFB, layer)
428 expRun +
'RPC mapped-strip time;' +
429 'Sector # (0-7 = backward, 8-15 = forward);' +
430 't - t(trigger) (ns)',
431 16, -0.5, 15.5, 128, -0.5, 1023.5)
434 expRun +
'RPC mapped-strip time;' +
435 'Sector # (0-7 = backward, 8-15 = forward);' +
436 't - t(trigger) - dt(layer) (ns)',
437 16, -0.5, 15.5, 128, -0.5, 1023.5)
440 expRun +
'RPC Ctime-range in event;' +
441 'CtimeMax - CtimeMin (ns)',
445 expRun +
'RPC Ctime-range in event;' +
446 'Sector # (0-7 = backward, 8-15 = forward);' +
447 'CtimeMax - CtimeMin (ns)',
448 16, -0.5, 15.5, 128, -0.5, 8191.5)
451 expRun +
'RPC unmapped-strip time distribution;' +
452 't - t(trigger) (ns)',
456 expRun +
'RPC unmapped-strip time;' +
457 'Sector # (0-7 = backward, 8-15 = forward);' +
458 't - t(trigger) (ns)',
459 16, -0.5, 15.5, 128, -0.5, 1023.5)
462 expRun +
'Scint TDC lowest-order bits;' +
463 'Sector # (0-7 = backward, 8-15 = forward);' +
465 16, -0.5, 15.5, 4, -0.5, 3.5)
468 expRun +
'Scint mapped-strip ctime distribution;' +
469 'ctime - ct(trigger) (ns)',
473 expRun +
'Scint mapped-strip ctime;' +
474 'Sector # (0-7 = backward, 8-15 = forward);' +
475 'ctime - ct(trigger) (ns)',
476 16, -0.5, 15.5, 32, -0.5, 1023.5)
479 expRun +
'Scint mapped-strip ctime distribution;' +
480 'ctime - ct(trigger) - dt(layer) (ns)',
484 expRun +
'Scint mapped-strip ctime;' +
485 'Sector # (0-7 = backward, 8-15 = forward);' +
486 'ctime - ct(trigger) - dt(layer) (ns)',
487 16, -0.5, 15.5, 32, -0.5, 1023.5)
492 for sectorFB
in range(0, 16):
495 for layer
in range(0, 2):
496 label =
'mappedScintPhiCtime_S{0:02d}L{1:02d}'.format(sectorFB, layer)
497 title =
'{0}Scint sector {1} layer {2} phi ctime distribution;ctime - ct(trigger) (ns)'.format(expRun,
500 label =
'mappedScintZCtime_S{0:02d}L{1:02d}'.format(sectorFB, layer)
501 title =
'{0}Scint sector {1} layer {2} z ctime distribution;ctime - ct(trigger) (ns)'.format(expRun,
506 expRun +
'Scint ctime-range in event;' +
507 'ctimeMax - ctimeMin (ns)',
511 expRun +
'Scint ctime-range in event;' +
512 'Sector # (0-7 = backward, 8-15 = forward);' +
513 'ctimeMax - ctimeMin (ns)',
514 16, -0.5, 15.5, 128, -0.5, 1023.5)
517 expRun +
'Scint unmapped-strip ctime distribution;' +
518 'ctime - ct(trigger) (ns)',
522 expRun +
'Scint unmapped-strip ctime;' +
523 'Sector # (0-7 = backward, 8-15 = forward);' +
524 'ctime - ct(trigger) (ns)',
525 16, -0.5, 15.5, 32, -0.5, 1023.5)
528 expRun +
'Scint mapped-strip TDC distribution;' +
533 expRun +
'Scint mapped-strip time distribution;' +
534 't - t(trigger) (ns)', 32, -0.5, 31.5)
537 expRun +
'Scint mapped-strip TDC;' +
538 'Sector # (0-7 = backward, 8-15 = forward);' +
540 16, -0.5, 15.5, 32, -0.5, 31.5)
543 expRun +
'Scint mapped-strip time;' +
544 'Sector # (0-7 = backward, 8-15 = forward);' +
545 't - t(trigger) (ns)',
546 16, -0.5, 15.5, 32, -0.5, 31.5)
549 expRun +
'Scint unmapped-strip time distribution;' +
550 't - t(trigger) (ns)',
554 expRun +
'Scint unmapped-strip time;' +
555 'Sector # (0-7 = backward, 8-15 = forward);' +
556 't - t(trigger) (ns)',
557 16, -0.5, 15.5, 32, -0.5, 31.5)
563 expRun +
'trigCtime - trigRevo9time (ns)',
564 256, -1024.5, 1023.5)
567 expRun +
'RPC TDC range;' +
568 'maxTDC - minTDC (ns)',
572 expRun +
'RPC Ctime range;' +
573 'maxCtime - minCtime (ns)',
577 expRun +
'RPC Ctime range vs TDC range;' +
578 'maxTDC - minTDC (ns);' +
579 'maxCtime - minCtime (ns)',
580 128, -0.5, 1023.5, 128, -0.5, 1023.5)
583 expRun +
'RPC TDC range vs time;' +
584 't - t(trigger) (ns);' +
585 'maxTDC - minTDC (ns)',
586 128, -0.5, 1023.5, 128, -0.5, 1023.5)
589 expRun +
'RPC Ctime range vs time;' +
590 't - t(trigger) (ns);' +
591 'maxCtime - minCtime (ns)',
592 128, -0.5, 1023.5, 128, -0.5, 1023.5)
597 self.
hist_nHit1d = ROOT.TH1F(
'NHit1d', expRun +
'# of BKLMHit1ds', 100, -0.5, 99.5)
599 self.
hist_nHit1dRPCPrompt = ROOT.TH1F(
'NHit1dRPCPrompt', expRun +
'# of prompt RPC BKLMHit1ds', 100, -0.5, 99.5)
601 self.
hist_nHit1dRPCBkgd = ROOT.TH1F(
'NHit1dRPCBkgd', expRun +
'# of background RPC BKLMHit1ds', 100, -0.5, 99.5)
603 self.
hist_nHit1dScint = ROOT.TH1F(
'NHit1dScint', expRun +
'# of scintillator BKLMHit1ds', 100, -0.5, 99.5)
605 self.
hist_nHit1dPrompt = ROOT.TH1F(
'NHit1dPrompt', expRun +
'# of prompt BKLMHit1ds', 100, -0.5, 99.5)
607 self.
hist_nHit1dBkgd = ROOT.TH1F(
'NHit1dBkgd', expRun +
'# of bkgd BKLMHit1ds', 100, -0.5, 99.5)
610 expRun +
'Distribution of BKLMHit1ds;# of phi BKLMHit1ds;# of z BKLMHit1ds',
611 60, -0.5, 59.5, 60, -0.5, 59.5)
614 expRun +
'BKLMHit1d phi-strip multiplicity;' +
615 'sector # (0-7 = backward, 8-15 = forward);' +
617 16, -0.5, 15.5, 8, -0.5, 7.5)
620 expRun +
'BKLMHit1d z-strip multiplicity;' +
621 'sector # (0-7 = backward, 8-15 = forward);' +
623 16, -0.5, 15.5, 8, -0.5, 7.5)
626 expRun +
'RPC BKLMHit1d phi-strip time distribution;' +
627 't(phi1D) - dt(layer) (ns)',
631 expRun +
'RPC BKLMHit1d z-strip time distribution;' +
632 't(z1D) - dt(layer) (ns)',
636 expRun +
'RPC BKLMHit1d x 2 calibrated average-time distribution;' +
637 '0.5*[t(phi1D) + t(z1D)] - dt(layer) (ns)',
641 expRun +
'RPC BKLMHit1d x 2 time-difference distribution;' +
642 't(phi1D) - t(z1D) (ns)',
646 expRun +
'Scintillator BKLMHit1d phi-strip ctime distribution;' +
647 't(phi1D) - dt(layer) (ns)',
651 expRun +
'Scintillator BKLMHit1d z-strip ctime distribution;' +
652 't(z1D) - dt(layer) (ns)',
656 expRun +
'Scintillator BKLMHit1d x 2 calibrated average-time distribution;' +
657 '0.5*[t(phi1D) + t(z1D)] - dt(layer) (ns)',
661 expRun +
'Scintillator BKLMHit1d x 2 time-difference distribution;' +
662 't(phi1D) - t(z1D) (ns)',
668 self.
hist_nHit2d = ROOT.TH1F(
'NHit2d', expRun +
'# of BKLMHit2ds', 50, -0.5, 49.5)
671 expRun +
'Forward xy RPC occupancy for in-time hits;x(cm);y(cm)',
672 230, -345.0, 345.0, 230, -345.0, 345.0)
675 expRun +
'Backward xy RPC occupancy for in-time hits;x(cm);y(cm)',
676 230, -345.0, 345.0, 230, -345.0, 345.0)
679 expRun +
'Forward xy RPC occupancy for out-of-time hits;x(cm);y(cm)',
680 230, -345.0, 345.0, 230, -345.0, 345.0)
683 expRun +
'Backward xy RPC occupancy for out-of-time hits;x(cm);y(cm)',
684 230, -345.0, 345.0, 230, -345.0, 345.0)
687 expRun +
'layer-z occupancy for in-time hits;z(cm);layer',
688 48, -190.0, 290.0, 16, -0.5, 15.5)
691 expRun +
'z occupancy for in-time hits;z(cm)',
695 expRun +
'layer occupancy for in-time hits;layer',
699 expRun +
'layer-z occupancy for out-of-time hits;z(cm);layer',
700 48, -190.0, 290.0, 16, -0.5, 15.5)
703 expRun +
'z occupancy for out-of-time hits;z(cm)',
707 expRun +
'layer occupancy for out-of-time hits;layer',
711 expRun +
'RPC BKLMHit2d time distribution;' +
712 't(2D) - dt(layer) (ns)',
716 expRun +
'RPC BKLMHit2d time distribution;' +
717 'sector # (0-7 = backward, 8-15 = forward);' +
718 't(2D) - dt(layer) (ns)',
719 16, -0.5, 15.5, 256, -0.5, 1023.5)
722 expRun +
'Scint BKLMHit2d ctime distribution;' +
723 't(2D) - dt(layer) (ns)',
727 expRun +
'Scint BKLMHit2d ctime distribution;' +
728 'sector # (0-7 = backward, 8-15 = forward);' +
729 't(2D) - dt(layer) (ns)',
730 16, -0.5, 15.5, 128, -0.5, 1023.5)
734 expRun +
'RPC BKLMHit2d time vs z (forward);' +
736 't(2D) - dt(layer) (ns)',
740 expRun +
'RPC BKLMHit2d time vs z (backward);' +
742 't(2D) - dt(layer) (ns)',
758 r0 = 201.9 + 0.5 * 4.4
760 tan0 = math.tan(math.pi / 8.0)
762 g.SetPoint(0, -200.0, 0.0)
763 g.SetPoint(1, +200.0, 0.0)
769 g.SetPoint(0, 0.0, -200.0)
770 g.SetPoint(1, 0.0, +200.0)
776 g.SetPoint(0, -5.0, 0.0)
777 g.SetPoint(1, +5.0, 0.0)
778 g.SetPoint(2, 0.0, 0.0)
779 g.SetPoint(3, 0.0, +5.0)
780 g.SetPoint(4, 0.0, -5.0)
784 for layer
in range(0, 15):
788 g.SetPoint(0, +r, -x)
789 g.SetPoint(1, +r, +x)
790 g.SetPoint(2, +x, +r)
791 g.SetPoint(3, -x, +r)
792 g.SetPoint(4, -r, +x)
793 g.SetPoint(5, -r, -x)
794 g.SetPoint(6, -x, -r)
795 g.SetPoint(7, +x, -r)
796 g.SetPoint(8, +r, -x)
812 g.SetPoint(0, -zL + z0 - 140.0, 0.0)
813 g.SetPoint(1, +zL + z0 + 70.0, 0.0)
819 g.SetPoint(0, 0.0, -315.0)
820 g.SetPoint(1, 0.0, +340.0)
826 g.SetPoint(0, -5.0, 0.0)
827 g.SetPoint(1, +5.0, 0.0)
828 g.SetPoint(2, 0.0, 0.0)
829 g.SetPoint(3, 0.0, +5.0)
830 g.SetPoint(4, 0.0, -5.0)
835 g.SetPoint(0, -zL + z0, +x0)
836 g.SetPoint(1, -zL + z0, +r0)
842 g.SetPoint(0, -zL + z0, -x0)
843 g.SetPoint(1, -zL + z0, -r0)
849 g.SetPoint(0, +zL + z0, +x0)
850 g.SetPoint(1, +zL + z0, +r0)
856 g.SetPoint(0, +zL + z0, -x0)
857 g.SetPoint(1, +zL + z0, -r0)
863 g.SetPoint(0, -zL + z0, r0)
864 g.SetPoint(1, +zL + z0, r0)
865 g.SetPoint(2, +zL + z0, rF)
866 g.SetPoint(3, -zL + z0, rF)
867 g.SetPoint(4, -zL + z0, r0)
872 g.SetPoint(0, -zL + z0, -r0)
873 g.SetPoint(1, +zL + z0, -r0)
874 g.SetPoint(2, +zL + z0, -rF)
875 g.SetPoint(3, -zL + z0, -rF)
876 g.SetPoint(4, -zL + z0, -r0)
881 g.SetPoint(0, -zL + z0, -x0)
882 g.SetPoint(1, +zL + z0, -x0)
883 g.SetPoint(2, +zL + z0, +x0)
884 g.SetPoint(3, -zL + z0, +x0)
885 g.SetPoint(4, -zL + z0, -x0)
891 """Handle job termination: draw histograms, close output files"""
897 for sectorFB
in range(0, 16):
899 if mappedScintSectorOccupancy > 0:
900 for laneAxis
in range(0, 42):
903 sectorFB + 1, laneAxis + 1, 100.0 * numerator / mappedScintSectorOccupancy)
905 if mappedRPCSectorOccupancy > 0:
906 for laneAxis
in range(0, 42):
909 sectorFB + 1, laneAxis + 1, 100.0 * numerator / mappedRPCSectorOccupancy)
911 if unmappedScintSectorOccupancy > 0:
912 for laneAxis
in range(0, 42):
915 sectorFB + 1, laneAxis + 1, 100.0 * numerator / unmappedScintSectorOccupancy)
917 if unmappedRPCSectorOccupancy > 0:
918 for laneAxis
in range(0, 42):
921 sectorFB + 1, laneAxis + 1, 100.0 * numerator / unmappedRPCSectorOccupancy)
922 canvas = ROOT.TCanvas(
"canvas", self.
pdfName, 1600, 1600)
923 title =
'{0}['.format(self.
pdfName)
926 canvas.GetPad(0).SetGrid(1, 1)
927 canvas.GetPad(0).Update()
952 for dc
in range(0, 16):
958 for dc
in range(0, 16):
961 for dc
in range(0, 16):
979 canvas.GetPad(0).SetGrid(1, 1)
980 canvas.GetPad(1).SetGrid(1, 1)
981 canvas.GetPad(2).SetGrid(1, 1)
983 borderRPC0x = [7.5, 20.5, 20.5, 7.5, 7.5]
984 borderRPC0y = [0.5, 0.5, 48.5, 48.5, 0.5]
985 borderRPC0yChimney = [0.5, 0.5, 34.5, 34.5, 0.5]
987 borderScint0x = [0.5, 1.5, 1.5, 2.5, 2.5, 1.5, 1.5, 0.5, 0.5]
988 borderScint0y = [4.5, 4.5, 2.5, 2.5, 44.5, 44.5, 41.5, 41.5, 4.5]
990 borderRPC1x = [7.5, 20.5, 20.5, 11.5, 11.5, 7.5, 7.5]
991 borderRPC1y = [0.5, 0.5, 48.5, 48.5, 36.5, 36.5, 0.5]
993 borderScint1x = [0.5, 2.5, 2.5, 0.5, 0.5]
994 borderScint1ay = [0.5, 0.5, 9.5, 9.5, 0.5]
995 borderScint1by = [15.5, 15.5, 60.5, 60.5, 15.5]
996 borderScint1xChimney = [0.5, 1.5, 1.5, 2.5, 2.5, 1.5, 1.5, 0.5, 0.5]
997 borderScint1ayChimney = [0.5, 0.5, 0.5, 0.5, 9.5, 9.5, 8.5, 8.5, 0.5]
998 borderScint1byChimney = [15.5, 15.5, 16.5, 16.5, 45.5, 45.5, 45.5, 45.5, 15.5]
1000 graphRPC0 = self.
makeGraph(borderRPC0x, borderRPC0y)
1001 graphRPC0Chimney = self.
makeGraph(borderRPC0x, borderRPC0yChimney)
1003 graphScint0 = self.
makeGraph(borderScint0x, borderScint0y)
1005 graphRPC1 = self.
makeGraph(borderRPC1x, borderRPC1y)
1007 graphScint1a = self.
makeGraph(borderScint1x, borderScint1ay)
1008 graphScint1b = self.
makeGraph(borderScint1x, borderScint1by)
1009 graphScint1aChimney = self.
makeGraph(borderScint1xChimney, borderScint1ayChimney)
1010 graphScint1bChimney = self.
makeGraph(borderScint1xChimney, borderScint1byChimney)
1012 textRPC0 = self.
makeText(6.8, 25.0,
"RPC z")
1013 textScint0 = self.
makeText(3.2, 25.0,
"Scint #phi")
1014 textRPC1 = self.
makeText(6.8, 25.0,
"RPC #phi")
1015 textScint1 = self.
makeText(3.2, 25.0,
"Scint z")
1016 for sectorFB
in range(0, 16):
1018 for lane
in range(8, 21):
1019 for channel
in range(0, 64):
1021 zmax = z
if z > zmax
else zmax
1026 graphRPC0Chimney.Draw(
"L")
1027 graphScint1aChimney.Draw(
"L")
1028 graphScint1bChimney.Draw(
"L")
1031 graphScint1a.Draw(
"L")
1032 graphScint1b.Draw(
"L")
1036 for lane
in range(8, 21):
1037 for channel
in range(0, 64):
1039 zmax = z
if z > zmax
else zmax
1044 graphScint0.Draw(
"L")
1049 for sectorFB
in range(0, 16):
1051 for lane
in range(8, 21):
1052 for channel
in range(0, 64):
1054 zmax = z
if z > zmax
else zmax
1059 graphRPC0Chimney.Draw(
"L")
1060 graphScint1aChimney.Draw(
"L")
1061 graphScint1bChimney.Draw(
"L")
1064 graphScint1a.Draw(
"L")
1065 graphScint1b.Draw(
"L")
1069 for lane
in range(8, 21):
1070 for channel
in range(0, 64):
1072 zmax = z
if z > zmax
else zmax
1077 graphScint0.Draw(
"L")
1081 for sectorFB
in range(0, 16):
1085 graphRPC0Chimney.Draw(
"L")
1086 graphScint1aChimney.Draw(
"L")
1087 graphScint1bChimney.Draw(
"L")
1090 graphScint1a.Draw(
"L")
1091 graphScint1b.Draw(
"L")
1097 graphScint0.Draw(
"L")
1105 timeFit = ROOT.TF1(
"timeFit",
"gausn(0)+pol0(3)", 100.0, 500.0)
1106 timeFit.SetParName(0,
"Area")
1107 timeFit.SetParName(1,
"Mean")
1108 timeFit.SetParName(2,
"Sigma")
1109 timeFit.SetParName(3,
"Bkgd")
1110 timeFit.SetParLimits(2, 10.0, 80.0)
1112 timeFit.SetParameter(0, n)
1113 timeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1114 timeFit.SetParameter(1, 320.0)
1115 timeFit.SetParameter(2, 20.0)
1116 timeFit.SetParameter(3, 100.0)
1123 timeFit.SetParameter(0, n)
1124 timeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1125 timeFit.SetParameter(1, 320.0)
1126 timeFit.SetParameter(2, 20.0)
1127 timeFit.SetParameter(3, 100.0)
1138 for sectorFB
in range(0, 16):
1139 for layer
in range(2, 15):
1141 timeFit.SetParameter(0, n)
1142 timeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1143 timeFit.SetParameter(1, 320.0)
1144 timeFit.SetParameter(2, 20.0)
1145 timeFit.SetParameter(3, 100.0)
1149 for sectorFB
in range(0, 16):
1150 for layer
in range(2, 15):
1152 timeFit.SetParameter(0, n)
1153 timeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1154 timeFit.SetParameter(1, 320.0)
1155 timeFit.SetParameter(2, 20.0)
1156 timeFit.SetParameter(3, 100.0)
1174 ctimeFit = ROOT.TF1(
"ctimeFit",
"gausn(0)+pol0(3)", 300.0, 700.0)
1175 ctimeFit.SetParName(0,
"Area")
1176 ctimeFit.SetParName(1,
"Mean")
1177 ctimeFit.SetParName(2,
"Sigma")
1178 ctimeFit.SetParName(3,
"Bkgd")
1179 ctimeFit.SetParLimits(2, 10.0, 80.0)
1181 ctimeFit.SetParameter(0, n)
1182 ctimeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1183 ctimeFit.SetParameter(1, 450.0)
1184 ctimeFit.SetParameter(2, 40.0)
1185 ctimeFit.SetParameter(3, 10.0)
1192 ctimeFit.SetParameter(0, n)
1193 ctimeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1194 ctimeFit.SetParameter(1, 450.0)
1195 ctimeFit.SetParameter(2, 40.0)
1196 ctimeFit.SetParameter(3, 10.0)
1207 for sectorFB
in range(0, 16):
1208 for layer
in range(0, 2):
1210 ctimeFit.SetParameter(0, n)
1211 ctimeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1212 ctimeFit.SetParameter(1, 440.0)
1213 ctimeFit.SetParameter(2, 40.0)
1214 ctimeFit.SetParameter(3, 10.0)
1218 for sectorFB
in range(0, 16):
1219 for layer
in range(0, 2):
1221 ctimeFit.SetParameter(0, n)
1222 ctimeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1223 ctimeFit.SetParameter(1, 440.0)
1224 ctimeFit.SetParameter(2, 40.0)
1225 ctimeFit.SetParameter(3, 10.0)
1287 timeFit.SetParameter(0, n)
1288 timeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1289 timeFit.SetParameter(1, 330.0)
1290 timeFit.SetParameter(2, 15.0)
1291 timeFit.SetParameter(3, 100.0)
1296 timeFit.SetParameter(0, n)
1297 timeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1298 timeFit.SetParameter(1, 330.0)
1299 timeFit.SetParameter(2, 15.0)
1300 timeFit.SetParameter(3, 100.0)
1306 timeFit.SetParameter(0, n)
1307 timeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1308 timeFit.SetParameter(1, 330.0)
1309 timeFit.SetParameter(2, 15.0)
1310 timeFit.SetParameter(3, 100.0)
1317 ctimeFit.SetParameter(0, n)
1318 ctimeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1319 ctimeFit.SetParameter(1, 520.0)
1320 ctimeFit.SetParameter(2, 40.0)
1321 ctimeFit.SetParameter(3, 10.0)
1326 ctimeFit.SetParameter(0, n)
1327 ctimeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1328 ctimeFit.SetParameter(1, 520.0)
1329 ctimeFit.SetParameter(2, 40.0)
1330 ctimeFit.SetParameter(3, 10.0)
1336 ctimeFit.SetParameter(0, n)
1337 ctimeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1338 ctimeFit.SetParameter(1, 520.0)
1339 ctimeFit.SetParameter(2, 40.0)
1340 ctimeFit.SetParameter(3, 10.0)
1376 timeFit.SetParameter(0, n)
1377 timeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1378 timeFit.SetParameter(1, 320.0)
1379 timeFit.SetParameter(2, 20.0)
1380 timeFit.SetParameter(3, 100.0)
1387 ctimeFit.SetParameter(0, n)
1388 ctimeFit.SetParLimits(0, 0.2 * n, 5.0 * n)
1389 ctimeFit.SetParameter(1, 500.0)
1390 ctimeFit.SetParameter(2, 40.0)
1391 ctimeFit.SetParameter(3, 10.0)
1398 pdfNameLast =
'{0}]'.format(self.
pdfName)
1405 """Handle begin of run: print diagnostic message"""
1407 print(
'beginRun', EventMetaData.getRun())
1410 """Handle end of run: print diagnostic message"""
1412 print(
'endRun', EventMetaData.getRun())
1415 """Process one event: fill histograms, (optionally) draw event display"""
1419 event = EventMetaData.getEvent()
1430 for hit1d
in hit1ds:
1431 tCal1d.append(hit1d.getTime())
1433 for hit2d
in hit2ds:
1434 tCal2d.append(hit2d.getTime())
1436 countAllMultihit = 0
1438 count = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
1439 rawFb = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
1440 rawSector = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
1441 rawLayer = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
1442 rawPlane = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
1443 rawStrip = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
1444 rawCtime = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
1445 for copper
in range(0, len(rawklms)):
1446 rawklm = rawklms[copper]
1449 if rawklm.GetNumEntries() != 1:
1450 print(
'##0 Event', event,
'copper', copper,
' getNumEntries=', rawklm.GetNumEntries())
1452 nodeID = rawklm.GetNodeID(0) - self.
BKLM_ID
1456 if (nodeID < 0)
or (nodeID > 4):
1458 trigCtime = (rawklm.GetTTCtime(0) & 0x7ffffff) << 3
1459 revo9time = trigCtime - 0x3b0
1460 for finesse
in range(0, 4):
1461 dc = (finesse << 2) + copper
1462 nWords = rawklm.GetDetectorNwords(0, finesse)
1466 countAllMultihit = countAllMultihit + nWords
1467 bufSlot = rawklm.GetDetectorBuffer(0, finesse)
1468 lastWord = bufSlot[nWords - 1]
1469 if lastWord & 0xffff != 0:
1470 print(
"##1 Event", event,
'copper', copper,
'finesse', finesse,
'n=', nWords,
'lastWord=', hex(lastWord))
1471 if (nWords % 2) == 0:
1472 print(
"##2 Event", event,
'copper', copper,
'finesse', finesse,
'n=', nWords,
'should be odd -- skipping')
1474 if int(self.
exp) != 3:
1475 revo9time = ((lastWord >> 16) << 3) & 0xffff
1476 dt = (trigCtime - revo9time) & 0x3ff
1484 channelMultiplicity = {}
1489 minScintCtime = 99999
1493 for j
in range(0, n):
1494 word0 = bufSlot[j * 2]
1495 word1 = bufSlot[j * 2 + 1]
1496 ctime = word0 & 0xffff
1497 channel = (word0 >> 16) & 0x7f
1498 axis = (word0 >> 23) & 0x01
1499 lane = (word0 >> 24) & 0x1f
1500 flag = (word0 >> 30) & 0x03
1501 adc = word1 & 0x0fff
1502 tdc = (word1 >> 16) & 0x07ff
1504 isScint = (flag == 2)
1505 laneAxisChannel = (word0 >> 16) & 0x1fff
1506 if laneAxisChannel
not in channelMultiplicity:
1507 countAll = countAll + 2
1508 count[dc] = count[dc] + 2
1509 channelMultiplicity[laneAxisChannel] = 0
1510 channelMultiplicity[laneAxisChannel] += 1
1512 if ctime < minRPCCtime:
1514 if ctime > maxRPCCtime:
1521 if int(self.
exp) <= 3:
1522 trigCtx = trigCtime >> 3
1523 ctime = trigCtx - ((trigCtx - ctime) << 2)
1524 if ctime < minScintCtime:
1525 minScintCtime = ctime
1526 if ctime > maxScintCtime:
1527 maxScintCtime = ctime
1528 electId = (channel << 12) | (axis << 11) | (lane << 6) | (finesse << 4) | nodeID
1536 rawFb[dc].append(fb)
1537 rawSector[dc].append(sector)
1538 rawLayer[dc].append(layer)
1539 rawPlane[dc].append(plane)
1540 rawStrip[dc].append(strip)
1541 rawCtime[dc].append(ctime)
1543 rawFb[dc].append(-1)
1544 rawSector[dc].append(-1)
1545 rawLayer[dc].append(-1)
1546 rawPlane[dc].append(-1)
1547 rawStrip[dc].append(-1)
1548 rawCtime[dc].append(-1)
1549 tdcRangeRPC = maxRPCtdc - minRPCtdc
1550 ctimeRangeRPC = (maxRPCCtime - minRPCCtime) << 3
1551 ctimeRangeScint = (maxScintCtime - minScintCtime) << 3
1555 if maxScintCtime > 0:
1559 for j
in range(0, n):
1560 word0 = bufSlot[j * 2]
1561 word1 = bufSlot[j * 2 + 1]
1562 ctime = word0 & 0xffff
1563 channel = (word0 >> 16) & 0x7f
1564 axis = (word0 >> 23) & 0x01
1565 lane = (word0 >> 24) & 0x1f
1566 flag = (word0 >> 30) & 0x03
1567 electId = (channel << 12) | (axis << 11) | (lane << 6) | (finesse << 4) | nodeID
1568 adc = word1 & 0x0fff
1569 tdc = (word1 >> 16) & 0x07ff
1570 tdcExtra = (word1 >> 27) & 0x1f
1571 adcExtra = (word1 >> 12) & 0x0f
1573 isScint = (flag == 2)
1574 laneAxis = axis
if ((lane < 1)
or (lane > 20))
else ((lane << 1) + axis)
1575 laneAxisChannel = (word0 >> 16) & 0x1fff
1576 multiplicity = channelMultiplicity[laneAxisChannel]
1577 if multiplicity > 1:
1589 if int(self.
exp) <= 3:
1590 trigCtx = trigCtime >> 3
1591 ctime = trigCtx - ((trigCtx - ctime) << 2)
1592 t = (tdc - trigCtime) & 0x03ff
1593 ct = (ctime << 3) - (trigCtime & 0x7fff8)
1597 if channelMultiplicity[laneAxisChannel] == 1:
1601 tCal = int(tdc - trigCtime - self.
t0RPC[axis][sectorFB][lane-6]) & 0x03ff
1608 if abs(tCal - self.
t0Cal) < 50:
1624 ctCal = int((ctime << 3) - trigCtime - self.
ct0Scint[1-axis][sectorFB][lane-1]) & 0x03ff
1625 if abs(ctCal - self.
ct0Cal) < 50:
1645 if channelMultiplicity[laneAxisChannel] == 1:
1669 cosine = [0, 0, 0, 0, 0, 0, 0, 0]
1670 sine = [0, 0, 0, 0, 0, 0, 0, 0]
1671 for sector
in range(0, 8):
1672 phi = math.pi * sector / 4
1673 cosine[sector] = math.cos(phi)
1674 sine[sector] = math.sin(phi)
1675 zyList = [[], [], [], [], [], [], [], []]
1676 xyList = [[], [], [], [], [], [], [], []]
1677 r0 = 201.9 + 0.5 * 4.4
1682 nPhiStrips = [37, 42, 36, 36, 36, 36, 48, 48, 48, 48, 48, 48, 48, 48, 48]
1683 dPhiStrips = [4.0, 4.0, 4.9, 5.11, 5.32, 5.53, 4.3, 4.46, 4.62, 4.77, 4.93, 5.09, 5.25, 5.4, 5.56]
1684 scintFlip = [[[-1, 1], [-1, 1], [1, 1], [1, -1], [1, -1], [1, -1], [-1, -1], [-1, 1]],
1685 [[1, -1], [1, -1], [1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, -1], [1, -1]]]
1689 zTimes = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
1695 for hit1d
in hit1ds:
1696 key = hit1d.getModuleID()
1703 sectorFB = sector
if fb == 0
else sector + 8
1708 n = rawklms[copper].GetDetectorNwords(0, finesse) >> 1
1709 trigCtime = (rawklms[copper].GetTTCtime(0) & 0x07ffffff) << 3
1712 for j
in range(0, n):
1713 if layer != rawLayer[dc][j]:
1715 if sector != rawSector[dc][j]:
1717 if fb != rawFb[dc][j]:
1719 if plane != rawPlane[dc][j]:
1721 strip = rawStrip[dc][j]
1722 if strip < stripMin:
1724 if strip > stripMax:
1727 ctime = rawCtime[dc][j] << 3
1728 ct = ctime - trigCtime - self.
ct0Scint[plane][sectorFB][layer]
1729 ctTrunc = int(ct) & 0x3ff
1730 if abs(ctTrunc - self.
ct0Cal) < ctDiffMax:
1731 ctDiffMax = int(abs(ctTrunc - self.
ct0Cal))
1736 tCal = tCal = hit1d.getTime() - trigCtime - self.
t0RPC[plane][sectorFB][layer]
1740 tCal = hit1d.getTime() - self.
ct0Scint[plane][sectorFB][layer]
1742 tCal = hit1d.getTime() - self.
t0RPC[plane][sectorFB][layer]
1743 tCalTrunc = int(tCal) & 0x3ff
1751 stripAverage = (stripMin + stripMax) * 0.5
1755 isPrompt = (abs(tCalTrunc - self.
ct0Cal1d) < 50)
1758 zA = z0 - stripAverage * dzScint
1760 zA = z0 + stripAverage * dzScint
1762 h = ((stripAverage - 0.5 * nPhiStrips[layer]) * dPhiStrips[layer]) * scintFlip[fb][sector][layer]
1763 xB = r * cosine[sector] - h * sine[sector]
1764 yB = r * sine[sector] + h * cosine[sector]
1766 isPrompt = (abs(tCalTrunc - self.
t0Cal1d) < 50)
1769 zA = z0 - stripAverage * dzRPC
1771 zA = z0 + stripAverage * dzRPC
1773 h = ((stripAverage - 0.5 * nPhiStrips[layer]) * dPhiStrips[layer])
1774 xB = r * cosine[sector] - h * sine[sector]
1775 yB = r * sine[sector] + h * cosine[sector]
1776 if abs(tCalTrunc - self.
t0Cal) < 50:
1786 phiTimes[key] = tCal
1793 zTimes[layer][key] = tCal
1802 gZY.SetPoint(0, zA - 1.0, yA - 1.0)
1803 gZY.SetPoint(1, zA - 1.0, yA + 1.0)
1804 gZY.SetPoint(2, zA + 1.0, yA + 1.0)
1805 gZY.SetPoint(3, zA + 1.0, yA - 1.0)
1806 gZY.SetPoint(4, zA - 1.0, yA - 1.0)
1809 gZY.SetLineColor(promptColor)
1811 gZY.SetLineColor(bkgdColor)
1812 zyList[sector].append(gZY)
1815 gXY.SetPoint(0, xB - 1.0, yB - 1.0)
1816 gXY.SetPoint(1, xB - 1.0, yB + 1.0)
1817 gXY.SetPoint(2, xB + 1.0, yB + 1.0)
1818 gXY.SetPoint(3, xB + 1.0, yB - 1.0)
1819 gXY.SetPoint(4, xB - 1.0, yB - 1.0)
1822 gXY.SetLineColor(promptColor)
1824 gXY.SetLineColor(bkgdColor)
1825 xyList[sector].append(gXY)
1834 for phiKey
in phiTimes:
1839 sectorFB = sector
if fb == 0
else sector + 8
1840 tphi = phiTimes[phiKey]
1841 tphiTrunc = int(tphi) & 0x3ff
1842 for zKey
in zTimes[layer]:
1845 tz = zTimes[layer][zKey]
1846 tzTrunc = int(tz) & 0x3ff
1847 dt = (tphiTrunc - tzTrunc) & 0x3ff
1850 t = (tphi + tz) * 0.5
1851 tTrunc = int(t) & 0x3ff
1867 for sector
in range(0, 8):
1871 title =
'e{0:02d}r{1}: event {2} z-readout hits in S{3}'.format(int(self.
exp), int(self.
run), event, sector)
1872 self.
hist_ZY1D[jCanvas - 1].SetTitle(title)
1876 for g
in zyList[sector]:
1883 enoughXYHits =
False
1884 for sector
in range(0, 8):
1892 title =
'e{0:02d}r{1}: event {2} phi-readout hits'.format(int(self.
exp), int(self.
run), event)
1897 for sector
in range(0, 8):
1898 for g
in xyList[sector]:
1909 if drawnSectors > 0:
1916 rpcHits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
1917 for hit2d
in hit2ds:
1918 key = hit2d.getModuleID()
1922 phiStripMin = hit2d.getPhiStripMin() - 1
1923 phiStripMax = hit2d.getPhiStripMax() - 1
1924 zStripMin = hit2d.getZStripMin() - 1
1925 zStripMax = hit2d.getZStripMax() - 1
1926 sectorFB = sector
if fb == 0
else sector + 8
1928 rpcHits[sectorFB] += 1
1933 n = rawklms[copper].GetDetectorNwords(0, finesse) >> 1
1934 trigCtime = (rawklms[copper].GetTTCtime(0) & 0x07ffffff) << 3
1941 for j
in range(0, n):
1942 if layer != rawLayer[dc][j]:
1944 if sector != rawSector[dc][j]:
1946 if fb != rawFb[dc][j]:
1948 strip = rawStrip[dc][j]
1949 plane = rawPlane[dc][j]
1951 if strip < zStripMin:
1953 if strip > zStripMax:
1955 ctZ = rawCtime[dc][j] << 3
1958 if strip < phiStripMin:
1960 if strip > phiStripMax:
1962 ctPhi = rawCtime[dc][j] << 3
1964 if (jZ >= 0)
and (jPhi >= 0):
1966 if abs(ctZ - ctPhi) > 40:
1968 ct = int((ctZ + ctPhi) * 0.5 - trigCtime - self.
ct0Scint[plane][sectorFB][layer]) & 0x3ff
1969 if abs(ct - self.
ct0Cal) < ctDiffMax:
1970 ctDiffMax = int(abs(ct - self.
ct0Cal))
1975 tCal = hit2d.getTime() - trigCtime - self.
t0RPC[plane][sectorFB][layer]
1979 tCal = hit2d.getTime() - self.
ct0Scint[plane][sectorFB][layer]
1981 tCal = hit2d.getTime() - self.
t0RPC[plane][sectorFB][layer]
1982 tCalTrunc = int(tCal) & 0x3ff
1983 x = hit2d.getGlobalPositionX()
1984 y = hit2d.getGlobalPositionY()
1985 z = hit2d.getGlobalPositionZ()
1986 r = math.sqrt(x * x + y * y)
1995 if abs(tCalTrunc - self.
ct0Cal2d) < 50:
2009 if abs(tCalTrunc - self.
t0Cal2d) < 50:
2020 elif abs(tCalTrunc - self.
t0Cal2d) >= 50:
2032 gXY.SetPoint(0, x - 1.0, y - 1.0)
2033 gXY.SetPoint(1, x - 1.0, y + 1.0)
2034 gXY.SetPoint(2, x + 1.0, y + 1.0)
2035 gXY.SetPoint(3, x + 1.0, y - 1.0)
2036 gXY.SetPoint(4, x - 1.0, y - 1.0)
2039 gZY.SetPoint(0, z - 1.0, y - 1.0)
2040 gZY.SetPoint(1, z - 1.0, y + 1.0)
2041 gZY.SetPoint(2, z + 1.0, y + 1.0)
2042 gZY.SetPoint(3, z + 1.0, y - 1.0)
2043 gZY.SetPoint(4, z - 1.0, y - 1.0)
2046 gXY.SetLineColor(promptColor)
2047 gZY.SetLineColor(promptColor)
2049 gXY.SetLineColor(bkgdColor)
2050 gZY.SetLineColor(bkgdColor)
2057 hasEnoughRPCHits =
False
2058 for count
in rpcHits:
2060 hasEnoughRPCHits =
True
2062 if hasEnoughRPCHits:
2064 title =
'e{0:02d}r{1}: event {2} 2D hits'.format(int(self.
exp), int(self.
run), event)