Belle II Software development
RelationFromSVDTracksCreator.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/svd/findlets/RelationFromSVDTracksCreator.h>
9
10#include <tracking/spacePointCreation/SpacePointTrackCand.h>
11#include <tracking/dataobjects/RecoTrack.h>
12#include <tracking/trackingUtilities/utilities/StringManipulation.h>
13#include <tracking/trackingUtilities/utilities/ReversedRange.h>
14
15#include <framework/core/ModuleParamList.h>
16
17using namespace Belle2;
18
22
28
30
31void RelationFromSVDTracksCreator::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
32{
33 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "vxdTracksStoreArrayName"),
35 "Store Array name for tracks coming from VXDTF2.");
36 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "cdcTracksStoreArrayName"),
38 "Store Array name for tracks coming from CDCTF.");
39
40 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "spacePointTrackCandidatesName"),
42 "Store Array name for the SpacePointTrackCandidates coming from VXDTF2.",
44}
45
46void RelationFromSVDTracksCreator::apply(std::vector<CKFToSVDState>& seedStates, std::vector<CKFToSVDState>& states,
48{
49 for (const RecoTrack& vxdRecoTrack : m_vxdRecoTracks) {
50 if (vxdRecoTrack.getRelated<RecoTrack>(m_param_cdcTracksStoreArrayName)) {
51 continue;
52 }
53
54 CKFToSVDState* currentState = nullptr;
55 const SpacePointTrackCand* spacePointTrackCand = [&]() -> const SpacePointTrackCand* {
56 for (const auto& suffix : {"", "Hough", "VXDTF2"})
57 {
58 if (auto* p = vxdRecoTrack.getRelated<SpacePointTrackCand>(m_param_spacePointTrackCandidateName + suffix))
59 return p;
60 }
61 return vxdRecoTrack.getRelated<SpacePointTrackCand>();
62 }();
63
64 B2ASSERT("There should be a related SPTC!", spacePointTrackCand);
65 const std::vector<const SpacePoint*> spacePoints = spacePointTrackCand->getSortedHits();
66
67 for (const SpacePoint* spacePoint : TrackingUtilities::reversedRange(spacePoints)) {
68 const auto hasSpacePoint = [spacePoint](const CKFToSVDState & state) {
69 return state.getHit() == spacePoint;
70 };
71
72 const auto nextStateIterator = std::find_if(states.begin(), states.end(), hasSpacePoint);
73 B2ASSERT("State can not be none!", nextStateIterator != states.end());
74
75 CKFToSVDState& nextState = *nextStateIterator;
76 nextState.setRelatedSVDTrack(&vxdRecoTrack);
77
78 if (currentState) {
79 relations.emplace_back(currentState, NAN, &nextState);
80 } else {
81 for (CKFToSVDState& seedState : seedStates) {
82 // We are not setting the related SVD track of the first state!
83 relations.emplace_back(&seedState, NAN, &nextState);
84 }
85 }
86
87 currentState = &nextState;
88 }
89 }
90
91 std::sort(relations.begin(), relations.end());
92}
Specialized CKF State for extrapolating into the SVD.
void setRelatedSVDTrack(const RecoTrack *relatedSVDTrack)
Set the related SVD track, if we go along one of them (or a nullptr)
The Module parameter list class.
This is the Reconstruction Event-Data Model Track.
Definition RecoTrack.h:79
std::string m_param_spacePointTrackCandidateName
Store Array name of the space point track candidates coming from VXDTF2.
RelationFromSVDTracksCreator()
Construct this findlet and add the subfindlet as listener.
std::string m_param_vxdTracksStoreArrayName
Store Array name coming from VXDTF2.
void initialize() final
Require the store array.
std::string m_param_cdcTracksStoreArrayName
Store Array name coming from CDCTF.
StoreArray< RecoTrack > m_vxdRecoTracks
Store Array of the VXD tracks to use.
void apply(std::vector< CKFToSVDState > &seedStates, std::vector< CKFToSVDState > &states, std::vector< TrackingUtilities::WeightedRelation< CKFToSVDState > > &relations) final
Create relations between seeds and hits or hits and hits.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters of the subfindlet.
~RelationFromSVDTracksCreator()
Default destructor.
Storage for (VXD) SpacePoint-based track candidates.
const std::vector< const Belle2::SpacePoint * > getSortedHits() const
get hits (space points) sorted by their respective sorting parameter
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition SpacePoint.h:42
Type for two related objects with a weight.
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.