Belle II Software  release-08-01-10
CosmicsTrackMergerFindlet.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 #include <tracking/modules/cosmicsTrackMerger/CosmicsTrackMergerFindlet.h>
9 
10 #include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
11 #include <tracking/trackFindingCDC/utilities/Algorithms.h>
12 
13 using namespace Belle2;
14 using namespace TrackFindingCDC;
15 
17 {
18  this->addProcessingSignalListener(&m_trackRelationCreator);
19 }
20 
22 {
23  return "Links tracks by extraction of track paths in a cellular automaton.";
24 }
25 
26 void CosmicsTrackMergerFindlet::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
27 {
28  m_trackRelationCreator.exposeParameters(moduleParamList, prefix);
29  m_cellularPathFinder.exposeParameters(moduleParamList, prefix);
30 
31  moduleParamList->addParameter("inputRecoTracks", m_param_inputRecoTracks,
32  "Store Array name of the input reco tracks.", m_param_inputRecoTracks);
33  moduleParamList->addParameter("outputRecoTracks", m_param_outputRecoTracks,
34  "Store Array name of the output reco tracks.", m_param_outputRecoTracks);
35 }
36 
38 {
39  m_inputTracks.isRequired(m_param_inputRecoTracks);
40 
41  m_outputTracks.registerInDataStore(m_param_outputRecoTracks, DataStore::c_ErrorIfAlreadyRegistered);
43 
44  Super::initialize();
45 }
46 
48 {
49  m_inputTrackVector.clear();
50 
51  // Read the tracks from the Store Array
52  for (const RecoTrack& recoTrack : m_inputTracks) {
53  m_inputTrackVector.emplace_back(&recoTrack);
54  }
55 
56  std::sort(m_inputTrackVector.begin(), m_inputTrackVector.end());
57 
58  // Obtain the tracks as pointers
59  std::vector<const CellularRecoTrack*> trackPtrs = as_pointers<const CellularRecoTrack>(m_inputTrackVector);
60 
61  // Create linking relations
62  m_trackRelations.clear();
63  m_trackRelationCreator.apply(trackPtrs, m_trackRelations);
64 
65  // Find linking paths
66  m_trackPaths.clear();
67  m_cellularPathFinder.apply(trackPtrs, m_trackRelations, m_trackPaths);
68 
69  // Write out the tracks to the data store
70  // TODO: other possibility would be to use relations for this!
71  // One would need to extend the RelatedTrackCombiner for this
72  for (const std::vector<const CellularRecoTrack*>& trackPath : m_trackPaths) {
73  // We use the first track to give us the momentum seed etc.
74  const RecoTrack* firstTrack = *(trackPath.front());
75  RecoTrack* newRecoTrack = firstTrack->copyToStoreArray(m_outputTracks);
76 
77  unsigned int numberOfAddedHits = 0;
78  for (const CellularRecoTrack* cellularRecoTrack : trackPath) {
79  numberOfAddedHits += newRecoTrack->addHitsFromRecoTrack(*cellularRecoTrack, numberOfAddedHits);
80  }
81  }
82 }
void initialize() final
Init the store arrays.
std::string getDescription() final
Short description of the findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
CosmicsTrackMergerFindlet()
Constructor adding the filter as a subordinary processing signal listener.
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:72
The Module parameter list class.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
size_t addHitsFromRecoTrack(const RecoTrack *recoTrack, unsigned int sortingParameterOffset=0, bool reversed=false, std::optional< double > optionalMinimalWeight=std::nullopt)
Add all hits from another RecoTrack to this RecoTrack.
Definition: RecoTrack.cc:240
RecoTrack * copyToStoreArray(StoreArray< RecoTrack > &storeArray) const
Append a new RecoTrack to the given store array and copy its general properties, but not the hits the...
Definition: RecoTrack.cc:529
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
Mixin class to attach an automaton cell to an object or pointer.
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.