Belle II Software  release-08-01-10
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 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 31 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 48 of file SuperClusterCreator.cc.

50 {
51  m_wireHitRelations.clear();
52 
54  auto wireHitsByLayer =
55  adjacent_groupby(inputWireHits.begin(), inputWireHits.end(), [](const CDCWireHit & wireHit) {
56  return wireHit.getWireID().getILayer();
57  });
58 
59  for (const auto& wireHitsInLayer : wireHitsByLayer) {
60  const CDCWireLayer& wireLayer = wireHitsInLayer.front().getWire().getWireLayer();
61  const int nWires = wireLayer.size();
62 
63  auto sameWireHitChain = [](const CDCWireHit & lhs, const CDCWireHit & rhs) {
64  return rhs.getWireID().getIWire() - lhs.getWireID().getIWire() == 1;
65  };
66 
67  auto wireHitChains =
68  unique_ranges(wireHitsInLayer.begin(), wireHitsInLayer.end(), sameWireHitChain);
69 
70  size_t nWireHits = 0;
71  for (const VectorRange<CDCWireHit>& wireHitChain : wireHitChains) {
72  nWireHits += wireHitChain.size();
73  }
74  assert(nWireHits == wireHitsInLayer.size());
75 
76  // Special treatment for the first and last wireHitChain as they might wrap around as one
77  VectorRange<CDCWireHit> frontWrapChain(wireHitsInLayer.begin(), wireHitsInLayer.begin());
78  VectorRange<CDCWireHit> backWrapChain(wireHitsInLayer.end(), wireHitsInLayer.end());
79  if (wireHitChains.size() > 1) {
80  if (wireHitChains.front().front().getWire().isPrimaryNeighborWith(
81  wireHitChains.back().back().getWire())) {
82  // Chains are touching
83  // Keep their information around but eliminate them from the regular chains
84  int wrapAroundChainSize = wireHitChains.front().size() + wireHitChains.back().size();
85  if (wrapAroundChainSize >= 5) {
86  // Warning reach over the local wire hit layer / outside the memory of the wire hit
87  // vector to transport the size.
88  frontWrapChain = wireHitChains.front();
89  frontWrapChain.first = frontWrapChain.end() - wrapAroundChainSize;
90 
91  backWrapChain = wireHitChains.back();
92  backWrapChain.second = backWrapChain.begin() + wrapAroundChainSize;
93 
94  wireHitChains.erase(wireHitChains.begin());
95  wireHitChains.pop_back();
96  }
97  }
98  }
99 
100  auto itLastChain = std::remove_if(wireHitChains.begin(), wireHitChains.end(), Size() < 5u);
101  wireHitChains.erase(itLastChain, wireHitChains.end());
102  if (wireHitChains.empty()) continue;
103 
104  auto connectWireHitChains = [this, nWires](const VectorRange<CDCWireHit>& lhs,
105  const VectorRange<CDCWireHit>& rhs) {
106  int iWireDelta = rhs.front().getWireID().getIWire() - lhs.back().getWireID().getIWire();
107  if (iWireDelta < 0) iWireDelta += nWires;
108  if (iWireDelta < static_cast<int>(lhs.size() + rhs.size())) {
109  m_wireHitRelations.push_back({&rhs.front(), 0, &lhs.back()});
110  m_wireHitRelations.push_back({&lhs.back(), 0, &rhs.front()});
111  }
112  return false;
113  };
114  // the return value is not needed
115  // cppcheck-suppress ignoredReturnValue
116  std::adjacent_find(wireHitChains.begin(), wireHitChains.end(), connectWireHitChains);
117 
118  if (not frontWrapChain.empty()) {
119  connectWireHitChains(frontWrapChain, wireHitChains.front());
120  }
121  if (not backWrapChain.empty()) {
122  connectWireHitChains(wireHitChains.back(), backWrapChain);
123  }
124  if (backWrapChain.empty() and frontWrapChain.empty()) {
125  connectWireHitChains(wireHitChains.back(), wireHitChains.front());
126  }
127  }
128  }
129 
131  const std::vector<CDCWireHit*> wireHitPtrs = as_pointers<CDCWireHit>(inputWireHits);
132 
135 
136  B2ASSERT("Expect wire hit neighborhood to be symmetric ",
138 
139  m_wirehitClusterizer.apply(wireHitPtrs, m_wireHitRelations, outputSuperClusters);
140 
141  int iSuperCluster = -1;
142  for (CDCWireHitCluster& superCluster : outputSuperClusters) {
143  ++iSuperCluster;
144  superCluster.setISuperCluster(iSuperCluster);
145  for (CDCWireHit* wireHit : superCluster) {
146  wireHit->setISuperCluster(iSuperCluster);
147  }
148  std::sort(superCluster.begin(), superCluster.end());
149  }
150 }
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
Definition: CDCWireHit.h:185
Class representating a sense wire layer in the central drift chamber.
Definition: CDCWireLayer.h:42
A pair of iterators usable with the range base for loop.
Definition: Range.h:25
Iterator begin() const
Begin of the range for range based for.
Definition: Range.h:64
Iterator end() const
End of the range for range based for.
Definition: Range.h:68
bool empty() const
Checks if the begin equals the end iterator, hence if the range is empty.
Definition: Range.h:72
Reference back() const
Returns the derefenced iterator before end()
Definition: Range.h:84
Reference front() const
Returns the derefenced iterator at begin()
Definition: Range.h:80
std::size_t size() const
Returns the total number of objects in this range.
Definition: Range.h:76
bool m_param_expandOverApogeeGap
Parameter : Expand the super clusters over the typical gap at the apogee of the trajectory.
std::vector< WeightedRelation< CDCWireHit > > m_wireHitRelations
Memory for the wire hit neighborhood in a cluster.
Clusterizer< CDCWireHit, CDCWireHitCluster > m_wirehitClusterizer
Instance of the hit cluster generator.
WholeWireHitRelationFilter m_wireHitRelationFilter
Wire hit neighborhood relation filter.
unsigned short getIWire() const
Getter for wire within the layer.
Definition: WireID.h:145
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.
Functor to get the .size() from an abitrary objects.
Definition: Functional.h:318
Utility structure with functions related to weighted relations.

The documentation for this class was generated from the following files: