Belle II Software  release-05-02-19
SuperClusterCreator Class Referenceabstract

Refines the clustering of wire hits from clusters to clusters. More...

#include <SuperClusterCreator.h>

Inheritance diagram for SuperClusterCreator:
Collaboration diagram for SuperClusterCreator:

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invokation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invokation.
 

Public Member Functions

 SuperClusterCreator ()
 Constructor.
 
std::string getDescription () final
 Short description of the findlet.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the parameters to a module.
 
void apply (std::vector< CDCWireHit > &inputWireHits, std::vector< CDCWireHitCluster > &outputSuperClusters) final
 Main algorithm applying the cluster refinement. More...
 
virtual void exposeParameters (ModuleParamList *moduleParamList __attribute__((unused)), const std::string &prefix __attribute__((unused)))
 Forward prefixed parameters of this findlet to the module parameter list.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
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.
 
void beginEvent () override
 Receive and dispatch signal for the start of a new event.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector = typename ToVectorImpl< T >::Type
 Short hand for ToRangeImpl.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = Findlet< CDCWireHit, CDCWireHitCluster >
 Type of the base class.
 

Private Attributes

bool m_param_expandOverApogeeGap = false
 Parameter : Expand the super clusters over the typical gap at the apogee of the trajectory.
 
Clusterizer< CDCWireHit, CDCWireHitClusterm_wirehitClusterizer
 Instance of the hit cluster generator.
 
std::vector< WeightedRelation< CDCWireHit > > m_wireHitRelations
 Memory for the wire hit neighborhood in a cluster.
 
WholeWireHitRelationFilter m_wireHitRelationFilter {2}
 Wire hit neighborhood relation filter.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happend before.
 
bool m_terminated = false
 Flag to keep track whether termination happend before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Refines the clustering of wire hits from clusters to clusters.

Definition at line 41 of file SuperClusterCreator.h.

Member Function Documentation

◆ apply()

void apply ( std::vector< CDCWireHit > &  inputWireHits,
std::vector< CDCWireHitCluster > &  outputSuperClusters 
)
final

Main algorithm applying the cluster refinement.

Obtain the wire hits as pointers

Create the wire hit relations

Definition at line 50 of file SuperClusterCreator.cc.

