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/trackFindingCDC/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;
18
19const std::string c_bkgSegmentColor = "orange";
20
21namespace {
22 std::string inTrackIdToColor(int inTrackId)
23 {
24 return Colors::getWheelColor(50 * inTrackId);
25 }
26}
27
29 : m_colors(Colors::getList())
30{
31}
32
33std::string SegmentMCTrackIdColorMap::map(int index __attribute__((unused)),
34 const CDCSegment2D& segment)
35{
37 ITrackType mcTrackId = mcSegmentLookUp.getMCTrackId(&segment);
38
39 if (mcTrackId < 0) {
40 return c_bkgSegmentColor;
41 } else {
42 int m_iColor = mcTrackId % m_colors.size();
43 return m_colors[m_iColor];
44 }
45}
46
47std::string SegmentFBInfoColorMap::map(int index __attribute__((unused)),
48 const CDCSegment2D& segment)
49{
51 ITrackType mcTrackId = mcSegmentLookUp.getMCTrackId(&segment);
52
53 if (mcTrackId < 0) return c_bkgSegmentColor;
54 EForwardBackward fbInfo = mcSegmentLookUp.isForwardOrBackwardToMCTrack(&segment);
55 if (fbInfo == EForwardBackward::c_Forward) {
56 return "green";
57 } else if (fbInfo == EForwardBackward::c_Backward) {
58 return "red";
59 } else {
60 B2INFO("Segment not orientable to match track");
61 return c_bkgSegmentColor;
62 }
63}
64
65std::string SegmentFirstInTrackIdColorMap::map(int index __attribute__((unused)),
66 const CDCSegment2D& segment)
67{
69 Index firstInTrackId = mcSegmentLookUp.getFirstInTrackId(&segment);
70
71 if (firstInTrackId < 0) return c_bkgSegmentColor;
72 return inTrackIdToColor(firstInTrackId);
73}
74
75std::string SegmentLastInTrackIdColorMap::map(int index __attribute__((unused)),
76 const CDCSegment2D& segment)
77{
79 Index lastInTrackId = mcSegmentLookUp.getLastInTrackId(&segment);
80
81 if (lastInTrackId < 0) return c_bkgSegmentColor;
82 return inTrackIdToColor(lastInTrackId);
83}
84
85std::string SegmentFirstNPassedSuperLayersColorMap::map(int index __attribute__((unused)),
86 const CDCSegment2D& segment)
87{
89 Index firstNPassedSuperLayers = mcSegmentLookUp.getFirstNPassedSuperLayers(&segment);
90
91 if (firstNPassedSuperLayers < 0) return c_bkgSegmentColor;
92 return inTrackIdToColor(firstNPassedSuperLayers);
93}
94
95std::string SegmentLastNPassedSuperLayersColorMap::map(int index __attribute__((unused)),
96 const CDCSegment2D& segment)
97{
99 Index lastNPassedSuperLayers = mcSegmentLookUp.getLastNPassedSuperLayers(&segment);
100
101 if (lastNPassedSuperLayers < 0) return c_bkgSegmentColor;
102 return inTrackIdToColor(lastNPassedSuperLayers);
103}
EForwardBackward isForwardOrBackwardToMCTrack(const ACDCHitCollection *ptrHits) const
Returns the orientation of the collection of hits relative to its matched track.
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
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...
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 ...
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...
Index getFirstNPassedSuperLayers(const ACDCHitCollection *ptrHits) const
Getter for number of passed superlayer till the first hit the collection of hits which has the Monte ...
Specialisation of the lookup for the truth values of two dimensional segments.
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
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 CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
std::string map(int index, const 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.
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Abstract base class for different kinds of events.