Belle II Software  release-05-01-25
CDCMCHitCollectionLookUp.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
13 
14 #include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
15 #include <tracking/trackFindingCDC/numerics/Index.h>
16 
17 #include <map>
18 
19 namespace Belle2 {
24  class MCParticle;
25  class CDCHit;
26 
27  namespace TrackFindingCDC {
28  class CDCTrajectory3D;
29 
31  struct MCTrackIdPurityPair {
32 
34  MCTrackIdPurityPair(ITrackType mcTrackId, float purity, int correctRLVote)
35  : m_mcTrackId(mcTrackId)
36  , m_purity(purity)
37  , m_correctRLVote(correctRLVote)
38  {
39  }
40 
42  ITrackType getMCTrackId() const
43  {
44  return m_mcTrackId;
45  }
46 
48  float getPurity() const
49  {
50  return m_purity;
51  }
52 
54  int getCorrectRLVote() const
55  {
57  }
58 
59  private:
61  ITrackType m_mcTrackId;
62 
64  float m_purity;
65 
67  int m_correctRLVote;
68  };
69 
71  template <typename ACDCHitCollection>
73 
74  public:
76  void clear();
77 
80 
81  private:
83  std::map<ITrackType, size_t> getHitCountByMCTrackId(const ACDCHitCollection& hits) const;
84 
85  public:
87  MCTrackIdPurityPair getHighestPurity(const ACDCHitCollection& hits) const;
88 
90 
94  ITrackType getMCTrackId(const ACDCHitCollection* ptrHits) const;
95 
97  int getCorrectRLVote(const ACDCHitCollection* ptrHits) const;
98 
100  double getRLPurity(const ACDCHitCollection* ptrHits) const;
101 
103  const MCParticle* getMCParticle(const ACDCHitCollection* ptrHits) const;
104 
105 
107  const CDCHit* getFirstHit(const ACDCHitCollection* ptrHits) const;
108 
110  const CDCHit* getLastHit(const ACDCHitCollection* ptrHits) const;
111 
112 
113 
115  Index getFirstInTrackId(const ACDCHitCollection* ptrHits) const
117 
119  Index getLastInTrackId(const ACDCHitCollection* ptrHits) const
120  { return CDCMCHitLookUp::getInstance().getInTrackId(getLastHit(ptrHits)); }
121 
122 
123 
125  Index getFirstInTrackSegmentId(const ACDCHitCollection* ptrHits) const
127 
129  Index getLastInTrackSegmentId(const ACDCHitCollection* ptrHits) const
131 
132 
133 
135  Index getFirstNPassedSuperLayers(const ACDCHitCollection* ptrHits) const
137 
139  Index getLastNPassedSuperLayers(const ACDCHitCollection* ptrHits) const
141 
143  Index getFirstNLoops(const ACDCHitCollection* ptrHits) const
144  { return CDCMCHitLookUp::getInstance().getNLoops(getFirstHit(ptrHits)); }
145 
147  Index getLastNLoops(const ACDCHitCollection* ptrHits) const
148  { return CDCMCHitLookUp::getInstance().getNLoops(getLastHit(ptrHits)); }
149 
157  EForwardBackward isForwardOrBackwardToMCTrack(const ACDCHitCollection* ptrHits) const;
158 
170  EForwardBackward areAlignedInMCTrack(const ACDCHitCollection* ptrFromHits,
171  const ACDCHitCollection* ptrToHits) const;
172 
178  EForwardBackward areAlignedInMCTrackWithRLCheck(const ACDCHitCollection* ptrFromHits,
179  const ACDCHitCollection* ptrToHits) const;
180 
182  CDCTrajectory3D getTrajectory3D(const ACDCHitCollection* ptrHits) const;
183 
184  private:
186  float m_minimalMatchPurity = 0.5;
187 
189  float m_minimalRLPurity = 0.5;
190  };
191  }
193 }
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::m_minimalMatchPurity
float m_minimalMatchPurity
Threshold for the purity that must be exceeded to be considered as a match.
Definition: CDCMCHitCollectionLookUp.h:194
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::areAlignedInMCTrackWithRLCheck
EForwardBackward areAlignedInMCTrackWithRLCheck(const ACDCHitCollection *ptrFromHits, const ACDCHitCollection *ptrToHits) const
Returns if the second collection of hits follows the first collection of hits in their common Monte C...
Definition: CDCMCHitCollectionLookUp.icc.h:327
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::CDCMCHitCollectionLookUp::getFirstHit
const CDCHit * getFirstHit(const ACDCHitCollection *ptrHits) const
Getter for the first hit in the collection of hits which has the Monte Carlo track id matched to this...
Definition: CDCMCHitCollectionLookUp.icc.h:156
Belle2::TrackFindingCDC::MCTrackIdPurityPair
Structure representing a matched Monte Carlo track id with the corresponding purity.
Definition: CDCMCHitCollectionLookUp.h:39
Belle2::CDCHit
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:51
Belle2::TrackFindingCDC::MCTrackIdPurityPair::getMCTrackId
ITrackType getMCTrackId() const
Getter for the Monte Carlo track Id.
Definition: CDCMCHitCollectionLookUp.h:50
Belle2::TrackFindingCDC::CDCMCHitLookUp::getNPassedSuperLayers
Index getNPassedSuperLayers(const CDCHit *ptrHit) const
Returns the number of superlayers the track traversed until this hit.
Definition: CDCMCHitLookUp.cc:141
Belle2::TrackFindingCDC::MCTrackIdPurityPair::m_purity
float m_purity
Purity wrt mc track.
Definition: CDCMCHitCollectionLookUp.h:72
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::CDCMCHitCollectionLookUp
CDCMCHitCollectionLookUp()
Dummy constructor to silence the intel-compiler warnings (NOTE: using "=default" will make the intel ...
Definition: CDCMCHitCollectionLookUp.h:87
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::CDCMCHitCollectionLookUp::getLastHit
const CDCHit * getLastHit(const ACDCHitCollection *ptrHits) const
Getter for the last hit in the collection of hits which has the Monte Carlo track id matched to this ...
Definition: CDCMCHitCollectionLookUp.icc.h:174
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getFirstNLoops
Index getFirstNLoops(const ACDCHitCollection *ptrHits) const
Getter for number of loops till the first hit the collection of hits which has the Monte Carlo track ...
Definition: CDCMCHitCollectionLookUp.h:151
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getLastNLoops
Index getLastNLoops(const ACDCHitCollection *ptrHits) const
Getter for number of loops till the last hit the collection of hits which has the Monte Carlo track i...
Definition: CDCMCHitCollectionLookUp.h:155
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::m_minimalRLPurity
float m_minimalRLPurity
Threshold for the correct fraction of right left passage informations to be considered a match.
Definition: CDCMCHitCollectionLookUp.h:197
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getLastInTrackSegmentId
Index getLastInTrackSegmentId(const ACDCHitCollection *ptrHits) const
Getter for in track collection of hits id for the last hit in the collection of hits which has the Mo...
Definition: CDCMCHitCollectionLookUp.h:137
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::clear
void clear()
Clears all Monte Carlo information left from the last event.
Definition: CDCMCHitCollectionLookUp.icc.h:41
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::areAlignedInMCTrack
EForwardBackward areAlignedInMCTrack(const ACDCHitCollection *ptrFromHits, const ACDCHitCollection *ptrToHits) const
Returns if the second collection of hits follows the first collection of hits in their common Monte C...
Definition: CDCMCHitCollectionLookUp.icc.h:210
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp
Interface class to the Monte Carlo information for collections of hits.
Definition: CDCMCHitCollectionLookUp.h:80
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getCorrectRLVote
int getCorrectRLVote(const ACDCHitCollection *ptrHits) const
Getter for the difference of correct versus incorrect right left passage informations.
Definition: CDCMCHitCollectionLookUp.icc.h:114
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCMCHitLookUp::getNLoops
Index getNLoops(const CDCHit *ptrHit) const
Returns the number of loops the track traversed until this hit.
Definition: CDCMCHitLookUp.cc:147
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
tracking.validation.scores.purity
def purity(truths, predictions)
Definition: scores.py:71
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::CDCMCHitCollectionLookUp::getMCParticle
const MCParticle * getMCParticle(const ACDCHitCollection *ptrHits) const
Getter for the mc particle matched to this collection of hits.
Definition: CDCMCHitCollectionLookUp.icc.h:146
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getFirstInTrackSegmentId
Index getFirstInTrackSegmentId(const ACDCHitCollection *ptrHits) const
Getter for in track collection of hits id for the first hit in the collection of hits which has the M...
Definition: CDCMCHitCollectionLookUp.h:133
Belle2::TrackFindingCDC::MCTrackIdPurityPair::m_mcTrackId
ITrackType m_mcTrackId
Id of the mc track.
Definition: CDCMCHitCollectionLookUp.h:69
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getHitCountByMCTrackId
std::map< ITrackType, size_t > getHitCountByMCTrackId(const ACDCHitCollection &hits) const
Fill a map with the number of hits for each track id contained in the given hit range.
Definition: CDCMCHitCollectionLookUp.icc.h:48
Belle2::TrackFindingCDC::CDCMCHitLookUp::getInstance
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCHitLookUp.cc:32
Belle2::TrackFindingCDC::MCTrackIdPurityPair::m_correctRLVote
int m_correctRLVote
Number of correct rl information in the track.
Definition: CDCMCHitCollectionLookUp.h:75
Belle2::TrackFindingCDC::CDCMCHitLookUp::getInTrackId
Index getInTrackId(const CDCHit *ptrHit) const
Returns the position of the wire hit in the track along the travel direction.
Definition: CDCMCHitLookUp.cc:129
Belle2::TrackFindingCDC::MCTrackIdPurityPair::MCTrackIdPurityPair
MCTrackIdPurityPair(ITrackType mcTrackId, float purity, int correctRLVote)
Constructor taking the Monte Carlo track id and the purity to be stored.
Definition: CDCMCHitCollectionLookUp.h:42
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getHighestPurity
MCTrackIdPurityPair getHighestPurity(const ACDCHitCollection &hits) const
Get the track id with the highest corresponding purity.
Definition: CDCMCHitCollectionLookUp.icc.h:63
Belle2::TrackFindingCDC::MCTrackIdPurityPair::getPurity
float getPurity() const
Getter for the purity.
Definition: CDCMCHitCollectionLookUp.h:56
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getRLPurity
double getRLPurity(const ACDCHitCollection *ptrHits) const
Getter for the right left passge purity which respects the forward backward reconstruction.
Definition: CDCMCHitCollectionLookUp.icc.h:129
Belle2::TrackFindingCDC::MCTrackIdPurityPair::getCorrectRLVote
int getCorrectRLVote() const
Getter for the rl vote.
Definition: CDCMCHitCollectionLookUp.h:62
Belle2::TrackFindingCDC::CDCTrajectory3D
Particle full three dimensional trajectory.
Definition: CDCTrajectory3D.h:47
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getTrajectory3D
CDCTrajectory3D getTrajectory3D(const ACDCHitCollection *ptrHits) const
Returns the trajectory of the collection of hits.
Definition: CDCMCHitCollectionLookUp.icc.h:359
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
Belle2::TrackFindingCDC::CDCMCHitLookUp::getInTrackSegmentId
Index getInTrackSegmentId(const CDCHit *ptrHit) const
Returns the id of the segment in the track.
Definition: CDCMCHitLookUp.cc:135