Belle II Software development
SegmentAliasResolver Class Referenceabstract

Resolves between the potential alias versions of the segments and contained hits. More...

#include <SegmentAliasResolver.h>

Inheritance diagram for SegmentAliasResolver:
Findlet< CDCSegment2D & > 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

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 initialize () final
 Signals the beginning of the event processing.
 
void apply (std::vector< CDCSegment2D > &outputSegments) final
 Main algorithm applying the fit to each segment.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
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< CDCSegment2D & >
 Type of the base class.
 

Private Member Functions

void refit (CDCSegment2D &segment, bool reestimate)
 Fit the alias segment.
 

Private Attributes

std::vector< std::string > m_param_investigateAlias = { "cross", "borders", }
 Parameter : Which alias resolutions should be applied.
 
bool m_fullAlias = false
 Switch whether the complete segment should be aliased.
 
bool m_crossAliases = false
 Switch whether the segment should be aliased at the waist where an rl side switch was missed.
 
bool m_borderAliases = false
 Switch whether the border hits at the beginning and the end should be aliased.
 
bool m_middleAliases = false
 Switch whether the hits in the middle with lowest drift radius should be aliased.
 
bool m_param_reestimateDriftLength = true
 Parameter : Switch to reestimate the drift length before each fit.
 
bool m_param_reestimatePositions = false
 Parameter : Switch to restimate the reconstructed positions with a pass of facets.
 
CDCRiemannFitter m_riemannFitter
 Instance of the riemann fitter to be used.
 
DriftLengthEstimator m_driftLengthEstimator
 Instance of the drift length estimator to be used.
 
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

Resolves between the potential alias versions of the segments and contained hits.

Definition at line 29 of file SegmentAliasResolver.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

using Super = Findlet<CDCSegment2D&>
private

Type of the base class.

Definition at line 33 of file SegmentAliasResolver.h.

◆ ToVector

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

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

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< CDCSegment2D > &  outputSegments)
final

Main algorithm applying the fit to each segment.

Definition at line 80 of file SegmentAliasResolver.cc.

