Belle II Software  release-05-01-25
PXDResultTruthVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - 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/ckf/pxd/filters/results/PXDResultTruthVarSet.h>
11 
12 #include <tracking/mcMatcher/TrackMatchLookUp.h>
13 #include <tracking/dataobjects/RecoTrack.h>
14 
15 using namespace std;
16 using namespace Belle2;
17 using namespace TrackFindingCDC;
18 
19 bool PXDResultTruthVarSet::extract(const CKFToPXDResult* result)
20 {
21  const RecoTrack* seedTrack = result->getSeed();
22  if (not seedTrack) return false;
23 
24  var<named("truth_event_number")>() = m_eventMetaData->getEvent();
25  var<named("truth_seed_number")>() = seedTrack->getArrayIndex();
26 
27  const std::string& seedTrackStoreArrayName = seedTrack->getArrayName();
28 
29  TrackMatchLookUp mcCDCMatchLookUp("MCRecoTracks", seedTrackStoreArrayName);
30  const RecoTrack* mcTrack = mcCDCMatchLookUp.getRelatedMCRecoTrack(*seedTrack);
31 
32  // Default to false
33  var<named("truth_number_of_correct_hits")>() = 0;
34  var<named("truth")>() = 0;
35  var<named("truth_number_of_mc_pxd_hits")>() = 0;
36  var<named("truth_number_of_mc_svd_hits")>() = 0;
37  var<named("truth_number_of_mc_cdc_hits")>() = 0;
38 
39  if (not mcTrack) {
40  // track is a fake.
41  return true;
42  }
43 
44  // Count the number of times the related MC-track is also related to the clusters.
45  const unsigned int numberOfCorrectHits = m_mcUtil.getNumberOfCorrectPXDHits(mcTrack, result->getHits());
46 
47  var<named("truth_number_of_correct_hits")>() = numberOfCorrectHits;
48  var<named("truth_number_of_mc_pxd_hits")>() = mcTrack->getNumberOfPXDHits();
49  var<named("truth_number_of_mc_svd_hits")>() = mcTrack->getNumberOfSVDHits();
50  var<named("truth_number_of_mc_cdc_hits")>() = mcTrack->getNumberOfCDCHits();
51 
52  var<named("truth")>() = static_cast<double>(numberOfCorrectHits) / static_cast<double>(mcTrack->getNumberOfPXDHits());
53 
54  return true;
55 }
Belle2::TrackMatchLookUp
Class to provide convenient methods to look up matching information between pattern recognition and M...
Definition: TrackMatchLookUp.h:43
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::CKFToPXDResult
Specialized CKF Result for extrapolating into the PXD.
Definition: CKFToPXDResult.h:31
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackMatchLookUp::getRelatedMCRecoTrack
const RecoTrack * getRelatedMCRecoTrack(const RecoTrack &prRecoTrack) const
Looks for a related Monte Carlo track for the given pattern recognition track and return it if found.
Definition: TrackMatchLookUp.cc:119