Belle II Software development
BestMatchedTruthVarSet.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/BestMatchedTruthVarSet.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
11#include <tracking/trackFindingCDC/mclookup/CDCMCTrackLookUp.h>
12#include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
13#include <tracking/trackFindingCDC/mclookup/CDCMCCloneLookUp.h>
14
15#include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
16#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
17
18using namespace Belle2;
19using namespace TrackFindingCDC;
20
22{
25}
26
28{
31}
32
34{
35 if (not ptrCDCTrack) return false;
36
38 const CDCMCTrackLookUp& mcTrackLookUp = CDCMCTrackLookUp::getInstance();
41
42 ITrackType trackMCMatch = mcTrackLookUp.getMCTrackId(ptrCDCTrack);
43 bool trackIsFake = false;
44
45 unsigned int numberOfCorrectHits = 0;
46
48 bool trackHasMinimalMatchPurity = (trackMCMatch != INVALID_ITRACK);
49
50 if (not trackHasMinimalMatchPurity) {
51 trackIsFake = true;
52 } else {
54 auto hitIsCorrect = [&hitLookUp, &trackMCMatch](const CDCRecoHit3D & recoHit) {
55 return hitLookUp.getMCTrackId(recoHit.getWireHit().getHit()) == trackMCMatch;
56 };
57 numberOfCorrectHits = std::count_if(begin(*ptrCDCTrack), end(*ptrCDCTrack), hitIsCorrect);
58
59 const double purity = (double)numberOfCorrectHits / ptrCDCTrack->size();
60 if (purity < 0.8) {
61 trackIsFake = true;
62 } else {
63 trackIsFake = false;
64 }
65 }
66
67 bool trackIsClone = cloneLookUp.isTrackClone(*ptrCDCTrack);
68 bool matchedNotClone = (not trackIsClone) and (not trackIsFake);
69 var<named("truth")>() = matchedNotClone;
70 var<named("truth_track_is_fake")>() = trackIsFake;
71 var<named("truth_track_is_matched")>() = not trackIsFake;
72 var<named("truth_matched_hits")>() = numberOfCorrectHits;
73 var<named("truth_track_is_clone")>() = trackIsClone;
74 var<named("truth_first_nloops")>() = mcTrackLookUp.getFirstNLoops(ptrCDCTrack);
75 var<named("truth_event_id")>() = m_eventMetaData->getEvent();
76 var<named("truth_MCTrackID")>() = trackMCMatch;
77 return true;
78}
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.
StoreObjPtr< EventMetaData > m_eventMetaData
Pointer to the store array object with the EventMetaData.
bool extract(const CDCTrack *ptrCDCTrack) override
Generate and assign the contained variables.
Class providing information whether a PR CDC track is the best match or a clone.
bool isTrackClone(const CDCTrack &cdcTrack)
getter for information from m_cdcTrackIsCloneMap
static CDCMCCloneLookUp & getInstance()
Getter for the singletone instance.
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
Index getFirstNLoops(const ACDCHitCollection *ptrHits) const
Getter for number of loops till the first hit the collection of hits which has the Monte Carlo track ...
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.
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.