Belle II Software  release-05-01-25
SegmentTrackTruthVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/filters/segmentTrack/SegmentTrackTruthVarSet.h>
11 
12 #include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
13 #include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
14 
15 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
16 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
17 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
18 
19 #include <tracking/trackFindingCDC/filters/base/Filter.h>
20 
21 using namespace Belle2;
22 using namespace TrackFindingCDC;
23 
25 {
26  if (not testPair) return false;
27 
28  const CDCTrack* track = testPair->getFrom();
29  const CDCSegment2D* segment = testPair->getTo();
30 
31  var<named("belongs_to_same_track_truth")>() = 0.0;
32 
33  const CDCMCHitLookUp& mcHitLookup = CDCMCHitLookUp::getInstance();
34 
35  // Find the track with the highest number of hits in the segment
37  ITrackType segmentMCMatch = mcSegmentLookup.getMCTrackId(segment);
38  if (segmentMCMatch == INVALID_ITRACK) {
39  var<named("segment_is_fake_truth")>() = 1.0;
40  var<named("segment_purity_truth")>() = 0.0;
41  var<named("track_purity_truth")>() = 0.0;
42 
43  } else {
44  var<named("segment_is_fake_truth")>() = 0.0;
45 
46  double numberOfCorrectHits = 0;
47  for (const CDCRecoHit3D& recoHit : *track) {
48  if (mcHitLookup.getMCTrackId(recoHit.getWireHit().getHit()) == segmentMCMatch) {
49  numberOfCorrectHits++;
50  }
51  }
52 
53  var<named("track_purity_truth")>() = numberOfCorrectHits / track->size();
54 
55  if (numberOfCorrectHits / track->size() > 0.5) {
56  var<named("belongs_to_same_track_truth")>() = 1.0;
57  } else {
58  var<named("belongs_to_same_track_truth")>() = 0.0;
59  }
60  }
61 
62 
63  var<named("truth")>() = var<named("belongs_to_same_track_truth")>();
64 
65  return true;
66 }
Belle2::TrackFindingCDC::CDCRecoHit3D
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:62
Belle2::TrackFindingCDC::CDCTrack
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:51
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp
Specialisation of the lookup for the truth values of two dimensional segments.
Definition: CDCMCSegment2DLookUp.h:33
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getMCTrackId
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
Definition: CDCMCHitCollectionLookUp.icc.h:101
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp::getInstance
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCSegment2DLookUp.cc:23
Belle2::TrackFindingCDC::SegmentTrackTruthVarSet::extract
bool extract(const BaseSegmentTrackFilter::Object *testPair) final
Generate and assign the contained variables.
Definition: SegmentTrackTruthVarSet.cc:24
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCMCHitLookUp
Interface class to the Monte Carlo information for individual hits.
Definition: CDCMCHitLookUp.h:41
Belle2::TrackFindingCDC::CDCMCHitLookUp::getInstance
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCHitLookUp.cc:32
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::VarSet< SegmentTrackTruthVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::VarSet< SegmentTrackTruthVarNames >::var
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:103
Belle2::TrackFindingCDC::Filter::Object
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:43