Belle II Software development
FacetCreator Class Referenceabstract

Class providing construction combinatorics for the facets. More...

#include <FacetCreator.h>

Inheritance diagram for FacetCreator:
Findlet< const TrackingUtilities::CDCWireHitCluster, TrackingUtilities::CDCFacet > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using IOTypes
 Types that should be served to apply on invocation.
 
using IOTypes
 Types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 

Public Member Functions

 FacetCreator ()
 Constructor adding the filter as a subordinary processing signal listener.
 
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 (const std::vector< TrackingUtilities::CDCWireHitCluster > &inputClusters, std::vector< TrackingUtilities::CDCFacet > &facets) final
 Central function creating the hit triplets from the clusters.
 
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
 Short hand for ToRangeImpl.
 
using ToVector
 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 = TrackingUtilities::Findlet<const TrackingUtilities::CDCWireHitCluster, TrackingUtilities::CDCFacet>
 Type of the base class.
 

Private Member Functions

void createFacets (const std::vector< TrackingUtilities::CDCWireHit * > &wireHits, const std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCWireHit > > &wireHitRelations, std::vector< TrackingUtilities::CDCFacet > &facets)
 Generates facets on the given wire hits generating neighboring triples of hits.
 
void createFacetsForHitTriple (const TrackingUtilities::CDCWireHit &startWireHit, const TrackingUtilities::CDCWireHit &middleWireHit, const TrackingUtilities::CDCWireHit &endWireHit, std::vector< TrackingUtilities::CDCFacet > &facets)
 Generates reconstruted facets on the three given wire hits by hypothesizing over the 8 left right passage combinations.
 

Private Attributes

bool m_param_feasibleRLOnly = true
 Parameter : Switch to apply the rl feasibility cut.
 
bool m_param_updateDriftLength = true
 Parameter : Switch to reestimate the drift length.
 
bool m_param_leastSquareFit = false
 Parameter : Switch to fit the facet with least square method for the drift length update.
 
BridgingWireHitRelationFilter m_wireHitRelationFilter
 The filter for the hit neighborhood.
 
FeasibleRLFacetFilter m_feasibleRLFacetFilter
 The feasibility filter for the right left passage information.
 
ChooseableFacetFilter m_facetFilter
 The filter to be used for the facet generation.
 
DriftLengthEstimator m_driftLengthEstimator
 Instance of the drift length estimator to be used.
 
std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCWireHit > > m_wireHitRelations
 Memory for the wire hit neighborhood in within a cluster.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized
 Flag to keep track whether initialization happened before.
 
bool m_terminated
 Flag to keep track whether termination happened before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Class providing construction combinatorics for the facets.

Definition at line 38 of file FacetCreator.h.

Member Typedef Documentation

