Belle II Software  release-08-01-10
SVDResultTruthVarSet.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/ckf/svd/filters/results/SVDResultTruthVarSet.h>
9 
10 #include <tracking/mcMatcher/TrackMatchLookUp.h>
11 #include <tracking/dataobjects/RecoTrack.h>
12 
13 using namespace Belle2;
14 using namespace TrackFindingCDC;
15 
17 {
18  const RecoTrack* seedTrack = result->getSeed();
19  if (not seedTrack) return false;
20 
21  var<named("truth_event_number")>() = m_eventMetaData->getEvent();
22  var<named("truth_seed_number")>() = seedTrack->getArrayIndex();
23 
24  const std::string& seedTrackStoreArrayName = seedTrack->getArrayName();
25 
26  TrackMatchLookUp mcCDCMatchLookUp("MCRecoTracks", seedTrackStoreArrayName);
27  const RecoTrack* cdcMCTrack = mcCDCMatchLookUp.getRelatedMCRecoTrack(*seedTrack);
28 
29  // Default to false
30  var<named("truth_number_of_correct_hits")>() = 0;
31  var<named("truth")>() = 0;
32  var<named("truth_svd_cdc_relation")>() = NAN;
33  var<named("truth_number_of_mc_pxd_hits")>() = 0;
34  var<named("truth_number_of_mc_svd_hits")>() = 0;
35  var<named("truth_number_of_mc_cdc_hits")>() = 0;
36 
37  if (not cdcMCTrack) {
38  // track is a fake.
39  return true;
40  }
41 
42  // Count the number of times the related MC-track is also related to the clusters.
43  const unsigned int numberOfCorrectHits = m_mcUtil.getNumberOfCorrectHits(cdcMCTrack, result->getHits());
44 
45  var<named("truth_number_of_correct_hits")>() = numberOfCorrectHits;
46  var<named("truth_number_of_mc_svd_hits")>() = cdcMCTrack->getNumberOfSVDHits();
47  var<named("truth_number_of_mc_pxd_hits")>() = cdcMCTrack->getNumberOfPXDHits();
48  var<named("truth_number_of_mc_cdc_hits")>() = cdcMCTrack->getNumberOfCDCHits();
49 
50  var<named("truth")>() = static_cast<double>(numberOfCorrectHits) / (static_cast<double>(cdcMCTrack->getNumberOfSVDHits()) / 2);
51 
52  const RecoTrack* relatedSVDRecoTrack = result->getRelatedSVDRecoTrack();
53  if (relatedSVDRecoTrack) {
54  const std::string& svdTrackStoreArrayName = relatedSVDRecoTrack->getArrayName();
55 
56  TrackMatchLookUp mcSVDMatchLookUp("MCRecoTracks", svdTrackStoreArrayName);
57  const RecoTrack* svdMCTrack = mcSVDMatchLookUp.getRelatedMCRecoTrack(*relatedSVDRecoTrack);
58 
59  // can not be a fake anyways
60  var<named("truth_svd_cdc_relation")>() = svdMCTrack == cdcMCTrack ? 1 : NAN;
61  }
62 
63  return true;
64 }
Specialized CKF Result for extrapolating into the SVD.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
unsigned int getNumberOfSVDHits() const
Return the number of svd hits.
Definition: RecoTrack.h:424
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
Definition: RecoTrack.h:427
unsigned int getNumberOfPXDHits() const
Return the number of pxd hits.
Definition: RecoTrack.h:421
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
bool extract(const CKFToSVDResult *result) final
Generate and assign the variables from the object.
Class to provide convenient methods to look up matching information between pattern recognition and M...
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.
Abstract base class for different kinds of events.