Belle II Software development
OffOriginExtension.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/legendre/quadtree/OffOriginExtension.h>
9
10#include <tracking/trackFindingCDC/legendre/quadtree/AxialHitQuadTreeProcessor.h>
11#include <tracking/trackFindingCDC/processing/AxialTrackUtil.h>
12
13#include <tracking/trackFindingCDC/fitting/CDCKarimakiFitter.h>
14#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
15
16#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
17
18#include <tracking/trackFindingCDC/numerics/LookupTable.h>
19#include <tracking/trackFindingCDC/geometry/Vector2D.h>
20
21#include <vector>
22
23using namespace Belle2;
24using namespace TrackFindingCDC;
25
26OffOriginExtension::OffOriginExtension(std::vector<const CDCWireHit*> allAxialWireHits,
27 double levelPrecision)
28 : BaseCandidateReceiver(std::move(allAxialWireHits))
29 , m_levelPrecision(levelPrecision)
30{
31}
32
33void OffOriginExtension::operator()(const std::vector<const CDCWireHit*>& inputWireHits,
34 void* qt __attribute__((unused)))
35{
36 // Unset the taken flag and let the postprocessing decide
37 for (const CDCWireHit* wireHit : inputWireHits) {
38 (*wireHit)->setTakenFlag(false);
39 }
40
41 std::vector<const CDCWireHit*> candidateHits = roadSearch(inputWireHits);
45 true);
46}
47
48std::vector<const CDCWireHit*>
49OffOriginExtension::roadSearch(const std::vector<const CDCWireHit*>& wireHits)
50{
52 CDCTrajectory2D trackTrajectory2D = fitter.fit(wireHits);
53
54 double chi2 = trackTrajectory2D.getChi2();
55 Vector2D refPos = trackTrajectory2D.getGlobalPerigee();
56
57 // change sign of the curvature; should be the same as the charge of the candidate
58 double curv = trackTrajectory2D.getCurvature();
59
60 // theta is the vector normal to the trajectory at the perigee
61 double theta = trackTrajectory2D.getGlobalCircle().phi0() + M_PI_2;
62
63 // Hide the current hits from the road search
64 for (const CDCWireHit* hit : wireHits) {
65 hit->getAutomatonCell().setTakenFlag(true);
66 }
67
68 std::vector<const CDCWireHit*> newWireHits = getHitsWRTtoRefPos(refPos, curv, theta);
69
70 // Unhide the current hits from the road search
71 for (const CDCWireHit* hit : wireHits) {
72 hit->getAutomatonCell().setTakenFlag(false);
73 }
74
75 if (newWireHits.size() == 0) return wireHits;
76
77 std::vector<const CDCWireHit*> combinedWireHits;
78
79 for (const CDCWireHit* hit : wireHits) {
80 combinedWireHits.push_back(hit);
81 }
82
83 for (const CDCWireHit* hit : newWireHits) {
84 combinedWireHits.push_back(hit);
85 }
86
87 CDCTrajectory2D combinedTrajectory2D = fitter.fit(wireHits);
88 double combinedChi2 = combinedTrajectory2D.getChi2();
89
90 if (combinedChi2 < chi2 * 2.) {
91 return combinedWireHits;
92 }
93
94 return wireHits;
95}
96
97std::vector<const CDCWireHit*>
98OffOriginExtension::getHitsWRTtoRefPos(const Vector2D& refPos, float curv, float theta)
99{
100 float thetaPrecision = 3.1415 / (pow(2., m_levelPrecision + 1));
101 float curvPrecision = 0.15 / (pow(2., m_levelPrecision));
102
104 YSpan curvSpan{curv - curvPrecision, curv + curvPrecision};
105 LookupTable<Vector2D> thetaSpan(&Vector2D::Phi, 1, theta - thetaPrecision, theta + thetaPrecision);
106
107 AxialHitQuadTreeProcessor qtProcessor(refPos, curvSpan, &thetaSpan);
108 qtProcessor.seed(m_allAxialWireHits);
109
110 std::vector<const CDCWireHit*> newWireHits = qtProcessor.getAssignedItems();
111 return newWireHits;
112}
Base class that receives candidates found by quadtree.
std::vector< const CDCWireHit * > m_allAxialWireHits
Pool of all axial hits from which the road search may select additional hits.
std::vector< CDCTrack > m_tracks
Collected tracks.
Class implementing the fitter using Karimakis method.
static const CDCKarimakiFitter & getNoDriftVarianceFitter()
Static getter for a general fitter that does not use the drift length variances.
Particle trajectory as it is seen in xy projection represented as a circle.
PerigeeCircle getGlobalCircle() const
Getter for the circle in global coordinates.
double getChi2() const
Getter for the chi2 value of the circle fit.
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.
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
Class which holds precomputed values of a function.
Definition: LookupTable.h:50
void operator()(const std::vector< const CDCWireHit * > &inputWireHits, void *qt) final
Main entry point for the post processing call from the QuadTreeProcessor.
double m_levelPrecision
Precision level for the width of the off origin hough search.
std::vector< const CDCWireHit * > roadSearch(const std::vector< const CDCWireHit * > &wireHits)
Perform transformation for set of given hits; reference position taken as POCA of the fitted trajecto...
std::vector< const CDCWireHit * > getHitsWRTtoRefPos(const Vector2D &refPos, float curv, float theta)
Get hits which are compatible with given trajectory.
OffOriginExtension(std::vector< const CDCWireHit * > allAxialWireHits, double levelPrecision=9)
Constructor.
double phi0() const
Getter for the azimuth angle of the direction of flight at the perigee.
std::vector< AData * > getAssignedItems()
Get items that have been assigned to the seed level The returned elements are unique even if items ar...
typename QuadTree::YSpan YSpan
This pair describes the span in Y for a node.
void seed(const std::vector< AData * > &datas)
Fill in the items in the given vector.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
static Vector2D Phi(const double phi)
Constructs a unit vector with azimuth angle equal to phi.
Definition: Vector2D.h:62
Abstract base class for different kinds of events.
STL namespace.
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.