11from ROOT
import gSystem
13from ROOT
import Belle2
18gSystem.Load(
'libframework')
20gSystem.Load(
'libtracking')
21gSystem.Load(
'libgenfit2')
22gSystem.Load(
'libdataobjects')
44def timeOfFlightToColor(timeOfFlight):
46 Translates the given floating point time of flight to a color.
52 hue = 360 / 3.0 * timeOfFlight % 360.0 / 360.0
56 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness, saturation)
58 color = f
'rgb({red:.2%}, {green:.2%}, {blue:.2%})'
62def inTrackIdToColor(inTrackId):
64 Translates the given integer in track id to a color.
67 hue = 50 * inTrackId % 360 / 360.0
71 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness, saturation)
73 color = f'rgb({red:.2%}, {green:.2%}, {blue:.2%})'
80 Base class for CDCHit to the stroke width map functional objects.
85 Function call to map the CDCHit id and object to a stroke width.
94 CDCHit to stroke width map highlighting the CDCHits with 0 drift length.
99 Function call to map the CDCHit id and object to a stroke width.
103 if wirehit.getRefDriftLength() == 0.0:
112 Base class for CDCHit to color map functional objects.
116 bkgHitColor = 'orange'
120 Function call to map the CDCHit id and object to a color.
129 CDCHit to color map highlighting the CDCHits with 0 drift length.
134 Function call to map the CDCHit id and object to a color.
138 if wirehit.getRefDriftLength() == 0.0:
147 CDCHit to color map highlighting the CDCHits that posses the do not use flag.
156 print(
'Could not find CDCWireHitVector in the data store to lookup TakenFlag')
160 Function call to map the CDCHit id and object to a color.
167 wireHit = wireHits.at(bisect.bisect_left(wireHits, cdcHit))
168 if wireHit.getAutomatonCell().hasTakenFlag():
177 CDCHit to color map by their local right left passage information from Monte Carlo truth
182 Function call to map the CDCHit id and object to a color.
186 rlInfo = mcHitLookUp.getRLInfo(cdcHit)
190 elif rlInfo == -1
or rlInfo == 65535:
198 Informal string summarizing the translation from right left passage variable to colors.
201 return 'Local right left passage variable: green <-> right, red <-> left, orange <-> not determinable.'
207 CDCRecoHit3D to color map for the correctness of the rl information
217 This function maps the cdcRecoHit3D to the color which indicates the correctness of the rl passage
220 cdcHit = cdcRecoHit3D.getWireHit().getHit()
223 rlInfo = mcHitLookUp.getRLInfo(cdcHit)
225 if rlInfo == -32768
or rlInfo == 32768:
227 elif rlInfo == cdcRecoHit3D.getRLInfo():
234 Informal string summarizing the translation from right left passage variable to colors.
236 return 'Correct RL info: gree, wrong RL info: red'
242 CDCHit to color map by their associated CDCSimHit::getPosFlag property.
247 Function call to map the CDCHit id and object to a color.
250 simHit = cdcHit.getRelated('CDCSimHits')
251 posFlag = simHit.getPosFlag()
263 Informal string summarizing the translation from CDCSimHit::getPosFlag variable to colors.
266 return 'PosFlag variable of the related CDCSimHit: green <-> 0 (Right), red <-> 1 (Left), orange <-> determinable.'
272 CDCHit to color map by their associated CDCSimHit::getBackgroundTag property.
279 bkgname_by_bkgtag = {
280 BackgroundMetaData.bg_none: 'bg_none',
281 BackgroundMetaData.bg_Coulomb_LER:
'bg_Coulomb_LER',
282 BackgroundMetaData.bg_Coulomb_HER:
'bg_Coulomb_HER',
283 BackgroundMetaData.bg_RBB_LER:
'bg_RBB_LER',
284 BackgroundMetaData.bg_RBB_HER:
'bg_RBB_HER',
285 BackgroundMetaData.bg_Touschek_LER:
'bg_Touschek_LER',
286 BackgroundMetaData.bg_Touschek_HER:
'bg_Touschek_HER',
287 BackgroundMetaData.bg_twoPhoton:
'bg_twoPhoton',
288 BackgroundMetaData.bg_RBB_gamma:
'bg_RBB_gamma',
289 BackgroundMetaData.bg_RBB_LER_far:
'bg_RBB_LER_far',
290 BackgroundMetaData.bg_RBB_HER_far:
'bg_RBB_HER_far',
291 BackgroundMetaData.bg_Touschek_LER_far:
'bg_Touschek_LER_far',
292 BackgroundMetaData.bg_Touschek_HER_far:
'bg_Touschek_HER_far',
293 BackgroundMetaData.bg_SynchRad_LER:
'bg_SynchRad_LER',
294 BackgroundMetaData.bg_SynchRad_HER:
'bg_SynchRad_HER',
295 BackgroundMetaData.bg_other:
'bg_other',
300 BackgroundMetaData.bg_none:
'orange',
301 BackgroundMetaData.bg_Coulomb_LER:
'red',
302 BackgroundMetaData.bg_Coulomb_HER:
'darkred',
303 BackgroundMetaData.bg_RBB_LER:
'blue',
304 BackgroundMetaData.bg_RBB_HER:
'darkblue',
305 BackgroundMetaData.bg_Touschek_LER:
'green',
306 BackgroundMetaData.bg_Touschek_HER:
'darkgreen',
307 BackgroundMetaData.bg_twoPhoton:
'violet',
308 BackgroundMetaData.bg_RBB_gamma:
'skyblue',
309 BackgroundMetaData.bg_RBB_LER_far:
'turquoise',
310 BackgroundMetaData.bg_RBB_HER_far:
'darkturquoise',
311 BackgroundMetaData.bg_Touschek_LER_far:
'olivergreen',
312 BackgroundMetaData.bg_Touschek_HER_far:
'darkolivegreen',
313 BackgroundMetaData.bg_SynchRad_LER:
'goldenrod',
314 BackgroundMetaData.bg_SynchRad_HER:
'darkgoldenrod',
315 BackgroundMetaData.bg_other:
'orange',
320 Function call to map the CDCHit id and object to a color.
323 cdcSimHit = cdcHit.getRelated('CDCSimHits')
324 backgroundTag = cdcSimHit.getBackgroundTag()
329 print(f
'Background tag {backgroundTag} not associated with a color.')
336 Informal string summarizing the translation from CDCSimHit::getBackgroundTag variable to colors.
339 color_by_bkgname = {}
344 color_by_bkgname[name] = color
346 bkgname_and_color = sorted(color_by_bkgname.items())
348 message = f
'Background tag color coding is \n{chr(10).join(name + " -> " + color for (name, color) in bkgname_and_color):s}'
355 CDCHit to color map by their Monte Carlo segment id
360 Function call to map the CDCHit id and object to a color.
364 inTrackSegmentId = mcHitLookUp.getInTrackSegmentId(cdcHit)
366 if inTrackSegmentId < 0:
370 hue = 50 * inTrackSegmentId % 360 / 360.0
374 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness,
377 color = f
'rgb({red:.2%}, {green:.2%}, {blue:.2%})'
384 CDCHit to color map by their associated CDCSimHit::getFlightTime.
389 Function call to map the CDCHit id and object to a color.
392 simHit = cdcHit.getRelated('CDCSimHits')
393 timeOfFlight = simHit.getFlightTime()
395 return timeOfFlightToColor(timeOfFlight)
401 CDCHit to color map indicating the reassignment to a different MCParticle.
406 Function call to map the CDCHit id and object to a color.
409 relatedMCParticles = cdcHit.getRelationsWith('MCParticles')
410 if relatedMCParticles.size() == 0:
413 mcRelationWeight = relatedMCParticles.weight(0)
414 if mcRelationWeight > 0:
423 CDCHit to color map coloring by the associated MCParticle::getArrayIndex()
428 Construction method setting up a Monte Carlo id to color dictionary which is continuously filled
429 as new during the event.
437 Function call to map the CDCHit id and object to a color.
440 mcParticle = cdcHit.getRelated('MCParticles')
442 mcParticleId = mcParticle.getArrayIndex()
456 iColor = iColor % len(listColors)
457 color = listColors[iColor]
466 CDCHit to color map by the associated MCParticle::getPDG()
471 -999: CDCHitColorMap.bkgHitColor,
487 missing_pdg_color =
'lime'
491 Function call to map the CDCHit id and object to a color.
494 mcParticle = cdcHit.getRelated('MCParticles')
496 pdgcode = mcParticle.getPDG()
505 print(
'Unknown PDG code', pdgcode)
512 Informal string summarizing the translation from pdg codes to colors.
515 legend_head = 'Legend:\n'
517 pdg_code_by_color = {}
520 pdg_code_by_color.setdefault(color, [])
521 pdg_code_by_color[color].append(pdgcode)
523 legend_content =
'\n'.join(str(color) +
'->' + str(pdg_code_by_color[color])
524 for color
in pdg_code_by_color)
526 return legend_head + legend_content
532 CDCHit to color map by the isPrimary information as well
as the secondary process type
in case the particle
is not primary.
537 Construction method setting up a dictionary to count the hits for each secondary type.
545 Function call to map the CDCHit id and object to a color.
548 mcParticle = cdcHit.getRelated('MCParticles')
551 isPrimary = mcParticle.hasStatus(primaryFlag)
552 secondaryProcess = mcParticle.getSecondaryPhysicsProcess()
553 if secondaryProcess > 0:
554 motherMCParticle = mcParticle.getMother()
555 secondary_type = (motherMCParticle.getPDG(),
558 motherMCParticle =
None
559 secondary_type = (-999, mcParticle.getPDG())
566 elif secondaryProcess > 200:
576 Informal string summarizing the translation from secondary process codes to colors.
582green->secondary decay in flight
583red->secondary other process
584orange->beam background
592 Base class for Segments to color map functional objects.
596 bkgSegmentColor = 'orange'
600 Function call to map a segments object from the local finder to a color.
609 Segment to color map based on the matched MCTrackId
614 Function call to map a segments object from the local finder to a color.
620 mcTrackId = mcSegmentLookUp.getMCTrackId(segment)
624 iColor = mcTrackId % len(listColors)
625 color = listColors[iColor]
632 Segment to color map based on the forward or backward alignment relative to the match Monte Carlo track.
637 Function call to map a segments object from the local finder to a color.
644 mcTrackId = mcSegmentLookUp.getMCTrackId(segment)
648 fbInfo = mcSegmentLookUp.isForwardOrBackwardToMCTrack(segment)
651 elif fbInfo == -1
or fbInfo == 65535:
654 print(
'Segment not orientable to match track')
661 Segment to color map by the in track id of the first hit.
666 Function call to map a segments object from the local finder to a color.
673 firstInTrackId = mcSegmentLookUp.getFirstInTrackId(segment)
675 if firstInTrackId < 0:
678 return inTrackIdToColor(firstInTrackId)
684 Segment to color map by the in track id of the last hit.
689 Function call to map a segments object from the local finder to a color.
696 lastInTrackId = mcSegmentLookUp.getLastInTrackId(segment)
698 if lastInTrackId < 0:
701 return inTrackIdToColor(lastInTrackId)
707 Segment to color map by the number of passed superlayers of the first hit.
712 Function call to map a segments object from the local finder to a color.
719 firstNPassedSuperLayers = \
720 mcSegmentLookUp.getFirstNPassedSuperLayers(segment)
722 if firstNPassedSuperLayers < 0:
725 return inTrackIdToColor(firstNPassedSuperLayers)
731 Segment to color map by the number of passed superlayers of the last hit.
736 Function call to map a segments object from the local finder to a color.
743 lastNPassedSuperLayers = \
744 mcSegmentLookUp.getLastNPassedSuperLayers(segment)
746 if lastNPassedSuperLayers < 0:
749 return inTrackIdToColor(lastNPassedSuperLayers)
a (simplified) python wrapper for StoreObjPtr.
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Class representing a hit wire in the central drift chamber.
dict bkgname_by_bkgtag
dictionary of (tag, label) pairs
def __call__(self, iCDCHit, cdcHit)
dict color_by_bkgtag
dictionary of (tag, color) pairs
str bkgHitColor
Default color to be used.
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iSegment, segment)
str bkgSegmentColor
Default color to be used.
def __call__(self, iCDCHit, cdcHit)
dict color_by_pdgcode
Dictionary to define the color for the most relevant.
str missing_pdg_color
Color for the case a particle a pdg code not mentioned in the color_by_pdgcode map.
def __call__(self, iCDCHit, cdcHit)
color_by_mcparticleId
Dictionary mapping the MCParticle ids to colors for consistent and continuous use of the available co...
def __call__(self, iCDCHit, cdcHit)
n_hits_by_secondary_type
Dictionary keeping track of the number of hits with a specific secondary process type.
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iSegment, segment)
def __call__(self, iSegment, segment)
def __call__(self, iSegment, segment)
def __call__(self, iSegment, segment)
def __call__(self, iSegment, segment)
def __call__(self, iSegment, segment)
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iCDCHit, cdcHit)
storedWireHits
cached copy of the CDCWireHitVector
def __call__(self, iCDCRecoHit, cdcRecoHit3D)
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iCDCHit, cdcHit)