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