Belle II Software  release-05-01-25
TruthSegmentVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/filters/segment/TruthSegmentVarSet.h>
11 
12 #include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
13 #include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
14 #include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
15 
16 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
17 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
18 
19 #include <tracking/trackFindingCDC/rootification/StoreWrappedObjPtr.h>
20 
21 using namespace Belle2;
22 using namespace TrackFindingCDC;
23 
25 {
28 }
29 
31 {
34 }
35 
37 {
38  if (not segment) return false;
39 
40  // Find the track with the highest number of hits in the segment
42  const CDCMCHitLookUp& hitLookup = CDCMCHitLookUp::getInstance();
43 
44  ITrackType segmentMCMatch = mcSegmentLookup.getMCTrackId(segment);
45  bool segmentIsFake = false;
46  bool trackIsAlreadyFound = false;
47 
48 
49  if (segmentMCMatch == INVALID_ITRACK) {
50  segmentIsFake = true;
51 
52  } else {
53  unsigned int numberOfCorrectHits = 0;
54  for (const CDCRecoHit2D& recoHit : *segment) {
55  if (hitLookup.getMCTrackId(recoHit.getWireHit().getHit()) == segmentMCMatch) {
56  numberOfCorrectHits++;
57  }
58  }
59  if (numberOfCorrectHits < 0.8 * segment->size()) {
60  segmentIsFake = true;
61  } else {
62  segmentIsFake = false;
63  }
64 
65  }
66 
67  if (not segmentIsFake) {
68  // It is a bit suspicuous that this low level objects accesses the DataStore.
69  // Maybe this code is the answer to the wrong question.?
70  StoreWrappedObjPtr<std::vector<CDCWireHit> > storedWireHits("CDCWireHitVector");
71  const std::vector<CDCWireHit>& wireHits = *storedWireHits;
72  unsigned int numberOfTakenHitsInThisTrack = 0;
73  unsigned int numberOfHitsInThisTrack = 0;
74 
75  for (const CDCWireHit& wireHit : wireHits) {
76  if (hitLookup.getMCTrackId(wireHit.getHit()) == segmentMCMatch) {
77  numberOfHitsInThisTrack++;
78  if (wireHit.getAutomatonCell().hasTakenFlag()) {
79  numberOfTakenHitsInThisTrack++;
80  }
81  }
82  }
83 
84  if (numberOfTakenHitsInThisTrack > 0.5 * numberOfHitsInThisTrack) {
85  trackIsAlreadyFound = true;
86  }
87  }
88 
89  var<named("segment_is_fake_truth")>() = segmentIsFake;
90  var<named("track_is_already_found_truth")>() = trackIsAlreadyFound;
91  var<named("segment_is_new_track_truth")>() = not segmentIsFake and not trackIsAlreadyFound;
92  var<named("truth")>() = false; // override in derived classes
93  return true;
94 }
Belle2::TrackFindingCDC::TruthSegmentVarSet::extract
bool extract(const CDCSegment2D *segment) override
Generate and assign the contained variables.
Definition: TruthSegmentVarSet.cc:36
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp
Specialisation of the lookup for the truth values of two dimensional segments.
Definition: CDCMCSegment2DLookUp.h:33
Belle2::TrackFindingCDC::TruthSegmentVarSet::initialize
void initialize() final
Require the Monte Carlo truth information at initialisation.
Definition: TruthSegmentVarSet.cc:24
Belle2::TrackFindingCDC::StoreWrappedObjPtr
This class is for convenience access and registration of objects, that are stored inside the StoreWra...
Definition: StoreWrappedObjPtr.h:40
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::CDCMCSegment2DLookUp::getInstance
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCSegment2DLookUp.cc:23
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::CDCRecoHit2D
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:57
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::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::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::VarSet< TruthSegmentVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::VarSet< TruthSegmentVarNames >::var
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:103
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::TrackFindingCDC::TruthSegmentVarSet::beginEvent
void beginEvent() final
Prepare the Monte Carlo truth information at start of the event.
Definition: TruthSegmentVarSet.cc:30