12 from ROOT
import gSystem
14 from ROOT
import Belle2
19 gSystem.Load(
'libframework')
20 gSystem.Load(
'libcdc')
21 gSystem.Load(
'libtracking')
22 gSystem.Load(
'libgenfit2')
23 gSystem.Load(
'libdataobjects')
45 def timeOfFlightToColor(timeOfFlight):
47 Translates the given floating point time of flight to a color.
53 hue = 360 / 3.0 * timeOfFlight % 360.0 / 360.0
57 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness, saturation)
59 color =
'rgb({0:.2%}, {1:.2%}, {2:.2%})'.format(red, green, blue)
63 def inTrackIdToColor(inTrackId):
65 Translates the given integer in track id to a color.
68 hue = 50 * inTrackId % 360 / 360.0
72 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness, saturation)
74 color =
'rgb({0:.2%}, {1:.2%}, {2:.2%})'.format(red, green, blue)
81 Base class for CDCHit to the stroke width map functional objects.
86 Function call to map the CDCHit id and object to a stroke width.
95 CDCHit to stroke width map highlighting the CDCHits with 0 drift length.
100 Function call to map the CDCHit id and object to a stroke width.
104 if wirehit.getRefDriftLength() == 0.0:
113 Base class for CDCHit to color map functional objects.
117 bkgHitColor =
'orange'
121 Function call to map the CDCHit id and object to a color.
130 CDCHit to color map highlighting the CDCHits with 0 drift length.
135 Function call to map the CDCHit id and object to a color.
139 if wirehit.getRefDriftLength() == 0.0:
148 CDCHit to color map highlighting the CDCHits that posses the do not use flag.
157 print(
'Could not find CDCWireHitVector in the data store to lookup TakenFlag')
161 Function call to map the CDCHit id and object to a color.
168 wireHit = wireHits.at(bisect.bisect_left(wireHits, cdcHit))
169 if wireHit.getAutomatonCell().hasTakenFlag():
178 CDCHit to color map by their local right left passage information from Monte Carlo truth
183 Function call to map the CDCHit id and object to a color.
187 rlInfo = mcHitLookUp.getRLInfo(cdcHit)
191 elif rlInfo == -1
or rlInfo == 65535:
199 Informal string summarizing the translation from right left passage variable to colors.
202 return 'Local right left passage variable: green <-> right, red <-> left, orange <-> not determinable.'
208 CDCRecoHit3D to color map for the correctness of the rl information
218 This function maps the cdcRecoHit3D to the color which inidcated the correctness of the rl passage
221 cdcHit = cdcRecoHit3D.getWireHit().getHit()
224 rlInfo = mcHitLookUp.getRLInfo(cdcHit)
226 if rlInfo == -32768
or rlInfo == 32768:
228 elif rlInfo == cdcRecoHit3D.getRLInfo():
235 Informal string summarizing the translation from right left passage variable to colors.
237 return 'Correct RL info: gree, wrong RL info: red'
243 CDCHit to color map by their assoziated CDCSimHit::getPosFlag property.
248 Function call to map the CDCHit id and object to a color.
251 simHit = cdcHit.getRelated(
'CDCSimHits')
252 posFlag = simHit.getPosFlag()
264 Informal string summarizing the translation from CDCSimHit::getPosFlag variable to colors.
267 return 'PosFlag variable of the related CDCSimHit: green <-> 0 (Right), red <-> 1 (Left), orange <-> determinable.'
273 CDCHit to color map by their assoziated CDCSimHit::getBackgroundTag property.
280 bkgname_by_bkgtag = {
281 BackgroundMetaData.bg_none:
'bg_none',
282 BackgroundMetaData.bg_Coulomb_LER:
'bg_Coulomb_LER',
283 BackgroundMetaData.bg_Coulomb_HER:
'bg_Coulomb_HER',
284 BackgroundMetaData.bg_RBB_LER:
'bg_RBB_LER',
285 BackgroundMetaData.bg_RBB_HER:
'bg_RBB_HER',
286 BackgroundMetaData.bg_Touschek_LER:
'bg_Touschek_LER',
287 BackgroundMetaData.bg_Touschek_HER:
'bg_Touschek_HER',
288 BackgroundMetaData.bg_twoPhoton:
'bg_twoPhoton',
289 BackgroundMetaData.bg_RBB_gamma:
'bg_RBB_gamma',
290 BackgroundMetaData.bg_RBB_LER_far:
'bg_RBB_LER_far',
291 BackgroundMetaData.bg_RBB_HER_far:
'bg_RBB_HER_far',
292 BackgroundMetaData.bg_Touschek_LER_far:
'bg_Touschek_LER_far',
293 BackgroundMetaData.bg_Touschek_HER_far:
'bg_Touschek_HER_far',
294 BackgroundMetaData.bg_SynchRad_LER:
'bg_SynchRad_LER',
295 BackgroundMetaData.bg_SynchRad_HER:
'bg_SynchRad_HER',
296 BackgroundMetaData.bg_other:
'bg_other',
301 BackgroundMetaData.bg_none:
'orange',
302 BackgroundMetaData.bg_Coulomb_LER:
'red',
303 BackgroundMetaData.bg_Coulomb_HER:
'darkred',
304 BackgroundMetaData.bg_RBB_LER:
'blue',
305 BackgroundMetaData.bg_RBB_HER:
'darkblue',
306 BackgroundMetaData.bg_Touschek_LER:
'green',
307 BackgroundMetaData.bg_Touschek_HER:
'darkgreen',
308 BackgroundMetaData.bg_twoPhoton:
'violet',
309 BackgroundMetaData.bg_RBB_gamma:
'skyblue',
310 BackgroundMetaData.bg_RBB_LER_far:
'turquoise',
311 BackgroundMetaData.bg_RBB_HER_far:
'darkturquoise',
312 BackgroundMetaData.bg_Touschek_LER_far:
'olivergreen',
313 BackgroundMetaData.bg_Touschek_HER_far:
'darkolivegreen',
314 BackgroundMetaData.bg_SynchRad_LER:
'goldenrod',
315 BackgroundMetaData.bg_SynchRad_HER:
'darkgoldenrod',
316 BackgroundMetaData.bg_other:
'orange',
321 Function call to map the CDCHit id and object to a color.
324 cdcSimHit = cdcHit.getRelated(
'CDCSimHits')
325 backgroundTag = cdcSimHit.getBackgroundTag()
330 print(
'Background tag %s not associated with a color.'
338 Informal string summarizing the translation from CDCSimHit::getBackgroundTag variable to colors.
341 color_by_bkgname = {}
346 color_by_bkgname[name] = color
348 bkgname_and_color = sorted(color_by_bkgname.items())
350 message =
'Background tag color coding is \n%s' %
'\n'.join(name +
' -> ' + color
for (name, color)
in bkgname_and_color)
357 CDCHit to color map by their Monte Carlo segment id
362 Function call to map the CDCHit id and object to a color.
366 inTrackSegmentId = mcHitLookUp.getInTrackSegmentId(cdcHit)
368 if inTrackSegmentId < 0:
372 hue = 50 * inTrackSegmentId % 360 / 360.0
376 (red, green, blue) = colorsys.hls_to_rgb(hue, lightness,
379 color =
'rgb({0:.2%}, {1:.2%}, {2:.2%})'.format(red, green, blue)
386 CDCHit to color map by their assoziated CDCSimHit::getFlightTime.
391 Function call to map the CDCHit id and object to a color.
394 simHit = cdcHit.getRelated(
'CDCSimHits')
395 timeOfFlight = simHit.getFlightTime()
397 return timeOfFlightToColor(timeOfFlight)
403 CDCHit to color map indicating the reassignment to a different MCParticle.
408 Function call to map the CDCHit id and object to a color.
411 relatedMCParticles = cdcHit.getRelationsWith(
'MCParticles')
412 if relatedMCParticles.size() == 0:
415 mcRelationWeight = relatedMCParticles.weight(0)
416 if mcRelationWeight > 0:
425 CDCHit to color map coloring by the assoziated MCParticle::getArrayIndex()
430 Construction method setting up a Monte Carlo id to color dictionary which is continously filled
431 as new during the event.
439 Function call to map the CDCHit id and object to a color.
442 mcParticle = cdcHit.getRelated(
'MCParticles')
444 mcParticleId = mcParticle.getArrayIndex()
458 iColor = iColor % len(listColors)
459 color = listColors[iColor]
468 CDCHit to color map by the assoziated MCParticle::getPDG()
473 -999: CDCHitColorMap.bkgHitColor,
489 missing_pdg_color =
'lime'
493 Function call to map the CDCHit id and object to a color.
496 mcParticle = cdcHit.getRelated(
'MCParticles')
498 pdgcode = mcParticle.getPDG()
507 print(
'Unknown PDG code', pdgcode)
514 Informal string summarizing the translation from pdg codes to colors.
517 legend_head =
'Legend:\n'
519 pdg_code_by_color = {}
521 for (pdgcode, color)
in list(self.
color_by_pdgcodecolor_by_pdgcode.items()):
522 pdg_code_by_color.setdefault(color, [])
523 pdg_code_by_color[color].append(pdgcode)
525 legend_content =
'\n'.join(str(color) +
'->' + str(pdg_code_by_color[color])
526 for color
in pdg_code_by_color)
528 return legend_head + legend_content
534 CDCHit to color map by the isPrimary information as well as the secondary process type in case the particle is not primary.
539 Constuction method setting up a dictionary to count the hits for each secondary type.
547 Function call to map the CDCHit id and object to a color.
550 mcParticle = cdcHit.getRelated(
'MCParticles')
553 isPrimary = mcParticle.hasStatus(primaryFlag)
554 secondaryProcess = mcParticle.getSecondaryPhysicsProcess()
555 if secondaryProcess > 0:
556 motherMCParticle = mcParticle.getMother()
557 secondary_type = (motherMCParticle.getPDG(),
560 motherMCParticle =
None
561 secondary_type = (-999, mcParticle.getPDG())
568 elif secondaryProcess > 200:
578 Informal string summarizing the translation from seconday process codes to colors.
584 green->secondary decay in flight
585 red->secondary other process
586 orange->beam background
594 Base class for Segments to color map functional objects.
598 bkgSegmentColor =
'orange'
602 Function call to map a segments object from the local finder to a color.
611 Segment to color map based on the matched MCTrackId
616 Function call to map a segments object from the local finder to a color.
622 mcTrackId = mcSegmentLookUp.getMCTrackId(segment)
626 iColor = mcTrackId % len(listColors)
627 color = listColors[iColor]
634 Segment to color map based on the forward or backward alignment relative to the match Monte Carlo track.
639 Function call to map a segments object from the local finder to a color.
646 mcTrackId = mcSegmentLookUp.getMCTrackId(segment)
650 fbInfo = mcSegmentLookUp.isForwardOrBackwardToMCTrack(segment)
653 elif fbInfo == -1
or fbInfo == 65535:
656 print(
'Segment not orientable to match track')
663 Segment to color map by the in track id of the first hit.
668 Function call to map a segments object from the local finder to a color.
675 firstInTrackId = mcSegmentLookUp.getFirstInTrackId(segment)
677 if firstInTrackId < 0:
680 return inTrackIdToColor(firstInTrackId)
686 Segment to color map by the in track id of the last hit.
691 Function call to map a segments object from the local finder to a color.
698 lastInTrackId = mcSegmentLookUp.getLastInTrackId(segment)
700 if lastInTrackId < 0:
703 return inTrackIdToColor(lastInTrackId)
709 Segment to color map by the number of passed superlayers of the first hit.
714 Function call to map a segments object from the local finder to a color.
721 firstNPassedSuperLayers = \
722 mcSegmentLookUp.getFirstNPassedSuperLayers(segment)
724 if firstNPassedSuperLayers < 0:
727 return inTrackIdToColor(firstNPassedSuperLayers)
733 Segment to color map by the number of passed superlayers of the last hit.
738 Function call to map a segments object from the local finder to a color.
745 lastNPassedSuperLayers = \
746 mcSegmentLookUp.getLastNPassedSuperLayers(segment)
748 if lastNPassedSuperLayers < 0:
751 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.
def __call__(self, iCDCHit, cdcHit)
dictionary bkgname_by_bkgtag
dictionary of (tag, label) pairs
dictionary color_by_bkgtag
dictionary of (tag, color) pairs
def __call__(self, iCDCHit, cdcHit)
string bkgHitColor
Default color to be used.
def __call__(self, iCDCHit, cdcHit)
def __call__(self, iSegment, segment)
string bkgSegmentColor
Default color to be used.
def __call__(self, iCDCHit, cdcHit)
dictionary color_by_pdgcode
Dictionary to define the color for the most relevant.
string 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 contious use of the available colo...
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)