9#include <tracking/trackFindingCDC/hough/perigee/AxialLegendreLeafProcessor.h>
11#include <tracking/trackFindingCDC/processing/AxialTrackUtil.h>
13#include <tracking/trackFindingCDC/hough/perigee/StereoHitContained.h>
14#include <tracking/trackFindingCDC/hough/perigee/OffOrigin.h>
15#include <tracking/trackFindingCDC/hough/algorithms/InPhi0ImpactCurvBox.h>
16#include <tracking/trackFindingCDC/hough/baseelements/WithSharedMark.h>
18#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
19#include <tracking/trackFindingCDC/fitting/CDCObservations2D.h>
20#include <tracking/trackFindingCDC/fitting/CDCKarimakiFitter.h>
21#include <tracking/trackFindingCDC/geometry/PerigeeCircle.h>
23#include <tracking/trackFindingCDC/legendre/precisionFunctions/PrecisionUtil.h>
25#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
27#include <framework/core/ModuleParamList.templateDetails.h>
34 namespace TrackFindingCDC {
36 template <
class ANode>
43 auto fitPos = EFitPos::c_RecoPos;
44 auto fitVariance = EFitVariance::c_DriftLength;
55 std::vector<WithSharedMark<CDCRLWireHit>> hits(leaf->begin(), leaf->end());
56 std::sort(hits.begin(), hits.end());
61 std::array<DiscreteCurv, 2> curvs = leaf->template getBounds<DiscreteCurv>();
63 float lowerCurv = *(curvs[0]);
64 float upperCurv = *(curvs[1]);
73 if (m_param_nRoadSearches > 0) {
76 ANode* roadNode = leaf;
77 while (roadNode->getParent() and roadNode->getLevel() > m_param_roadLevel) {
78 roadNode = roadNode->getParent();
81 for (
int iRoadSearch = 0; iRoadSearch < m_param_nRoadSearches; ++iRoadSearch) {
87 int nHitsBefore = hits.size();
88 std::vector<WithSharedMark<CDCRLWireHit>> roadHits = this->searchRoad(*roadNode, trajectory2D);
89 std::sort(roadHits.begin(), roadHits.end());
90 hits.insert(hits.end(), roadHits.begin(), roadHits.end());
91 std::inplace_merge(hits.begin(), hits.begin() + nHitsBefore, hits.end());
92 hits.erase(std::unique(hits.begin(), hits.end()), hits.end());
95 observations2D.
clear();
97 trajectory2D = fitter.fit(observations2D);
104 std::vector<const CDCWireHit*> foundWireHits;
106 foundWireHits.push_back(&rlWireHit.getWireHit());
113 const AutomatonCell& automatonCell = markableRLWireHit.getWireHit().getAutomatonCell();
115 markableRLWireHit.mark();
117 markableRLWireHit.unmark();
122 template <
class ANode>
123 std::vector<WithSharedMark<CDCRLWireHit> >
129 const float phi0 = circle.
phi0();
132 hitInPhi0CurvBox.setLocalOrigin(support);
138 const float levelPrecision = 9.0;
141 const float phi0Precision = 3.1415 / std::pow(2.0, levelPrecision + 1.0);
143 const float curvPrecision = 0.15 / std::pow(2.0, levelPrecision);
152 std::vector<WithSharedMark<CDCRLWireHit>> hitsInPrecisionBox;
157 if (markableRLWireHit.isMarked())
continue;
158 Weight weight = hitInPhi0CurvBox(markableRLWireHit, &precisionPhi0CurvBox);
159 if (not std::isnan(weight)) hitsInPrecisionBox.push_back(markableRLWireHit);
162 return hitsInPrecisionBox;
173 namespace TrackFindingCDC {
174 template <
class ANode>
175 std::vector<typename AxialLegendreLeafProcessor<ANode>::Candidate>
178 std::vector<Candidate> result;
179 for (
const CDCTrack& track : m_tracks) {
180 std::vector<CDCRLWireHit> rlWireHits;
182 rlWireHits.push_back(recoHit3D.getRLWireHit());
184 CDCTrajectory2D trajectory2D = track.getStartTrajectory3D().getTrajectory2D();
185 result.emplace_back(std::move(trajectory2D), std::move(rlWireHits));
190 template <
class ANode>
192 const std::string& prefix)
194 moduleParamList->
addParameter(prefixed(prefix,
"maxLevel"),
196 "Level of divisions in the hough space at which a leaf is reached",
199 moduleParamList->
addParameter(prefixed(prefix,
"minWeight"),
201 "Minimal exceptable weight of a leaf to be considered",
204 moduleParamList->
addParameter(prefixed(prefix,
"maxCurv"),
206 "Maximal curvature of a leaf to be considered",
209 moduleParamList->
addParameter(prefixed(prefix,
"curlCurv"),
211 "Curvature below which hits on both arms of the trajectory are allowed",
214 moduleParamList->
addParameter(prefixed(prefix,
"nRoadSearches"),
215 m_param_nRoadSearches,
216 "How often the road search should be performed to find new hits",
217 m_param_nRoadSearches);
219 moduleParamList->
addParameter(prefixed(prefix,
"roadLevel"),
221 "Level of the read from which additional hits in the road search can be taken",
224 moduleParamList->
addParameter(prefixed(prefix,
"curvResolution"),
225 m_param_curvResolution,
226 "The name of the resolution function to be used. "
227 "Valid values are 'none', 'const', 'basic', 'origin', 'nonOrigin'",
228 m_param_curvResolution);
231 template <
class ANode>
235 if (m_param_curvResolution ==
"none") {
236 m_curvResolution = [](
double curv __attribute__((unused))) {
return NAN; };
237 }
else if (m_param_curvResolution ==
"const") {
238 m_curvResolution = [](
double curv __attribute__((unused))) {
return 0.0008; };
239 }
else if (m_param_curvResolution ==
"basic") {
241 }
else if (m_param_curvResolution ==
"origin") {
243 }
else if (m_param_curvResolution ==
"nonOrigin") {
246 B2WARNING(
"Unknown curvature resolution function " << m_param_curvResolution);
247 m_curvResolution = [](
double curv __attribute__((unused))) {
return NAN; };
The Module parameter list class.
Cell used by the cellular automata.
bool hasMaskedFlag() const
Gets the current state of the masked marker flag.
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
std::vector< Candidate > getCandidates() const
Getter for the candidates structure still used in some tests.
std::vector< WithSharedMark< CDCRLWireHit > > searchRoad(const ANode &node, const CDCTrajectory2D &trajectory2D)
Look for more hits near a ftted trajectory from hits available in the give node.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters as a module parameter list.
void processLeaf(ANode *leaf)
A valuable leaf has been found in the hough tree walk.
void beginWalk()
Function to notify the leaf processor about changes in parameters before a new walk.
Class implementing the fitter using Karimakis method.
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.
void clear()
Removes all observations stored.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Class representing a three dimensional reconstructed hit.
Class representing a sequence of three dimensional reconstructed hits.
Particle trajectory as it is seen in xy projection represented as a circle.
PerigeeCircle getGlobalCircle() const
Getter for the circle in global coordinates.
void reverse()
Reverses the trajectory in place.
double setLocalOrigin(const Vector2D &localOrigin)
Setter for the origin of the local coordinate system.
Vector2D getGlobalPerigee() const
Getter for the closest approach on the trajectory to the global origin.
double getCurvature() const
Getter for the curvature as seen from the xy projection.
static constexpr const double c_simpleDriftLengthVariance
A default value for the drift length variance if no variance from the drift length translation is ava...
std::array< T, 2 > Array
Mock array type to be a drop in replacement for the discrete values.
static std::array< This, 2 > getRange(const Array &bounds)
Extract the range from an array providing the discrete values.
static std::array< This, 2 > getRange(Array &values)
Extract the range from an array providing the discrete values.
std::vector< T > Array
The type of the array which contains the underlying values.
Extension of the generalized circle also caching the perigee coordinates.
double phi0() const
Getter for the azimuth angle of the direction of flight at the perigee.
double curvature() const
Getter for the signed curvature.
static double getOriginCurvPrecision(double curv)
Function which estimates desired curvature resolution of quadtree node in the given pt region paramet...
static double getNonOriginCurvPrecision(double curv)
Function which estimates desired curvature resolution of quadtree node in the given pt region paramet...
static double getBasicCurvPrecision(double curv)
Basic function to estimate the curvature precision Takes a curvature value and returns a width that.
Predicate class to check for the containment of axial and stereo hits in some hough space part.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
static Vector2D Phi(const double phi)
Constructs a unit vector with azimuth angle equal to phi.
Mixin class to attach a mark that is shared among many instances.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
static ESign common(ESign n1, ESign n2)
Check if two values have a common sign.
Abstract base class for different kinds of events.
static void addCandidateFromHits(const std::vector< const CDCWireHit * > &foundAxialWireHits, const std::vector< const CDCWireHit * > &allAxialWireHits, std::vector< CDCTrack > &axialTracks, bool withPostprocessing=true)
Create CDCTrack using CDCWireHit hits and store it in the list. Then call the postprocessing on it.