Main algorithm applying the fit to each segment.
82{
84 for (CDCSegment2D& segment : outputSegments) {
85 if (segment->hasAliasFlag()) continue;
86 int nRLSwitches = segment.getNRLSwitches();
87
88 bool aliasStable = nRLSwitches > 2;
89 if (aliasStable) continue;
90
91 CDCSegment2D aliasSegment = segment.getAlias();
92 refit(aliasSegment,
true);
93 swapBetterChi2(segment, aliasSegment);
94 }
95 }
96
97
99 for (CDCSegment2D& segment : outputSegments) {
100 int nRLSwitches = segment.getNRLSwitches();
101
102 bool aliasStable = nRLSwitches > 2;
103 if (aliasStable) continue;
104
105 if (nRLSwitches == 1) {
106
107 CDCSegment2D rightSegment = segment;
108 CDCSegment2D leftSegment = segment;
109 for (CDCRecoHit2D& recoHit2D : rightSegment) {
110 if (recoHit2D.getRLInfo() == ERightLeft::c_Left) {
111 recoHit2D = recoHit2D.getAlias();
112 }
113 }
114
115 for (CDCRecoHit2D& recoHit2D : leftSegment) {
116 if (recoHit2D.getRLInfo() == ERightLeft::c_Right) {
117 recoHit2D = recoHit2D.getAlias();
118 }
119 }
120 refit(rightSegment,
true);
121 refit(leftSegment,
true);
122 swapBetterChi2(segment, rightSegment);
123 swapBetterChi2(segment, leftSegment);
124
125 } else if (nRLSwitches == 0) {
126
127 CDCSegment2D frontCrossSegment = segment;
128 CDCSegment2D backCrossSegment = segment;
129
130 auto lessDriftLength = [](const CDCRecoHit2D & lhs, const CDCRecoHit2D & rhs) {
132 };
133
134
135 {
136 auto itMinLRecoHit2D =
137 std::min_element(frontCrossSegment.begin(), frontCrossSegment.end(), lessDriftLength);
138 for (CDCRecoHit2D& recoHit2D : asRange(frontCrossSegment.begin(), itMinLRecoHit2D)) {
139 recoHit2D = recoHit2D.getAlias();
140 }
141 }
142
143
144 {
145 auto itMinLRecoHit2D =
146 std::min_element(backCrossSegment.begin(), backCrossSegment.end(), lessDriftLength);
147 for (CDCRecoHit2D& recoHit2D : asRange(itMinLRecoHit2D, backCrossSegment.end())) {
148 recoHit2D = recoHit2D.getAlias();
149 }
150 }
151 refit(frontCrossSegment,
true);
152 refit(backCrossSegment,
true);
153 swapBetterChi2(segment, frontCrossSegment);
154 swapBetterChi2(segment, backCrossSegment);
155 }
156 }
157 }
158
160 for (CDCSegment2D& segment : outputSegments) {
161
162 CDCSegment2D aliasSegment = segment;
163 CDCRecoHit2D& aliasHit = aliasSegment.back();
167 refit(aliasSegment,
false);
172 swapBetterChi2(segment, aliasSegment);
173 }
174 }
175
176 for (CDCSegment2D& segment : outputSegments) {
177
178 CDCSegment2D aliasSegment = segment;
179 CDCRecoHit2D& aliasHit = aliasSegment.front();
183 refit(aliasSegment,
false);
188 swapBetterChi2(segment, aliasSegment);
189 }
190 }
191 }
192
194 for (CDCSegment2D& segment : outputSegments) {
195
196 CDCSegment2D aliasSegment = segment;
197
198
199 double minimalDriftLength = 0.1;
200 CDCRecoHit2D* minimalHit = nullptr;
201 for (CDCRecoHit2D& aliasHit : aliasSegment) {
203 minimalHit = &aliasHit;
205 }
206 }
207 if (minimalHit) {
208 CDCRecoHit2D& aliasHit = *minimalHit;
211 refit(aliasSegment,
false);
212 Vector2D recoPos2D = aliasSegment.getTrajectory2D().getClosest(aliasHit.
getRefPos2D());
216 swapBetterChi2(segment, aliasSegment);
217 }
218 }
219 }
220
221 std::sort(outputSegments.begin(), outputSegments.end());
222}
bool m_middleAliases
Switch whether the hits in the middle with lowest drift radius should be aliased.
void refit(TrackingUtilities::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.
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 ROOT::Math::XYVector & getRefPos2D() const
Getter for the reference position of the wire.
void setRecoPos2D(const Vector2D &recoPos2D)
Setter for the position in the reference plane.
CDCTrajectory2D & getTrajectory2D() const
Getter for the two dimensional trajectory fitted to the segment.
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.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.