◆ IOTypes [1/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOTypes [2/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors [1/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ IOVectors [2/2]

using IOVectors
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 42 of file FacetCreator.h.

◆ ToVector [1/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

◆ ToVector [2/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Constructor & Destructor Documentation

◆ FacetCreator()

Constructor adding the filter as a subordinary processing signal listener.

Definition at line 31 of file FacetCreator.cc.

32{
35}
BridgingWireHitRelationFilter m_wireHitRelationFilter
The filter for the hit neighborhood.
ChooseableFacetFilter m_facetFilter
The filter to be used for the facet generation.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener * psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 53 of file CompositeProcessingSignalListener.cc.

56{
58}
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition Findlet.h:26

◆ apply()

void apply ( const std::vector< TrackingUtilities::CDCWireHitCluster > & inputClusters,
std::vector< TrackingUtilities::CDCFacet > & facets )
final

Central function creating the hit triplets from the clusters.

Hit triplets are always contained within one cluster and the output hit triplets follow the order of the input clusters such that the triplets of the same cluster remain close to each other.

Definition at line 60 of file FacetCreator.cc.

61{
62 int iCluster = -1;
63 for (const CDCWireHitCluster& cluster : inputClusters) {
64 ++iCluster;
65 // Skip clusters that have been detected as background
66 if (cluster.getBackgroundFlag()) {
67 continue;
68 }
69 B2ASSERT("Expect the clusters to be sorted", std::is_sorted(cluster.begin(), cluster.end()));
70
71 // Obtain the set of wire hits as references
72 const std::vector<CDCWireHit*>& wireHits = cluster;
73
74 // Create the neighborhood of wire hits on the cluster
75 m_wireHitRelations.clear();
76 m_wireHitRelationFilter.prepare(wireHits);
78
79 // Create the facets
80 std::size_t nBefore = facets.size();
81 createFacets(cluster, m_wireHitRelations, facets);
82 std::size_t nAfter = facets.size();
83
84 VectorRange<CDCFacet> facetsInCluster(facets.begin() + nBefore, facets.begin() + nAfter);
85 // Sort the facets in their cluster
86 std::sort(facetsInCluster.begin(), facetsInCluster.end());
87
88 B2ASSERT("Expected all facets to be different",
89 std::adjacent_find(facetsInCluster.begin(), facetsInCluster.end()) ==
90 facetsInCluster.end());
91
92 for (CDCFacet& facet : facetsInCluster) {
93 facet.setICluster(iCluster);
94 }
95 }
96}
std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCWireHit > > m_wireHitRelations
Memory for the wire hit neighborhood in within a cluster.
void createFacets(const std::vector< TrackingUtilities::CDCWireHit * > &wireHits, const std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCWireHit > > &wireHitRelations, std::vector< TrackingUtilities::CDCFacet > &facets)
Generates facets on the given wire hits generating neighboring triples of hits.
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.

◆ beginEvent()

void beginEvent ( )
overrideinherited

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

Definition at line 36 of file CompositeProcessingSignalListener.cc.

32{
35 psl->beginEvent();
36 }
37}
void beginEvent() override
Receive and dispatch signal for the start of a new event.
virtual void beginEvent()
Receive signal for the start of a new event.

◆ beginRun()

void beginRun ( )
overrideinherited

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

Definition at line 33 of file CompositeProcessingSignalListener.cc.

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

◆ createFacets()

void createFacets ( const std::vector< TrackingUtilities::CDCWireHit * > & wireHits,
const std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCWireHit > > & wireHitRelations,
std::vector< TrackingUtilities::CDCFacet > & facets )
private

Generates facets on the given wire hits generating neighboring triples of hits.

Inserts the result to the end of the GenericFacetCollection.

Definition at line 98 of file FacetCreator.cc.

101{
102 for (const CDCWireHit* ptrMiddleWireHit : wireHits) {
103 if (not ptrMiddleWireHit) continue;
104 const CDCWireHit& middleWireHit = *ptrMiddleWireHit;
105 if (middleWireHit->hasTakenFlag()) continue;
106
107 const auto neighbors = asRange(
108 std::equal_range(wireHitRelations.begin(), wireHitRelations.end(), ptrMiddleWireHit));
109
110 for (const WeightedRelation<CDCWireHit>& startWireHitRelation : neighbors) {
111 const CDCWireHit* ptrStartWireHit(startWireHitRelation.getTo());
112
113 if (not ptrStartWireHit) continue;
114 const CDCWireHit& startWireHit = *ptrStartWireHit;
115 if (startWireHit->hasTakenFlag()) continue;
116
117 for (const WeightedRelation<CDCWireHit>& endWireHitRelation : neighbors) {
118 const CDCWireHit* ptrEndWireHit(endWireHitRelation.getTo());
119
120 if (not ptrEndWireHit) continue;
121 const CDCWireHit& endWireHit = *ptrEndWireHit;
122 if (endWireHit->hasTakenFlag()) continue;
123
124 // Skip combinations where the facet starts and ends on the same wire
125 if (ptrStartWireHit->isOnWire(ptrEndWireHit->getWire())) continue;
126
127 createFacetsForHitTriple(startWireHit, middleWireHit, endWireHit, facets);
128 } // end for itEndWireHit
129 } // end for itStartWireHit
130 } // end for itMiddleWireHit
131}
void createFacetsForHitTriple(const TrackingUtilities::CDCWireHit &startWireHit, const TrackingUtilities::CDCWireHit &middleWireHit, const TrackingUtilities::CDCWireHit &endWireHit, std::vector< TrackingUtilities::CDCFacet > &facets)
Generates reconstruted facets on the three given wire hits by hypothesizing over the 8 left right pas...
bool hasTakenFlag() const
Gets the current state of the taken marker flag.

◆ createFacetsForHitTriple()

void createFacetsForHitTriple ( const TrackingUtilities::CDCWireHit & startWireHit,
const TrackingUtilities::CDCWireHit & middleWireHit,
const TrackingUtilities::CDCWireHit & endWireHit,
std::vector< TrackingUtilities::CDCFacet > & facets )
private

Generates reconstruted facets on the three given wire hits by hypothesizing over the 8 left right passage combinations.

Inserts the result to the end of the GenericFacetCollection.

Prepare a facet - without fitted tangent lines.

Definition at line 133 of file FacetCreator.cc.

137{
139 CDCRLWireHit startRLWireHit(&startWireHit, ERightLeft::c_Left);
140 CDCRLWireHit middleRLWireHit(&middleWireHit, ERightLeft::c_Left);
141 CDCRLWireHit endRLWireHit(&endWireHit, ERightLeft::c_Left);
142 CDCFacet facet(startRLWireHit, middleRLWireHit, endRLWireHit, UncertainParameterLine2D());
143
144 // The shape of the hit triple does not depend on the right left passage hypotheses
145 const CDCRLWireHitTriple::Shape shape = facet.getShape();
147 shape.getCellExtend() + std::abs(shape.getOClockDelta()) > 6) {
148 // No right left passage combination is feasible for this shape - skip all of them
149 return;
150 }
151
152 // The middle right left passage hypothesis is scanned in the innermost loop:
153 // facets that differ only in it share the same start to end fit line, such that
154 // most of the drift length update can be reused between them.
155 for (ERightLeft startRLInfo : {ERightLeft::c_Left, ERightLeft::c_Right}) {
156 facet.setStartRLInfo(startRLInfo);
157 for (ERightLeft endRLInfo : {ERightLeft::c_Left, ERightLeft::c_Right}) {
158 facet.setEndRLInfo(endRLInfo);
159
160 // Results of the drift length update shared between the middle right left passage hypotheses
161 DriftLengthEstimator::FacetDriftLengthCache driftLengthCache;
162
163 for (ERightLeft middleRLInfo : {ERightLeft::c_Left, ERightLeft::c_Right}) {
164 facet.setMiddleRLInfo(middleRLInfo);
165
166 // Reset the lines
167 // The filter shall do the fitting of the tangent lines if it wants to.
168 // He should set them if he accepts the facet.
169 facet.invalidateFitLine();
170
172 // Same check as m_feasibleRLFacetFilter(facet) but reusing the precomputed shape
173 if (not m_feasibleRLFacetFilter.isFeasible(shape, startRLInfo, middleRLInfo, endRLInfo)) continue;
174 }
175
178 // The fitted line depends on the middle hit drift length - no sharing possible
179
180 // Reset drift length
181 facet.getStartRLWireHit().setRefDriftLength(startWireHit.getRefDriftLength());
182 facet.getMiddleRLWireHit().setRefDriftLength(middleWireHit.getRefDriftLength());
183 facet.getEndRLWireHit().setRefDriftLength(endWireHit.getRefDriftLength());
184
185 /*double chi2 =*/FacetFitter::fit(facet);
186
187 // Update drift length
188 m_driftLengthEstimator.updateDriftLength(facet);
189 } else {
190 if (not driftLengthCache.valid) {
191 // Reset drift length
192 facet.getStartRLWireHit().setRefDriftLength(startWireHit.getRefDriftLength());
193 facet.getMiddleRLWireHit().setRefDriftLength(middleWireHit.getRefDriftLength());
194 facet.getEndRLWireHit().setRefDriftLength(endWireHit.getRefDriftLength());
195
196 facet.adjustFitLine();
197 }
198
199 // Update drift length reusing the shareable results of the previous hypothesis
200 m_driftLengthEstimator.updateDriftLength(facet, driftLengthCache);
201 }
202 }
203
204 Weight weight = m_facetFilter(facet);
205
206 if (not std::isnan(weight)) {
207 facet.getAutomatonCell().setCellWeight(weight);
208 facets.insert(facets.end(), facet);
209 }
210 } // end for middleRLWireHit
211 } // end for endRLWireHit
212 } // end for startRLWireHit
213}
DriftLengthEstimator m_driftLengthEstimator
Instance of the drift length estimator to be used.
bool m_param_feasibleRLOnly
Parameter : Switch to apply the rl feasibility cut.
bool m_param_leastSquareFit
Parameter : Switch to fit the facet with least square method for the drift length update.
bool m_param_updateDriftLength
Parameter : Switch to reestimate the drift length.
FeasibleRLFacetFilter m_feasibleRLFacetFilter
The feasibility filter for the right left passage information.
static double fit(const TrackingUtilities::CDCFacet &facet, int nSteps=100, double maxChi2=std::numeric_limits< double >::infinity())
Fits a proper line to the facet and returns the chi2.
short getCellExtend() const
Getter for the sum of cell distances from start to middle and middle to end.
short getOClockDelta() const
Getter for the o'clock direction difference from start to middle compared to middle to end.

