Belle II Software development
SegmentTrackTruthVarSet.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/filters/segmentTrack/SegmentTrackTruthVarSet.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
11#include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
12
13#include <tracking/trackingUtilities/eventdata/tracks/CDCTrack.h>
14#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
15#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
16
17#include <tracking/trackingUtilities/filters/base/Filter.icc.h>
18
19using namespace Belle2;
20using namespace TrackFindingCDC;
21using namespace TrackingUtilities;
22
24{
25 if (not testPair) return false;
26
27 const CDCTrack* track = testPair->getFrom();
28 const CDCSegment2D* segment = testPair->getTo();
29
30 var<named("belongs_to_same_track_truth")>() = 0.0;
31
32 const CDCMCHitLookUp& mcHitLookup = CDCMCHitLookUp::getInstance();
33
34 // Find the track with the highest number of hits in the segment
36 ITrackType segmentMCMatch = mcSegmentLookup.getMCTrackId(segment);
37 if (segmentMCMatch == INVALID_ITRACK) {
38 var<named("segment_is_fake_truth")>() = 1.0;
39 var<named("segment_purity_truth")>() = 0.0;
40 var<named("track_purity_truth")>() = 0.0;
41
42 } else {
43 var<named("segment_is_fake_truth")>() = 0.0;
44
45 double numberOfCorrectHits = 0;
46 for (const CDCRecoHit3D& recoHit : *track) {
47 if (mcHitLookup.getMCTrackId(recoHit.getWireHit().getHit()) == segmentMCMatch) {
48 numberOfCorrectHits++;
49 }
50 }
51
52 var<named("track_purity_truth")>() = numberOfCorrectHits / track->size();
53
54 if (numberOfCorrectHits / track->size() > 0.5) {
55 var<named("belongs_to_same_track_truth")>() = 1.0;
56 } else {
57 var<named("belongs_to_same_track_truth")>() = 0.0;
58 }
59 }
60
61
62 var<named("truth")>() = var<named("belongs_to_same_track_truth")>();
63
64 return true;
65}
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
Interface class to the Monte Carlo information for individual hits.
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
Specialisation of the lookup for the truth values of two dimensional segments.
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
bool extract(const BaseSegmentTrackFilter::Object *testPair) final
Generate and assign the contained variables.
Class representing a three dimensional reconstructed hit.
A reconstructed sequence of two dimensional hits in one super layer.
Class representing a sequence of three dimensional reconstructed hits.
Definition CDCTrack.h:39
TrackingUtilities::WeightedRelation< TrackingUtilities::CDCTrack, const TrackingUtilities::CDCSegment2D > Object
Definition Filter.dcl.h:35
static constexpr int named(const char *name)
Definition VarSet.h:78
From * getFrom() const
Getter for the pointer to the from side object.
To * getTo() const
Getter for the pointer to the to side object.
Abstract base class for different kinds of events.