Belle II Software development
SuperClusterCreator Class Referenceabstract

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

#include <SuperClusterCreator.h>

Inheritance diagram for SuperClusterCreator:
Findlet< CDCWireHit &, CDCWireHitCluster > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

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

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.
 
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 happened before.
 
bool m_terminated = false
 Flag to keep track whether termination happened 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 Typedef Documentation

◆ IOTypes

using IOTypes = std::tuple<AIOTypes...>
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors

using IOVectors = std::tuple< std::vector<AIOTypes>... >
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

Type of the base class.

Definition at line 35 of file SuperClusterCreator.h.

◆ ToVector

using ToVector = typename ToVectorImpl<T>::Type
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Constructor & Destructor Documentation

◆ SuperClusterCreator()

Constructor.

Definition at line 30 of file SuperClusterCreator.cc.

31{
33}
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
WholeWireHitRelationFilter m_wireHitRelationFilter
Wire hit neighborhood relation filter.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 55 of file CompositeProcessingSignalListener.cc.

56{
58}
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
References to subordinary signal processing listener contained in this findlet.

◆ 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 51 of file SuperClusterCreator.cc.

53{
54 m_wireHitRelations.clear();
55
57 auto wireHitsByLayer =
58 adjacent_groupby(inputWireHits.begin(), inputWireHits.end(), [](const CDCWireHit & wireHit) {
59 return wireHit.getWireID().getILayer();
60 });
61
62 for (const auto& wireHitsInLayer : wireHitsByLayer) {
63 const CDCWireLayer& wireLayer = wireHitsInLayer.front().getWire().getWireLayer();
64 const int nWires = wireLayer.size();
65
66 auto sameWireHitChain = [](const CDCWireHit & lhs, const CDCWireHit & rhs) {
67 return rhs.getWireID().getIWire() - lhs.getWireID().getIWire() == 1;
68 };
69
70 auto wireHitChains =
71 unique_ranges(wireHitsInLayer.begin(), wireHitsInLayer.end(), sameWireHitChain);
72
73 size_t nWireHits = 0;
74 for (const VectorRange<CDCWireHit>& wireHitChain : wireHitChains) {
75 nWireHits += wireHitChain.size();
76 }
77 assert(nWireHits == wireHitsInLayer.size());
78
79 // Special treatment for the first and last wireHitChain as they might wrap around as one
80 VectorRange<CDCWireHit> frontWrapChain(wireHitsInLayer.begin(), wireHitsInLayer.begin());
81 VectorRange<CDCWireHit> backWrapChain(wireHitsInLayer.end(), wireHitsInLayer.end());
82 if (wireHitChains.size() > 1) {
83 if (wireHitChains.front().front().getWire().isPrimaryNeighborWith(
84 wireHitChains.back().back().getWire())) {
85 // Chains are touching
86 // Keep their information around but eliminate them from the regular chains
87 int wrapAroundChainSize = wireHitChains.front().size() + wireHitChains.back().size();
88 if (wrapAroundChainSize >= 5) {
89 // Warning reach over the local wire hit layer / outside the memory of the wire hit
90 // vector to transport the size.
91 frontWrapChain = wireHitChains.front();
92 frontWrapChain.first = frontWrapChain.end() - wrapAroundChainSize;
93
94 backWrapChain = wireHitChains.back();
95 backWrapChain.second = backWrapChain.begin() + wrapAroundChainSize;
96
97 wireHitChains.erase(wireHitChains.begin());
98 wireHitChains.pop_back();
99 }
100 }
101 }
102
103 auto itLastChain = std::remove_if(wireHitChains.begin(), wireHitChains.end(), Size() < 5u);
104 wireHitChains.erase(itLastChain, wireHitChains.end());
105 if (wireHitChains.empty()) continue;
106
107 auto connectWireHitChains = [this, nWires](const VectorRange<CDCWireHit>& lhs,
108 const VectorRange<CDCWireHit>& rhs) {
109 int iWireDelta = rhs.front().getWireID().getIWire() - lhs.back().getWireID().getIWire();
110 if (iWireDelta < 0) iWireDelta += nWires;
111 if (iWireDelta < static_cast<int>(lhs.size() + rhs.size())) {
112 m_wireHitRelations.push_back({&rhs.front(), 0, &lhs.back()});
113 m_wireHitRelations.push_back({&lhs.back(), 0, &rhs.front()});
114 }
115 return false;
116 };
117 // the return value is not needed
118 std::ignore = 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}
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 representing 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 dereferenced iterator before end()
Definition: Range.h:84
Reference front() const
Returns the dereferenced 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.
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 arbitrary objects.
Definition: Functional.h:318
Utility structure with functions related to weighted relations.

◆ beginEvent()

void beginEvent ( )
overridevirtualinherited

Receive and dispatch signal for the start of a new event.

Reimplemented from ProcessingSignalListener.

Reimplemented in SpacePointTagger< Belle2::CKFToPXDResult, Belle2::PXDCluster >, SpacePointTagger< Belle2::CKFToSVDResult, Belle2::SVDCluster >, BaseEventTimeExtractor< RecoTrack * >, BaseEventTimeExtractor< TrackFindingCDC::CDCWireHit & >, SharingHitsMatcher< Belle2::TrackFindingCDC::CDCTrack, Belle2::TrackFindingCDC::CDCSegment2D >, MCSymmetric< BaseAxialSegmentPairFilter >, MCSymmetric< BaseFacetFilter >, MCSymmetric< BaseFacetRelationFilter >, MCSymmetric< BaseSegmentPairFilter >, MCSymmetric< BaseSegmentPairRelationFilter >, MCSymmetric< BaseSegmentRelationFilter >, MCSymmetric< BaseSegmentTripleFilter >, MCSymmetric< BaseSegmentTripleRelationFilter >, MCSymmetric< BaseTrackRelationFilter >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCFacet >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCWireHit, true >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegment2D >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCTrack >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentPair >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentTriple >, RecoTrackStorer, ROIFinder, and SVDHoughTracking.

Definition at line 31 of file CompositeProcessingSignalListener.cc.

32{
35 psl->beginEvent();
36 }
37}
Interface for an algorithm part that needs to receive the module processing signals.
virtual void beginEvent()
Receive signal for the start of a new event.

