8#include <tracking/trackFindingCDC/findlets/minimal/SegmentAliasResolver.h>
10#include <tracking/trackFindingCDC/fitting/CDCObservations2D.h>
12#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13#include <tracking/trackFindingCDC/eventdata/segments/CDCFacetSegment.h>
14#include <tracking/trackFindingCDC/eventdata/segments/CDCRLWireHitSegment.h>
15#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
17#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
19#include <framework/core/ModuleParamList.templateDetails.h>
24using namespace TrackFindingCDC;
31 aliasTrajectory2D.
getChi2() < segment.getTrajectory2D().getChi2()) {
33 std::swap(segment, aliasSegment);
40 return "Resolves the rl aliasing of segments in various scenarios";
45 moduleParamList->
addParameter(prefixed(prefix,
"investigateAlias"),
47 "Which alias resolutions should be applied. "
48 "Options are trailing_hit, last_hit, full.",
51 moduleParamList->
addParameter(prefixed(prefix,
"reestimateDriftLength"),
53 "Switch to reestimate the drift length in the alias resolver",
56 moduleParamList->
addParameter(prefixed(prefix,
"reestimatePositions"),
58 "Switch to reestimate the reconstructed positions in the alias resolver",
66 if (investigatedAlias ==
"full") {
68 }
else if (investigatedAlias ==
"cross") {
70 }
else if (investigatedAlias ==
"borders") {
72 }
else if (investigatedAlias ==
"middle") {
75 B2ERROR(
"Unknown alias to investigate " << investigatedAlias);
84 if (segment->hasAliasFlag())
continue;
85 int nRLSwitches = segment.getNRLSwitches();
87 bool aliasStable = nRLSwitches > 2;
88 if (aliasStable)
continue;
91 refit(aliasSegment,
true);
92 swapBetterChi2(segment, aliasSegment);
99 int nRLSwitches = segment.getNRLSwitches();
101 bool aliasStable = nRLSwitches > 2;
102 if (aliasStable)
continue;
104 if (nRLSwitches == 1) {
109 if (recoHit2D.getRLInfo() == ERightLeft::c_Left) {
110 recoHit2D = recoHit2D.getAlias();
115 if (recoHit2D.getRLInfo() == ERightLeft::c_Right) {
116 recoHit2D = recoHit2D.getAlias();
119 refit(rightSegment,
true);
120 refit(leftSegment,
true);
121 swapBetterChi2(segment, rightSegment);
122 swapBetterChi2(segment, leftSegment);
124 }
else if (nRLSwitches == 0) {
135 auto itMinLRecoHit2D =
136 std::min_element(frontCrossSegment.begin(), frontCrossSegment.end(), lessDriftLength);
137 for (
CDCRecoHit2D& recoHit2D : asRange(frontCrossSegment.begin(), itMinLRecoHit2D)) {
138 recoHit2D = recoHit2D.getAlias();
144 auto itMinLRecoHit2D =
145 std::min_element(backCrossSegment.begin(), backCrossSegment.end(), lessDriftLength);
146 for (
CDCRecoHit2D& recoHit2D : asRange(itMinLRecoHit2D, backCrossSegment.end())) {
147 recoHit2D = recoHit2D.getAlias();
150 refit(frontCrossSegment,
true);
151 refit(backCrossSegment,
true);
152 swapBetterChi2(segment, frontCrossSegment);
153 swapBetterChi2(segment, backCrossSegment);
166 refit(aliasSegment,
false);
171 swapBetterChi2(segment, aliasSegment);
182 refit(aliasSegment,
false);
187 swapBetterChi2(segment, aliasSegment);
198 double minimalDriftLength = 0.1;
201 if (aliasHit.getRefDriftLength() < minimalDriftLength) {
202 minimalHit = &aliasHit;
210 refit(aliasSegment,
false);
215 swapBetterChi2(segment, aliasSegment);
220 std::sort(outputSegments.begin(), outputSegments.end());
230 rlWireHit.setRefDriftLength(rlWireHit.getWireHit().getRefDriftLength());
233 for (
CDCFacet& facet : facetSegment) {
234 facet.adjustFitLine();
240 segment = replacement;
248 const EFitPos fitPos = EFitPos::c_RecoPos;
249 const EFitVariance fitVariance = EFitVariance::c_Proper;
252 if (observations2D.
size() < 4) {
253 segment.getTrajectory2D().clear();
256 segment.setTrajectory2D(trajectory2D);
The Module parameter list class.
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.
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.
std::size_t appendRange(const CDCSegment2D &segment2D)
Appends all reconstructed hits from the two dimensional segment.
std::size_t size() const
Returns the number of observations stored.
A segment consisting of two dimensional reconstructed hits.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Class representing a two dimensional reconstructed hit in the central drift chamber.
void setRLInfo(ERightLeft &rlInfo)
Setter the right left passage information.
void reverse()
Turns the orientation in place.
double getRefDriftLength() const
Getter for the drift length at the wire reference position.
const Vector2D & getRefPos2D() const
Getter for the reference position of the wire.
void setRecoPos2D(const Vector2D &recoPos2D)
Setter for the position in the reference plane.
A reconstructed sequence of two dimensional hits in one super layer.
static CDCSegment2D condense(const CDCTangentSegment &tangentSegment)
Averages the reconstructed positions from hits that overlap in adjacent tangents in the given tangent...
CDCTrajectory2D & getTrajectory2D() const
Getter for the two dimensional trajectory fitted to the segment.
void setAliasScore(double aliasScore)
Setter for the flag that this segment may have an aliased version.
Particle trajectory as it is seen in xy projection represented as a circle.
double getChi2() const
Getter for the chi2 value of the circle fit.
bool isFitted() const
Checks if the circle is already set to a valid value.
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.
void initialize() override
Receive and dispatch signal before the start of the event processing.
DriftLengthEstimator m_driftLengthEstimator
Instance of the drift length estimator to be used.
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.
void initialize() final
Signals the beginning of the event processing.
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.
bool m_fullAlias
Switch whether the complete segment should be aliased.
std::string getDescription() final
Short description of the findlet.
void apply(std::vector< CDCSegment2D > &outputSegments) final
Main algorithm applying the fit to each segment.
bool m_borderAliases
Switch whether the border hits at the beginning and the end should be aliased.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
CDCRiemannFitter m_riemannFitter
Instance of the riemann fitter to be used.
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...
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Abstract base class for different kinds of events.
double updateDriftLength(CDCRecoHit2D &recoHit2D)
Update the drift length of the reconstructed hit in place.