Main algorithm applying the fit to each segment.
84{
86 for (CDCSegment2D& segment : outputSegments) {
87 if (segment->hasAliasFlag()) continue;
88 int nRLSwitches = segment.getNRLSwitches();
89
90 bool aliasStable = nRLSwitches > 2;
91 if (aliasStable) continue;
92
93 CDCSegment2D aliasSegment = segment.getAlias();
94 refit(aliasSegment,
true);
95 swapBetterChi2(segment, aliasSegment);
96 }
97 }
98
99
101 for (CDCSegment2D& segment : outputSegments) {
102 int nRLSwitches = segment.getNRLSwitches();
103
104 bool aliasStable = nRLSwitches > 2;
105 if (aliasStable) continue;
106
107 if (nRLSwitches == 1) {
108
109 CDCSegment2D rightSegment = segment;
110 CDCSegment2D leftSegment = segment;
111 for (CDCRecoHit2D& recoHit2D : rightSegment) {
112 if (recoHit2D.getRLInfo() == ERightLeft::c_Left) {
113 recoHit2D = recoHit2D.getAlias();
114 }
115 }
116
117 for (CDCRecoHit2D& recoHit2D : leftSegment) {
118 if (recoHit2D.getRLInfo() == ERightLeft::c_Right) {
119 recoHit2D = recoHit2D.getAlias();
120 }
121 }
122 refit(rightSegment,
true);
123 refit(leftSegment,
true);
124 swapBetterChi2(segment, rightSegment);
125 swapBetterChi2(segment, leftSegment);
126
127 } else if (nRLSwitches == 0) {
128
129 CDCSegment2D frontCrossSegment = segment;
130 CDCSegment2D backCrossSegment = segment;
131
132 auto lessDriftLength = [](const CDCRecoHit2D & lhs, const CDCRecoHit2D & rhs) {
134 };
135
136
137 {
138 auto itMinLRecoHit2D =
139 std::min_element(frontCrossSegment.begin(), frontCrossSegment.end(), lessDriftLength);
140 for (CDCRecoHit2D& recoHit2D : asRange(frontCrossSegment.begin(), itMinLRecoHit2D)) {
141 recoHit2D = recoHit2D.getAlias();
142 }
143 }
144
145
146 {
147 auto itMinLRecoHit2D =
148 std::min_element(backCrossSegment.begin(), backCrossSegment.end(), lessDriftLength);
149 for (CDCRecoHit2D& recoHit2D : asRange(itMinLRecoHit2D, backCrossSegment.end())) {
150 recoHit2D = recoHit2D.getAlias();
151 }
152 }
153 refit(frontCrossSegment,
true);
154 refit(backCrossSegment,
true);
155 swapBetterChi2(segment, frontCrossSegment);
156 swapBetterChi2(segment, backCrossSegment);
157 }
158 }
159 }
160
162 for (CDCSegment2D& segment : outputSegments) {
163
164 CDCSegment2D aliasSegment = segment;
165 CDCRecoHit2D& aliasHit = aliasSegment.back();
169 refit(aliasSegment,
false);
174 swapBetterChi2(segment, aliasSegment);
175 }
176 }
177
178 for (CDCSegment2D& segment : outputSegments) {
179
180 CDCSegment2D aliasSegment = segment;
181 CDCRecoHit2D& aliasHit = aliasSegment.front();
185 refit(aliasSegment,
false);
190 swapBetterChi2(segment, aliasSegment);
191 }
192 }
193 }
194
196 for (CDCSegment2D& segment : outputSegments) {
197
198 CDCSegment2D aliasSegment = segment;
199
200
201 double minimalDriftLength = 0.1;
202 CDCRecoHit2D* minimalHit = nullptr;
203 for (CDCRecoHit2D& aliasHit : aliasSegment) {
205 minimalHit = &aliasHit;
207 }
208 }
209 if (minimalHit) {
210 CDCRecoHit2D& aliasHit = *minimalHit;
213 refit(aliasSegment,
false);
214 ROOT::Math::XYVector recoPos2D = aliasSegment.getTrajectory2D().getClosest(aliasHit.
getRefPos2D());
218 swapBetterChi2(segment, aliasSegment);
219 }
220 }
221 }
222
223 std::sort(outputSegments.begin(), outputSegments.end());
224}
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 ROOT::Math::XYVector &recoPos2D)
Setter for the position in the reference plane.
CDCTrajectory2D & getTrajectory2D() const
Getter for the two dimensional trajectory fitted to the segment.
ROOT::Math::XYVector getClosest(const ROOT::Math::XYVector &point) const
Calculates the closest approach on the trajectory to the given point.
ERightLeft isRightOrLeft(const ROOT::Math::XYVector &point) const
Checks if the given point is to the right or to the left of the trajectory.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.