Belle II Software development
TruthTrackVarSet.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/track/TruthTrackVarSet.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
11#include <tracking/trackFindingCDC/mclookup/CDCMCTrackLookUp.h>
12#include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
13
14#include <tracking/trackingUtilities/eventdata/tracks/CDCTrack.h>
15#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
16
17using namespace Belle2;
18using namespace TrackFindingCDC;
19using namespace TrackingUtilities;
20
26
32
34{
35 if (not track) return false;
36
37 // Find the track with the highest number of hits in the segment
38 const CDCMCTrackLookUp& mcTrackLookup = CDCMCTrackLookUp::getInstance();
40
41 ITrackType trackMCMatch = mcTrackLookup.getMCTrackId(track);
42 bool trackIsFake = false;
43
44 if (trackMCMatch == INVALID_ITRACK) {
45 trackIsFake = true;
46 } else {
47
48 unsigned int numberOfCorrectHits = 0;
49 for (const CDCRecoHit3D& recoHit : *track) {
50 if (hitLookup.getMCTrackId(recoHit.getWireHit().getHit()) == trackMCMatch) {
51 numberOfCorrectHits++;
52 }
53 }
54 if ((double)numberOfCorrectHits / track->size() < 0.8) {
55 trackIsFake = 1.0;
56 } else {
57 trackIsFake = 0.0;
58 }
59 }
60
61 var<named("track_is_fake_truth")>() = trackIsFake;
62 var<named("truth")>() = not trackIsFake;
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.
ITrackType getMCTrackId(const CDCHit *ptrHit) const
Returns the track id for the hit.
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
void requireTruthInformation()
Require the MC information store arrays.
void fill()
Fill Monte Carlo look up maps from the DataStore.
static CDCMCManager & getInstance()
Getter for the singleton instance.
Specialisation of the lookup for the truth values of reconstructed tracks.
static const CDCMCTrackLookUp & getInstance()
Getter for the singletone instance.
void initialize() final
Require the Monte Carlo truth information at initialisation.
void beginEvent() final
Prepare the Monte Carlo truth information at start of the event.
bool extract(const TrackingUtilities::CDCTrack *track) override
Generate and assign the contained variables.
Class representing a three dimensional reconstructed hit.
Class representing a sequence of three dimensional reconstructed hits.
Definition CDCTrack.h:39
static constexpr int named(const char *name)
Definition VarSet.h:78
Abstract base class for different kinds of events.