8#include <tracking/trackFindingCDC/testFixtures/TrackFindingCDCTestWithSimpleSimulation.h>
10#include <tracking/trackFindingCDC/hough/perigee/AxialLegendreLeafProcessor.h>
11#include <tracking/trackFindingCDC/hough/perigee/AxialLegendreLeafProcessor.icc.h>
13#include <tracking/trackFindingCDC/hough/perigee/SimpleRLTaggedWireHitHoughTree.h>
14#include <tracking/trackFindingCDC/hough/perigee/SimpleSegmentHoughTree.h>
15#include <tracking/trackFindingCDC/hough/perigee/StandardBinSpec.h>
17#include <tracking/trackFindingCDC/hough/algorithms/InPhi0CurvBox.h>
19#include <framework/core/ModuleParamList.templateDetails.h>
20#include <framework/core/ModuleParam.h>
25using namespace TrackFindingCDC;
26using namespace PerigeeBinSpec;
31 std::string svgFileName =
"phi0_curv_on_hits.svg";
33 Helix lowerCurvOriginHelix(0.015, 2.52033, 0, 1, 0);
34 Helix higherCurvOriginHelix(0.027, 3.0718, 0, 0, 0);
39 simulate({lowerCurvOriginHelix, higherCurvOriginHelix});
40 saveDisplay(svgFileName);
42 using SimpleRLTaggedWireHitPhi0CurvHough =
44 SimpleRLTaggedWireHitPhi0CurvHough houghTree(maxLevel);
45 using HoughBox = SimpleRLTaggedWireHitPhi0CurvHough::HoughBox;
47 const double minWeight = 30.0;
51 houghTree.initialize();
55 std::vector< std::pair<HoughBox, std::vector<CDCRLWireHit> > > candidates;
60 houghTree.seed(m_axialWireHits);
62 candidates = houghTree.find(minWeight, maxCurvAcceptance);
65 ASSERT_EQ(m_mcTracks.size(), candidates.size());
68 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
69 EXPECT_GE(candidates[iCand].second.size(), 30);
74 std::size_t nNodes = houghTree.getTree()->getNNodes();
75 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
80 for (std::pair<HoughBox, std::vector<CDCRLWireHit> >& candidate : candidates) {
81 const HoughBox& houghBox = candidate.first;
82 const std::vector<CDCRLWireHit>& taggedHits = candidate.second;
84 B2DEBUG(100,
"Candidate");
85 B2DEBUG(100,
"size " << taggedHits.size());
86 B2DEBUG(100,
"Phi0 " << houghBox.getLowerBound<
DiscretePhi0>()->phi());
87 B2DEBUG(100,
"Curv " << houghBox.getLowerBound<
DiscreteCurv>());
88 B2DEBUG(100,
"Tags of the hits");
90 B2DEBUG(100,
"Tags of the hits");
93 "rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
" " <<
94 "dl = " << rlTaggedWireHit.getRefDriftLength());
98 const CDCWireHit& wireHit = rlTaggedWireHit.getWireHit();
99 std::string color =
"blue";
100 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
102 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
107 draw(wireHit, strokeAttr);
112 saveDisplay(svgFileName);
121 std::string svgFileName =
"phi0_curv_on_segments.svg";
123 Helix lowerCurvOriginHelix(0.015, 2.52033, 0, 1, 0);
124 Helix higherCurvOriginHelix(0.027, 3.0718, 0, 0, 0);
129 simulate({lowerCurvOriginHelix, higherCurvOriginHelix});
130 saveDisplay(svgFileName);
132 using SimpleSegmentPhi0CurvHoughTree =
134 SimpleSegmentPhi0CurvHoughTree houghTree(maxLevel);
135 using HoughBox = SimpleSegmentPhi0CurvHoughTree::HoughBox;
137 const double minWeight = 30.0;
141 houghTree.initialize();
144 std::vector< std::pair<HoughBox, std::vector<const CDCSegment2D*> > > candidates;
151 houghTree.seed(m_mcAxialSegment2Ds);
153 candidates = houghTree.find(minWeight, maxCurvAcceptance);
156 ASSERT_EQ(m_mcTracks.size(), candidates.size());
160 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
161 EXPECT_GE(candidates[iCand].second.size(), 4);
166 std::size_t nNodes = houghTree.getTree()->getNNodes();
167 B2INFO(
"Tree generated " << nNodes <<
" nodes");
172 for (std::pair<HoughBox, std::vector<const CDCSegment2D*> >& candidate : candidates) {
173 const HoughBox& houghBox = candidate.first;
174 const std::vector<const CDCSegment2D*>& segments = candidate.second;
176 B2DEBUG(100,
"Candidate");
177 B2DEBUG(100,
"size " << segments.size());
178 B2DEBUG(100,
"Phi0 " << houghBox.getLowerBound<
DiscretePhi0>()->phi());
179 B2DEBUG(100,
"Curv " << houghBox.getLowerBound<
DiscreteCurv>());
183 draw(*segment2D, strokeAttr);
187 saveDisplay(svgFileName);
196 std::string svgFileName =
"phi0_curv_on_hits.svg";
198 Helix zeroCurvOriginHelix(0.000, 1.52033, 0, -0.5, 0);
199 Helix lowerCurvOriginHelix(0.015, 2.52033, 0, 1, 0);
200 Helix higherCurvOriginHelix(0.027, 3.0718, 3, 0, 0);
205 simulate({zeroCurvOriginHelix, lowerCurvOriginHelix, higherCurvOriginHelix});
206 saveDisplay(svgFileName);
208 using SimpleRLTaggedWireHitPhi0CurvHough =
210 SimpleRLTaggedWireHitPhi0CurvHough houghTree(maxLevel, curlCurv);
214 houghTree.initialize();
216 const double minWeight = 30.0;
217 using Node =
typename SimpleRLTaggedWireHitPhi0CurvHough::Node;
221 const std::string prefix =
"";
222 leafProcessor.exposeParameters(&moduleParamList, prefix);
223 moduleParamList.
getParameter<
double>(
"minWeight").setDefaultValue(minWeight);
224 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(maxCurvAcceptance);
227 std::vector< std::pair<CDCTrajectory2D, std::vector<CDCRLWireHit> > > candidates;
230 TimeItResult timeItResult = this->timeIt(100,
true, [&]() {
233 for (
const CDCWireHit* wireHit : m_axialWireHits) {
239 houghTree.seed(m_axialWireHits);
241 leafProcessor.clear();
244 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(curlCurv);
245 moduleParamList.
getParameter<
int>(
"nRoadSearches").setDefaultValue(2);
246 moduleParamList.
getParameter<
int>(
"roadLevel").setDefaultValue(4);
247 leafProcessor.beginWalk();
248 houghTree.findUsing(leafProcessor);
250 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(maxCurvAcceptance);
251 moduleParamList.
getParameter<
int>(
"nRoadSearches").setDefaultValue(3);
252 moduleParamList.
getParameter<
int>(
"roadLevel").setDefaultValue(0);
253 leafProcessor.beginWalk();
254 houghTree.findUsing(leafProcessor);
256 candidates = leafProcessor.getCandidates();
258 ASSERT_EQ(m_mcTracks.size(), candidates.size());
261 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
262 EXPECT_GE(candidates[iCand].second.size(), 30);
267 std::size_t nNodes = houghTree.getTree()->getNNodes();
268 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
273 for (std::pair<
CDCTrajectory2D, std::vector<CDCRLWireHit> >& candidate : candidates) {
275 const std::vector<CDCRLWireHit >& taggedHits = candidate.second;
277 B2DEBUG(100,
"Candidate");
278 B2DEBUG(100,
"size " << taggedHits.size());
282 B2DEBUG(100,
"Support " << trajectory2D.
getSupport());
283 B2DEBUG(100,
"Tags of the hits");
285 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
286 B2DEBUG(100,
" rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
287 " dl = " << rlTaggedWireHit.getRefDriftLength());
290 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
291 const CDCWireHit wireHit = rlTaggedWireHit.getWireHit();
292 std::string color =
"blue";
293 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
295 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
300 draw(wireHit, strokeAttr);
305 saveDisplay(svgFileName);
313 std::string svgFileName =
"phi0_curv_on_prepared_event_hits_using_leaf_processing.svg";
315 saveDisplay(svgFileName);
318 using SimpleRLTaggedWireHitPhi0CurvHough =
320 SimpleRLTaggedWireHitPhi0CurvHough houghTree(maxLevel, curlCurv);
324 houghTree.initialize();
326 const double minWeight = 30.0;
327 using Node =
typename SimpleRLTaggedWireHitPhi0CurvHough::Node;
331 const std::string prefix =
"";
332 leafProcessor.exposeParameters(&moduleParamList, prefix);
333 moduleParamList.
getParameter<
double>(
"minWeight").setDefaultValue(minWeight);
334 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(maxCurvAcceptance);
337 std::vector< std::pair<CDCTrajectory2D, std::vector<CDCRLWireHit> > > candidates;
344 for (
const CDCWireHit* wireHit : m_axialWireHits) {
350 houghTree.seed(m_axialWireHits);
352 leafProcessor.clear();
355 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(curlCurv);
356 moduleParamList.
getParameter<
int>(
"nRoadSearches").setDefaultValue(2);
357 moduleParamList.
getParameter<
int>(
"roadLevel").setDefaultValue(4);
358 leafProcessor.beginWalk();
359 houghTree.findUsing(leafProcessor);
361 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(maxCurvAcceptance);
362 moduleParamList.
getParameter<
int>(
"nRoadSearches").setDefaultValue(3);
363 moduleParamList.
getParameter<
int>(
"roadLevel").setDefaultValue(0);
364 leafProcessor.beginWalk();
365 houghTree.findUsing(leafProcessor);
367 candidates = leafProcessor.getCandidates();
369 ASSERT_EQ(m_mcTracks.size(), candidates.size());
372 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
373 EXPECT_GE(candidates[iCand].second.size(), 30);
378 std::size_t nNodes = houghTree.getTree()->getNNodes();
379 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
384 for (std::pair<
CDCTrajectory2D, std::vector<CDCRLWireHit> >& candidate : candidates) {
386 const std::vector<CDCRLWireHit >& taggedHits = candidate.second;
388 B2DEBUG(100,
"Candidate");
389 B2DEBUG(100,
"size " << taggedHits.size());
393 B2DEBUG(100,
"Support " << trajectory2D.
getSupport());
394 B2DEBUG(100,
"Tags of the hits");
396 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
397 B2DEBUG(100,
" rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
398 " dl = " << rlTaggedWireHit.getRefDriftLength());
401 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
402 const CDCWireHit wireHit = rlTaggedWireHit.getWireHit();
403 std::string color =
"blue";
404 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
406 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
411 draw(wireHit, strokeAttr);
416 saveDisplay(svgFileName);
423 std::string svgFileName =
"phi0_curv_on_prepared_event_hits.svg";
425 saveDisplay(svgFileName);
428 using Phi0CurvBox = RLTaggedWireHitPhi0CurvHough::HoughBox;
429 RLTaggedWireHitPhi0CurvHough houghTree(maxLevel);
437 houghTree.initialize();
438 const double minWeight = 30.0;
441 std::vector< std::pair<Phi0CurvBox, std::vector<CDCRLWireHit> > > candidates;
447 houghTree.seed(m_axialWireHits);
449 candidates = houghTree.find(minWeight, maxCurvAcceptance);
452 ASSERT_EQ(m_mcTracks.size(), candidates.size());
455 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
456 EXPECT_GE(candidates[iCand].second.size(), 30);
461 std::size_t nNodes = houghTree.getTree()->getNNodes();
462 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
467 for (std::pair<Phi0CurvBox, std::vector<CDCRLWireHit> >& candidate : candidates) {
468 const Phi0CurvBox& phi0CurvBox = candidate.first;
469 const std::vector<CDCRLWireHit>& taggedHits = candidate.second;
471 B2DEBUG(100,
"Candidate");
472 B2DEBUG(100,
"size " << taggedHits.size());
473 B2DEBUG(100,
"Phi0 " << phi0CurvBox.getLowerBound<
DiscretePhi0>()->phi());
474 B2DEBUG(100,
"Curv " << phi0CurvBox.getLowerBound<
DiscreteCurv>());
475 B2DEBUG(100,
"Tags of the hits");
477 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
478 B2DEBUG(100,
" rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
479 " dl = " << rlTaggedWireHit.getRefDriftLength());
482 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
483 const CDCWireHit& wireHit = rlTaggedWireHit.getWireHit();
484 std::string color =
"blue";
485 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
487 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
492 draw(wireHit, strokeAttr);
496 saveDisplay(svgFileName);
The Module parameter list class.
Cell used by the cellular automata.
void unsetTemporaryFlags()
Resets the assigned, start and cycle marker flag.
void unsetTakenFlag()
Resets the taken flag to false.
Predicate class that is feed the nodes in a WeightedHoughTree walk It decides if a node should be fur...
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
A reconstructed sequence of two dimensional hits in one super layer.
Particle trajectory as it is seen in xy projection represented as a circle.
PerigeeCircle getGlobalCircle() const
Getter for the circle in global coordinates.
Vector2D getSupport() const
Get the support point of the trajectory in global coordinates.
double getCurvature() const
Getter for the curvature as seen from the xy projection.
Class representing a hit wire in the central drift chamber.
DiscreteCurv::Array constructArray() const
Construct the array of discrete curve positions.
int getNOverlap() const
Getter for the overlap in discrete number of positions.
Representation for a discrete position in an array of discrete positions.
PrimitivePlotter::AttributeMap AttributeMap
Forward the Attribute map from the primitive plotter.
double phi0() const
Getter for the azimuth angle of the direction of flight at the perigee.
double impact() const
Getter for the signed distance of the origin to the circle.
DiscretePhi0::Array constructArray() const
Construct the array of discrete phi0 positions.
int getNOverlap() const
Getter for the overlap in discrete number of positions.
A convenience class based on a BoxDivisionHoughTree for "hit-like" classes.
Class to capture the time a repeated execution took.
void printSummary() const
Print a summary of the collected time to the console.
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
Abstract base class for different kinds of events.