Belle II Software development
CDCCKFResultStorer.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
9#include <tracking/ckf/cdc/findlets/CDCCKFResultStorer.h>
10
11#include <tracking/ckf/general/utilities/SearchDirection.h>
12#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
13#include <tracking/dataobjects/RecoTrack.h>
14
15#include <framework/core/ModuleParamList.h>
16
17using namespace Belle2;
18
19void CDCCKFResultStorer::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
20{
21 Super::exposeParameters(moduleParamList, prefix);
22
23 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "exportTracks"), m_param_exportTracks,
24 "Export the result tracks into a StoreArray.",
26
27 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "outputRecoTrackStoreArrayName"),
29 "StoreArray name of the output Track Store Array.");
30 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "outputRelationRecoTrackStoreArrayName"),
32 "StoreArray name of the tracks, the output reco tracks should be related to.");
33
34 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "writeOutDirection"),
36 "Write out the relations with the direction of the CDC part as weight");
37
38 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "trackFindingDirection"),
40 "Direction in which the track is reconstructed (SVD/ECL seed)",
42
43 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "exportAllTracks"),
45 "Export all tracks, even if they did not reach the center of the CDC",
47
48 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "seedComponent"),
50 "Where does the seed track come from (typically SVD, ECL)",
52
53 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "setTakenFlag"),
55 "Set flag that hit is taken",
57}
58
60{
62
63 if (not m_param_exportTracks) {
64 return;
65 }
66
69
71 relationRecoTracks.registerRelationTo(m_outputRecoTracks);
72 m_outputRecoTracks.registerRelationTo(relationRecoTracks);
73
75
77
78 if (m_seedComponentString == "SVD") {
79 m_trackFinderType = RecoHitInformation::c_SVDtoCDCCKF;
80 } else if (m_seedComponentString == "ECL") {
81 m_trackFinderType = RecoHitInformation::c_ECLtoCDCCKF;
82 } else {
83 B2FATAL("CDCCKFResultStorer: No valid seed component specified. Please use SVD/ECL.");
84 }
85}
86
87void CDCCKFResultStorer::apply(const std::vector<CDCCKFResult>& results)
88{
89 for (const CDCCKFResult& result : results) {
90 if (result.size() < 2) {
91 continue;
92 }
93
94 genfit::MeasuredStateOnPlane const* trackState = nullptr;
95 if (m_param_trackFindingDirection == TrackFindingCDC::EForwardBackward::c_Forward) {
96 trackState = &result.at(1).getTrackState();
97 } else if (m_param_trackFindingDirection == TrackFindingCDC::EForwardBackward::c_Backward) {
98 trackState = &result.back().getTrackState();
99 } else {
100 B2FATAL("CDCCKFResultStorer: No valid direction specified. Please use forward/backward.");
101 }
102
103 // only accept paths that reached the center of the CDC (for ECL seeding)
105 && m_param_trackFindingDirection == TrackFindingCDC::EForwardBackward::c_Backward
106 && result.back().getWireHit()->getWire().getICLayer() > 2) {
107 continue;
108 }
109
110 const ROOT::Math::XYZVector& trackPosition = ROOT::Math::XYZVector(trackState->getPos());
111 const ROOT::Math::XYZVector& trackMomentum = ROOT::Math::XYZVector(trackState->getMom());
112 const double trackCharge = trackState->getCharge();
113
114 RecoTrack* newRecoTrack = m_outputRecoTracks.appendNew(trackPosition, trackMomentum, trackCharge);
115
116 unsigned int sortingParameter = 0;
117 for (const CDCCKFState& state : result) {
118 if (state.isSeed()) {
119 continue;
120 }
121
122 const TrackFindingCDC::CDCWireHit* wireHit = state.getWireHit();
123
124 auto rl = state.getRLinfo() == TrackFindingCDC::ERightLeft::c_Right ?
125 RecoHitInformation::RightLeftInformation::c_right :
126 RecoHitInformation::RightLeftInformation::c_left;
127
128 newRecoTrack->addCDCHit(wireHit->getHit(), sortingParameter, rl, m_trackFinderType);
129 sortingParameter++;
130
132 wireHit->getAutomatonCell().setTakenFlag();
133 }
134 }
135
136 const RecoTrack* seed = result.front().getSeed();
137 if (not seed) {
138 continue;
139 }
140
141 seed->addRelationTo(newRecoTrack, m_param_writeOutDirection);
142 newRecoTrack->addRelationTo(seed, m_param_writeOutDirection);
143 }
144}
StoreArray< RecoTrack > m_outputRecoTracks
Output Reco Tracks Store Array.
void initialize() override
Register the store arrays.
std::string m_seedComponentString
Where does the seed track for the CKF come from (typically SVD, ECL)
bool m_param_exportTracks
Export the tracks or not.
std::string m_param_outputRelationRecoTrackStoreArrayName
StoreArray name of the tracks, the output reco tracks should be related to.
RecoHitInformation::OriginTrackFinder m_trackFinderType
What was used to seed the CKF (typically c_SVDtoCDCCKF, c_ECLtoCDCCKF)
bool m_param_exportAllTracks
Export all tracks, even if they did not reach the center of the CDC.
bool m_param_setTakenFlag
Set flag that hit is taken.
TrackFindingCDC::EForwardBackward m_param_writeOutDirection
Direction parameter converted from the string parameters.
TrackFindingCDC::EForwardBackward m_param_trackFindingDirection
Direction parameter converted from the string parameters.
std::string m_param_trackFindingDirectionAsString
Parameter for the direction of the CKF.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
std::string m_param_writeOutDirectionAsString
Parameter for the distance given to the framework (can not handle EForwardBackward directly)
std::string m_param_outputRecoTrackStoreArrayName
StoreArray name of the output Track Store Array.
void apply(const std::vector< CDCCKFResult > &results) override
Do the track/hit finding/merging.
Define states for CKF algorithm, which can be seed track or CDC wire hit.
Definition: CDCCKFState.h:25
The Module parameter list class.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
bool addCDCHit(const UsedCDCHit *cdcHit, const unsigned int sortingParameter, RightLeftInformation rightLeftInformation=RightLeftInformation::c_undefinedRightLeftInformation, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a cdc hit with the given information to the reco track.
Definition: RecoTrack.h:243
static void registerRequiredRelations(StoreArray< RecoTrack > &recoTracks, std::string const &pxdHitsStoreArrayName="", std::string const &svdHitsStoreArrayName="", std::string const &cdcHitsStoreArrayName="", std::string const &bklmHitsStoreArrayName="", std::string const &eklmHitsStoreArrayName="", std::string const &recoHitInformationStoreArrayName="")
Convenience method which registers all relations required to fully use a RecoTrack.
Definition: RecoTrack.cc:53
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
void initialize() override
Receive and dispatch signal before the start of the event processing.
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 addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
CDCCKFPath CDCCKFResult
Alias for the collection of CDC CKF-algorithm states.
Definition: CDCCKFResult.h:18
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.