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/trackFindingCDC/eventdata/tracks/CDCTrack.h>
14#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
15#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
16
17#include <tracking/trackFindingCDC/filters/base/Filter.h>
18
19using namespace Belle2;
20using namespace TrackFindingCDC;
21
23{
24 if (not testPair) return false;
25
26 const CDCTrack* track = testPair->getFrom();
27 const CDCSegment2D* segment = testPair->getTo();
28
29 var<named("belongs_to_same_track_truth")>() = 0.0;
30
31 const CDCMCHitLookUp& mcHitLookup = CDCMCHitLookUp::getInstance();
32
33 // Find the track with the highest number of hits in the segment
35 ITrackType segmentMCMatch = mcSegmentLookup.getMCTrackId(segment);
36 if (segmentMCMatch == INVALID_ITRACK) {
37 var<named("segment_is_fake_truth")>() = 1.0;
38 var<named("segment_purity_truth")>() = 0.0;
39 var<named("track_purity_truth")>() = 0.0;
40
41 } else {
42 var<named("segment_is_fake_truth")>() = 0.0;
43
44 double numberOfCorrectHits = 0;
45 for (const CDCRecoHit3D& recoHit : *track) {
46 if (mcHitLookup.getMCTrackId(recoHit.getWireHit().getHit()) == segmentMCMatch) {
47 numberOfCorrectHits++;
48 }
49 }
50
51 var<named("track_purity_truth")>() = numberOfCorrectHits / track->size();
52
53 if (numberOfCorrectHits / track->size() > 0.5) {
54 var<named("belongs_to_same_track_truth")>() = 1.0;
55 } else {
56 var<named("belongs_to_same_track_truth")>() = 0.0;
57 }
58 }
59
60
61 var<named("truth")>() = var<named("belongs_to_same_track_truth")>();
62
63 return true;
64}
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.
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:52
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:35
bool extract(const BaseSegmentTrackFilter::Object *testPair) final
Generate and assign the contained variables.
static constexpr int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:78
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:93
Abstract base class for different kinds of events.