Belle II Software  release-05-02-19
ClusterRefiner.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/findlets/base/Findlet.h>
13 
14 #include <tracking/trackFindingCDC/eventdata/segments/CDCWireHitCluster.h>
15 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
16 
17 #include <tracking/trackFindingCDC/ca/Clusterizer.h>
18 
19 #include <tracking/trackFindingCDC/filters/base/RelationFilterUtil.h>
20 
21 #include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
22 
23 #include <vector>
24 #include <string>
25 #include <algorithm>
26 
27 namespace Belle2 {
32  namespace TrackFindingCDC {
33 
35  template <class AWireHitRelationFilter>
36  class ClusterRefiner : public Findlet<const CDCWireHitCluster, CDCWireHitCluster> {
37 
38  private:
40  using Super = Findlet<const CDCWireHitCluster, CDCWireHitCluster>;
41 
42  public:
45  {
47  }
48 
50  std::string getDescription() final {
51  return "Breaks bigger wire hit super cluster into smaller wire hit clusters";
52  }
53 
55  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) final {
56  m_wireHitRelationFilter.exposeParameters(moduleParamList, prefix);
57  }
58 
59  public:
61  void apply(const std::vector<CDCWireHitCluster>& inputSuperClusters,
62  std::vector<CDCWireHitCluster>& outputClusters) final {
63  for (const CDCWireHitCluster& superCluster : inputSuperClusters)
64  {
65  B2ASSERT("Expect the clusters to be sorted", std::is_sorted(superCluster.begin(),
66  superCluster.end()));
67 
68  // Obtain the wire hits as pointers
69  const std::vector<CDCWireHit*>& wireHitPtrs = superCluster;
70 
71  // Create the wire hit relations within the supercluster.
72  m_wireHitRelations.clear();
74  const std::size_t nClustersBefore = outputClusters.size();
75  m_wireHitClusterizer.apply(superCluster, m_wireHitRelations, outputClusters);
76  const std::size_t nClustersAfter = outputClusters.size();
77 
78  // Update the super cluster id of the just created clusters
79  int iSuperCluster = superCluster.getISuperCluster();
80  for (std::size_t iCluster = nClustersBefore; iCluster < nClustersAfter; ++iCluster) {
81  CDCWireHitCluster& cluster = outputClusters[iCluster];
82  cluster.setISuperCluster(iSuperCluster);
83  std::sort(cluster.begin(), cluster.end());
84  }
85  }
86  }
87 
88  private:
90  Clusterizer<CDCWireHit, CDCWireHitCluster> m_wireHitClusterizer;
91 
93  std::vector<WeightedRelation<CDCWireHit>> m_wireHitRelations;
94 
96  AWireHitRelationFilter m_wireHitRelationFilter;
97  };
98  }
100 }
Belle2::TrackFindingCDC::ClusterRefiner::ClusterRefiner
ClusterRefiner()
Constructor adding the filter as a subordinary processing signal listener.
Definition: ClusterRefiner.h:52
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::addProcessingSignalListener
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Definition: CompositeProcessingSignalListener.cc:57
Belle2::TrackFindingCDC::ClusterRefiner::m_wireHitRelations
std::vector< WeightedRelation< CDCWireHit > > m_wireHitRelations
Memory for the wire hit neighborhood in a super cluster.
Definition: ClusterRefiner.h:101
Belle2::TrackFindingCDC::RelationFilterUtil::appendUsing
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.
Definition: RelationFilterUtil.h:71
Belle2::TrackFindingCDC::ClusterRefiner::Super
Findlet< const CDCWireHitCluster, CDCWireHitCluster > Super
Type of the base class.
Definition: ClusterRefiner.h:48
Belle2::TrackFindingCDC::ClusterRefiner::apply
void apply(const std::vector< CDCWireHitCluster > &inputSuperClusters, std::vector< CDCWireHitCluster > &outputClusters) final
Main algorithm applying the cluster refinement.
Definition: ClusterRefiner.h:69
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::ClusterRefiner::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
Definition: ClusterRefiner.h:63
Belle2::TrackFindingCDC::ClusterRefiner::getDescription
std::string getDescription() final
Short description of the findlet.
Definition: ClusterRefiner.h:58
Belle2::TrackFindingCDC::ClusterRefiner::m_wireHitRelationFilter
AWireHitRelationFilter m_wireHitRelationFilter
Wire hit neighborhood relation filter.
Definition: ClusterRefiner.h:104
Belle2::TrackFindingCDC::CDCWireHitCluster
An aggregation of CDCWireHits.
Definition: CDCWireHitCluster.h:31
Belle2::TrackFindingCDC::ClusterRefiner::m_wireHitClusterizer
Clusterizer< CDCWireHit, CDCWireHitCluster > m_wireHitClusterizer
Instance of the hit cluster generator.
Definition: ClusterRefiner.h:98
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46