Belle II Software  release-08-01-10
ResultStorer.icc.h
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 #pragma once
9 
10 #include <tracking/ckf/general/findlets/ResultStorer.dcl.h>
11 
12 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
13 #include <tracking/ckf/general/utilities/SearchDirection.h>
14 #include <tracking/dataobjects/RecoTrack.h>
15 
16 #include <framework/core/ModuleParamList.templateDetails.h>
17 
18 namespace Belle2 {
24  template <class AResult>
25  void ResultStorer<AResult>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
26  {
27  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "exportTracks"), m_param_exportTracks,
28  "Export the result tracks into a StoreArray.",
29  m_param_exportTracks);
30 
31  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "outputRecoTrackStoreArrayName"),
32  m_param_outputRecoTrackStoreArrayName,
33  "StoreArray name of the output Track Store Array.");
34  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "outputRelationRecoTrackStoreArrayName"),
35  m_param_outputRelationRecoTrackStoreArrayName,
36  "StoreArray name of the tracks, the output reco tracks should be related to.");
37 
38  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "writeOutDirection"),
39  m_param_writeOutDirectionAsString,
40  "Write out the relations with the direction of the VXD part as weight");
41  }
42 
44  template <class AResult>
46  {
47  Super::initialize();
48 
49  if (not m_param_exportTracks) {
50  return;
51  }
52 
53  m_outputRecoTracks.registerInDataStore(m_param_outputRecoTrackStoreArrayName);
54  RecoTrack::registerRequiredRelations(m_outputRecoTracks);
55 
56  StoreArray<RecoTrack> relationRecoTracks(m_param_outputRelationRecoTrackStoreArrayName);
57  relationRecoTracks.registerRelationTo(m_outputRecoTracks);
58 
59  m_param_writeOutDirection = fromString(m_param_writeOutDirectionAsString);
60  }
61 
63  template <class AResult>
64  void ResultStorer<AResult>::apply(std::vector<AResult>& results)
65  {
66  if (not m_param_exportTracks) {
67  return;
68  }
69 
70  for (const auto& result : results) {
71 
72  const ROOT::Math::XYZVector& trackPosition = result.getPosition();
73  const ROOT::Math::XYZVector& trackMomentum = result.getMomentum();
74  const short& trackCharge = result.getCharge();
75 
76  RecoTrack* newRecoTrack = m_outputRecoTracks.appendNew(trackPosition, trackMomentum, trackCharge);
77  result.addToRecoTrack(*newRecoTrack);
78 
79  const RecoTrack* seed = result.getSeed();
80  if (not seed) {
81  continue;
82  }
83  seed->addRelationTo(newRecoTrack, m_param_writeOutDirection);
84  }
85  }
87 }
The Module parameter list class.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
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
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 addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
void initialize() override
Create the store arrays.
TrackFindingCDC::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
void apply(std::vector< AResult > &results) override
Load in the reco tracks and the hits.
Abstract base class for different kinds of events.