Belle II Software  release-05-01-25
MCVXDCDCTrackMergerModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - 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/modules/vxdCDCTrackMerger/MCVXDCDCTrackMergerModule.h>
11 #include <tracking/dataobjects/RecoTrack.h>
12 
13 #include <tracking/mcMatcher/TrackMatchLookUp.h>
14 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15 
16 using namespace Belle2;
17 
18 REG_MODULE(MCVXDCDCTrackMerger)
19 
20 
22 {
23  addProcessingSignalListener(&m_storeArrayMerger);
24  addProcessingSignalListener(&m_bestMatchSelector);
25  addProcessingSignalListener(&m_relationAdder);
26 }
27 
28 void MCVXDCDCTrackMergerFindlet::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
29 {
30  m_storeArrayMerger.exposeParameters(moduleParamList, prefix);
31  m_bestMatchSelector.exposeParameters(moduleParamList, prefix);
32  m_relationAdder.exposeParameters(moduleParamList, prefix);
33 
34  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "onlyFittedCDCTracks"), m_param_onlyFittedCDCTracks,
35  "Only use fitted CDC tracks as otherwise the comparison with the CKF is unfair.",
37 }
38 
40 {
41  // Pick up items from the data store.
42  std::vector<RecoTrack*> cdcRecoTrackVector;
43  std::vector<RecoTrack*> vxdRecoTrackVector;
44 
45  m_storeArrayMerger.apply(cdcRecoTrackVector, vxdRecoTrackVector);
46 
47  // Prepare the weighted relations for later
48  std::vector<TrackFindingCDC::WeightedRelation<RecoTrack*, RecoTrack* const>> weightedRelations;
49  weightedRelations.reserve(cdcRecoTrackVector.size() * vxdRecoTrackVector.size());
50 
51  TrackMatchLookUp cdcMCLookUp("MCRecoTracks", m_storeArrayMerger.getCDCStoreArrayName());
52  TrackMatchLookUp vxdMCLookUp("MCRecoTracks", m_storeArrayMerger.getVXDStoreArrayName());
53  for (auto& cdcRecoTrack : cdcRecoTrackVector) {
54  if (m_param_onlyFittedCDCTracks and not cdcRecoTrack->wasFitSuccessful()) {
55  continue;
56  }
57 
58  const RecoTrack* cdcMCRecoTrack = cdcMCLookUp.getMatchedMCRecoTrack(*cdcRecoTrack);
59 
60  if (not cdcMCRecoTrack) {
61  continue;
62  }
63 
64  for (auto& vxdRecoTrack : vxdRecoTrackVector) {
65  const RecoTrack* vxdMCRecoTrack = vxdMCLookUp.getMatchedMCRecoTrack(*vxdRecoTrack);
66  if (not vxdMCRecoTrack) {
67  continue;
68  }
69 
70  if (cdcMCRecoTrack != vxdMCRecoTrack) {
71  continue;
72  }
73 
74 
75  const float matchedEfficiency = vxdMCLookUp.getMatchedEfficiency(*vxdMCRecoTrack);
76  weightedRelations.emplace_back(&cdcRecoTrack, matchedEfficiency, &vxdRecoTrack);
77  }
78  }
79 
80  // Select the ones with the best efficiency
81  m_bestMatchSelector.apply(weightedRelations);
82 
83  for (auto& relation : weightedRelations) {
84  relation.setWeight(-1);
85  }
86 
87  // Add the already found items from the filter-based decision
88  m_relationAdder.apply(weightedRelations);
89 }
Belle2::StoreArrayMerger::apply
void apply(std::vector< RecoTrack * > &cdcRecoTrackVector, std::vector< RecoTrack * > &vxdRecoTrackVector) override
Fetch the RecoTracks from the two input Store Arrays and fill them into two vectors.
Definition: StoreArrayMerger.cc:42
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::MCVXDCDCTrackMergerFindlet::m_relationAdder
TrackFindingCDC::RelationAdder< RecoTrack *, RecoTrack * > m_relationAdder
Use the weighted relations to turn them into real DataStore relations.
Definition: MCVXDCDCTrackMergerModule.h:55
Belle2::TrackMatchLookUp
Class to provide convenient methods to look up matching information between pattern recognition and M...
Definition: TrackMatchLookUp.h:43
Belle2::MCVXDCDCTrackMergerFindlet
Findlet for merging VXD and CDC tracks with MC information.
Definition: MCVXDCDCTrackMergerModule.h:37
Belle2::TrackMatchLookUp::getMatchedMCRecoTrack
const RecoTrack * getMatchedMCRecoTrack(const RecoTrack &prRecoTrack) const
Looks up the matched Monte Carlo track for the given pattern recognition track.
Definition: TrackMatchLookUp.cc:160
Belle2::StoreArrayMerger::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the findlet.
Definition: StoreArrayMerger.cc:19
Belle2::MCVXDCDCTrackMergerFindlet::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: MCVXDCDCTrackMergerModule.cc:28
Belle2::TrackMatchLookUp::getMatchedEfficiency
float getMatchedEfficiency(const RecoTrack &recoTrack) const
Get the hit efficiency of the matched track.
Definition: TrackMatchLookUp.cc:210
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::ModuleParamList::addParameter
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Definition: ModuleParamList.templateDetails.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MCVXDCDCTrackMergerFindlet::apply
void apply() override
Do the track merging.
Definition: MCVXDCDCTrackMergerModule.cc:39
Belle2::MCVXDCDCTrackMergerFindlet::m_bestMatchSelector
TrackFindingCDC::BestMatchSelector< RecoTrack *, RecoTrack * > m_bestMatchSelector
Make a best candidate selection.
Definition: MCVXDCDCTrackMergerModule.h:53
Belle2::MCVXDCDCTrackMergerFindlet::m_param_onlyFittedCDCTracks
bool m_param_onlyFittedCDCTracks
Only use fitted CDC tracks, as otherwise the comparison with the CKF is unfair.
Definition: MCVXDCDCTrackMergerModule.h:59
Belle2::StoreArrayMerger::getVXDStoreArrayName
const std::string & getVXDStoreArrayName()
Get the name of the VXD StoreArray<RecoTrack>
Definition: StoreArrayMerger.h:57
Belle2::StoreArrayMerger::getCDCStoreArrayName
const std::string & getCDCStoreArrayName()
Get the name of the CDC StoreArray<RecoTrack>
Definition: StoreArrayMerger.h:59
Belle2::MCVXDCDCTrackMergerFindlet::m_storeArrayMerger
StoreArrayMerger m_storeArrayMerger
Get and write back the relations to the store array.
Definition: MCVXDCDCTrackMergerModule.h:51
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46