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