◆ beginRun()

void beginRun ( )
overridevirtualinherited

Receive and dispatch signal for the beginning of a new run.

Reimplemented from ProcessingSignalListener.

Reimplemented in LayerRelationFilter< AFilter >, FourHitFilter, QualityIndicatorFilter, ThreeHitFilter, TwoHitVirtualIPFilter, TwoHitVirtualIPQIFilter, RecoTrackStorer, ROIFinder, SpacePointLoaderAndPreparer, and TrackCandidateResultRefiner.

Definition at line 23 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
virtual void beginRun()
Receive signal for the beginning of a new run.

◆ endRun()

void endRun ( )
overridevirtualinherited

Receive and dispatch signal for the end of the run.

Reimplemented from ProcessingSignalListener.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
virtual void endRun()
Receive signal for the end of the run.

◆ exposeParameters()

void exposeParameters ( ModuleParamList moduleParamList,
const std::string &  prefix 
)
finalvirtual

Expose the parameters to a module.

Reimplemented from Findlet< CDCWireHit &, CDCWireHitCluster >.

Definition at line 41 of file SuperClusterCreator.cc.

42{
43 moduleParamList->addParameter(prefixed(prefix, "expandOverApogeeGap"),
45 "Expand the super clusters over the typical gap at the apogee of the trajectory",
47
48 m_wireHitRelationFilter.exposeParameters(moduleParamList, prefix);
49}
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ getDescription()

std::string getDescription ( )
finalvirtual

Short description of the findlet.

Reimplemented from Findlet< CDCWireHit &, CDCWireHitCluster >.

Definition at line 35 of file SuperClusterCreator.cc.

36{
37 return "Groups the wire hits into super cluster by expanding the secondary wire "
38 "neighborhood";
39}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overridevirtualinherited

Receive and dispatch signal before the start of the event processing.

Reimplemented from ProcessingSignalListener.

Reimplemented in UnionVarSet< AObject >, UnionVarSet< Object >, VariadicUnionVarSet< AVarSets >, ResultStorer< Belle2::CKFToPXDResult >, ResultStorer< Belle2::CKFToSVDResult >, BaseEventTimeExtractor< RecoTrack * >, BaseEventTimeExtractor< TrackFindingCDC::CDCWireHit & >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >, OnVarSet< Filter< ATruthVarSet::Object > >, OnVarSet< Filter< AVarSet::Object > >, OnVarSet< BaseFacetFilter >, OnVarSet< BaseFacetRelationFilter >, OnVarSet< BaseAxialSegmentPairFilter >, OnVarSet< BaseSegmentRelationFilter >, OnVarSet< BaseTrackRelationFilter >, OnVarSet< BaseSegmentPairRelationFilter >, MCSymmetric< BaseAxialSegmentPairFilter >, MCSymmetric< BaseFacetFilter >, MCSymmetric< BaseFacetRelationFilter >, MCSymmetric< BaseSegmentPairFilter >, MCSymmetric< BaseSegmentPairRelationFilter >, MCSymmetric< BaseSegmentRelationFilter >, MCSymmetric< BaseSegmentTripleFilter >, MCSymmetric< BaseSegmentTripleRelationFilter >, MCSymmetric< BaseTrackRelationFilter >, StoreArrayLoader< const Belle2::SpacePoint >, StoreArrayLoader< DataStoreInputTypeRefType >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCFacet >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCWireHit, true >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegment2D >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCTrack >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentPair >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentTriple >, RelationVarSet< ABaseVarSet >, QualityIndicatorFilter, TwoHitVirtualIPQIFilter, MultiHoughSpaceFastInterceptFinder, RawTrackCandCleaner< AHit >, RawTrackCandCleaner< Belle2::vxdHoughTracking::VXDHoughState >, RecoTrackStorer, ROIFinder, SingleHoughSpaceFastInterceptFinder, SpacePointLoaderAndPreparer, TrackCandidateOverlapResolver, and TrackCandidateResultRefiner.

Definition at line 15 of file CompositeProcessingSignalListener.cc.

16{
19 psl->initialize();
20 }
21}
virtual void initialize()
Receive signal before the start of the event processing.

