Belle II Software development
PXDResultTruthVarSet.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/pxd/filters/results/PXDResultTruthVarSet.h>
9#include <tracking/ckf/pxd/entities/CKFToPXDResult.h>
10
11#include <tracking/mcMatcher/TrackMatchLookUp.h>
12#include <tracking/dataobjects/RecoTrack.h>
13#include <framework/dataobjects/EventMetaData.h>
14
15using namespace Belle2;
16using namespace TrackFindingCDC;
17
19{
20 const RecoTrack* seedTrack = result->getSeed();
21 if (not seedTrack) return false;
22
23 var<named("truth_event_number")>() = m_eventMetaData->getEvent();
24 var<named("truth_seed_number")>() = seedTrack->getArrayIndex();
25
26 const std::string& seedTrackStoreArrayName = seedTrack->getArrayName();
27
28 TrackMatchLookUp mcCDCMatchLookUp("MCRecoTracks", seedTrackStoreArrayName);
29 const RecoTrack* mcTrack = mcCDCMatchLookUp.getRelatedMCRecoTrack(*seedTrack);
30
31 // Default to false
32 var<named("truth_number_of_correct_hits")>() = 0;
33 var<named("truth")>() = 0;
34 var<named("truth_number_of_mc_pxd_hits")>() = 0;
35 var<named("truth_number_of_mc_svd_hits")>() = 0;
36 var<named("truth_number_of_mc_cdc_hits")>() = 0;
37
38 if (not mcTrack) {
39 // track is a fake.
40 return true;
41 }
42
43 // Count the number of times the related MC-track is also related to the clusters.
44 const unsigned int numberOfCorrectHits = m_mcUtil.getNumberOfCorrectPXDHits(mcTrack, result->getHits());
45
46 var<named("truth_number_of_correct_hits")>() = numberOfCorrectHits;
47 var<named("truth_number_of_mc_pxd_hits")>() = mcTrack->getNumberOfPXDHits();
48 var<named("truth_number_of_mc_svd_hits")>() = mcTrack->getNumberOfSVDHits();
49 var<named("truth_number_of_mc_cdc_hits")>() = mcTrack->getNumberOfCDCHits();
50
51 var<named("truth")>() = static_cast<double>(numberOfCorrectHits) / static_cast<double>(mcTrack->getNumberOfPXDHits());
52
53 return true;
54}
Specialized CKF Result for extrapolating into the PXD.
MCUtil m_mcUtil
MC information used in the PXD CKF.
bool extract(const CKFToPXDResult *result) final
Generate and assign the variables from the object.
StoreObjPtr< EventMetaData > m_eventMetaData
Pointer to the object containing event number etc.
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.
static constexpr int named(const char *name)
Definition VarSet.h:78
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.