Belle II Software development
CDCMCSegment2DLookUp Class Reference

Specialisation of the lookup for the truth values of two dimensional segments. More...

#include <CDCMCSegment2DLookUp.h>

Inheritance diagram for CDCMCSegment2DLookUp:
CDCMCHitCollectionLookUp< TrackingUtilities::CDCSegment2D >

Public Member Functions

 CDCMCSegment2DLookUp ()=default
 Default constructor, needs to be public for initialization in CDCMCManager.
 
 CDCMCSegment2DLookUp (CDCMCSegment2DLookUp &)=delete
 Singleton: Delete copy constructor and assignment operator,.
 
CDCMCSegment2DLookUpoperator= (const CDCMCSegment2DLookUp &)=delete
 Operator =.
 
void clear ()
 Clears all Monte Carlo information left from the last event.
 
MCTrackIdPurityPair getHighestPurity (const TrackingUtilities::CDCSegment2D &hits) const
 Get the track id with the highest corresponding purity.
 
ITrackType getMCTrackId (const TrackingUtilities::CDCSegment2D *ptrHits) const
 Getter for the Monte Carlo track id matched to this collection of hits.
 
int getCorrectRLVote (const TrackingUtilities::CDCSegment2D *ptrHits) const
 Getter for the difference of correct versus incorrect right left passage information.
 
double getRLPurity (const TrackingUtilities::CDCSegment2D *ptrHits) const
 Getter for the right left passge purity which respects the forward backward reconstruction.
 
const MCParticlegetMCParticle (const TrackingUtilities::CDCSegment2D *ptrHits) const
 Getter for the mc particle matched to this collection of hits.
 
