Belle II Software  release-05-01-25
CDCCKFResultStorer.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, Simon Kurz *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/ckf/cdc/findlets/CDCCKFResultStorer.h>
12 
13 #include <tracking/ckf/general/utilities/SearchDirection.h>
14 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15 #include <tracking/dataobjects/RecoTrack.h>
16 
17 #include <framework/core/ModuleParamList.h>
18 
19 using namespace Belle2;
20 
21 void CDCCKFResultStorer::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
22 {
23  Super::exposeParameters(moduleParamList, prefix);
24 
25  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "exportTracks"), m_param_exportTracks,
26  "Export the result tracks into a StoreArray.",
28 
29  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "outputRecoTrackStoreArrayName"),
31  "StoreArray name of the output Track Store Array.");
32  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "outputRelationRecoTrackStoreArrayName"),
34  "StoreArray name of the tracks, the output reco tracks should be related to.");
35 
36  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "writeOutDirection"),
38  "Write out the relations with the direction of the CDC part as weight");
39 
40  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "trackFindingDirection"),
42  "Direction in which the track is reconstructed (SVD/ECL seed)",
44 
45  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "exportAllTracks"),
47  "Export all tracks, even if they did not reach the center of the CDC",
49 
50  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "seedComponent"),
52  "Where does the seed track come from (typically SVD, ECL)",
54 
55  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "setTakenFlag"),
57  "Set flag that hit is taken",
59 }
60 
62 {
64 
65  if (not m_param_exportTracks) {
66  return;
67  }
68 
71 
73  relationRecoTracks.registerRelationTo(m_outputRecoTracks);
74  m_outputRecoTracks.registerRelationTo(relationRecoTracks);
75 
77 
79 
80  if (m_seedComponentString == "SVD") {
81  m_trackFinderType = RecoHitInformation::c_SVDtoCDCCKF;
82  } else if (m_seedComponentString == "ECL") {
83  m_trackFinderType = RecoHitInformation::c_ECLtoCDCCKF;
84  } else {
85  B2FATAL("CDCCKFResultStorer: No valid seed component specified. Please use SVD/ECL.");
86  }
87 }
88 
89 void CDCCKFResultStorer::apply(const std::vector<CDCCKFResult>& results)
90 {
91  for (const CDCCKFResult& result : results) {
92  if (result.size() < 2) {
93  continue;
94  }
95 
96  genfit::MeasuredStateOnPlane const* trackState = nullptr;
97  if (m_param_trackFindingDirection == TrackFindingCDC::EForwardBackward::c_Forward) {
98  trackState = &result.at(1).getTrackState();
99  } else if (m_param_trackFindingDirection == TrackFindingCDC::EForwardBackward::c_Backward) {
100  trackState = &result.back().getTrackState();
101  } else {
102  B2FATAL("CDCCKFResultStorer: No valid direction specified. Please use forward/backward.");
103  }
104 
105  // only accept paths that reached the center of the CDC (for ECL seeding)
107  && m_param_trackFindingDirection == TrackFindingCDC::EForwardBackward::c_Backward
108  && result.back().getWireHit()->getWire().getICLayer() > 2) {
109  continue;
110  }
111 
112  const TVector3& trackPosition = trackState->getPos();
113  const TVector3& trackMomentum = trackState->getMom();
114  const double trackCharge = trackState->getCharge();
115 
116  RecoTrack* newRecoTrack = m_outputRecoTracks.appendNew(trackPosition, trackMomentum, trackCharge);
117 
118  unsigned int sortingParameter = 0;
119  for (const CDCCKFState& state : result) {
120  if (state.isSeed()) {
121  continue;
122  }
123 
124  const TrackFindingCDC::CDCWireHit* wireHit = state.getWireHit();
125 
126  auto rl = state.getRLinfo() == TrackFindingCDC::ERightLeft::c_Right ?
127  RecoHitInformation::RightLeftInformation::c_right :
128  RecoHitInformation::RightLeftInformation::c_left;
129 
130  newRecoTrack->addCDCHit(wireHit->getHit(), sortingParameter, rl, m_trackFinderType);
131  sortingParameter++;
132 
133  if (m_param_setTakenFlag) {
134  wireHit->getAutomatonCell().setTakenFlag();
135  }
136  }
137 
138  const RecoTrack* seed = result.front().getSeed();
139  if (not seed) {
140  continue;
141  }
142 
143  seed->addRelationTo(newRecoTrack, m_param_writeOutDirection);
144  newRecoTrack->addRelationTo(seed, m_param_writeOutDirection);
145  }
146 }
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::CDCCKFResultStorer::m_param_trackFindingDirection
TrackFindingCDC::EForwardBackward m_param_trackFindingDirection
Direction parameter converted from the string parameters.
Definition: CDCCKFResultStorer.h:69
Belle2::RecoTrack::registerRequiredRelations
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:42
Belle2::CDCCKFResult
CDCCKFPath CDCCKFResult
Alias for the collection of CDC CKF-algorithm states.
Definition: CDCCKFResult.h:28
Belle2::StoreArray::registerRelationTo
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:150
genfit::MeasuredStateOnPlane
#StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:39
Belle2::CDCCKFResultStorer::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: CDCCKFResultStorer.cc:21
Belle2::CDCCKFResultStorer::m_param_exportTracks
bool m_param_exportTracks
Export the tracks or not.
Definition: CDCCKFResultStorer.h:59
Belle2::CDCCKFResultStorer::m_param_writeOutDirectionAsString
std::string m_param_writeOutDirectionAsString
Parameter for the distance given to the framework (can not handle EForwardBackward directly)
Definition: CDCCKFResultStorer.h:55
Belle2::CDCCKFResultStorer::m_param_writeOutDirection
TrackFindingCDC::EForwardBackward m_param_writeOutDirection
Direction parameter converted from the string parameters.
Definition: CDCCKFResultStorer.h:57
Belle2::CDCCKFResultStorer::m_param_setTakenFlag
bool m_param_setTakenFlag
Set flag that hit is taken.
Definition: CDCCKFResultStorer.h:71
Belle2::TrackFindingCDC::AutomatonCell::setTakenFlag
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
Definition: AutomatonCell.h:234
Belle2::RelationsInterface::addRelationTo
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).
Definition: RelationsObject.h:144
Belle2::CDCCKFResultStorer::m_param_trackFindingDirectionAsString
std::string m_param_trackFindingDirectionAsString
Parameter for the direction of the CKF.
Definition: CDCCKFResultStorer.h:67
Belle2::CDCCKFResultStorer::m_param_outputRelationRecoTrackStoreArrayName
std::string m_param_outputRelationRecoTrackStoreArrayName
StoreArray name of the tracks, the output reco tracks should be related to.
Definition: CDCCKFResultStorer.h:65
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::initialize
void initialize() override
Receive and dispatch signal before the start of the event processing.
Definition: CompositeProcessingSignalListener.cc:17
Belle2::CDCCKFResultStorer::apply
void apply(const std::vector< CDCCKFResult > &results) override
Do the track/hit finding/merging.
Definition: CDCCKFResultStorer.cc:89
Belle2::RecoTrack::addCDCHit
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:240
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
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< const CDCCKFResult >::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::CDCCKFResultStorer::m_outputRecoTracks
StoreArray< RecoTrack > m_outputRecoTracks
Output Reco Tracks Store Array.
Definition: CDCCKFResultStorer.h:79
Belle2::CDCCKFResultStorer::m_seedComponentString
std::string m_seedComponentString
Where does the seed track for the CKF come from (typically SVD, ECL)
Definition: CDCCKFResultStorer.h:75
Belle2::CDCCKFResultStorer::m_param_exportAllTracks
bool m_param_exportAllTracks
Export all tracks, even if they did not reach the center of the CDC.
Definition: CDCCKFResultStorer.h:61
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::CDCCKFState
Define states for CKF algorithm, which can be seed track or CDC wire hit.
Definition: CDCCKFState.h:37
Belle2::CDCCKFResultStorer::m_param_outputRecoTrackStoreArrayName
std::string m_param_outputRecoTrackStoreArrayName
StoreArray name of the output Track Store Array.
Definition: CDCCKFResultStorer.h:63
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::CDCCKFResultStorer::initialize
void initialize() override
Register the store arrays.
Definition: CDCCKFResultStorer.cc:61
Belle2::CDCCKFResultStorer::m_trackFinderType
RecoHitInformation::OriginTrackFinder m_trackFinderType
What was used to seed the CKF (typically c_SVDtoCDCCKF, c_ECLtoCDCCKF)
Definition: CDCCKFResultStorer.h:73