Belle II Software  release-05-01-25
TrackLoader.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/general/findlets/TrackLoader.h>
11 #include <tracking/ckf/general/utilities/SearchDirection.h>
12 
13 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
14 
15 #include <tracking/dataobjects/RecoTrack.h>
16 
17 #include <framework/core/ModuleParamList.h>
18 
19 using namespace Belle2;
20 
22 {
24 }
25 
26 void TrackLoader::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
27 {
28  m_trackFitter.exposeParameters(moduleParamList, prefix);
29 
30  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "inputRecoTrackStoreArrayName"),
32  "StoreArray name of the input Track Store Array.");
33 
34  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "relatedRecoTrackStoreArrayName"),
36  "Check for relations to this store array name and only use the unrelated ones or "
37  "relations with different direction",
39 
40  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "minimalPtRequirement"),
42  "Minimal Pt requirement for the input tracks",
44 
45  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "relationCheckForDirection"),
47  "Check for this direction when checking for related tracks.");
48 
49  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "ignoreTracksWithCDChits"),
50  m_noCDChits, "Do not consider tracks containing CDC hits.", false);
51 
52 }
53 
55 {
57 
59 
61 
62  if (m_param_relationCheckForDirection != TrackFindingCDC::EForwardBackward::c_Invalid) {
63  StoreArray<RecoTrack> relatedRecoTracks;
64  if (not relatedRecoTracks.isOptional(m_param_relationRecoTrackStoreArrayName)) {
65  m_param_relationCheckForDirection = TrackFindingCDC::EForwardBackward::c_Invalid;
66  }
67  }
68 }
69 
70 void TrackLoader::apply(std::vector<RecoTrack*>& seeds)
71 {
72  seeds.reserve(seeds.size() + m_inputRecoTracks.getEntries());
73 
74  for (auto& item : m_inputRecoTracks) {
75 
76  if (m_noCDChits) {
77  if (item.hasCDCHits()) continue;
78  }
79 
80  if (m_param_relationCheckForDirection != TrackFindingCDC::EForwardBackward::c_Invalid) {
81  const auto& relatedTracksWithWeight = item.template getRelationsWith<RecoTrack>(m_param_relationRecoTrackStoreArrayName);
82  bool hasAlreadyRelation = false;
83  for (unsigned int index = 0; index < relatedTracksWithWeight.size(); ++index) {
84  const RecoTrack* relatedTrack = relatedTracksWithWeight[index];
85  const float weight = relatedTracksWithWeight.weight(index);
86  if (relatedTrack and weight == m_param_relationCheckForDirection) {
87  hasAlreadyRelation = true;
88  break;
89  }
90  }
91 
92  if (not hasAlreadyRelation) {
93  seeds.push_back(&item);
94  } else {
95  B2DEBUG(100, "Do not use this track, because it has already a valid relation");
96  }
97  } else {
98  seeds.push_back(&item);
99  }
100  }
101 
102  const auto hasLowPt = [this](const auto & track) {
103  return track->getMomentumSeed().Pt() < m_param_minimalPtRequirement;
104  };
105  TrackFindingCDC::erase_remove_if(seeds, hasLowPt);
106 
107  m_trackFitter.apply(seeds);
108 }
Belle2::fromString
TrackFindingCDC::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.
Definition: SearchDirection.h:46
Belle2::TrackLoader::m_param_inputRecoTrackStoreArrayName
std::string m_param_inputRecoTrackStoreArrayName
StoreArray name of the input Track Store Array.
Definition: TrackLoader.h:72
Belle2::TrackFindingCDC::Findlet< RecoTrack * >
Belle2::TrackLoader::m_trackFitter
TrackFitterAndDeleter m_trackFitter
Findlet for fitting the tracks.
Definition: TrackLoader.h:66
Belle2::TrackLoader::m_param_relationRecoTrackStoreArrayName
std::string m_param_relationRecoTrackStoreArrayName
StoreArray name of the output Track Store Array.
Definition: TrackLoader.h:70
Belle2::TrackLoader::m_noCDChits
bool m_noCDChits
Ignore tracks with CDC hits attached.
Definition: TrackLoader.h:85
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::addProcessingSignalListener
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Definition: CompositeProcessingSignalListener.cc:57
Belle2::TrackLoader::TrackLoader
TrackLoader()
Add the subfindlets.
Definition: TrackLoader.cc:21
Belle2::TrackLoader::apply
void apply(std::vector< RecoTrack * > &seeds) override
Load in the reco tracks and the hits.
Definition: TrackLoader.cc:70
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::initialize
void initialize() override
Receive and dispatch signal before the start of the event processing.
Definition: CompositeProcessingSignalListener.cc:17
Belle2::TrackLoader::initialize
void initialize() override
Create the store arrays.
Definition: TrackLoader.cc:54
Belle2::TrackLoader::m_param_relationCheckForDirectionAsString
std::string m_param_relationCheckForDirectionAsString
Parameter for the distance given to the framework (can not handle EForwardBackward directly)
Definition: TrackLoader.h:76
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::TrackLoader::m_inputRecoTracks
StoreArray< RecoTrack > m_inputRecoTracks
Output Reco Tracks Store Array.
Definition: TrackLoader.h:83
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::TrackFindingCDC::Findlet::exposeParameters
virtual void exposeParameters(ModuleParamList *moduleParamList __attribute__((unused)), const std::string &prefix __attribute__((unused)))
Forward prefixed parameters of this findlet to the module parameter list.
Definition: Findlet.h:79
Belle2::TrackLoader::m_param_minimalPtRequirement
double m_param_minimalPtRequirement
Minimal pt requirement.
Definition: TrackLoader.h:74
Belle2::TrackLoader::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: TrackLoader.cc:26
Belle2::TrackLoader::m_param_relationCheckForDirection
TrackFindingCDC::EForwardBackward m_param_relationCheckForDirection
Direction parameter converted from the string parameters.
Definition: TrackLoader.h:78
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFitterAndDeleter::apply
void apply(std::vector< RecoTrack * > &recoTracks) override
Fit the tracks and remove unfittable ones.
Definition: TrackFitterAndDeleter.cc:17