◆ endRun()

void endRun ( )
overrideinherited

Receive and dispatch signal for the end of the run.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
void endRun() override
Receive and dispatch signal for the end of the run.
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 CompositeProcessingSignalListener.

Definition at line 42 of file FacetCreator.cc.

43{
44 m_wireHitRelationFilter.exposeParameters(moduleParamList, prefix);
45 m_feasibleRLFacetFilter.exposeParameters(moduleParamList, prefix);
46 m_facetFilter.exposeParameters(moduleParamList, prefix);
47
48 moduleParamList->addParameter(prefixed(prefix, "updateDriftLength"),
50 "Switch to reestimate the drift length",
52
53 moduleParamList->addParameter(prefixed(prefix, "leastSquareFit"),
55 "Switch to fit the facet with the least square method "
56 "for drift length estimation",
58}
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< const TrackingUtilities::CDCWireHitCluster, TrackingUtilities::CDCFacet >.

Definition at line 37 of file FacetCreator.cc.

38{
39 return "Creates hit triplet (facets) from each cluster filtered by a acceptance criterion.";
40}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 56 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overrideinherited

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

Definition at line 30 of file CompositeProcessingSignalListener.cc.

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

◆ terminate()

void terminate ( )
overrideinherited

Receive and dispatch Signal for termination of the event processing.

Definition at line 42 of file CompositeProcessingSignalListener.cc.

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

Member Data Documentation

◆ m_driftLengthEstimator

DriftLengthEstimator m_driftLengthEstimator
private

Instance of the drift length estimator to be used.

Definition at line 103 of file FacetCreator.h.

◆ m_facetFilter

ChooseableFacetFilter m_facetFilter
private

The filter to be used for the facet generation.

Definition at line 100 of file FacetCreator.h.

◆ m_feasibleRLFacetFilter

FeasibleRLFacetFilter m_feasibleRLFacetFilter
private

The feasibility filter for the right left passage information.

Definition at line 97 of file FacetCreator.h.

◆ m_initialized

bool m_initialized
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_feasibleRLOnly

bool m_param_feasibleRLOnly = true
private

Parameter : Switch to apply the rl feasibility cut.

Definition at line 84 of file FacetCreator.h.

◆ m_param_leastSquareFit

bool m_param_leastSquareFit = false
private

Parameter : Switch to fit the facet with least square method for the drift length update.

Definition at line 90 of file FacetCreator.h.

◆ m_param_updateDriftLength

bool m_param_updateDriftLength = true
private

Parameter : Switch to reestimate the drift length.

Definition at line 87 of file FacetCreator.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 60 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated
privateinherited

Flag to keep track whether termination happened before.

Definition at line 55 of file ProcessingSignalListener.h.

◆ m_wireHitRelationFilter

BridgingWireHitRelationFilter m_wireHitRelationFilter
private

The filter for the hit neighborhood.

Definition at line 94 of file FacetCreator.h.

◆ m_wireHitRelations

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

Memory for the wire hit neighborhood in within a cluster.

Definition at line 107 of file FacetCreator.h.


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