12 #include <tracking/trackFindingCDC/hough/perigee/AxialLegendreLeafProcessor.h>
14 #include <tracking/trackFindingCDC/processing/AxialTrackUtil.h>
16 #include <tracking/trackFindingCDC/hough/perigee/StereoHitContained.h>
17 #include <tracking/trackFindingCDC/hough/perigee/OffOrigin.h>
18 #include <tracking/trackFindingCDC/hough/algorithms/InPhi0ImpactCurvBox.h>
19 #include <tracking/trackFindingCDC/hough/baseelements/WithSharedMark.h>
21 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
22 #include <tracking/trackFindingCDC/fitting/CDCObservations2D.h>
23 #include <tracking/trackFindingCDC/fitting/CDCKarimakiFitter.h>
24 #include <tracking/trackFindingCDC/geometry/PerigeeCircle.h>
26 #include <tracking/trackFindingCDC/legendre/precisionFunctions/PrecisionUtil.h>
28 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
30 #include <framework/core/ModuleParamList.templateDetails.h>
37 namespace TrackFindingCDC {
39 template <
class ANode>
46 auto fitPos = EFitPos::c_RecoPos;
47 auto fitVariance = EFitVariance::c_DriftLength;
58 std::vector<WithSharedMark<CDCRLWireHit>> hits(leaf->begin(), leaf->end());
59 std::sort(hits.begin(), hits.end());
60 observations2D.appendRange(hits);
64 std::array<DiscreteCurv, 2> curvs = leaf->template getBounds<DiscreteCurv>();
66 float lowerCurv = *(curvs[0]);
67 float upperCurv = *(curvs[1]);
76 if (m_param_nRoadSearches > 0) {
79 ANode* roadNode = leaf;
80 while (roadNode->getParent() and roadNode->getLevel() > m_param_roadLevel) {
81 roadNode = roadNode->getParent();
84 for (
int iRoadSearch = 0; iRoadSearch < m_param_nRoadSearches; ++iRoadSearch) {
90 int nHitsBefore = hits.size();
91 std::vector<WithSharedMark<CDCRLWireHit>> roadHits = this->searchRoad(*roadNode, trajectory2D);
92 std::sort(roadHits.begin(), roadHits.end());
93 hits.insert(hits.end(), roadHits.begin(), roadHits.end());
94 std::inplace_merge(hits.begin(), hits.begin() + nHitsBefore, hits.end());
95 hits.erase(std::unique(hits.begin(), hits.end()), hits.end());
98 observations2D.clear();
99 observations2D.appendRange(hits);
100 trajectory2D = fitter.fit(observations2D);
107 std::vector<const CDCWireHit*> foundWireHits;
108 for (CDCRLWireHit& rlWireHit : hits) {
109 foundWireHits.push_back(&rlWireHit.getWireHit());
115 for (WithSharedMark<CDCRLWireHit>& markableRLWireHit : leaf->getTree()->getTopNode()) {
116 const AutomatonCell& automatonCell = markableRLWireHit.getWireHit().getAutomatonCell();
117 if (automatonCell.hasTakenFlag() or automatonCell.hasMaskedFlag()) {
118 markableRLWireHit.mark();
120 markableRLWireHit.unmark();
125 template <
class ANode>
126 std::vector<WithSharedMark<CDCRLWireHit> >
129 PerigeeCircle circle = trajectory2D.getGlobalCircle();
130 Vector2D support = trajectory2D.getGlobalPerigee();
131 const float curv = circle.curvature();
132 const float phi0 = circle.phi0();
134 StereoHitContained<OffOrigin<InPhi0ImpactCurvBox> > hitInPhi0CurvBox(m_param_curlCurv);
135 hitInPhi0CurvBox.setLocalOrigin(support);
141 const float levelPrecision = 9.0;
144 const float phi0Precision = 3.1415 / std::pow(2.0, levelPrecision + 1.0);
146 const float curvPrecision = 0.15 / std::pow(2.0, levelPrecision);
155 std::vector<WithSharedMark<CDCRLWireHit>> hitsInPrecisionBox;
158 for (WithSharedMark<CDCRLWireHit> markableRLWireHit : node) {
160 if (markableRLWireHit.isMarked())
continue;
161 Weight weight = hitInPhi0CurvBox(markableRLWireHit, &precisionPhi0CurvBox);
162 if (not std::isnan(weight)) hitsInPrecisionBox.push_back(markableRLWireHit);
165 return hitsInPrecisionBox;
176 namespace TrackFindingCDC {
177 template <
class ANode>
178 std::vector<typename AxialLegendreLeafProcessor<ANode>::Candidate>
181 std::vector<Candidate> result;
182 for (
const CDCTrack& track : m_tracks) {
183 std::vector<CDCRLWireHit> rlWireHits;
185 rlWireHits.push_back(recoHit3D.getRLWireHit());
187 CDCTrajectory2D trajectory2D = track.getStartTrajectory3D().getTrajectory2D();
188 result.emplace_back(std::move(trajectory2D), std::move(rlWireHits));
193 template <
class ANode>
195 const std::string& prefix)
197 moduleParamList->
addParameter(prefixed(prefix,
"maxLevel"),
199 "Level of divisions in the hough space at which a leaf is reached",
202 moduleParamList->
addParameter(prefixed(prefix,
"minWeight"),
204 "Minimal exceptable weight of a leaf to be considered",
207 moduleParamList->
addParameter(prefixed(prefix,
"maxCurv"),
209 "Maximal curvature of a leaf to be considered",
212 moduleParamList->
addParameter(prefixed(prefix,
"curlCurv"),
214 "Curvature below which hits on both arms of the trajectory are allowed",
217 moduleParamList->
addParameter(prefixed(prefix,
"nRoadSearches"),
218 m_param_nRoadSearches,
219 "How often the road search should be performed to find new hits",
220 m_param_nRoadSearches);
222 moduleParamList->
addParameter(prefixed(prefix,
"roadLevel"),
224 "Level of the read from which additional hits in the road search can be taken",
227 moduleParamList->
addParameter(prefixed(prefix,
"curvResolution"),
228 m_param_curvResolution,
229 "The name of the resolution function to be used. "
230 "Valid values are 'none', 'const', 'basic', 'origin', 'nonOrigin'",
231 m_param_curvResolution);
234 template <
class ANode>
238 if (m_param_curvResolution ==
"none") {
239 m_curvResolution = [](
double curv __attribute__((unused))) {
return NAN; };
240 }
else if (m_param_curvResolution ==
"const") {
241 m_curvResolution = [](
double curv __attribute__((unused))) {
return 0.0008; };
242 }
else if (m_param_curvResolution ==
"basic") {
244 }
else if (m_param_curvResolution ==
"origin") {
246 }
else if (m_param_curvResolution ==
"nonOrigin") {
249 B2WARNING(
"Unknown curvature resolution function " << m_param_curvResolution);
250 m_curvResolution = [](
double curv __attribute__((unused))) {
return NAN; };