const CDCHitgetFirstHit (const TrackingUtilities::CDCSegment2D *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 TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::Index getFirstInTrackId (const TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::Index getLastInTrackId (const TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::Index getFirstInTrackSegmentId (const TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::Index getLastInTrackSegmentId (const TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::Index getFirstNPassedSuperLayers (const TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::Index getLastNPassedSuperLayers (const TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::Index getFirstNLoops (const TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::Index getLastNLoops (const TrackingUtilities::CDCSegment2D *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.
 
TrackingUtilities::EForwardBackward isForwardOrBackwardToMCTrack (const TrackingUtilities::CDCSegment2D *ptrHits) const
 Returns the orientation of the collection of hits relative to its matched track.
 
TrackingUtilities::EForwardBackward areAlignedInMCTrack (const TrackingUtilities::CDCSegment2D *ptrFromHits, const TrackingUtilities::CDCSegment2D *ptrToHits) const
 Returns if the second collection of hits follows the first collection of hits in their common Monte Carlo track.
 
TrackingUtilities::EForwardBackward areAlignedInMCTrackWithRLCheck (const TrackingUtilities::CDCSegment2D *ptrFromHits, const TrackingUtilities::CDCSegment2D *ptrToHits) const
 Returns if the second collection of hits follows the first collection of hits in their common Monte Carlo track.
 
TrackingUtilities::CDCTrajectory3D getTrajectory3D (const TrackingUtilities::CDCSegment2D *ptrHits) const
 Returns the trajectory of the collection of hits.
 

Static Public Member Functions

static const CDCMCSegment2DLookUpgetInstance ()
 Getter for the singletone instance.
 

Private Member Functions

std::map< ITrackType, size_t > getHitCountByMCTrackId (const TrackingUtilities::CDCSegment2D &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
 Threshold for the purity that must be exceeded to be considered as a match.
 
float m_minimalRLPurity
 Threshold for the correct fraction of right left passage information to be considered a match.
 

Detailed Description

Specialisation of the lookup for the truth values of two dimensional segments.

Definition at line 25 of file CDCMCSegment2DLookUp.h.

Member Function Documentation

◆ areAlignedInMCTrack()

TrackingUtilities::EForwardBackward areAlignedInMCTrack ( const TrackingUtilities::CDCSegment2D * ptrFromHits,
const TrackingUtilities::CDCSegment2D * ptrToHits ) const
inherited

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 171 of file CDCMCHitCollectionLookUp.icc.h.

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

◆ areAlignedInMCTrackWithRLCheck()

TrackingUtilities::EForwardBackward areAlignedInMCTrackWithRLCheck ( const TrackingUtilities::CDCSegment2D * ptrFromHits,
const TrackingUtilities::CDCSegment2D * ptrToHits ) const
inherited

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 179 of file CDCMCHitCollectionLookUp.icc.h.

322 {
323 TrackingUtilities::EForwardBackward result = areAlignedInMCTrack(ptrFromHits, ptrToHits);
324 if (result == TrackingUtilities::EForwardBackward::c_Invalid) return result;
325
326 int fromCorrectRLVote = getCorrectRLVote(ptrFromHits);
327 int toCorrectRLVote = getCorrectRLVote(ptrToHits);
328
329 if (result == TrackingUtilities::EForwardBackward::c_Backward) {
330 fromCorrectRLVote = -fromCorrectRLVote;
331 toCorrectRLVote = -toCorrectRLVote;
332 }
333
334 int fromNCorrectRL = (fromCorrectRLVote + ptrFromHits->size()) / 2;
335 int toNCorrectRL = (toCorrectRLVote + ptrToHits->size()) / 2;
336
337 float fromRLPurity = 1.0 * fromNCorrectRL / ptrFromHits->size();
338 float toRLPurity = 1.0 * toNCorrectRL / ptrToHits->size();
339
340 // Require the minimal rl purity and also at least 2.5 correct hits
341 // (cut chosen to require all correct in single hit triplet segment)
342 if (fromRLPurity > m_minimalRLPurity and toRLPurity > m_minimalRLPurity and
343 fromNCorrectRL > 2.5 and toNCorrectRL > 2.5) {
344 return result;
345 }
346
347 return TrackingUtilities::EForwardBackward::c_Invalid;
348 }

◆ clear()

void clear ( )
inherited

Clears all Monte Carlo information left from the last event.

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

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

◆ getCorrectRLVote()

int getCorrectRLVote ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inherited

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

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

108 {
109 if (not ptrHits) return INVALID_ITRACK;
110 const ACDCHitCollection& hits = *ptrHits;
111 MCTrackIdPurityPair mcTrackIdAndPurity = getHighestPurity(hits);
112 if (mcTrackIdAndPurity.getPurity() >= m_minimalMatchPurity) {
113 return mcTrackIdAndPurity.getCorrectRLVote();
114 } else {
115 return 0;
116 }
117 }

◆ getFirstHit()

const CDCHit * getFirstHit ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inherited

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 108 of file CDCMCHitCollectionLookUp.icc.h.

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

◆ getFirstInTrackId()

TrackingUtilities::Index getFirstInTrackId ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inlineinherited

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 116 of file CDCMCHitCollectionLookUp.h.

117 { return CDCMCHitLookUp::getInstance().getInTrackId(getFirstHit(ptrHits)); }

◆ getFirstInTrackSegmentId()

TrackingUtilities::Index getFirstInTrackSegmentId ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inlineinherited

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 126 of file CDCMCHitCollectionLookUp.h.

127 { return CDCMCHitLookUp::getInstance().getInTrackSegmentId(getFirstHit(ptrHits)); }

◆ getFirstNLoops()

TrackingUtilities::Index getFirstNLoops ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inlineinherited

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 144 of file CDCMCHitCollectionLookUp.h.

145 { return CDCMCHitLookUp::getInstance().getNLoops(getFirstHit(ptrHits)); }

◆ getFirstNPassedSuperLayers()

TrackingUtilities::Index getFirstNPassedSuperLayers ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inlineinherited

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 136 of file CDCMCHitCollectionLookUp.h.

137 { return CDCMCHitLookUp::getInstance().getNPassedSuperLayers(getFirstHit(ptrHits)); }

◆ getHighestPurity()

MCTrackIdPurityPair getHighestPurity ( const TrackingUtilities::CDCSegment2D & hits) const
inherited

Get the track id with the highest corresponding purity.

Definition at line 88 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(),
62 TrackingUtilities::LessOf<TrackingUtilities::Second>()));
63
64 for (const auto& hitCountForMCTrackId : hitCountByMCTrackId) {
65
66 nHits += hitCountForMCTrackId.second;
67
68 if (highestHitCountMCTrackId.second < hitCountForMCTrackId.second) {
69 highestHitCountMCTrackId = hitCountForMCTrackId;
70 }
71 }
72
73 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
74
75 int correctRLVote = 0;
76 for (const auto& recoHit : hits) {
77 const CDCHit* hit = recoHit;
78 TrackingUtilities::ERightLeft mcRLInfo = mcHitLookUp.getRLInfo(hit);
79 TrackingUtilities::ERightLeft rlInfo = recoHit.getRLInfo();
80 if (rlInfo == mcRLInfo) {
81 ++correctRLVote;
82 } else {
83 --correctRLVote;
84 }
85 }
86
87 const float purity = static_cast<float>(highestHitCountMCTrackId.second) / nHits;
88 return MCTrackIdPurityPair(highestHitCountMCTrackId.first, purity, correctRLVote);
89 }

◆ getHitCountByMCTrackId()

std::map< ITrackType, size_t > getHitCountByMCTrackId ( const TrackingUtilities::CDCSegment2D & hits) const
privateinherited

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

Definition at line 84 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 }

◆ getInstance()

const CDCMCSegment2DLookUp & getInstance ( )
static

Getter for the singletone instance.

Definition at line 22 of file CDCMCSegment2DLookUp.cc.

23{
25}
static const CDCMCSegment2DLookUp & getMCSegment2DLookUp()
Getter for the singleton instance of the CDCMCSegment2DLookUp.

◆ getLastHit()

const CDCHit * getLastHit ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inherited

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 111 of file CDCMCHitCollectionLookUp.icc.h.

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

◆ getLastInTrackId()

TrackingUtilities::Index getLastInTrackId ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inlineinherited

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 120 of file CDCMCHitCollectionLookUp.h.

121 { return CDCMCHitLookUp::getInstance().getInTrackId(getLastHit(ptrHits)); }

◆ getLastInTrackSegmentId()

TrackingUtilities::Index getLastInTrackSegmentId ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inlineinherited

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 130 of file CDCMCHitCollectionLookUp.h.

131 { return CDCMCHitLookUp::getInstance().getInTrackSegmentId(getLastHit(ptrHits)); }

◆ getLastNLoops()

TrackingUtilities::Index getLastNLoops ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inlineinherited

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 148 of file CDCMCHitCollectionLookUp.h.

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

◆ getLastNPassedSuperLayers()

TrackingUtilities::Index getLastNPassedSuperLayers ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inlineinherited

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 140 of file CDCMCHitCollectionLookUp.h.

141 { return CDCMCHitLookUp::getInstance().getNPassedSuperLayers(getLastHit(ptrHits)); }

◆ getMCParticle()

const MCParticle * getMCParticle ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inherited

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

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

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

◆ getMCTrackId()

ITrackType getMCTrackId ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inherited

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 95 of file CDCMCHitCollectionLookUp.icc.h.

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

◆ getRLPurity()

double getRLPurity ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inherited

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

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

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

◆ getTrajectory3D()

TrackingUtilities::CDCTrajectory3D getTrajectory3D ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inherited

Returns the trajectory of the collection of hits.

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

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

◆ isForwardOrBackwardToMCTrack()

TrackingUtilities::EForwardBackward isForwardOrBackwardToMCTrack ( const TrackingUtilities::CDCSegment2D * ptrHits) const
inherited

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 158 of file CDCMCHitCollectionLookUp.icc.h.

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

Member Data Documentation

◆ m_minimalMatchPurity

float m_minimalMatchPurity
privateinherited

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

Definition at line 187 of file CDCMCHitCollectionLookUp.h.

◆ m_minimalRLPurity

float m_minimalRLPurity
privateinherited

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

Definition at line 190 of file CDCMCHitCollectionLookUp.h.


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