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