Belle II Software development
TruthSegmentVarSet.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/segment/TruthSegmentVarSet.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
11#include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
12#include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
13
14#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
15#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
16
17#include <tracking/trackFindingCDC/rootification/StoreWrappedObjPtr.h>
18
19using namespace Belle2;
20using namespace TrackFindingCDC;
21
23{
26}
27
29{
32}
33
35{
36 if (not segment) return false;
37
38 // Find the track with the highest number of hits in the segment
41
42 ITrackType segmentMCMatch = mcSegmentLookup.getMCTrackId(segment);
43 bool segmentIsFake = false;
44 bool trackIsAlreadyFound = false;
45
46
47 if (segmentMCMatch == INVALID_ITRACK) {
48 segmentIsFake = true;
49
50 } else {
51 unsigned int numberOfCorrectHits = 0;
52 for (const CDCRecoHit2D& recoHit : *segment) {
53 if (hitLookup.getMCTrackId(recoHit.getWireHit().getHit()) == segmentMCMatch) {
54 numberOfCorrectHits++;
55 }
56 }
57 if (numberOfCorrectHits < 0.8 * segment->size()) {
58 segmentIsFake = true;
59 } else {
60 segmentIsFake = false;
61 }
62
63 }
64
65 if (not segmentIsFake) {
66 // It is a bit suspicuous that this low level objects accesses the DataStore.
67 // Maybe this code is the answer to the wrong question.?
68 StoreWrappedObjPtr<std::vector<CDCWireHit> > storedWireHits("CDCWireHitVector");
69 const std::vector<CDCWireHit>& wireHits = *storedWireHits;
70 unsigned int numberOfTakenHitsInThisTrack = 0;
71 unsigned int numberOfHitsInThisTrack = 0;
72
73 for (const CDCWireHit& wireHit : wireHits) {
74 if (hitLookup.getMCTrackId(wireHit.getHit()) == segmentMCMatch) {
75 numberOfHitsInThisTrack++;
76 if (wireHit.getAutomatonCell().hasTakenFlag()) {
77 numberOfTakenHitsInThisTrack++;
78 }
79 }
80 }
81
82 if (numberOfTakenHitsInThisTrack > 0.5 * numberOfHitsInThisTrack) {
83 trackIsAlreadyFound = true;
84 }
85 }
86
87 var<named("segment_is_fake_truth")>() = segmentIsFake;
88 var<named("track_is_already_found_truth")>() = trackIsAlreadyFound;
89 var<named("segment_is_new_track_truth")>() = not segmentIsFake and not trackIsAlreadyFound;
90 var<named("truth")>() = false; // override in derived classes
91 return true;
92}
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 two dimensional segments.
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
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.
This class is for convenience access and registration of objects, that are stored inside the StoreWra...
void initialize() final
Require the Monte Carlo truth information at initialisation.
bool extract(const CDCSegment2D *segment) override
Generate and assign the contained variables.
void beginEvent() final
Prepare the Monte Carlo truth information at start of the 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.