Belle II Software development
CDCMCHitCollectionLookUp< ACDCHitCollection > Class Template Reference

Interface class to the Monte Carlo information for collections of hits. More...

#include <CDCMCHitCollectionLookUp.h>

Public Member Functions

void clear ()
 Clears all Monte Carlo information left from the last event.
 
 CDCMCHitCollectionLookUp ()
 Dummy constructor to silence the intel-compiler warnings (NOTE: using "=default" will make the intel compilation fail)
 
MCTrackIdPurityPair getHighestPurity (const ACDCHitCollection &hits) const
 Get the track id with the highest corresponding purity.
 
ITrackType getMCTrackId (const ACDCHitCollection *ptrHits) const
 Getter for the Monte Carlo track id matched to this collection of hits.
 
int getCorrectRLVote (const ACDCHitCollection *ptrHits) const
 Getter for the difference of correct versus incorrect right left passage information.
 
double getRLPurity (const ACDCHitCollection *ptrHits) const
 Getter for the right left passge purity which respects the forward backward reconstruction.
 
const MCParticlegetMCParticle (const ACDCHitCollection *ptrHits) const
 Getter for the mc particle matched to this collection of hits.
 
const CDCHitgetFirstHit (const ACDCHitCollection *ptrHits) const
 Getter for the first hit in the collection of hits which has the Monte Carlo track id matched to this collection of hits.
 
const CDCHitgetLastHit (const ACDCHitCollection *ptrHits) const
 Getter for the last hit in the collection of hits which has the Monte Carlo track id matched to this collection of hits.
 
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 matched to this collection of hits.
 
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 matched to this collection of hits.
 
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 Monte Carlo track id matched to this collection of hits.
 
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 Monte Carlo track id matched to this collection of hits.
 
Index getFirstNPassedSuperLayers (const ACDCHitCollection *ptrHits) const
 Getter for number of passed superlayer till the first hit the collection of hits which has the Monte Carlo track id matched to this collection of hits.
 
Index getLastNPassedSuperLayers (const ACDCHitCollection *ptrHits) const
 Getter for number of passed superlayer till the last hit the collection of hits which has the Monte Carlo track id matched to this collection of hits.
 
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 id matched to this collection of hits.
 
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 id matched to this collection of hits.
 
EForwardBackward isForwardOrBackwardToMCTrack (const ACDCHitCollection *ptrHits) const
 Returns the orientation of the collection of hits relative to its matched track.
 
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 Carlo track.
 
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 Carlo track.
 
CDCTrajectory3D getTrajectory3D (const ACDCHitCollection *ptrHits) const
 Returns the trajectory of the collection of hits.
 

Private Member Functions

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.
 

Private Attributes

float m_minimalMatchPurity = 0.5
 Threshold for the purity that must be exceeded to be considered as a match.
 
float m_minimalRLPurity = 0.5
 Threshold for the correct fraction of right left passage information to be considered a match.
 

Detailed Description

template<typename ACDCHitCollection>
class Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp< ACDCHitCollection >

Interface class to the Monte Carlo information for collections of hits.

Definition at line 70 of file CDCMCHitCollectionLookUp.h.

Constructor & Destructor Documentation

◆ CDCMCHitCollectionLookUp()

Dummy constructor to silence the intel-compiler warnings (NOTE: using "=default" will make the intel compilation fail)

Definition at line 77 of file CDCMCHitCollectionLookUp.h.

77{};

Member Function Documentation

◆ 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 Carlo track.

  • Returns EForwardBackward::c_Invalid if the collection of hits is not matched in the same Monte Carlo track.
  • Returns EForwardBackward::c_Forward if both collections of hits are coaligned with the Monte Carlo track and the second collection of hits comes after the first.
  • Returns EForwardBackward::c_Backward if both collections of hits are anticoaligned with the Monte Carlo track and the second collection of hits comes after the first in the reversed sense.

Check if the segments are in the same track

Definition at line 201 of file CDCMCHitCollectionLookUp.icc.h.