◆ terminate()

void terminate ( )
overridevirtualinherited

Receive and dispatch Signal for termination of the event processing.

Reimplemented from ProcessingSignalListener.

Reimplemented in StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, and StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >.

Definition at line 47 of file CompositeProcessingSignalListener.cc.

48{
50 psl->terminate();
51 }
53}
virtual void terminate()
Receive Signal for termination of the event processing.

Member Data Documentation

◆ m_initialized

bool m_initialized = false
privateinherited

Flag to keep track whether initialization happened before.

Definition at line 52 of file ProcessingSignalListener.h.

◆ m_initializedAs

std::string m_initializedAs
privateinherited

Name of the type during initialisation.

Definition at line 58 of file ProcessingSignalListener.h.

◆ m_param_expandOverApogeeGap

bool m_param_expandOverApogeeGap = false
private

Parameter : Expand the super clusters over the typical gap at the apogee of the trajectory.

Definition at line 54 of file SuperClusterCreator.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 52 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated = false
privateinherited

Flag to keep track whether termination happened before.

Definition at line 55 of file ProcessingSignalListener.h.

◆ m_wirehitClusterizer

Clusterizer<CDCWireHit, CDCWireHitCluster> m_wirehitClusterizer
private

Instance of the hit cluster generator.

Definition at line 58 of file SuperClusterCreator.h.

◆ m_wireHitRelationFilter

WholeWireHitRelationFilter m_wireHitRelationFilter {2}
private

Wire hit neighborhood relation filter.

Definition at line 64 of file SuperClusterCreator.h.

◆ m_wireHitRelations

std::vector<WeightedRelation<CDCWireHit> > m_wireHitRelations
private

Memory for the wire hit neighborhood in a cluster.

Definition at line 61 of file SuperClusterCreator.h.


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