Belle II Software  release-05-02-19
SegmentColorMapping.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: dschneider, Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/display/SegmentColorMapping.h>
11 
12 #include <tracking/trackFindingCDC/display/Colors.h>
13 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
14 #include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
15 
16 #include <framework/logging/Logger.h>
17 
18 using namespace Belle2;
19 using namespace TrackFindingCDC;
20 
21 const std::string c_bkgSegmentColor = "orange";
22 
23 namespace {
24  std::string inTrackIdToColor(int inTrackId)
25  {
26  return Colors::getWheelColor(50 * inTrackId);
27  }
28 }
29 
31  : m_colors(Colors::getList())
32 {
33 }
34 
35 std::string SegmentMCTrackIdColorMap::map(int index __attribute__((unused)),
36  const CDCSegment2D& segment)
37 {
39  ITrackType mcTrackId = mcSegmentLookUp.getMCTrackId(&segment);
40 
41  if (mcTrackId < 0) {
42  return c_bkgSegmentColor;
43  } else {
44  int m_iColor = mcTrackId % m_colors.size();
45  return m_colors[m_iColor];
46  }
47 }
48 
49 std::string SegmentFBInfoColorMap::map(int index __attribute__((unused)),
50  const CDCSegment2D& segment)
51 {
53  ITrackType mcTrackId = mcSegmentLookUp.getMCTrackId(&segment);
54 
55  if (mcTrackId < 0) return c_bkgSegmentColor;
56  EForwardBackward fbInfo = mcSegmentLookUp.isForwardOrBackwardToMCTrack(&segment);
57  if (fbInfo == EForwardBackward::c_Forward) {
58  return "green";
59  } else if (fbInfo == EForwardBackward::c_Backward) {
60  return "red";
61  } else {
62  B2INFO("Segment not orientable to match track");
63  return c_bkgSegmentColor;
64  }
65 }
66 
67 std::string SegmentFirstInTrackIdColorMap::map(int index __attribute__((unused)),
68  const CDCSegment2D& segment)
69 {
71  Index firstInTrackId = mcSegmentLookUp.getFirstInTrackId(&segment);
72 
73  if (firstInTrackId < 0) return c_bkgSegmentColor;
74  return inTrackIdToColor(firstInTrackId);
75 }
76 
77 std::string SegmentLastInTrackIdColorMap::map(int index __attribute__((unused)),
78  const CDCSegment2D& segment)
79 {
81  Index lastInTrackId = mcSegmentLookUp.getLastInTrackId(&segment);
82 
83  if (lastInTrackId < 0) return c_bkgSegmentColor;
84  return inTrackIdToColor(lastInTrackId);
85 }
86 
87 std::string SegmentFirstNPassedSuperLayersColorMap::map(int index __attribute__((unused)),
88  const CDCSegment2D& segment)
89 {
91  Index firstNPassedSuperLayers = mcSegmentLookUp.getFirstNPassedSuperLayers(&segment);
92 
93  if (firstNPassedSuperLayers < 0) return c_bkgSegmentColor;
94  return inTrackIdToColor(firstNPassedSuperLayers);
95 }
96 
97 std::string SegmentLastNPassedSuperLayersColorMap::map(int index __attribute__((unused)),
98  const CDCSegment2D& segment)
99 {
100  const CDCMCSegment2DLookUp& mcSegmentLookUp = CDCMCSegment2DLookUp::getInstance();
101  Index lastNPassedSuperLayers = mcSegmentLookUp.getLastNPassedSuperLayers(&segment);
102 
103  if (lastNPassedSuperLayers < 0) return c_bkgSegmentColor;
104  return inTrackIdToColor(lastNPassedSuperLayers);
105 }
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getLastInTrackId
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 ...
Definition: CDCMCHitCollectionLookUp.h:127
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getFirstNPassedSuperLayers
Index getFirstNPassedSuperLayers(const ACDCHitCollection *ptrHits) const
Getter for number of passed superlayer till the first hit the collection of hits which has the Monte ...
Definition: CDCMCHitCollectionLookUp.h:143
Belle2::TrackFindingCDC::SegmentMCTrackIdColorMap::m_colors
std::vector< std::string > m_colors
List of colors to be cycled through.
Definition: SegmentColorMapping.h:52
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp
Specialisation of the lookup for the truth values of two dimensional segments.
Definition: CDCMCSegment2DLookUp.h:33
Belle2::TrackFindingCDC::NForwardBackward::EForwardBackward
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Definition: EForwardBackward.h:35
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getMCTrackId
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
Definition: CDCMCHitCollectionLookUp.icc.h:101
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp::getInstance
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCSegment2DLookUp.cc:23
Belle2::TrackFindingCDC::SegmentMCTrackIdColorMap::SegmentMCTrackIdColorMap
SegmentMCTrackIdColorMap()
Constructor.
Definition: SegmentColorMapping.cc:30
Belle2::TrackFindingCDC::SegmentMCTrackIdColorMap::map
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
Definition: SegmentColorMapping.cc:35
Belle2::TrackFindingCDC::SegmentFBInfoColorMap::map
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
Definition: SegmentColorMapping.cc:49
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::isForwardOrBackwardToMCTrack
EForwardBackward isForwardOrBackwardToMCTrack(const ACDCHitCollection *ptrHits) const
Returns the orientation of the collection of hits relative to its matched track.
Definition: CDCMCHitCollectionLookUp.icc.h:192
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getFirstInTrackId
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...
Definition: CDCMCHitCollectionLookUp.h:123
Belle2::TrackFindingCDC::SegmentLastInTrackIdColorMap::map
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
Definition: SegmentColorMapping.cc:77
Belle2::TrackFindingCDC::SegmentLastNPassedSuperLayersColorMap::map
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
Definition: SegmentColorMapping.cc:97
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::SegmentFirstInTrackIdColorMap::map
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
Definition: SegmentColorMapping.cc:67
Belle2::TrackFindingCDC::SegmentFirstNPassedSuperLayersColorMap::map
std::string map(int index, const CDCSegment2D &segment) override
Function call to map a segments object from the local finder to a color.
Definition: SegmentColorMapping.cc:87
Belle2::TrackFindingCDC::Colors::getWheelColor
static std::string getWheelColor(int degree)
Get a color from the wheel of colors.
Definition: Colors.cc:73
Belle2::TrackFindingCDC::Colors
Utility functions related to colors.
Definition: Colors.h:32
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getLastNPassedSuperLayers
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...
Definition: CDCMCHitCollectionLookUp.h:147