204 {
206 ITrackType fromMCTrackId = getMCTrackId(ptrFromHits);
207 if (fromMCTrackId == INVALID_ITRACK) return EForwardBackward::c_Invalid;
208
209 ITrackType toMCTrackId = getMCTrackId(ptrToHits);
210 if (toMCTrackId == INVALID_ITRACK) return EForwardBackward::c_Invalid;
211
212 if (fromMCTrackId != toMCTrackId) return EForwardBackward::c_Invalid;
213
214 // Check if the segments are meaningful on their own
215 EForwardBackward fromFBInfo = isForwardOrBackwardToMCTrack(ptrFromHits);
216 if (fromFBInfo == EForwardBackward::c_Invalid) return EForwardBackward::c_Invalid;
217
219 if (toFBInfo == EForwardBackward::c_Invalid) return EForwardBackward::c_Invalid;
220
221 if (fromFBInfo != toFBInfo) return EForwardBackward::c_Invalid;
222
223 {
224 // Now check if hits are aligned within their common track
225 // Index firstNPassedSuperLayersOfFromHits = getFirstNPassedSuperLayers(ptrFromHits);
226 Index lastNPassedSuperLayersOfFromHits = getLastNPassedSuperLayers(ptrFromHits);
227 // if (firstNPassedSuperLayersOfFromHits == c_InvalidIndex) return
228 // EForwardBackward::c_Invalid;
229 if (lastNPassedSuperLayersOfFromHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
230
231 Index firstNPassedSuperLayersOfToHits = getFirstNPassedSuperLayers(ptrToHits);
232 // Index lastNPassedSuperLayersOfToHits = getLastNPassedSuperLayers(ptrToHits);
233 if (firstNPassedSuperLayersOfToHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
234 // if (lastNPassedSuperLayersOfToHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
235
236 if (lastNPassedSuperLayersOfFromHits < firstNPassedSuperLayersOfToHits) {
237 if (fromFBInfo == EForwardBackward::c_Forward and
238 toFBInfo == EForwardBackward::c_Forward) {
239 return EForwardBackward::c_Forward;
240 } else {
241 return EForwardBackward::c_Invalid;
242 }
243 } else if (firstNPassedSuperLayersOfToHits < lastNPassedSuperLayersOfFromHits) {
244 if (fromFBInfo == EForwardBackward::c_Backward and
245 toFBInfo == EForwardBackward::c_Backward) {
246 return EForwardBackward::c_Backward;
247 } else {
248 return EForwardBackward::c_Invalid;
249 }
250 }
251 }
252
253 {
254 // Now we are in the same true segment with both segments
255 // Index firstInTrackSegmentIdOfFromHits = getFirstInTrackSegmentId(ptrFromHits);
256 Index lastInTrackSegmentIdOfFromHits = getLastInTrackSegmentId(ptrFromHits);
257 // if (firstInTrackSegmentIdOfFromHits == c_InvalidIndex) return
258 // EForwardBackward::c_Invalid;
259 if (lastInTrackSegmentIdOfFromHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
260
261 Index firstInTrackSegmentIdOfToHits = getFirstInTrackSegmentId(ptrToHits);
262 // Index lastInTrackSegmentIdOfToHits = getLastInTrackSegmentId(ptrToHits);
263 if (firstInTrackSegmentIdOfToHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
264 // if (lastInTrackSegmentIdOfToHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
265
266 if (lastInTrackSegmentIdOfFromHits < firstInTrackSegmentIdOfToHits) {
267 if (fromFBInfo == EForwardBackward::c_Forward and
268 toFBInfo == EForwardBackward::c_Forward) {
269 return EForwardBackward::c_Forward;
270 } else {
271 return EForwardBackward::c_Invalid;
272 }
273 } else if (firstInTrackSegmentIdOfToHits < lastInTrackSegmentIdOfFromHits) {
274 // Test if to segment lies before in the mc track
275 // Hence the whole pair of segments is reverse to the track direction of flight
276 if (fromFBInfo == EForwardBackward::c_Backward and
277 toFBInfo == EForwardBackward::c_Backward) {
278 return EForwardBackward::c_Backward;
279 } else {
280 return EForwardBackward::c_Invalid;
281 }
282 }
283 }
284
285 {
286 // Now we are in the same true segment with both of the hits
287 // Index firstInTrackIdOfFromHits = getFirstInTrackId(ptrFromHits);
288 Index lastInTrackIdOfFromHits = getLastInTrackId(ptrFromHits);
289 // if (firstInTrackIdOfFromHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
290 if (lastInTrackIdOfFromHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
291
292 Index firstInTrackIdOfToHits = getFirstInTrackId(ptrToHits);
293 // Index lastInTrackIdOfToHits = getLastInTrackId(ptrToHits);
294 if (firstInTrackIdOfToHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
295 // if (lastInTrackIdOfToHits == c_InvalidIndex) return EForwardBackward::c_Invalid;
296
297 // Relax conditions somewhat such that segments may overlap at the borders.
298
299 if (lastInTrackIdOfFromHits - 1 < firstInTrackIdOfToHits + 1) {
300 if (fromFBInfo == EForwardBackward::c_Forward and
301 toFBInfo == EForwardBackward::c_Forward) {
302 return EForwardBackward::c_Forward;
303 }
304 }
305
306 if (firstInTrackIdOfToHits - 1 < lastInTrackIdOfFromHits + 1) {
307 if (fromFBInfo == EForwardBackward::c_Backward and
308 toFBInfo == EForwardBackward::c_Backward) {
309 return EForwardBackward::c_Backward;
310 }
311 }
312 }
313 // FIXME: Handle intertwined hits that are not cleanly consecutive along the track?
314 return EForwardBackward::c_Invalid;
315 }
EForwardBackward isForwardOrBackwardToMCTrack(const ACDCHitCollection *ptrHits) const
Returns the orientation of the collection of hits relative to its matched track.
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
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...
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 ...
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...
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...
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...
Index getFirstNPassedSuperLayers(const ACDCHitCollection *ptrHits) const
Getter for number of passed superlayer till the first hit the collection of hits which has the Monte ...
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.

◆ 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 Carlo track.

Also checks that the majority of the right left passage information agrees with the forward backward information

Definition at line 318 of file CDCMCHitCollectionLookUp.icc.h.

321 {
322 EForwardBackward result = areAlignedInMCTrack(ptrFromHits, ptrToHits);
323 if (result == EForwardBackward::c_Invalid) return result;
324
325 int fromCorrectRLVote = getCorrectRLVote(ptrFromHits);
326 int toCorrectRLVote = getCorrectRLVote(ptrToHits);
327
328 if (result == EForwardBackward::c_Backward) {
329 fromCorrectRLVote = -fromCorrectRLVote;
330 toCorrectRLVote = -toCorrectRLVote;
331 }
332
333 int fromNCorrectRL = (fromCorrectRLVote + ptrFromHits->size()) / 2;
334 int toNCorrectRL = (toCorrectRLVote + ptrToHits->size()) / 2;
335
336 float fromRLPurity = 1.0 * fromNCorrectRL / ptrFromHits->size();
337 float toRLPurity = 1.0 * toNCorrectRL / ptrToHits->size();
338
339 // Require the minimal rl purity and also at least 2.5 correct hits
340 // (cut chosen to require all correct in single hit triplet segment)
341 if (fromRLPurity > m_minimalRLPurity and toRLPurity > m_minimalRLPurity and
342 fromNCorrectRL > 2.5 and toNCorrectRL > 2.5) {
343 return result;
344 }
345
346 return EForwardBackward::c_Invalid;
347 }
int getCorrectRLVote(const ACDCHitCollection *ptrHits) const
Getter for the difference of correct versus incorrect right left passage information.
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...
float m_minimalRLPurity
Threshold for the correct fraction of right left passage information to be considered a match.

◆ clear()

void clear

Clears all Monte Carlo information left from the last event.

Definition at line 31 of file CDCMCHitCollectionLookUp.icc.h.

32 {
33 B2DEBUG(25, "Clearing CDCMCHitCollectionLookUp<ACDCHitCollection>");
34 }

◆ getCorrectRLVote()

int getCorrectRLVote ( const ACDCHitCollection *  ptrHits) const

Getter for the difference of correct versus incorrect right left passage information.

Definition at line 105 of file CDCMCHitCollectionLookUp.icc.h.

107 {
108 if (not ptrHits) return INVALID_ITRACK;
109 const ACDCHitCollection& hits = *ptrHits;
110 MCTrackIdPurityPair mcTrackIdAndPurity = getHighestPurity(hits);
111 if (mcTrackIdAndPurity.getPurity() >= m_minimalMatchPurity) {
112 return mcTrackIdAndPurity.getCorrectRLVote();
113 } else {
114 return 0;
115 }
116 }
float m_minimalMatchPurity
Threshold for the purity that must be exceeded to be considered as a match.
MCTrackIdPurityPair getHighestPurity(const ACDCHitCollection &hits) const
Get the track id with the highest corresponding purity.

◆ 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 collection of hits.

Definition at line 147 of file CDCMCHitCollectionLookUp.icc.h.

148 {
149 if (not ptrHits) return nullptr;
150 const ACDCHitCollection& hits = *ptrHits;
151
152 ITrackType mcTrackId = getMCTrackId(ptrHits);
153 if (mcTrackId == INVALID_ITRACK) return nullptr;
154
155 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
156
157 for (const CDCHit* hit : hits) {
158 if (mcTrackId == mcHitLookUp.getMCTrackId(hit)) return hit;
159 }
160 return nullptr;
161 }
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.

◆ getFirstInTrackId()

Index getFirstInTrackId ( const ACDCHitCollection *  ptrHits) const
inline

Getter for in track id for the first hit in the collection of hits which has the Monte Carlo track id matched to this collection of hits.

Definition at line 113 of file CDCMCHitCollectionLookUp.h.

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...
Index getInTrackId(const CDCHit *ptrHit) const
Returns the position of the wire hit in the track along the travel direction.

◆ getFirstInTrackSegmentId()

Index getFirstInTrackSegmentId ( const ACDCHitCollection *  ptrHits) const
inline

Getter for in track collection of hits id for the first hit in the collection of hits which has the Monte Carlo track id matched to this collection of hits.

Definition at line 123 of file CDCMCHitCollectionLookUp.h.

Index getInTrackSegmentId(const CDCHit *ptrHit) const
Returns the id of the segment in the track.

◆ getFirstNLoops()

Index getFirstNLoops ( const ACDCHitCollection *  ptrHits) const
inline

Getter for number of loops till the first hit the collection of hits which has the Monte Carlo track id matched to this collection of hits.

Definition at line 141 of file CDCMCHitCollectionLookUp.h.

Index getNLoops(const CDCHit *ptrHit) const
Returns the number of loops the track traversed until this hit.

◆ getFirstNPassedSuperLayers()

Index getFirstNPassedSuperLayers ( const ACDCHitCollection *  ptrHits) const
inline

Getter for number of passed superlayer till the first hit the collection of hits which has the Monte Carlo track id matched to this collection of hits.

Definition at line 133 of file CDCMCHitCollectionLookUp.h.

Index getNPassedSuperLayers(const CDCHit *ptrHit) const
Returns the number of superlayers the track traversed until this hit.

◆ getHighestPurity()

MCTrackIdPurityPair getHighestPurity ( const ACDCHitCollection &  hits) const

Get the track id with the highest corresponding purity.

Definition at line 54 of file CDCMCHitCollectionLookUp.icc.h.

56 {
57 std::map<ITrackType, size_t> hitCountByMCTrackId = getHitCountByMCTrackId(hits);
58
59 size_t nHits = 0;
60 std::pair<ITrackType, size_t> highestHitCountMCTrackId(0, 0);
61 static_cast<void>(std::max_element(hitCountByMCTrackId.begin(), hitCountByMCTrackId.end(), LessOf<Second>()));
62
63 for (const auto& hitCountForMCTrackId : hitCountByMCTrackId) {
64
65 nHits += hitCountForMCTrackId.second;
66
67 if (highestHitCountMCTrackId.second < hitCountForMCTrackId.second) {
68 highestHitCountMCTrackId = hitCountForMCTrackId;
69 }
70 }
71
72 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
73
74 int correctRLVote = 0;
75 for (const auto& recoHit : hits) {
76 const CDCHit* hit = recoHit;
77 ERightLeft mcRLInfo = mcHitLookUp.getRLInfo(hit);
78 ERightLeft rlInfo = recoHit.getRLInfo();
79 if (rlInfo == mcRLInfo) {
80 ++correctRLVote;
81 } else {
82 --correctRLVote;
83 }
84 }
85
86 const float purity = static_cast<float>(highestHitCountMCTrackId.second) / nHits;
87 return MCTrackIdPurityPair(highestHitCountMCTrackId.first, purity, correctRLVote);
88 }
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.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25

◆ getHitCountByMCTrackId()

std::map< ITrackType, size_t > getHitCountByMCTrackId ( const ACDCHitCollection &  hits) const
private

Fill a map with the number of hits for each track id contained in the given hit range.

Definition at line 38 of file CDCMCHitCollectionLookUp.icc.h.

40 {
41 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
42
43 std::map<ITrackType, size_t> hitCountByMCTrackId;
44 for (const CDCHit* ptrHit : hits) {
45 ITrackType mcTrackId = mcHitLookUp.getMCTrackId(ptrHit);
46 // cppcheck-suppress stlFindInsert
47 if (hitCountByMCTrackId.count(mcTrackId) == 0) hitCountByMCTrackId[mcTrackId] = 0;
48 ++(hitCountByMCTrackId[mcTrackId]);
49 }
50 return hitCountByMCTrackId;
51 }

◆ 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 collection of hits.

Definition at line 165 of file CDCMCHitCollectionLookUp.icc.h.

166 {
167
168 if (not ptrHits) return nullptr;
169 const ACDCHitCollection& hits = *ptrHits;
170
171 ITrackType mcTrackId = getMCTrackId(ptrHits);
172 if (mcTrackId == INVALID_ITRACK) return nullptr;
173
174 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
175
176 for (const CDCHit* hit : reversedRange(hits)) {
177 if (mcTrackId == mcHitLookUp.getMCTrackId(hit)) return hit;
178 }
179 return nullptr;
180 }

◆ getLastInTrackId()

Index getLastInTrackId ( const ACDCHitCollection *  ptrHits) const
inline

Getter for in track id for the last hit in the collection of hits which has the Monte Carlo track id matched to this collection of hits.

Definition at line 117 of file CDCMCHitCollectionLookUp.h.

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 ...

◆ getLastInTrackSegmentId()

Index getLastInTrackSegmentId ( const ACDCHitCollection *  ptrHits) const
inline

Getter for in track collection of hits id for the last hit in the collection of hits which has the Monte Carlo track id matched to this collection of hits.

Definition at line 127 of file CDCMCHitCollectionLookUp.h.

◆ getLastNLoops()

Index getLastNLoops ( const ACDCHitCollection *  ptrHits) const
inline

Getter for number of loops till the last hit the collection of hits which has the Monte Carlo track id matched to this collection of hits.

Definition at line 145 of file CDCMCHitCollectionLookUp.h.

146 { return CDCMCHitLookUp::getInstance().getNLoops(getLastHit(ptrHits)); }

◆ getLastNPassedSuperLayers()

Index getLastNPassedSuperLayers ( const ACDCHitCollection *  ptrHits) const
inline

Getter for number of passed superlayer till the last hit the collection of hits which has the Monte Carlo track id matched to this collection of hits.

Definition at line 137 of file CDCMCHitCollectionLookUp.h.

◆ getMCParticle()

const MCParticle * getMCParticle ( const ACDCHitCollection *  ptrHits) const

Getter for the mc particle matched to this collection of hits.

Definition at line 137 of file CDCMCHitCollectionLookUp.icc.h.

139 {
140 const CDCHit* ptrHit = getFirstHit(ptrHits);
141 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
142 return mcHitLookUp.getMCParticle(ptrHit);
143 }

◆ getMCTrackId()

ITrackType getMCTrackId ( const ACDCHitCollection *  ptrHits) const

Getter for the Monte Carlo track id matched to this collection of hits.

On first encounter of a collection of hits this evaluates the purities for the contained track ids. The match is valid if the highest purity exceeds the s_minimalMatchPurity threshold. In case the highest purity is to low to result will be INVALID_ITRACK. To result is stored in member map object for fast look up for repeated calls.

Definition at line 92 of file CDCMCHitCollectionLookUp.icc.h.

93 {
94 if (not ptrHits) return INVALID_ITRACK;
95 const ACDCHitCollection& hits = *ptrHits;
96 MCTrackIdPurityPair mcTrackIdAndPurity = getHighestPurity(hits);
97 if (mcTrackIdAndPurity.getPurity() >= m_minimalMatchPurity) {
98 return mcTrackIdAndPurity.getMCTrackId();
99 } else {
100 return INVALID_ITRACK;
101 }
102 }

◆ getRLPurity()

double getRLPurity ( const ACDCHitCollection *  ptrHits) const

Getter for the right left passge purity which respects the forward backward reconstruction.

Definition at line 120 of file CDCMCHitCollectionLookUp.icc.h.

121 {
123 if (fbInfo == EForwardBackward::c_Invalid) return NAN;
124
125 int correctRLVote = getCorrectRLVote(ptrHits);
126
127 if (fbInfo == EForwardBackward::c_Backward) {
128 correctRLVote = -correctRLVote;
129 }
130
131 int nCorrectRL = (correctRLVote + ptrHits->size()) / 2;
132 float rlPurity = 1.0 * nCorrectRL / ptrHits->size();
133 return rlPurity;
134 }

◆ getTrajectory3D()

CDCTrajectory3D getTrajectory3D ( const ACDCHitCollection *  ptrHits) const

Returns the trajectory of the collection of hits.

Definition at line 350 of file CDCMCHitCollectionLookUp.icc.h.

352 {
353 if (not ptrHits) {
354 B2WARNING("Segment is nullptr. Could not get fit.");
355 return CDCTrajectory3D();
356 }
357
358 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
359
360 const CDCHit* ptrFirstHit = getFirstHit(ptrHits);
361 const CDCSimHit* ptrPrimarySimHit = mcHitLookUp.getClosestPrimarySimHit(ptrFirstHit);
362
363 if (not ptrPrimarySimHit) {
364 // If there is no primary SimHit simply use the secondary simhit as reference
365 ptrPrimarySimHit = mcHitLookUp.getSimHit(ptrFirstHit);
366 if (not ptrPrimarySimHit) {
367 return CDCTrajectory3D();
368 }
369 }
370
371 const CDCSimHit& primarySimHit = *ptrPrimarySimHit;
372
373 Vector3D mom3D{primarySimHit.getMomentum()};
374 Vector3D pos3D{primarySimHit.getPosTrack()};
375 double time{primarySimHit.getFlightTime()};
376
377 int pdgCode = primarySimHit.getPDGCode();
378 const TParticlePDG* ptrTPDGParticle = TDatabasePDG::Instance()->GetParticle(pdgCode);
379
380 if (not ptrTPDGParticle) {
381 B2WARNING("No particle for PDG code " << pdgCode << ". Could not get fit");
382 return CDCTrajectory3D();
383 }
384
385 const TParticlePDG& tPDGParticle = *ptrTPDGParticle;
386
387 double charge = tPDGParticle.Charge() / 3.0;
388
389 ESign chargeSign = sign(charge);
390
391 CDCTrajectory3D trajectory3D(pos3D, time, mom3D, charge);
392
393 ESign settedChargeSign = trajectory3D.getChargeSign();
394
395 if (chargeSign != settedChargeSign) {
396 B2WARNING("Charge sign of mc particle is not the same as the one of the fit");
397 }
398
399 return trajectory3D;
400 }
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:44
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:27

◆ isForwardOrBackwardToMCTrack()

EForwardBackward isForwardOrBackwardToMCTrack ( const ACDCHitCollection *  ptrHits) const

Returns the orientation of the collection of hits relative to its matched track.

  • Returns EForwardBackward::c_Invalid if the collection of hits is not matched to any track.
  • Returns EForwardBackward::c_Forward if the collection of hits is coaligned with the matched track.
  • Returns EForwardBackward::c_Backward if the collection of hits is coaligned with the matched track interpreted in reverse.
  • Returns EForwardBackward::c_Unknown if the matter cannot be decided.

Definition at line 183 of file CDCMCHitCollectionLookUp.icc.h.

185 {
186 Index firstInTrackId = getFirstInTrackId(ptrHits);
187 Index lastInTrackId = getLastInTrackId(ptrHits);
188 if (firstInTrackId == c_InvalidIndex or lastInTrackId == c_InvalidIndex) {
189 return EForwardBackward::c_Invalid;
190 } else if (firstInTrackId < lastInTrackId) {
191 return EForwardBackward::c_Forward;
192 } else if (firstInTrackId > lastInTrackId) {
193 return EForwardBackward::c_Backward;
194 } else if (firstInTrackId == lastInTrackId) {
195 return EForwardBackward::c_Unknown;
196 }
197 return EForwardBackward::c_Invalid;
198 }

Member Data Documentation

◆ m_minimalMatchPurity

float m_minimalMatchPurity = 0.5
private

Threshold for the purity that must be exceeded to be considered as a match.

Definition at line 184 of file CDCMCHitCollectionLookUp.h.

◆ m_minimalRLPurity

float m_minimalRLPurity = 0.5
private

Threshold for the correct fraction of right left passage information to be considered a match.

Definition at line 187 of file CDCMCHitCollectionLookUp.h.


The documentation for this class was generated from the following files: