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/trackFindingCDC/eventdata/tracks/CDCTrack.h>
15#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
16
17using namespace Belle2;
18using namespace TrackFindingCDC;
19
21{
24}
25
27{
30}
31
33{
34 if (not track) return false;
35
36 // Find the track with the highest number of hits in the segment
37 const CDCMCTrackLookUp& mcTrackLookup = CDCMCTrackLookUp::getInstance();
39
40 ITrackType trackMCMatch = mcTrackLookup.getMCTrackId(track);
41 bool trackIsFake = false;
42
43 if (trackMCMatch == INVALID_ITRACK) {
44 trackIsFake = true;
45 } else {
46
47 unsigned int numberOfCorrectHits = 0;
48 for (const CDCRecoHit3D& recoHit : *track) {
49 if (hitLookup.getMCTrackId(recoHit.getWireHit().getHit()) == trackMCMatch) {
50 numberOfCorrectHits++;
51 }
52 }
53 if ((double)numberOfCorrectHits / track->size() < 0.8) {
54 trackIsFake = 1.0;
55 } else {
56 trackIsFake = 0.0;
57 }
58 }
59
60 var<named("track_is_fake_truth")>() = trackIsFake;
61 var<named("truth")>() = not trackIsFake;
62 return true;
63}
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 singletone instance.
Definition: CDCMCManager.cc:74
Specialisation of the lookup for the truth values of reconstructed tracks.
static const CDCMCTrackLookUp & getInstance()
Getter for the singletone instance.
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:52
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
void initialize() override
Receive and dispatch signal before the start of the event processing.
void beginEvent() override
Receive and dispatch signal for the start of a new event.
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 CDCTrack *track) override
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.