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