Belle II Software  release-08-01-10
SpacePointLoaderAndPreparer.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 <framework/datastore/StoreArray.h>
11 #include <framework/core/ModuleParamList.h>
12 #include <framework/geometry/B2Vector3.h>
13 #include <framework/database/DBObjPtr.h>
14 #include <mdst/dbobjects/BeamSpot.h>
15 #include <tracking/trackFindingCDC/findlets/base/Findlet.h>
16 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
17 #include <tracking/vxdHoughTracking/entities/VXDHoughState.h>
18 #include <tracking/spacePointCreation/SpacePoint.h>
19 #include <vxd/geometry/GeoCache.h>
20 
21 #include <string>
22 #include <vector>
23 
24 namespace Belle2 {
29  namespace vxdHoughTracking {
35  class SpacePointLoaderAndPreparer : public TrackFindingCDC::Findlet<const SpacePoint*, VXDHoughState> {
38 
39  public:
42 
44  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
45  {
46  Super::exposeParameters(moduleParamList, prefix);
47 
48  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "SVDSpacePointStoreArrayName"), m_SVDSpacePointStoreArrayName,
49  "Name of the SVDSpacePoints Store Array.", m_SVDSpacePointStoreArrayName);
50 
51  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "useAllSpacePoints"), m_useAllSpacePoints,
52  "Use all SVDSpacePoints for track finding or only unassigned ones?", m_useAllSpacePoints);
53  };
54 
56  void initialize() override
57  {
60  };
61 
63  void beginRun() override
64  {
66 
67  DBObjPtr<BeamSpot> beamSpotDB;
68  if (beamSpotDB.isValid()) {
69  m_BeamSpotPosition = (*beamSpotDB).getIPPosition();
70  } else {
71  m_BeamSpotPosition.SetXYZ(0., 0., 0.);
72  }
73  }
74 
76  void apply(std::vector<const SpacePoint*>& spacePoints, std::vector<VXDHoughState>& hits) override
77  {
78  if (m_storeSpacePoints.getEntries() == 0) return;
79 
80  hits.reserve(m_storeSpacePoints.getEntries());
81  spacePoints.reserve(m_storeSpacePoints.getEntries());
82  for (auto& spacePoint : m_storeSpacePoints) {
83  if (not m_useAllSpacePoints and spacePoint.getAssignmentState() == true) {
84  continue;
85  }
86  hits.emplace_back(VXDHoughState(&spacePoint, m_BeamSpotPosition));
87  spacePoints.emplace_back(&spacePoint);
88  }
89  };
90 
91  private:
93  std::string m_SVDSpacePointStoreArrayName = "SVDSpacePoints";
94 
96  bool m_useAllSpacePoints = false;
97 
100 
103  };
104 
105  }
107 }
void SetXYZ(DataType x, DataType y, DataType z)
set all coordinates using data type
Definition: B2Vector3.h:464
bool isValid() const
Check whether a valid object was obtained from the database.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
The Module parameter list class.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
void initialize() override
Receive and dispatch signal before the start of the event processing.
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition: Findlet.h:26
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Forward prefixed parameters of this findlet to the module parameter list.
Definition: Findlet.h:69
Interface for an algorithm part that needs to receive the module processing signals.
Findlet for loading SVDSpacePoints and prepare them for usage in the FastInterceptFinder2D by creatin...
SpacePointLoaderAndPreparer()
Load clusters and prepare them for intercept finding.
B2Vector3D m_BeamSpotPosition
B2Vector3D actually contining the BeamSpot position. This will be passed on to the VXDHoughState for ...
bool m_useAllSpacePoints
Use all SVDSpacePoints for track finding or only unassigned ones.
void apply(std::vector< const SpacePoint * > &spacePoints, std::vector< VXDHoughState > &hits) override
Load the SVD SpacePoints and create a VXDHoughState object for each hit.
std::string m_SVDSpacePointStoreArrayName
StoreArray name of the input Track Store Array.
StoreArray< SpacePoint > m_storeSpacePoints
Input SpacePoints Store Array.
void beginRun() override
Retrieve the BeamSpot from DB.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Simple container for hit information to be used during intercept finding.
Definition: VXDHoughState.h:24
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.