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/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
19#include <tracking/trackFindingCDC/fitting/CDCObservations2D.h>
20#include <tracking/trackFindingCDC/fitting/CDCKarimakiFitter.h>
21#include <tracking/trackingUtilities/geometry/PerigeeCircle.h>
22#include <tracking/trackingUtilities/geometry/VectorUtil.h>
24#include <tracking/trackFindingCDC/legendre/precisionFunctions/PrecisionUtil.h>
26#include <tracking/trackingUtilities/utilities/StringManipulation.h>
28#include <framework/core/ModuleParamList.templateDetails.h>
30#include <Math/Vector2D.h>
37 namespace TrackFindingCDC {
39 template <
class ANode>
46 auto fitPos = EFitPos::c_RecoPos;
47 auto fitVariance = EFitVariance::c_DriftLength;
58 std::vector<WithSharedMark<TrackingUtilities::CDCRLWireHit>> hits(leaf->begin(), leaf->end());
59 std::sort(hits.begin(), hits.end());
64 std::array<DiscreteCurv, 2> curvs = leaf->template getBounds<DiscreteCurv>();
66 float lowerCurv = *(curvs[0]);
67 float upperCurv = *(curvs[1]);
79 ANode* roadNode = leaf;
81 roadNode = roadNode->getParent();
90 int nHitsBefore = hits.size();
91 std::vector<WithSharedMark<TrackingUtilities::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();
100 trajectory2D = fitter.fit(observations2D);
107 std::vector<const TrackingUtilities::CDCWireHit*> foundWireHits;
109 foundWireHits.push_back(&rlWireHit.getWireHit());
118 markableRLWireHit.mark();
120 markableRLWireHit.unmark();
125 template <
class ANode>
126 std::vector<WithSharedMark<TrackingUtilities::CDCRLWireHit> >
132 const float phi0 = circle.
phi0();
135 hitInPhi0CurvBox.setLocalOrigin(support);
141 const float levelPrecision = 9.0;
144 const float phi0Precision = M_PI / std::pow(2.0, levelPrecision + 1.0);
146 const float curvPrecision = 0.15 / std::pow(2.0, levelPrecision);
150 DiscretePhi0::Array phi0Bounds{{VectorUtil::Phi(phi0 - phi0Precision), VectorUtil::Phi(phi0 + phi0Precision)}};
155 std::vector<WithSharedMark<TrackingUtilities::CDCRLWireHit>> hitsInPrecisionBox;
160 if (markableRLWireHit.isMarked())
continue;
161 TrackingUtilities::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;
183 std::vector<TrackingUtilities::CDCRLWireHit> rlWireHits;
185 rlWireHits.push_back(recoHit3D.getRLWireHit());
188 result.emplace_back(std::move(trajectory2D), std::move(rlWireHits));
193 template <
class ANode>
195 const std::string& prefix)
197 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"maxLevel"),
199 "Level of divisions in the hough space at which a leaf is reached",
202 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"minWeight"),
204 "Minimal exceptable weight of a leaf to be considered",
207 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"maxCurv"),
209 "Maximal curvature of a leaf to be considered",
212 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"curlCurv"),
214 "Curvature below which hits on both arms of the trajectory are allowed",
217 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"nRoadSearches"),
219 "How often the road search should be performed to find new hits",
222 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"roadLevel"),
224 "Level of the read from which additional hits in the road search can be taken",
227 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"curvResolution"),
229 "The name of the resolution function to be used. "
230 "Valid values are 'none', 'const', 'basic', 'origin', 'nonOrigin'",
234 template <
class ANode>
241 m_curvResolution = [](
double curv __attribute__((unused))) {
return 0.0008; };
The Module parameter list class.
std::vector< Candidate > getCandidates() const
Getter for the candidates structure still used in some tests.
std::vector< TrackingUtilities::CDCTrack > m_tracks
Memory for found trajectories.
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....
std::vector< const TrackingUtilities::CDCWireHit * > m_axialWireHits
Memory for the pool of axial wire hits to can be used in the post processing.
double m_param_curlCurv
Memory for the curvature of a curler in the CDC.
std::vector< WithSharedMark< TrackingUtilities::CDCRLWireHit > > searchRoad(const ANode &node, const TrackingUtilities::CDCTrajectory2D &trajectory2D)
Look for more hits near a ftted trajectory from hits available in the give node.
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.
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 TrackingUtilities::CDCSegment2D &segment2D)
Appends all reconstructed hits from the two dimensional segment.
void clear()
Removes all observations stored.
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
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.
Mixin class to attach a mark that is shared among many instances.
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.
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 ROOT::Math::XYVector &localOrigin)
Setter for the origin of the local coordinate system.
ROOT::Math::XYVector 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...
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.
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 TrackingUtilities::CDCWireHit * > &foundAxialWireHits, const std::vector< const TrackingUtilities::CDCWireHit * > &allAxialWireHits, std::vector< TrackingUtilities::CDCTrack > &axialTracks, bool withPostprocessing=true)
Create CDCTrack using CDCWireHit hits and store it in the list. Then call the postprocessing on it.