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/trackingUtilities/eventdata/hits/CDCWireHit.h>
15
16#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
17
18#include <tracking/trackingUtilities/numerics/LookupTable.h>
19#include <tracking/trackingUtilities/geometry/Vector2D.h>
20
21#include <vector>
22
23using namespace Belle2;
24using namespace TrackFindingCDC;
25using namespace TrackingUtilities;
26
27OffOriginExtension::OffOriginExtension(std::vector<const CDCWireHit*> allAxialWireHits,
28 double levelPrecision)
29 : BaseCandidateReceiver(std::move(allAxialWireHits))
30 , m_levelPrecision(levelPrecision)
31{
32}
33
34void OffOriginExtension::operator()(const std::vector<const CDCWireHit*>& inputWireHits,
35 void* qt __attribute__((unused)))
36{
37 // Unset the taken flag and let the postprocessing decide
38 for (const CDCWireHit* wireHit : inputWireHits) {
39 (*wireHit)->setTakenFlag(false);
40 }
41
42 std::vector<const CDCWireHit*> candidateHits = roadSearch(inputWireHits);
46 true);
47}
48
49std::vector<const CDCWireHit*>
50OffOriginExtension::roadSearch(const std::vector<const CDCWireHit*>& wireHits)
51{
53 CDCTrajectory2D trackTrajectory2D = fitter.fit(wireHits);
54
55 double chi2 = trackTrajectory2D.getChi2();
56 Vector2D refPos = trackTrajectory2D.getGlobalPerigee();
57
58 // change sign of the curvature; should be the same as the charge of the candidate
59 double curv = trackTrajectory2D.getCurvature();
60
61 // theta is the vector normal to the trajectory at the perigee
62 double theta = trackTrajectory2D.getGlobalCircle().phi0() + M_PI_2;
63
64 // Hide the current hits from the road search
65 for (const CDCWireHit* hit : wireHits) {
66 hit->getAutomatonCell().setTakenFlag(true);
67 }
68
69 std::vector<const CDCWireHit*> newWireHits = getHitsWRTtoRefPos(refPos, curv, theta);
70
71 // Unhide the current hits from the road search
72 for (const CDCWireHit* hit : wireHits) {
73 hit->getAutomatonCell().setTakenFlag(false);
74 }
75
76 if (newWireHits.size() == 0) return wireHits;
77
78 std::vector<const CDCWireHit*> combinedWireHits;
79
80 for (const CDCWireHit* hit : wireHits) {
81 combinedWireHits.push_back(hit);
82 }
83
84 for (const CDCWireHit* hit : newWireHits) {
85 combinedWireHits.push_back(hit);
86 }
87
88 CDCTrajectory2D combinedTrajectory2D = fitter.fit(wireHits);
89 double combinedChi2 = combinedTrajectory2D.getChi2();
90
91 if (combinedChi2 < chi2 * 2.) {
92 return combinedWireHits;
93 }
94
95 return wireHits;
96}
97
98std::vector<const CDCWireHit*>
99OffOriginExtension::getHitsWRTtoRefPos(const Vector2D& refPos, float curv, float theta)
100{
101 float thetaPrecision = M_PI / (pow(2., m_levelPrecision + 1));
102 float curvPrecision = 0.15 / (pow(2., m_levelPrecision));
103
105 YSpan curvSpan{curv - curvPrecision, curv + curvPrecision};
106 LookupTable<Vector2D> thetaSpan(&Vector2D::Phi, 1, theta - thetaPrecision, theta + thetaPrecision);
107
108 AxialHitQuadTreeProcessor qtProcessor(refPos, curvSpan, &thetaSpan);
109 qtProcessor.seed(m_allAxialWireHits);
110
111 std::vector<const CDCWireHit*> newWireHits = qtProcessor.getAssignedItems();
112 return newWireHits;
113}
std::vector< TrackingUtilities::CDCTrack > m_tracks
Collected tracks.
BaseCandidateReceiver(std::vector< const TrackingUtilities::CDCWireHit * > allAxialWireHits)
Constructor.
std::vector< const TrackingUtilities::CDCWireHit * > m_allAxialWireHits
Pool of all axial hits from which the road search may select additional hits.
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.
std::vector< const TrackingUtilities::CDCWireHit * > getHitsWRTtoRefPos(const TrackingUtilities::Vector2D &refPos, float curv, float theta)
Get hits which are compatible with given trajectory.
double m_levelPrecision
Precision level for the width of the off origin hough search.
std::vector< const TrackingUtilities::CDCWireHit * > roadSearch(const std::vector< const TrackingUtilities::CDCWireHit * > &wireHits)
Perform transformation for set of given hits; reference position taken as POCA of the fitted trajecto...
void operator()(const std::vector< const TrackingUtilities::CDCWireHit * > &inputWireHits, void *qt) final
Main entry point for the post processing call from the QuadTreeProcessor.
OffOriginExtension(std::vector< const TrackingUtilities::CDCWireHit * > allAxialWireHits, double levelPrecision=9)
Constructor.
std::vector< AData * > getAssignedItems()
Get items that have been assigned to the seed level The returned elements are unique even if items ar...
void seed(const std::vector< AData * > &datas)
Fill in the items in the given vector.
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:58
Class which holds precomputed values of a function.
Definition LookupTable.h:50
double phi0() const
Getter for the azimuth angle of the direction of flight at the perigee.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition Vector2D.h:36
static Vector2D Phi(const double phi)
Constructs a unit vector with azimuth angle equal to phi.
Definition Vector2D.h:82
Abstract base class for different kinds of events.
STL namespace.
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.