Belle II Software  release-05-02-19
TrackNode.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jakob Lettenbichler *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/spacePointCreation/SpacePoint.h>
13 #include <tracking/trackFindingVXD/environment/VXDTFFilters.h>
14 #include <tracking/trackFindingVXD/segmentNetwork/ActiveSector.h>
15 
16 #include <string>
17 
18 namespace Belle2 {
24  struct TrackNode {
27 
29  TrackNode() : m_sector(nullptr), m_spacePoint(nullptr), m_identifier(-1) {}
30 
32  explicit TrackNode(SpacePoint* spacePoint) :
33  m_sector(nullptr), m_spacePoint(spacePoint), m_identifier(spacePoint->getArrayIndex())
34  {}
35 
38 
39 
42 
45 
47  const std::int32_t m_identifier;
48 
49 
54  bool operator==(const TrackNode& b) const
55  {
56  // simple case: no null-ptrs interfering:
57  if (m_spacePoint != nullptr and b.m_spacePoint != nullptr and m_sector != nullptr and b.m_sector != nullptr) {
58  // compares objects:
59  return (*m_spacePoint == *(b.m_spacePoint)) and (*m_sector == *(b.m_sector));
60  }
61 
62  // case: at least one of the 2 nodes has no null-ptrs:
63  if (m_spacePoint != nullptr and m_sector != nullptr) return false; // means: this Node has no null-Ptrs -> the other one has
64  if (b.m_spacePoint != nullptr and b.m_sector != nullptr) return false; // means: the other Node has no null-Ptrs -> this one has
65 
66  // case: both nodes have got at least one null-ptr:
67  bool spacePointsAreEqual = false;
68  if (m_spacePoint != nullptr and b.m_spacePoint != nullptr) {
69  spacePointsAreEqual = (*m_spacePoint == *(b.m_spacePoint));
70  } else {
71  spacePointsAreEqual = (m_spacePoint == b.m_spacePoint);
72  }
73  bool sectorsAreEqual = false;
74  if (m_sector != nullptr and b.m_sector != nullptr) {
75  sectorsAreEqual = (*m_sector == *(b.m_sector));
76  } else {
77  sectorsAreEqual = (m_sector == b.m_sector);
78  }
79  return (spacePointsAreEqual == true and sectorsAreEqual == true);
80  }
81 
82 
84  bool operator!=(const TrackNode& b) const
85  {
86  if (m_spacePoint == nullptr) {
87  B2FATAL("TrackNode::operator !=: m_spacePoint for Tracknode not set - aborting run.");
88  }
89  return !(*this == b);
90  }
91 
92 
94  const SpacePoint& getHit() const
95  {
96  if (m_spacePoint == nullptr) {
97  B2FATAL("TrackNode::getHit: m_spacePoint for Tracknode not set - aborting run.");
98  }
99  return *m_spacePoint;
100  }
101 
102 
105  {
106  if (m_sector == nullptr) {
107  B2FATAL("TrackNode::getActiveSector: ActiveSector for Tracknode not set - aborting run.");
108  }
109  return *m_sector;
110  }
111 
112 
114  std::int32_t getID() const { return m_identifier; }
115 
116 
118  std::string getName() const
119  {
120  if (m_identifier >= 0)
121  return "SP: " + m_spacePoint->getName();
122  else
123  return "SP: missing";
124  }
125  };
127 }
Belle2::TrackNode::operator!=
bool operator!=(const TrackNode &b) const
Overloaded '!='-operator.
Definition: TrackNode.h:92
Belle2::TrackNode
Minimal class to store combination of sector and spacePoint, since SpacePoint can not carry sectorCon...
Definition: TrackNode.h:32
Belle2::ActiveSector
The ActiveSector Class.
Definition: ActiveSector.h:39
Belle2::VXDTFFilters::staticSector_t
StaticSector< point_t, twoHitFilter_t, threeHitFilter_t, int > staticSector_t
typedef to make a static sector type more readable.
Definition: VXDTFFilters.h:129
Belle2::TrackNode::m_spacePoint
SpacePoint * m_spacePoint
Pointer to spacePoint.
Definition: TrackNode.h:52
Belle2::TrackNode::~TrackNode
~TrackNode()
Destructor.
Definition: TrackNode.h:45
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::SpacePoint::getName
std::string getName() const override
Print out some info for this SpacePoint.
Definition: SpacePoint.h:125
Belle2::TrackNode::getID
std::int32_t getID() const
Return ID of this node.
Definition: TrackNode.h:122
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackNode::getHit
const SpacePoint & getHit() const
returns reference to hit.
Definition: TrackNode.h:102
Belle2::TrackNode::getActiveSector
ActiveSector< StaticSectorType, TrackNode > & getActiveSector()
returns reference to hit.
Definition: TrackNode.h:112
Belle2::TrackNode::StaticSectorType
VXDTFFilters< SpacePoint >::staticSector_t StaticSectorType
To improve readability of the code, here the definition of the static sector type.
Definition: TrackNode.h:34
Belle2::TrackNode::TrackNode
TrackNode()
Constructor.
Definition: TrackNode.h:37
Belle2::TrackNode::m_sector
ActiveSector< StaticSectorType, TrackNode > * m_sector
Pointer to sector.
Definition: TrackNode.h:49
Belle2::TrackNode::operator==
bool operator==(const TrackNode &b) const
Overloaded '=='-operator TODO JKL: pretty ugly operator overload, should be fixed ASAP!...
Definition: TrackNode.h:62
Belle2::TrackNode::m_identifier
const std::int32_t m_identifier
Unique integer identifier.
Definition: TrackNode.h:55
Belle2::TrackNode::getName
std::string getName() const
Returns longer debugging name of this node.
Definition: TrackNode.h:126