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]);
76 ANode* roadNode = leaf;
78 roadNode = roadNode->getParent();
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 = M_PI / 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;
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"),
216 "How often the road search should be performed to find new hits",
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"),
226 "The name of the resolution function to be used. "
227 "Valid values are 'none', 'const', 'basic', 'origin', 'nonOrigin'",
231 template <
class ANode>
238 m_curvResolution = [](
double curv __attribute__((unused))) {
return 0.0008; };
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.
std::string m_param_curvResolution
Memory for the name of the resolution function to be used. Valid values are 'none',...
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.
std::function< double(double)> m_curvResolution
Memory for the freely defined curvature resolution function.
int m_param_roadLevel
Memory for the tree node level which should be the source of hits for the road searches....
double m_param_curlCurv
Memory for the curvature of a curler in the CDC.
std::vector< const CDCWireHit * > m_axialWireHits
Memory for the pool of axial wire hits to can be used in the post processing.
int m_param_maxLevel
Memory for the maximal level of the tree.
double m_param_maxCurv
Memory for the maximal curvature that should be searched in the current walk.
double m_param_minWeight
Memory for the minimal weight threshold for following the children of a node.
int m_param_nRoadSearches
Memory for the number of repeated road searches.
std::vector< CDCTrack > m_tracks
Memory for found trajectories.
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< double, 2 > Array
static std::array< This, 2 > getRange(const Array &bounds)
static std::array< This, 2 > getRange(Array &values)
std::vector< float > Array
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.