81{
82 if (m_fullAlias) {
83 for (CDCSegment2D& segment : outputSegments) {
84 if (segment->hasAliasFlag()) continue; // A full alias has been found in the facet ca.
85 int nRLSwitches = segment.getNRLSwitches();
86 // Sufficiently right left constrained that the alias is already fixed.
87 bool aliasStable = nRLSwitches > 2;
88 if (aliasStable) continue;
89
90 CDCSegment2D aliasSegment = segment.getAlias();
91 refit(aliasSegment, true);
92 swapBetterChi2(segment, aliasSegment);
93 } // end alias loop
94 }
95
96 // Detect whether the segment has a waist and flip the rest of the segment to right
97 if (m_crossAliases) {
98 for (CDCSegment2D& segment : outputSegments) {
99 int nRLSwitches = segment.getNRLSwitches();
100 // Sufficiently right left constrained that the alias is already fixed.
101 bool aliasStable = nRLSwitches > 2;
102 if (aliasStable) continue;
103
104 if (nRLSwitches == 1) {
105 // One RL switch. Try the all left and all right aliases
106 CDCSegment2D rightSegment = segment;
107 CDCSegment2D leftSegment = segment;
108 for (CDCRecoHit2D& recoHit2D : rightSegment) {
109 if (recoHit2D.getRLInfo() == ERightLeft::c_Left) {
110 recoHit2D = recoHit2D.getAlias();
111 }
112 }
113
114 for (CDCRecoHit2D& recoHit2D : leftSegment) {
115 if (recoHit2D.getRLInfo() == ERightLeft::c_Right) {
116 recoHit2D = recoHit2D.getAlias();
117 }
118 }
119 refit(rightSegment, true);
120 refit(leftSegment, true);
121 swapBetterChi2(segment, rightSegment);
122 swapBetterChi2(segment, leftSegment);
123
124 } else if (nRLSwitches == 0) {
125 // No RL switch. Try to introduce one at the smallest drift length
126 CDCSegment2D frontCrossSegment = segment;
127 CDCSegment2D backCrossSegment = segment;
128
129 auto lessDriftLength = [](const CDCRecoHit2D & lhs, const CDCRecoHit2D & rhs) {
130 return lhs.getRefDriftLength() < rhs.getRefDriftLength();
131 };
132
133 // Alias before the minimal drift length
134 {
135 auto itMinLRecoHit2D =
136 std::min_element(frontCrossSegment.begin(), frontCrossSegment.end(), lessDriftLength);
137 for (CDCRecoHit2D& recoHit2D : asRange(frontCrossSegment.begin(), itMinLRecoHit2D)) {
138 recoHit2D = recoHit2D.getAlias();
139 }
140 }
141
142 // Alias after the minimal drift length
143 {
144 auto itMinLRecoHit2D =
145 std::min_element(backCrossSegment.begin(), backCrossSegment.end(), lessDriftLength);
146 for (CDCRecoHit2D& recoHit2D : asRange(itMinLRecoHit2D, backCrossSegment.end())) {
147 recoHit2D = recoHit2D.getAlias();
148 }
149 }
150 refit(frontCrossSegment, true);
151 refit(backCrossSegment, true);
152 swapBetterChi2(segment, frontCrossSegment);
153 swapBetterChi2(segment, backCrossSegment);
154 }
155 }
156 }
157
158 if (m_borderAliases) {
159 for (CDCSegment2D& segment : outputSegments) {
160 // Check aliasing last hit
161 CDCSegment2D aliasSegment = segment;
162 CDCRecoHit2D& aliasHit = aliasSegment.back();
163 aliasHit.reverse();
164 aliasHit.setRecoPos2D(Vector2D(NAN, NAN));
165 if (aliasHit.getRefDriftLength() < 0.2) {
166 refit(aliasSegment, false);
167 Vector2D recoPos2D = aliasSegment.getTrajectory2D().getClosest(aliasHit.getRefPos2D());
168 ERightLeft rlInfo = aliasSegment.getTrajectory2D().isRightOrLeft(aliasHit.getRefPos2D());
169 aliasHit.setRecoPos2D(recoPos2D);
170 aliasHit.setRLInfo(rlInfo);
171 swapBetterChi2(segment, aliasSegment);
172 }
173 }
174
175 for (CDCSegment2D& segment : outputSegments) {
176 // Check aliasing first hit
177 CDCSegment2D aliasSegment = segment;
178 CDCRecoHit2D& aliasHit = aliasSegment.front();
179 aliasHit.reverse();
180 aliasHit.setRecoPos2D(Vector2D(NAN, NAN));
181 if (aliasHit.getRefDriftLength() < 0.2) {
182 refit(aliasSegment, false);
183 Vector2D recoPos2D = aliasSegment.getTrajectory2D().getClosest(aliasHit.getRefPos2D());
184 ERightLeft rlInfo = aliasSegment.getTrajectory2D().isRightOrLeft(aliasHit.getRefPos2D());
185 aliasHit.setRecoPos2D(recoPos2D);
186 aliasHit.setRLInfo(rlInfo);
187 swapBetterChi2(segment, aliasSegment);
188 }
189 }
190 }// end if (m_borderAliases)
191
192 if (m_middleAliases) {
193 for (CDCSegment2D& segment : outputSegments) {
194 // Check aliasing hit with lowest drift length
195 CDCSegment2D aliasSegment = segment;
196
197 // Find hit with minimal drift length
198 double minimalDriftLength = 0.1;
199 CDCRecoHit2D* minimalHit = nullptr;
200 for (CDCRecoHit2D& aliasHit : aliasSegment) {
201 if (aliasHit.getRefDriftLength() < minimalDriftLength) {
202 minimalHit = &aliasHit;
203 minimalDriftLength = aliasHit.getRefDriftLength();
204 }
205 }
206 if (minimalHit) {
207 CDCRecoHit2D& aliasHit = *minimalHit;
208 aliasHit.reverse();
209 aliasHit.setRecoPos2D(Vector2D(NAN, NAN));
210 refit(aliasSegment, false);
211 Vector2D recoPos2D = aliasSegment.getTrajectory2D().getClosest(aliasHit.getRefPos2D());
212 ERightLeft rlInfo = aliasSegment.getTrajectory2D().isRightOrLeft(aliasHit.getRefPos2D());
213 aliasHit.setRecoPos2D(recoPos2D);
214 aliasHit.setRLInfo(rlInfo);
215 swapBetterChi2(segment, aliasSegment);
216 }
217 }
218 }
219
220 std::sort(outputSegments.begin(), outputSegments.end());
221}
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
void setRLInfo(ERightLeft &rlInfo)
Setter the right left passage information.
Definition: CDCRecoHit2D.h:211
void reverse()
Turns the orientation in place.
Definition: CDCRecoHit2D.cc:93
double getRefDriftLength() const
Getter for the drift length at the wire reference position.
Definition: CDCRecoHit2D.h:217
const Vector2D & getRefPos2D() const
Getter for the reference position of the wire.
Definition: CDCRecoHit2D.h:181
void setRecoPos2D(const Vector2D &recoPos2D)
Setter for the position in the reference plane.
Definition: CDCRecoHit2D.h:244
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
CDCTrajectory2D & getTrajectory2D() const
Getter for the two dimensional trajectory fitted to the segment.
Definition: CDCSegment.h:69
ERightLeft isRightOrLeft(const Vector2D &point) const
Checks if the given point is to the right or to the left of the trajectory.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
bool m_middleAliases
Switch whether the hits in the middle with lowest drift radius should be aliased.
void refit(CDCSegment2D &segment, bool reestimate)
Fit the alias segment.
bool m_fullAlias
Switch whether the complete segment should be aliased.
bool m_borderAliases
Switch whether the border hits at the beginning and the end should be aliased.
bool m_crossAliases
Switch whether the segment should be aliased at the waist where an rl side switch was missed.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25

