Belle II Software  release-08-01-10
AnalizerTCInfo.h
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 #pragma once
9 
10 // tracking:
11 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
12 #include <tracking/spacePointCreation/MCVXDPurityInfo.h>
13 #include <tracking/trackFindingVXD/analyzingTools/TCType.h>
14 
15 // root:
16 #include <Math/Vector3D.h>
17 
18 // stl:
19 #include <vector>
20 #include <utility> // std::pair
21 
22 namespace Belle2 {
29  public:
30 
31 
33  ROOT::Math::XYZVector posSeed;
34 
36  ROOT::Math::XYZVector momSeed;
37 
40 
43 
46 
49 
50 
52  AnalizerTCInfo() : tC(nullptr), assignedTC(nullptr), tcType(TCType::Unclassified) {}
53 
54 
56  static AnalizerTCInfo createTC(bool isReference, const MCVXDPurityInfo& iD, SpacePointTrackCand& aTC)
57  {
58  AnalizerTCInfo newTC;
59 
60  newTC.posSeed = aTC.getPosSeed();
61  newTC.momSeed = aTC.getMomSeed();
62  newTC.tC = &aTC;
63  newTC.assignedID = iD;
64  newTC.tcType = isReference ? TCType::Reference : TCType::Unclassified;
65  return newTC;
66  }
67 
68 
70  static void markUnused(std::vector<AnalizerTCInfo>& tcs, TCType::Type newType)
71  {
72  for (AnalizerTCInfo& aTC : tcs) {
73  if (aTC.assignedTC == nullptr) {
74  aTC.tcType = newType;
75  }
76  }
77  }
78 
79 
81  static TCType::Type classifyTC(AnalizerTCInfo& referenceTC, AnalizerTCInfo& testTC, double purityThreshold,
82  unsigned int ndfThreshold)
83  {
84  std::pair<int, float> testPurity = testTC.assignedID.getPurity();
85  std::pair<int, float> refPurity = referenceTC.assignedID.getPurity();
86  // catch ill case
87  if (testPurity.first != refPurity.first) { return TCType::Unclassified; }
88 
89  if (testPurity.second < purityThreshold) { return TCType::Ghost; }
90 
91  if (testTC.assignedID.getNDFTotal() < ndfThreshold) { return TCType::SmallStump; }
92 
93  if (testPurity.second < 1.f) { return TCType::Contaminated; }
94 
95  if (testTC.assignedID.getNClustersTotal() < referenceTC.assignedID.getNClustersTotal()) { return TCType::Clean; }
96 
97  return TCType::Perfect;
98  }
99 
100 
105  void discardTC()
106  {
107  assignedTC->tcType = TCType::Clone;
108  assignedTC = nullptr;
109  }
110 
111 
113  void assignTCs(AnalizerTCInfo* otherTC)
114  {
115  assignedTC = otherTC;
116  otherTC->assignedTC = this;
117  }
118 
119 
121  void pairUp(AnalizerTCInfo* otherTC)
122  {
123  // case: this TC was not assigned before
124  if (assignedTC == nullptr) {
125  assignTCs(otherTC);
126  return;
127  }
128 
129  // case: was already assigned, but old one was not as good as the new one
130  if (assignedTC->tcType < otherTC->tcType) {
131  discardTC();
132  assignTCs(otherTC);
133  return;
134  }
135 
136  // case: was already assigned, but old one was better.
137  otherTC->assignedTC = this;
138  otherTC->tcType = TCType::Clone;
139  }
140 
141 
143  TCType::Type getType() const { return tcType; }
144  };
146 }
simple class storing infos relevant for a TC for analizing it.
static TCType::Type classifyTC(AnalizerTCInfo &referenceTC, AnalizerTCInfo &testTC, double purityThreshold, unsigned int ndfThreshold)
for given pair of TCs their compatibility will be checked and the testTC classified,...
AnalizerTCInfo * assignedTC
for reference TC: best test TC found, for test TC, compatible reference TC found
MCVXDPurityInfo assignedID
stores the iD of the particle and knows the purity for it
void pairUp(AnalizerTCInfo *otherTC)
links otherTC to this one
void assignTCs(AnalizerTCInfo *otherTC)
function for assigning TCs to each other
const SpacePointTrackCand * tC
a link to the TC itself
static void markUnused(std::vector< AnalizerTCInfo > &tcs, TCType::Type newType)
find unpaired tcs and mark them with given type
AnalizerTCInfo()
constructor, makes sure that pointers are on nullptr until set
ROOT::Math::XYZVector momSeed
carries the momentum vector at the position of the seed hit (typically the innermost hit)
static AnalizerTCInfo createTC(bool isReference, const MCVXDPurityInfo &iD, SpacePointTrackCand &aTC)
static function for correctly creating TrackCandidates
void discardTC()
function for discarding the old TC.
ROOT::Math::XYZVector posSeed
carries the global coordinates of the position of the seed hit (typically the innermost hit)
TCType::Type getType() const
a type-identifier function
TCType::Type tcType
classifies attached TC
The MC VXD Purity info container class.
std::pair< int, float > getPurity() const
getter - returns overal purity (.second) for this particleID (.first).
unsigned int getNClustersTotal() const
returns total number of clusters the trackCandidate had
unsigned int getNDFTotal() const
getter - returns number of degrees of freedom for all Clusters in TC total
Storage for (VXD) SpacePoint-based track candidates.
const ROOT::Math::XYZVector getPosSeed() const
get position seed as ROOT::Math::XYZVector
const ROOT::Math::XYZVector getMomSeed() const
get momentum seed as ROOT::Math::XYZVector
Small class for classifying types of reconstructed track candidates.
Definition: TCType.h:25
Type
allows classifying TCs
Definition: TCType.h:29
Abstract base class for different kinds of events.