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