◆ 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< CDCSegment2D & >.

Definition at line 43 of file SegmentAliasResolver.cc.

44{
45 moduleParamList->addParameter(prefixed(prefix, "investigateAlias"),
47 "Which alias resolutions should be applied. "
48 "Options are trailing_hit, last_hit, full.",
50
51 moduleParamList->addParameter(prefixed(prefix, "reestimateDriftLength"),
53 "Switch to reestimate the drift length in the alias resolver",
55
56 moduleParamList->addParameter(prefixed(prefix, "reestimatePositions"),
58 "Switch to reestimate the reconstructed positions in the alias resolver",
60}
bool m_param_reestimatePositions
Parameter : Switch to restimate the reconstructed positions with a pass of facets.
std::vector< std::string > m_param_investigateAlias
Parameter : Which alias resolutions should be applied.
bool m_param_reestimateDriftLength
Parameter : Switch to reestimate the drift length before each fit.
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< CDCSegment2D & >.

Definition at line 38 of file SegmentAliasResolver.cc.

39{
40 return "Resolves the rl aliasing of segments in various scenarios";
41}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
finalvirtual

Signals the beginning of the event processing.

Reimplemented from ProcessingSignalListener.

Definition at line 62 of file SegmentAliasResolver.cc.

63{
65 for (const std::string& investigatedAlias : m_param_investigateAlias) {
66 if (investigatedAlias == "full") {
67 m_fullAlias = true;
68 } else if (investigatedAlias == "cross") {
69 m_crossAliases = true;
70 } else if (investigatedAlias == "borders") {
71 m_borderAliases = true;
72 } else if (investigatedAlias == "middle") {
73 m_middleAliases = true;
74 } else {
75 B2ERROR("Unknown alias to investigate " << investigatedAlias);
76 }
77 }
78}
void initialize() override
Receive and dispatch signal before the start of the event processing.

◆ refit()

void refit ( CDCSegment2D segment,
bool  reestimate 
)
private

Fit the alias segment.

Definition at line 223 of file SegmentAliasResolver.cc.

224{
225 if (reestimate) {
227 CDCRLWireHitSegment rlWireHitSegment = segment.getRLWireHitSegment();
228 // Reset the drift length to the default values.
229 for (CDCRLWireHit& rlWireHit : rlWireHitSegment) {
230 rlWireHit.setRefDriftLength(rlWireHit.getWireHit().getRefDriftLength());
231 }
232 CDCFacetSegment facetSegment = CDCFacetSegment::create(rlWireHitSegment);
233 for (CDCFacet& facet : facetSegment) {
234 facet.adjustFitLine();
237 }
238 }
239 CDCSegment2D replacement = CDCSegment2D::condense(facetSegment);
240 segment = replacement;
241 }
242
245 }
246 }
247
248 const EFitPos fitPos = EFitPos::c_RecoPos;
249 const EFitVariance fitVariance = EFitVariance::c_Proper;
250 CDCObservations2D observations2D(fitPos, fitVariance);
251 observations2D.appendRange(segment);
252 if (observations2D.size() < 4) {
253 segment.getTrajectory2D().clear();
254 } else {
255 CDCTrajectory2D trajectory2D = m_riemannFitter.fit(observations2D);
256 segment.setTrajectory2D(trajectory2D);
257 }
258
259}
A segment consisting of adjacent facets.
static CDCFacetSegment create(const CDCRLWireHitSegment &rlWireHitSegment)
Construct a train of facets from the given oriented wire hits.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:32
CDCTrajectory2D fit(const CDCObservations2D &observations2D) const
Fits a collection of observation drift circles.
Class serving as a storage of observed drift circles to present to the Riemann fitter.
A segment consisting of two dimensional reconstructed hits.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
static CDCSegment2D condense(const CDCTangentSegment &tangentSegment)
Averages the reconstructed positions from hits that overlap in adjacent tangents in the given tangent...
Particle trajectory as it is seen in xy projection represented as a circle.
DriftLengthEstimator m_driftLengthEstimator
Instance of the drift length estimator to be used.
CDCRiemannFitter m_riemannFitter
Instance of the riemann fitter to be used.
double updateDriftLength(CDCRecoHit2D &recoHit2D)
Update the drift length of the reconstructed hit in place.