52 {
53  m_wireHitRelations.clear();
54 
56  auto wireHitsByLayer =
57  adjacent_groupby(inputWireHits.begin(), inputWireHits.end(), [](const CDCWireHit & wireHit) {
58  return wireHit.getWireID().getILayer();
59  });
60 
61  for (const auto& wireHitsInLayer : wireHitsByLayer) {
62  const CDCWireLayer& wireLayer = wireHitsInLayer.front().getWire().getWireLayer();
63  const int nWires = wireLayer.size();
64 
65  auto sameWireHitChain = [](const CDCWireHit & lhs, const CDCWireHit & rhs) {
66  return rhs.getWireID().getIWire() - lhs.getWireID().getIWire() == 1;
67  };
68 
69  auto wireHitChains =
70  unique_ranges(wireHitsInLayer.begin(), wireHitsInLayer.end(), sameWireHitChain);
71 
72  size_t nWireHits = 0;
73  for (const VectorRange<CDCWireHit>& wireHitChain : wireHitChains) {
74  nWireHits += wireHitChain.size();
75  }
76  assert(nWireHits == wireHitsInLayer.size());
77 
78  // Special treatment for the first and last wireHitChain as they might wrap around as one
79  VectorRange<CDCWireHit> frontWrapChain(wireHitsInLayer.begin(), wireHitsInLayer.begin());
80  VectorRange<CDCWireHit> backWrapChain(wireHitsInLayer.end(), wireHitsInLayer.end());
81  if (wireHitChains.size() > 1) {
82  if (wireHitChains.front().front().getWire().isPrimaryNeighborWith(
83  wireHitChains.back().back().getWire())) {
84  // Chains are touching
85  // Keep their information around but eliminate them from the regular chains
86  int wrapAroundChainSize = wireHitChains.front().size() + wireHitChains.back().size();
87  if (wrapAroundChainSize >= 5) {
88  // Warning reach over the local wire hit layer / outside the memory of the wire hit
89  // vector to transport the size.
90  frontWrapChain = wireHitChains.front();
91  frontWrapChain.first = frontWrapChain.end() - wrapAroundChainSize;
92 
93  backWrapChain = wireHitChains.back();
94  backWrapChain.second = backWrapChain.begin() + wrapAroundChainSize;
95 
96  wireHitChains.erase(wireHitChains.begin());
97  wireHitChains.pop_back();
98  }
99  }
100  }
101 
102  auto itLastChain = std::remove_if(wireHitChains.begin(), wireHitChains.end(), Size() < 5u);
103  wireHitChains.erase(itLastChain, wireHitChains.end());
104  if (wireHitChains.empty()) continue;
105 
106  auto connectWireHitChains = [this, nWires](const VectorRange<CDCWireHit>& lhs,
107  const VectorRange<CDCWireHit>& rhs) {
108  int iWireDelta = rhs.front().getWireID().getIWire() - lhs.back().getWireID().getIWire();
109  if (iWireDelta < 0) iWireDelta += nWires;
110  if (iWireDelta < static_cast<int>(lhs.size() + rhs.size())) {
111  m_wireHitRelations.push_back({&rhs.front(), 0, &lhs.back()});
112  m_wireHitRelations.push_back({&lhs.back(), 0, &rhs.front()});
113  }
114  return false;
115  };
116  // the return value is not needed
117  // cppcheck-suppress ignoredReturnValue
118  std::adjacent_find(wireHitChains.begin(), wireHitChains.end(), connectWireHitChains);
119 
120  if (not frontWrapChain.empty()) {
121  connectWireHitChains(frontWrapChain, wireHitChains.front());
122  }
123  if (not backWrapChain.empty()) {
124  connectWireHitChains(wireHitChains.back(), backWrapChain);
125  }
126  if (backWrapChain.empty() and frontWrapChain.empty()) {
127  connectWireHitChains(wireHitChains.back(), wireHitChains.front());
128  }
129  }
130  }
131 
133  const std::vector<CDCWireHit*> wireHitPtrs = as_pointers<CDCWireHit>(inputWireHits);
134 
137 
138  B2ASSERT("Expect wire hit neighborhood to be symmetric ",
140 
141  m_wirehitClusterizer.apply(wireHitPtrs, m_wireHitRelations, outputSuperClusters);
142 
143  int iSuperCluster = -1;
144  for (CDCWireHitCluster& superCluster : outputSuperClusters) {
145  ++iSuperCluster;
146  superCluster.setISuperCluster(iSuperCluster);
147  for (CDCWireHit* wireHit : superCluster) {
148  wireHit->setISuperCluster(iSuperCluster);
149  }
150  std::sort(superCluster.begin(), superCluster.end());
151  }
152 }

The documentation for this class was generated from the following files:
Belle2::TrackFindingCDC::SuperClusterCreator::m_wirehitClusterizer
Clusterizer< CDCWireHit, CDCWireHitCluster > m_wirehitClusterizer
Instance of the hit cluster generator.
Definition: SuperClusterCreator.h:68
Belle2::TrackFindingCDC::CDCWireHit::getWireID
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
Definition: CDCWireHit.h:193
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::SuperClusterCreator::m_wireHitRelations
std::vector< WeightedRelation< CDCWireHit > > m_wireHitRelations
Memory for the wire hit neighborhood in a cluster.
Definition: SuperClusterCreator.h:71
Belle2::TrackFindingCDC::WeightedRelationUtil::areSymmetric
static bool areSymmetric(const AWeightedRelations &weightedRelations)
Checks for the symmetry of a range of weighted relations Explicitly checks for each weighted relation...
Definition: WeightedRelation.h:147
Belle2::TrackFindingCDC::SuperClusterCreator::m_param_expandOverApogeeGap
bool m_param_expandOverApogeeGap
Parameter : Expand the super clusters over the typical gap at the apogee of the trajectory.
Definition: SuperClusterCreator.h:64
Belle2::TrackFindingCDC::SuperClusterCreator::m_wireHitRelationFilter
WholeWireHitRelationFilter m_wireHitRelationFilter
Wire hit neighborhood relation filter.
Definition: SuperClusterCreator.h:74
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::WireID::getIWire
unsigned short getIWire() const
Getter for wire within the layer.
Definition: WireID.h:155