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