◆ 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_borderAliases

bool m_borderAliases = false
private

Switch whether the border hits at the beginning and the end should be aliased.

Definition at line 64 of file SegmentAliasResolver.h.

◆ m_crossAliases

bool m_crossAliases = false
private

Switch whether the segment should be aliased at the waist where an rl side switch was missed.

Definition at line 61 of file SegmentAliasResolver.h.

◆ m_driftLengthEstimator

DriftLengthEstimator m_driftLengthEstimator
private

Instance of the drift length estimator to be used.

Definition at line 79 of file SegmentAliasResolver.h.

◆ m_fullAlias

bool m_fullAlias = false
private

Switch whether the complete segment should be aliased.

Definition at line 58 of file SegmentAliasResolver.h.

◆ 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_middleAliases

bool m_middleAliases = false
private

Switch whether the hits in the middle with lowest drift radius should be aliased.

Definition at line 67 of file SegmentAliasResolver.h.

◆ m_param_investigateAlias

std::vector<std::string> m_param_investigateAlias = { "cross", "borders", }
private

Parameter : Which alias resolutions should be applied.

Definition at line 55 of file SegmentAliasResolver.h.

◆ m_param_reestimateDriftLength

bool m_param_reestimateDriftLength = true
private

Parameter : Switch to reestimate the drift length before each fit.

Definition at line 70 of file SegmentAliasResolver.h.

◆ m_param_reestimatePositions

bool m_param_reestimatePositions = false
private

Parameter : Switch to restimate the reconstructed positions with a pass of facets.

Definition at line 73 of file SegmentAliasResolver.h.

◆ m_riemannFitter

CDCRiemannFitter m_riemannFitter
private

Instance of the riemann fitter to be used.

Definition at line 76 of file SegmentAliasResolver.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.


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