Belle II Software  release-08-01-10
ClusterRefiner.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/trackFindingCDC/findlets/base/Findlet.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/segments/CDCWireHitCluster.h>
13 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
14 
15 #include <tracking/trackFindingCDC/ca/Clusterizer.h>
16 
17 #include <tracking/trackFindingCDC/filters/base/RelationFilterUtil.h>
18 
19 #include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
20 
21 #include <vector>
22 #include <string>
23 #include <algorithm>
24 
25 namespace Belle2 {
30  namespace TrackFindingCDC {
31 
33  template <class AWireHitRelationFilter>
34  class ClusterRefiner : public Findlet<const CDCWireHitCluster, CDCWireHitCluster> {
35 
36  private:
39 
40  public:
43  {
45  }
46 
48  std::string getDescription() final {
49  return "Breaks bigger wire hit super cluster into smaller wire hit clusters";
50  }
51 
53  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) final {
54  m_wireHitRelationFilter.exposeParameters(moduleParamList, prefix);
55  }
56 
57  public:
59  void apply(const std::vector<CDCWireHitCluster>& inputSuperClusters,
60  std::vector<CDCWireHitCluster>& outputClusters) final {
61  for (const CDCWireHitCluster& superCluster : inputSuperClusters)
62  {
63  B2ASSERT("Expect the clusters to be sorted", std::is_sorted(superCluster.begin(),
64  superCluster.end()));
65 
66  // Obtain the wire hits as pointers
67  const std::vector<CDCWireHit*>& wireHitPtrs = superCluster;
68 
69  // Create the wire hit relations within the supercluster.
70  m_wireHitRelations.clear();
72  const std::size_t nClustersBefore = outputClusters.size();
73  m_wireHitClusterizer.apply(superCluster, m_wireHitRelations, outputClusters);
74  const std::size_t nClustersAfter = outputClusters.size();
75 
76  // Update the super cluster id of the just created clusters
77  int iSuperCluster = superCluster.getISuperCluster();
78  for (std::size_t iCluster = nClustersBefore; iCluster < nClustersAfter; ++iCluster) {
79  CDCWireHitCluster& cluster = outputClusters[iCluster];
80  cluster.setISuperCluster(iSuperCluster);
81  std::sort(cluster.begin(), cluster.end());
82  }
83  }
84  }
85 
86  private:
89 
91  std::vector<WeightedRelation<CDCWireHit>> m_wireHitRelations;
92 
94  AWireHitRelationFilter m_wireHitRelationFilter;
95  };
96  }
98 }
The Module parameter list class.
Refines the clustering of wire hits from super clusters to clustexrs.
std::vector< WeightedRelation< CDCWireHit > > m_wireHitRelations
Memory for the wire hit neighborhood in a super cluster.
AWireHitRelationFilter m_wireHitRelationFilter
Wire hit neighborhood relation filter.
std::string getDescription() final
Short description of the findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
ClusterRefiner()
Constructor adding the filter as a subordinary processing signal listener.
Clusterizer< CDCWireHit, CDCWireHitCluster > m_wireHitClusterizer
Instance of the hit cluster generator.
void apply(const std::vector< CDCWireHitCluster > &inputSuperClusters, std::vector< CDCWireHitCluster > &outputClusters) final
Main algorithm applying the cluster refinement.
Implementation of the clustering Clusters elements of a given collection using the relations presente...
Definition: Clusterizer.h:41
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition: Findlet.h:26
Abstract base class for different kinds of events.
static void appendUsing(ARelationFilter &relationFilter, const std::vector< AObject * > &froms, const std::vector< AObject * > &tos, std::vector< WeightedRelation< AObject >> &weightedRelations, unsigned int maximumNumberOfRelations=std::numeric_limits< unsigned int >::max())
Appends relations between elements in the given AItems using the ARelationFilter.