Belle II Software  release-05-01-25
TruthTrackVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/filters/track/TruthTrackVarSet.h>
11 
12 #include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
13 #include <tracking/trackFindingCDC/mclookup/CDCMCTrackLookUp.h>
14 #include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
15 
16 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
17 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
23 {
26 }
27 
29 {
32 }
33 
35 {
36  if (not track) return false;
37 
38  // Find the track with the highest number of hits in the segment
39  const CDCMCTrackLookUp& mcTrackLookup = CDCMCTrackLookUp::getInstance();
40  const CDCMCHitLookUp& hitLookup = CDCMCHitLookUp::getInstance();
41 
42  ITrackType trackMCMatch = mcTrackLookup.getMCTrackId(track);
43  bool trackIsFake = false;
44 
45  if (trackMCMatch == INVALID_ITRACK) {
46  trackIsFake = true;
47  } else {
48 
49  unsigned int numberOfCorrectHits = 0;
50  for (const CDCRecoHit3D& recoHit : *track) {
51  if (hitLookup.getMCTrackId(recoHit.getWireHit().getHit()) == trackMCMatch) {
52  numberOfCorrectHits++;
53  }
54  }
55  if ((double)numberOfCorrectHits / track->size() < 0.8) {
56  trackIsFake = 1.0;
57  } else {
58  trackIsFake = 0.0;
59  }
60  }
61 
62  var<named("track_is_fake_truth")>() = trackIsFake;
63  var<named("truth")>() = not trackIsFake;
64  return true;
65 }
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::TruthTrackVarSet::initialize
void initialize() final
Require the Monte Carlo truth information at initialisation.
Definition: TruthTrackVarSet.cc:22
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::CompositeProcessingSignalListener::initialize
void initialize() override
Receive and dispatch signal before the start of the event processing.
Definition: CompositeProcessingSignalListener.cc:17
Belle2::TrackFindingCDC::CDCMCManager::requireTruthInformation
void requireTruthInformation()
Require the mc information store arrays.
Definition: CDCMCManager.cc:117
Belle2::TrackFindingCDC::CDCMCManager::fill
void fill()
Fill Monte Carlo look up maps from the DataStore.
Definition: CDCMCManager.cc:137
Belle2::TrackFindingCDC::CDCMCHitLookUp::getMCTrackId
ITrackType getMCTrackId(const CDCHit *ptrHit) const
Returns the track id for the hit.
Definition: CDCMCHitLookUp.cc:122
Belle2::TrackFindingCDC::CDCMCTrackLookUp::getInstance
static const CDCMCTrackLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCTrackLookUp.cc:23
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::CDCMCManager::getInstance
static CDCMCManager & getInstance()
Getter for the singletone instance.
Definition: CDCMCManager.cc:76
Belle2::TrackFindingCDC::TruthTrackVarSet::extract
bool extract(const CDCTrack *track) override
Generate and assign the contained variables.
Definition: TruthTrackVarSet.cc:34
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::beginEvent
void beginEvent() override
Receive and dispatch signal for the start of a new event.
Definition: CompositeProcessingSignalListener.cc:33
Belle2::TrackFindingCDC::CDCMCHitLookUp::getInstance
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCHitLookUp.cc:32
Belle2::TrackFindingCDC::TruthTrackVarSet::beginEvent
void beginEvent() final
Prepare the Monte Carlo truth information at start of the event.
Definition: TruthTrackVarSet.cc:28
Belle2::TrackFindingCDC::VarSet< TruthTrackVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::VarSet< TruthTrackVarNames >::var
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:103
Belle2::TrackFindingCDC::CDCMCTrackLookUp
Specialisation of the lookup for the truth values of reconstructed tracks.
Definition: CDCMCTrackLookUp.h:33