4 from ROOT
import gSystem
5 gSystem.Load(
'libframework')
7 gSystem.Load(
'libtracking')
8 gSystem.Load(
'libgenfit2')
10 gSystem.Load(
'libdataobjects')
12 from ROOT
import Belle2
14 from ROOT
import genfit
40 def timeOfFlightToColor(timeOfFlight):
42 Translates the given floating point time of flight to a color.
48 hue = 360 / 3.0 * timeOfFlight % 360.0 / 360.0
52 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness, saturation)
54 color =
'rgb({0:.2%}, {1:.2%}, {2:.2%})'.format(red, green, blue)
58 def inTrackIdToColor(inTrackId):
60 Translates the given integer in track id to a color.
63 hue = 50 * inTrackId % 360 / 360.0
67 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness, saturation)
69 color =
'rgb({0:.2%}, {1:.2%}, {2:.2%})'.format(red, green, blue)
76 Base class for CDCHit to the stroke width map functional objects.
81 Function call to map the CDCHit id and object to a stroke width.
90 CDCHit to stroke width map highlighting the CDCHits with 0 drift length.
95 Function call to map the CDCHit id and object to a stroke width.
99 if wirehit.getRefDriftLength() == 0.0:
108 Base class for CDCHit to color map functional objects.
112 bkgHitColor =
'orange'
116 Function call to map the CDCHit id and object to a color.
125 CDCHit to color map highlighting the CDCHits with 0 drift length.
130 Function call to map the CDCHit id and object to a color.
134 if wirehit.getRefDriftLength() == 0.0:
143 CDCHit to color map highlighting the CDCHits that posses the do not use flag.
152 print(
'Could not find CDCWireHitVector in the data store to lookup TakenFlag')
156 Function call to map the CDCHit id and object to a color.
163 wireHit = wireHits.at(bisect.bisect_left(wireHits, cdcHit))
164 if wireHit.getAutomatonCell().hasTakenFlag():
173 CDCHit to color map by their local right left passage information from Monte Carlo truth
178 Function call to map the CDCHit id and object to a color.
182 rlInfo = mcHitLookUp.getRLInfo(cdcHit)
186 elif rlInfo == -1
or rlInfo == 65535:
194 Informal string summarizing the translation from right left passage variable to colors.
197 return 'Local right left passage variable: green <-> right, red <-> left, orange <-> not determinable.'
203 CDCRecoHit3D to color map for the correctness of the rl information
213 This function maps the cdcRecoHit3D to the color which inidcated the correctness of the rl passage
216 cdcHit = cdcRecoHit3D.getWireHit().getHit()
219 rlInfo = mcHitLookUp.getRLInfo(cdcHit)
221 if rlInfo == -32768
or rlInfo == 32768:
223 elif rlInfo == cdcRecoHit3D.getRLInfo():
230 Informal string summarizing the translation from right left passage variable to colors.
232 return 'Correct RL info: gree, wrong RL info: red'
238 CDCHit to color map by their assoziated CDCSimHit::getPosFlag property.
243 Function call to map the CDCHit id and object to a color.
246 simHit = cdcHit.getRelated(
'CDCSimHits')
247 posFlag = simHit.getPosFlag()
259 Informal string summarizing the translation from CDCSimHit::getPosFlag variable to colors.
262 return 'PosFlag variable of the related CDCSimHit: green <-> 0 (Right), red <-> 1 (Left), orange <-> determinable.'
268 CDCHit to color map by their assoziated CDCSimHit::getBackgroundTag property.
275 bkgname_by_bkgtag = {
276 BackgroundMetaData.bg_none:
'bg_none',
277 BackgroundMetaData.bg_Coulomb_LER:
'bg_Coulomb_LER',
278 BackgroundMetaData.bg_Coulomb_HER:
'bg_Coulomb_HER',
279 BackgroundMetaData.bg_RBB_LER:
'bg_RBB_LER',
280 BackgroundMetaData.bg_RBB_HER:
'bg_RBB_HER',
281 BackgroundMetaData.bg_Touschek_LER:
'bg_Touschek_LER',
282 BackgroundMetaData.bg_Touschek_HER:
'bg_Touschek_HER',
283 BackgroundMetaData.bg_twoPhoton:
'bg_twoPhoton',
284 BackgroundMetaData.bg_RBB_gamma:
'bg_RBB_gamma',
285 BackgroundMetaData.bg_RBB_LER_far:
'bg_RBB_LER_far',
286 BackgroundMetaData.bg_RBB_HER_far:
'bg_RBB_HER_far',
287 BackgroundMetaData.bg_Touschek_LER_far:
'bg_Touschek_LER_far',
288 BackgroundMetaData.bg_Touschek_HER_far:
'bg_Touschek_HER_far',
289 BackgroundMetaData.bg_SynchRad_LER:
'bg_SynchRad_LER',
290 BackgroundMetaData.bg_SynchRad_HER:
'bg_SynchRad_HER',
291 BackgroundMetaData.bg_other:
'bg_other',
296 BackgroundMetaData.bg_none:
'orange',
297 BackgroundMetaData.bg_Coulomb_LER:
'red',
298 BackgroundMetaData.bg_Coulomb_HER:
'darkred',
299 BackgroundMetaData.bg_RBB_LER:
'blue',
300 BackgroundMetaData.bg_RBB_HER:
'darkblue',
301 BackgroundMetaData.bg_Touschek_LER:
'green',
302 BackgroundMetaData.bg_Touschek_HER:
'darkgreen',
303 BackgroundMetaData.bg_twoPhoton:
'violet',
304 BackgroundMetaData.bg_RBB_gamma:
'skyblue',
305 BackgroundMetaData.bg_RBB_LER_far:
'turquoise',
306 BackgroundMetaData.bg_RBB_HER_far:
'darkturquoise',
307 BackgroundMetaData.bg_Touschek_LER_far:
'olivergreen',
308 BackgroundMetaData.bg_Touschek_HER_far:
'darkolivegreen',
309 BackgroundMetaData.bg_SynchRad_LER:
'goldenrod',
310 BackgroundMetaData.bg_SynchRad_HER:
'darkgoldenrod',
311 BackgroundMetaData.bg_other:
'orange',
316 Function call to map the CDCHit id and object to a color.
319 cdcSimHit = cdcHit.getRelated(
'CDCSimHits')
320 backgroundTag = cdcSimHit.getBackgroundTag()
325 print(
'Background tag %s not associated with a color.'
333 Informal string summarizing the translation from CDCSimHit::getBackgroundTag variable to colors.
336 color_by_bkgname = {}
341 color_by_bkgname[name] = color
343 bkgname_and_color = sorted(color_by_bkgname.items())
345 message =
'Background tag color coding is \n%s' %
'\n'.join(name +
' -> ' + color
for (name, color)
in bkgname_and_color)
352 CDCHit to color map by their Monte Carlo segment id
357 Function call to map the CDCHit id and object to a color.
361 inTrackSegmentId = mcHitLookUp.getInTrackSegmentId(cdcHit)
363 if inTrackSegmentId < 0:
367 hue = 50 * inTrackSegmentId % 360 / 360.0
371 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness,
374 color =
'rgb({0:.2%}, {1:.2%}, {2:.2%})'.format(red, green, blue)
381 CDCHit to color map by their assoziated CDCSimHit::getFlightTime.
386 Function call to map the CDCHit id and object to a color.
389 simHit = cdcHit.getRelated(
'CDCSimHits')
390 timeOfFlight = simHit.getFlightTime()
392 return timeOfFlightToColor(timeOfFlight)
398 CDCHit to color map indicating the reassignment to a different MCParticle.
403 Function call to map the CDCHit id and object to a color.
406 relatedMCParticles = cdcHit.getRelationsWith(
'MCParticles')
407 if relatedMCParticles.size() == 0:
410 mcRelationWeight = relatedMCParticles.weight(0)
411 if mcRelationWeight > 0:
420 CDCHit to color map coloring by the assoziated MCParticle::getArrayIndex()
425 Construction method setting up a Monte Carlo id to color dictionary which is continously filled
426 as new during the event.
434 Function call to map the CDCHit id and object to a color.
437 mcParticle = cdcHit.getRelated(
'MCParticles')
439 mcParticleId = mcParticle.getArrayIndex()
453 iColor = iColor % len(listColors)
454 color = listColors[iColor]
463 CDCHit to color map by the assoziated MCParticle::getPDG()
468 -999: CDCHitColorMap.bkgHitColor,
484 missing_pdg_color =
'lime'
488 Function call to map the CDCHit id and object to a color.
491 mcParticle = cdcHit.getRelated(
'MCParticles')
493 pdgcode = mcParticle.getPDG()
502 print(
'Unknown PDG code', pdgcode)
509 Informal string summarizing the translation from pdg codes to colors.
512 legend_head =
'Legend:\n'
514 pdg_code_by_color = {}
517 pdg_code_by_color.setdefault(color, [])
518 pdg_code_by_color[color].append(pdgcode)
520 legend_content =
'\n'.join(str(color) +
'->' + str(pdg_code_by_color[color])
521 for color
in pdg_code_by_color)
523 return legend_head + legend_content
529 CDCHit to color map by the isPrimary information as well as the secondary process type in case the particle is not primary.
534 Constuction method setting up a dictionary to count the hits for each secondary type.
542 Function call to map the CDCHit id and object to a color.
545 mcParticle = cdcHit.getRelated(
'MCParticles')
548 isPrimary = mcParticle.hasStatus(primaryFlag)
549 secondaryProcess = mcParticle.getSecondaryPhysicsProcess()
550 if secondaryProcess > 0:
551 motherMCParticle = mcParticle.getMother()
552 secondary_type = (motherMCParticle.getPDG(),
555 motherMCParticle =
None
556 secondary_type = (-999, mcParticle.getPDG())
563 elif secondaryProcess > 200:
573 Informal string summarizing the translation from seconday process codes to colors.
579 green->secondary decay in flight
580 red->secondary other process
581 orange->beam background
589 Base class for Segments to color map functional objects.
593 bkgSegmentColor =
'orange'
597 Function call to map a segments object from the local finder to a color.
606 Segment to color map based on the matched MCTrackId
611 Function call to map a segments object from the local finder to a color.
617 mcTrackId = mcSegmentLookUp.getMCTrackId(segment)
621 iColor = mcTrackId % len(listColors)
622 color = listColors[iColor]
629 Segment to color map based on the forward or backward alignment relative to the match Monte Carlo track.
634 Function call to map a segments object from the local finder to a color.
641 mcTrackId = mcSegmentLookUp.getMCTrackId(segment)
645 fbInfo = mcSegmentLookUp.isForwardOrBackwardToMCTrack(segment)
648 elif fbInfo == -1
or fbInfo == 65535:
651 print(
'Segment not orientable to match track')
658 Segment to color map by the in track id of the first hit.
663 Function call to map a segments object from the local finder to a color.
670 firstInTrackId = mcSegmentLookUp.getFirstInTrackId(segment)
672 if firstInTrackId < 0:
675 return inTrackIdToColor(firstInTrackId)
681 Segment to color map by the in track id of the last hit.
686 Function call to map a segments object from the local finder to a color.
693 lastInTrackId = mcSegmentLookUp.getLastInTrackId(segment)
695 if lastInTrackId < 0:
698 return inTrackIdToColor(lastInTrackId)
704 Segment to color map by the number of passed superlayers of the first hit.
709 Function call to map a segments object from the local finder to a color.
716 firstNPassedSuperLayers = \
717 mcSegmentLookUp.getFirstNPassedSuperLayers(segment)
719 if firstNPassedSuperLayers < 0:
722 return inTrackIdToColor(firstNPassedSuperLayers)
728 Segment to color map by the number of passed superlayers of the last hit.
733 Function call to map a segments object from the local finder to a color.
740 lastNPassedSuperLayers = \
741 mcSegmentLookUp.getLastNPassedSuperLayers(segment)
743 if lastNPassedSuperLayers < 0:
746 return inTrackIdToColor(lastNPassedSuperLayers)