94 """Handle job initialization: fill the mapping database, create histograms, open the event-display file"""
100 title = f
'{self.eventPdfName}['
110 self.
sine = [0, 0, 0, 0, 0, 0, 0, 0]
111 for sector
in range(0, 8):
112 phi = math.pi * sector / 4
113 self.
cosine[sector] = math.cos(phi)
114 self.
sine[sector] = math.sin(phi)
116 self.
hist_XY = ROOT.TH2F(
'XY',
' ;x;y', 10, -345.0, 345.0, 10, -345.0, 345.0)
119 self.
hist_ZY = ROOT.TH2F(
'ZY',
' ;z;y', 10, -345.0, 345.0, 10, -345.0, 345.0)
129 self.
hist_XYS[0] = ROOT.TH2F(
'XYS0',
' ;x;y', 10, +u3, +u4, 10, -u5, +u5)
131 self.
hist_XYS[1] = ROOT.TH2F(
'XYS1',
' ;x;y', 10, +u1, +u2, 10, +u1, +u2)
133 self.
hist_XYS[2] = ROOT.TH2F(
'XYS2',
' ;x;y', 10, -u5, +u5, 10, +u3, +u4)
135 self.
hist_XYS[3] = ROOT.TH2F(
'XYS3',
' ;x;y', 10, -u2, -u1, 10, +u1, +u2)
137 self.
hist_XYS[4] = ROOT.TH2F(
'XYS4',
' ;x;y', 10, -u4, -u3, 10, -u5, +u5)
139 self.
hist_XYS[5] = ROOT.TH2F(
'XYS5',
' ;x;y', 10, -u2, -u1, 10, -u2, -u1)
141 self.
hist_XYS[6] = ROOT.TH2F(
'XYS6',
' ;x;y', 10, -u5, +u5, 10, -u4, -u3)
143 self.
hist_XYS[7] = ROOT.TH2F(
'XYS7',
' ;x;y', 10, +u1, +u2, 10, -u2, -u1)
146 self.
hist_ZYS = ROOT.TH2F(
'ZYS',
' ;z;y', 10, -150.0, 150.0, 10, 125.0, 425.0)
148 ROOT.gStyle.SetOptStat(10)
151 r0 = 201.9 + 0.5 * 4.4
153 tan0 = math.tan(math.pi / 8.0)
155 g.SetPoint(0, -200.0, 0.0)
156 g.SetPoint(1, +200.0, 0.0)
162 g.SetPoint(0, 0.0, -200.0)
163 g.SetPoint(1, 0.0, +200.0)
169 g.SetPoint(0, -5.0, 0.0)
170 g.SetPoint(1, +5.0, 0.0)
171 g.SetPoint(2, 0.0, 0.0)
172 g.SetPoint(3, 0.0, +5.0)
173 g.SetPoint(4, 0.0, -5.0)
177 for layer
in range(0, 15):
181 g.SetPoint(0, +r, -x)
182 g.SetPoint(1, +r, +x)
183 g.SetPoint(2, +x, +r)
184 g.SetPoint(3, -x, +r)
185 g.SetPoint(4, -r, +x)
186 g.SetPoint(5, -r, -x)
187 g.SetPoint(6, -x, -r)
188 g.SetPoint(7, +x, -r)
189 g.SetPoint(8, +r, -x)
205 g.SetPoint(0, -zL + z0 - 140.0, 0.0)
206 g.SetPoint(1, +zL + z0 + 70.0, 0.0)
212 g.SetPoint(0, 0.0, -315.0)
213 g.SetPoint(1, 0.0, +340.0)
219 g.SetPoint(0, -5.0, 0.0)
220 g.SetPoint(1, +5.0, 0.0)
221 g.SetPoint(2, 0.0, 0.0)
222 g.SetPoint(3, 0.0, +5.0)
223 g.SetPoint(4, 0.0, -5.0)
228 g.SetPoint(0, -zL + z0, +x0)
229 g.SetPoint(1, -zL + z0, +r0)
235 g.SetPoint(0, -zL + z0, -x0)
236 g.SetPoint(1, -zL + z0, -r0)
242 g.SetPoint(0, +zL + z0, +x0)
243 g.SetPoint(1, +zL + z0, +r0)
249 g.SetPoint(0, +zL + z0, -x0)
250 g.SetPoint(1, +zL + z0, -r0)
256 g.SetPoint(0, -zL + z0, r0)
257 g.SetPoint(1, +zL + z0, r0)
258 g.SetPoint(2, +zL + z0, rF)
259 g.SetPoint(3, -zL + z0, rF)
260 g.SetPoint(4, -zL + z0, r0)
265 g.SetPoint(0, -zL + z0, -r0)
266 g.SetPoint(1, +zL + z0, -r0)
267 g.SetPoint(2, +zL + z0, -rF)
268 g.SetPoint(3, -zL + z0, -rF)
269 g.SetPoint(4, -zL + z0, -r0)
274 g.SetPoint(0, -zL + z0, -x0)
275 g.SetPoint(1, +zL + z0, -x0)
276 g.SetPoint(2, +zL + z0, +x0)
277 g.SetPoint(3, -zL + z0, +x0)
278 g.SetPoint(4, -zL + z0, -x0)
284 for layer
in range(0, 15):
289 g.SetPoint(0, -zL + z0, r)
290 g.SetPoint(1, +zL + z0, r)
297 self.
sectorFBToDC = [11, 15, 2, 6, 10, 14, 3, 7, 9, 13, 0, 4, 8, 12, 1, 5]
299 self.
dcToSectorFB = [10, 14, 2, 6, 11, 15, 3, 7, 12, 8, 4, 0, 13, 9, 5, 1]
309 self.
t0RPC = [8, -14, -6, -14, -2, 10, 9, 13, 0, -10, -14, -20, 2, 6, 14, 11]
311 self.
ct0Scint = [-1, -33, -46, -33, -2, 32, 51, 32, 0, -32, -45, -33, -4, 34, 45, 27]
331 """Process one event: (optionally) draw event display"""
340 event = EventMetaData.getEvent()
346 rawFb = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
347 rawSector = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
348 rawLayer = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
349 rawPlane = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
350 rawStrip = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
351 rawCtime = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
353 for copper
in range(0, len(rawklms)):
354 rawklm = rawklms[copper]
355 nodeID = rawklm.GetNodeID(0) - self.
BKLM_ID
358 if (nodeID < 0)
or (nodeID > 4):
360 for finesse
in range(0, 4):
361 dc = (finesse << 2) + copper
362 n = rawklm.GetDetectorNwords(0, finesse)
363 bufSlot = rawklm.GetDetectorBuffer(0, finesse)
366 for j
in range(0, n):
367 word0 = bufSlot[j * 2]
368 word1 = bufSlot[j * 2 + 1]
369 ctime = word0 & 0xffff
370 channel = (word0 >> 16) & 0x7f
371 axis = (word0 >> 23) & 0x01
372 lane = (word0 >> 24) & 0x1f
373 flag = (word0 >> 30) & 0x03
379 electId = (channel << 12) | (axis << 11) | (lane << 6) | (finesse << 4) | nodeID
388 rawSector[dc].append(sector)
389 rawLayer[dc].append(layer)
390 rawPlane[dc].append(plane)
391 rawStrip[dc].append(strip)
392 rawCtime[dc].append(ctime)
396 tCal2d.append(hit2d.getTime())
409 for exthit
in exthits:
411 extPosition = exthit.getPosition()
418 if (dx * dx + dy * dy + dz * dz > 36)
and (sumn > 0):
419 eposition = [sumx / sumn, sumy / sumn, sumz / sumn, sold]
420 epositions.append(eposition)
436 eposition = [sumx / sumn, sumy / sumn, sumz / sumn, sold]
437 epositions.append(eposition)
438 extXYGraph = ROOT.TGraph()
439 extXYGraph.SetMarkerColor(30)
440 extXYGraph.SetMarkerSize(2.25)
441 extXYGraph.SetMarkerStyle(21)
442 extZYGraph = ROOT.TGraph()
443 extZYGraph.SetMarkerColor(30)
444 extZYGraph.SetMarkerSize(2.25)
445 extZYGraph.SetMarkerStyle(21)
446 extZYSGraph = [0, 0, 0, 0, 0, 0, 0, 0]
447 for sector
in range(0, 8):
448 extZYSGraph[sector] = ROOT.TGraph()
449 extZYSGraph[sector].SetMarkerColor(30)
450 extZYSGraph[sector].SetMarkerSize(2.25)
451 extZYSGraph[sector].SetMarkerStyle(21)
453 for eposition
in epositions:
458 extXYGraph.SetPoint(j, x, y)
459 extZYGraph.SetPoint(j, z, y)
460 sector = int(eposition[3])
461 nPoint = extZYSGraph[sector].GetN()
462 extZYSGraph[sector].SetPoint(nPoint, z, abs(x * self.
cosine[sector] + y * self.
sine[sector]))
466 zMuids = [0, 0, 0, 0, 0, 0, 0, 0]
467 nMuids = [0, 0, 0, 0, 0, 0, 0, 0]
468 muidXYGraph = ROOT.TGraph()
469 muidXYGraph.SetMarkerColor(5)
470 muidXYGraph.SetMarkerSize(2.0)
471 muidXYGraph.SetMarkerStyle(20)
472 muidZYGraph = ROOT.TGraph()
473 muidZYGraph.SetMarkerColor(5)
474 muidZYGraph.SetMarkerSize(2.0)
475 muidZYGraph.SetMarkerStyle(20)
476 muidZYSGraph = [0, 0, 0, 0, 0, 0, 0, 0]
477 for sector
in range(0, 8):
478 muidZYSGraph[sector] = ROOT.TGraph()
479 muidZYSGraph[sector].SetMarkerColor(5)
480 muidZYSGraph[sector].SetMarkerSize(2.0)
481 muidZYSGraph[sector].SetMarkerStyle(20)
483 for muidhit
in muidhits:
485 muidPosition = muidhit.getExtPosition()
489 muidXYGraph.SetPoint(j, x, y)
490 muidZYGraph.SetPoint(j, z, y)
491 sector = muidhit.getSector()
492 nPoint = muidZYSGraph[sector].GetN()
493 muidZYSGraph[sector].SetPoint(nPoint, z, abs(x * self.
cosine[sector] + y * self.
sine[sector]))
494 if nMuids[sector] == 0:
500 rpcHitCount = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
501 promptXYGraph = ROOT.TGraph()
502 promptXYGraph.SetMarkerColor(4)
503 promptXYGraph.SetMarkerSize(2.0)
504 promptXYGraph.SetMarkerStyle(29)
505 promptZYGraph = ROOT.TGraph()
506 promptZYGraph.SetMarkerColor(4)
507 promptZYGraph.SetMarkerSize(2.0)
508 promptZYGraph.SetMarkerStyle(29)
509 bkgdXYGraph = ROOT.TGraph()
510 bkgdXYGraph.SetMarkerColor(2)
511 bkgdXYGraph.SetMarkerSize(2.0)
512 bkgdXYGraph.SetMarkerStyle(29)
513 bkgdZYGraph = ROOT.TGraph()
514 bkgdZYGraph.SetMarkerColor(2)
515 bkgdZYGraph.SetMarkerSize(2.0)
516 bkgdZYGraph.SetMarkerStyle(29)
517 promptZYSGraph = [0, 0, 0, 0, 0, 0, 0, 0]
518 bkgdZYSGraph = [0, 0, 0, 0, 0, 0, 0, 0]
519 for sector
in range(0, 8):
520 promptZYSGraph[sector] = ROOT.TGraph()
521 promptZYSGraph[sector].SetMarkerColor(4)
522 promptZYSGraph[sector].SetMarkerSize(2.0)
523 promptZYSGraph[sector].SetMarkerStyle(29)
524 bkgdZYSGraph[sector] = ROOT.TGraph()
525 bkgdZYSGraph[sector].SetMarkerColor(2)
526 bkgdZYSGraph[sector].SetMarkerSize(2.0)
527 bkgdZYSGraph[sector].SetMarkerStyle(29)
531 key = hit2d.getModuleID()
535 phiStripMin = hit2d.getPhiStripMin() - 1
536 phiStripMax = hit2d.getPhiStripMax() - 1
537 zStripMin = hit2d.getZStripMin() - 1
538 zStripMax = hit2d.getZStripMax() - 1
539 sectorFB = sector
if fb == 0
else sector + 8
541 rpcHitCount[sectorFB] += 1
545 n = rawklms[copper].GetDetectorNwords(0, finesse) >> 1
546 trigCtime = (rawklms[copper].GetTTCtime(0) & 0x07ffffff) << 3
553 for j
in range(0, n):
554 if layer != rawLayer[dc][j]:
556 if sector != rawSector[dc][j]:
558 if fb != rawFb[dc][j]:
560 strip = rawStrip[dc][j]
561 plane = rawPlane[dc][j]
563 if strip < zStripMin:
565 if strip > zStripMax:
567 ctZ = rawCtime[dc][j] << 3
570 if strip < phiStripMin:
572 if strip > phiStripMax:
574 ctPhi = rawCtime[dc][j] << 3
576 if (jZ >= 0)
and (jPhi >= 0):
578 if abs(ctZ - ctPhi) > 40:
580 ct = int((ctZ + ctPhi) * 0.5 - trigCtime - self.
ct0Scint[sectorFB]) & 0x3ff
581 if abs(ct - self.
ct0Cal) < ctDiffMax:
582 ctDiffMax = int(abs(ct - self.
ct0Cal))
587 tCal = ((int(hit2d.getTime()) - trigCtime) & 0x03ff) - self.
t0RPC[sectorFB] - 0.75 * jPhi - 0.75 * jZ
589 x = hit2d.getGlobalPositionX()
590 y = hit2d.getGlobalPositionY()
591 z = hit2d.getGlobalPositionZ()
597 if abs(tCal - self.
t0Cal2d) < 20:
601 promptXYGraph.SetPoint(jPrompt, x, y)
602 promptZYGraph.SetPoint(jPrompt, z, y)
603 nPoint = promptZYSGraph[sector].GetN()
604 promptZYSGraph[sector].SetPoint(nPoint, z, abs(x * self.
cosine[sector] + y * self.
sine[sector]))
607 bkgdXYGraph.SetPoint(jBkgd, x, y)
608 bkgdZYGraph.SetPoint(jBkgd, z, y)
609 nPoint = bkgdZYSGraph[sector].GetN()
610 bkgdZYSGraph[sector].SetPoint(nPoint, z, abs(x * self.
cosine[sector] + y * self.
sine[sector]))
612 hasEnoughRPCHits =
False
613 for count
in rpcHitCount:
615 hasEnoughRPCHits =
True
617 if hasEnoughRPCHits
and (len(muidhits) > self.
minMuidHits):
619 title = f
'e{int(self.exp):02d}r{int(self.run)}: event {event}'
626 if extXYGraph.GetN() > 0:
628 if muidXYGraph.GetN() > 0:
629 muidXYGraph.Draw(
"P")
630 if bkgdXYGraph.GetN() > 0:
631 bkgdXYGraph.Draw(
"P")
632 if promptXYGraph.GetN() > 0:
633 promptXYGraph.Draw(
"P")
638 if extZYGraph.GetN() > 0:
640 if muidZYGraph.GetN() > 0:
641 muidZYGraph.Draw(
"P")
642 if bkgdZYGraph.GetN() > 0:
643 bkgdZYGraph.Draw(
"P")
644 if promptZYGraph.GetN() > 0:
645 promptZYGraph.Draw(
"P")
646 self.
lastTitle = f
"Title:E{event} (#{self.eventCounter})"
648 for sector
in range(0, 8):
649 if nMuids[sector] > 0:
650 title = f
'e{int(self.exp):02d}r{int(self.run)}: event {event} sector {sector}'
651 self.
hist_XYS[sector].SetTitle(title)
656 if extXYGraph.GetN() > 0:
658 if muidXYGraph.GetN() > 0:
659 muidXYGraph.Draw(
"P")
660 if bkgdXYGraph.GetN() > 0:
661 bkgdXYGraph.Draw(
"P")
662 if promptXYGraph.GetN() > 0:
663 promptXYGraph.Draw(
"P")
667 self.
hist_ZYS.SetBins(10, z0 - 150.0, z0 + 150.0, 10, 125.0, 425.0)
673 if extZYSGraph[sector].GetN() > 0:
674 extZYSGraph[sector].Draw(
"P")
675 if muidZYSGraph[sector].GetN() > 0:
676 muidZYSGraph[sector].Draw(
"P")
677 if bkgdZYSGraph[sector].GetN() > 0:
678 bkgdZYSGraph[sector].Draw(
"P")
679 if promptZYSGraph[sector].GetN() > 0:
680 promptZYSGraph[sector].Draw(
"P")
681 self.
lastTitle = f
"Title:E{event} sector {sector}"