Belle II Software development
CDCMCSegment3DLookUp Class Reference

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

#include <CDCMCSegment3DLookUp.h>

Inheritance diagram for CDCMCSegment3DLookUp:
CDCMCHitCollectionLookUp< TrackingUtilities::CDCSegment3D >

Public Member Functions

 CDCMCSegment3DLookUp ()=default
 Default constructor, needs to be public for initialization in CDCMCManager.
 
 CDCMCSegment3DLookUp (CDCMCSegment3DLookUp &)=delete
 Singleton: Delete copy constructor and assignment operator.
 
CDCMCSegment3DLookUpoperator= (const CDCMCSegment3DLookUp &)=delete
 Operator =.
 
MCTrackIdPurityPair getHighestPurity (const TrackingUtilities::CDCSegment3D &hits) const
 Get the track id with the highest corresponding purity.
 
ITrackType getMCTrackId (const TrackingUtilities::CDCSegment3D *ptrHits) const
 Getter for the Monte Carlo track id matched to this collection of hits.
 
int getCorrectRLVote (const TrackingUtilities::CDCSegment3D *ptrHits) const
 Getter for the difference of correct versus incorrect right left passage information.
 
double getRLPurity (const TrackingUtilities::CDCSegment3D *ptrHits) const
 Getter for the right left passge purity which respects the forward backward reconstruction.
 
const MCParticlegetMCParticle (const TrackingUtilities::CDCSegment3D *ptrHits) const
 Getter for the mc particle matched to this collection of hits.
 
const CDCHitgetFirstHit (const TrackingUtilities::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *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::CDCSegment3D *ptrHits) const
 Returns the orientation of the collection of hits relative to its matched track.
 
TrackingUtilities::EForwardBackward areAlignedInMCTrack (const TrackingUtilities::CDCSegment3D *ptrFromHits, const TrackingUtilities::CDCSegment3D *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::CDCSegment3D *ptrFromHits, const TrackingUtilities::CDCSegment3D *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::CDCSegment3D *ptrHits) const
 Returns the trajectory of the collection of hits.
 

Static Public Member Functions

static const CDCMCSegment3DLookUpgetInstance ()
 Getter for the singletone instance.
 
static void clear ()
 Clears all Monte Carlo information left from the last event.
 

Static Private Member Functions

static std::map< ITrackType, size_t > getHitCountByMCTrackId (const TrackingUtilities::CDCSegment3D &hits)
 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 CDCMCSegment3DLookUp.h.

Member Function Documentation

◆ areAlignedInMCTrack()

TrackingUtilities::EForwardBackward areAlignedInMCTrack ( const TrackingUtilities::CDCSegment3D * ptrFromHits,
const TrackingUtilities::CDCSegment3D * 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.

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

◆ areAlignedInMCTrackWithRLCheck()

TrackingUtilities::EForwardBackward areAlignedInMCTrackWithRLCheck ( const TrackingUtilities::CDCSegment3D * ptrFromHits,
const TrackingUtilities::CDCSegment3D * 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.

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

◆ clear()

void clear ( )
staticinherited

Clears all Monte Carlo information left from the last event.

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

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

◆ getCorrectRLVote()

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

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

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

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

◆ getFirstHit()

const CDCHit * getFirstHit ( const TrackingUtilities::CDCSegment3D * 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.

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

◆ getFirstInTrackId()

TrackingUtilities::Index getFirstInTrackId ( const TrackingUtilities::CDCSegment3D * 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::CDCSegment3D * 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::CDCSegment3D * 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::CDCSegment3D * 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::CDCSegment3D & hits) const
inherited

Get the track id with the highest corresponding purity.

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

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

◆ getHitCountByMCTrackId()

std::map< ITrackType, size_t > getHitCountByMCTrackId ( const TrackingUtilities::CDCSegment3D & hits)
staticprivateinherited

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.

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

◆ getInstance()

const CDCMCSegment3DLookUp & getInstance ( )
static

Getter for the singletone instance.

Definition at line 22 of file CDCMCSegment3DLookUp.cc.

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

◆ getLastHit()

const CDCHit * getLastHit ( const TrackingUtilities::CDCSegment3D * 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.

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

◆ getLastInTrackId()

TrackingUtilities::Index getLastInTrackId ( const TrackingUtilities::CDCSegment3D * 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::CDCSegment3D * 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::CDCSegment3D * 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::CDCSegment3D * 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::CDCSegment3D * ptrHits) const
inherited

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

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

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

◆ getMCTrackId()

ITrackType getMCTrackId ( const TrackingUtilities::CDCSegment3D * 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.

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

◆ getRLPurity()

double getRLPurity ( const TrackingUtilities::CDCSegment3D * 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.

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

◆ getTrajectory3D()

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

Returns the trajectory of the collection of hits.

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

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

◆ isForwardOrBackwardToMCTrack()

TrackingUtilities::EForwardBackward isForwardOrBackwardToMCTrack ( const TrackingUtilities::CDCSegment3D * 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.

187 {
188 TrackingUtilities::Index firstInTrackId = getFirstInTrackId(ptrHits);
189 TrackingUtilities::Index lastInTrackId = getLastInTrackId(ptrHits);
190 if (firstInTrackId == TrackingUtilities::c_InvalidIndex or lastInTrackId == TrackingUtilities::c_InvalidIndex) {
191 return TrackingUtilities::EForwardBackward::c_Invalid;
192 } else if (firstInTrackId < lastInTrackId) {
193 return TrackingUtilities::EForwardBackward::c_Forward;
194 } else if (firstInTrackId > lastInTrackId) {
195 return TrackingUtilities::EForwardBackward::c_Backward;
196 // cppcheck-suppress knownConditionTrueFalse ; defensive check kept deliberately
197 } else if (firstInTrackId == lastInTrackId) {
198 return TrackingUtilities::EForwardBackward::c_Unknown;
199 }
200 return TrackingUtilities::EForwardBackward::c_Invalid;
201 }

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: