Belle II Software development
SegmentColorMapping.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/display/SegmentColorMapping.h>
9
10#include <tracking/trackFindingCDC/display/Colors.h>
11#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
12#include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
13
14#include <framework/logging/Logger.h>
15
16using namespace Belle2;
17using namespace TrackFindingCDC;
18using namespace TrackingUtilities;
19
20const std::string c_bkgSegmentColor = "orange";
21
22namespace {
23 std::string inTrackIdToColor(int inTrackId)
24 {
25 return Colors::getWheelColor(50 * inTrackId);
26 }
27}
28
33
34std::string SegmentMCTrackIdColorMap::map(int index __attribute__((unused)),
35 const CDCSegment2D& segment)
36{
38 ITrackType mcTrackId = mcSegmentLookUp.getMCTrackId(&segment);
39
40 if (mcTrackId < 0) {
41 return c_bkgSegmentColor;
42 } else {
43 int m_iColor = mcTrackId % m_colors.size();
44 return m_colors[m_iColor];
45 }
46}
47
48std::string SegmentFBInfoColorMap::map(int index __attribute__((unused)),
49 const CDCSegment2D& segment)
50{
52 ITrackType mcTrackId = mcSegmentLookUp.getMCTrackId(&segment);
53
54 if (mcTrackId < 0) return c_bkgSegmentColor;
55 EForwardBackward fbInfo = mcSegmentLookUp.isForwardOrBackwardToMCTrack(&segment);
56 if (fbInfo == EForwardBackward::c_Forward) {
57 return "green";
58 } else if (fbInfo == EForwardBackward::c_Backward) {
59 return "red";
60 } else {
61 B2INFO("Segment not orientable to match track");
62 return c_bkgSegmentColor;
63 }
64}
65
66std::string SegmentFirstInTrackIdColorMap::map(int index __attribute__((unused)),
67 const CDCSegment2D& segment)
68{
70 Index firstInTrackId = mcSegmentLookUp.getFirstInTrackId(&segment);
71
72 if (firstInTrackId < 0) return c_bkgSegmentColor;
73 return inTrackIdToColor(firstInTrackId);
74}
75
76std::string SegmentLastInTrackIdColorMap::map(int index __attribute__((unused)),
77 const CDCSegment2D& segment)
78{
80 Index lastInTrackId = mcSegmentLookUp.getLastInTrackId(&segment);
81
82 if (lastInTrackId < 0) return c_bkgSegmentColor;
83 return inTrackIdToColor(lastInTrackId);
84}
85
86std::string SegmentFirstNPassedSuperLayersColorMap::map(int index __attribute__((unused)),
87 const CDCSegment2D& segment)
88{
90 Index firstNPassedSuperLayers = mcSegmentLookUp.getFirstNPassedSuperLayers(&segment);
91
92 if (firstNPassedSuperLayers < 0) return c_bkgSegmentColor;
93 return inTrackIdToColor(firstNPassedSuperLayers);
94}
95
96std::string SegmentLastNPassedSuperLayersColorMap::map(int index __attribute__((unused)),
97 const CDCSegment2D& segment)
98{
100 Index lastNPassedSuperLayers = mcSegmentLookUp.getLastNPassedSuperLayers(&segment);
101
102 if (lastNPassedSuperLayers < 0) return c_bkgSegmentColor;
103 return inTrackIdToColor(lastNPassedSuperLayers);
104}
TrackingUtilities::Index getFirstInTrackId(const ACDCHitCollection *ptrHits) const
Getter for in track id for the first hit in the collection of hits which has the Monte Carlo track id...
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
TrackingUtilities::EForwardBackward isForwardOrBackwardToMCTrack(const ACDCHitCollection *ptrHits) const
Returns the orientation of the collection of hits relative to its matched track.
TrackingUtilities::Index getLastNPassedSuperLayers(const ACDCHitCollection *ptrHits) const
Getter for number of passed superlayer till the last hit the collection of hits which has the Monte C...
TrackingUtilities::Index getFirstNPassedSuperLayers(const ACDCHitCollection *ptrHits) const
Getter for number of passed superlayer till the first hit the collection of hits which has the Monte ...
TrackingUtilities::Index getLastInTrackId(const ACDCHitCollection *ptrHits) const
Getter for in track id for the last hit in the collection of hits which has the Monte Carlo track id ...
Specialisation of the lookup for the truth values of two dimensional segments.
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Utility functions related to colors.
Definition Colors.h:22
static std::string getWheelColor(int degree)
Get a color from the wheel of colors.
Definition Colors.cc:71
std::string map(int index, const TrackingUtilities::CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const TrackingUtilities::CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const TrackingUtilities::CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const TrackingUtilities::CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const TrackingUtilities::CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const TrackingUtilities::CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::vector< std::string > m_colors
List of colors to be cycled through.
A reconstructed sequence of two dimensional hits in one super layer.
Abstract base class for different kinds of events.