8#include <tracking/trackingUtilities/eventdata/hits/CDCRecoHit3D.h>
10#include <tracking/trackingUtilities/eventdata/hits/CDCRecoHit2D.h>
11#include <tracking/trackingUtilities/eventdata/hits/CDCRLWireHit.h>
12#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
14#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory3D.h>
15#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
16#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectorySZ.h>
18#include <cdc/topology/CDCWire.h>
19#include <cdc/topology/EStereoKind.h>
21#include <tracking/trackingUtilities/geometry/VectorUtil.h>
23#include <tracking/trackingUtilities/numerics/ERightLeft.h>
25#include <tracking/trackingUtilities/numerics/ESign.h>
27#include <cdc/dataobjects/CDCSimHit.h>
29#include <framework/logging/Logger.h>
35using namespace TrackingUtilities;
38 const ROOT::Math::XYZVector& recoPos3D,
49 double arcLength2D = std::numeric_limits<double>::quiet_NaN();
59 ROOT::Math::XYZVector recoPos3D = recoHit2D.
reconstruct3D(trajectory2D);
60 double arcLength2D = trajectory2D.
calcArcLength2D(VectorUtil::getXYVector(recoPos3D));
68 ROOT::Math::XYZVector recoPos3D = wireHit->reconstruct3D(trajectory2D, rlInfo);
69 double arcLength2D = trajectory2D.
calcArcLength2D(VectorUtil::getXYVector(recoPos3D));
77 ROOT::Math::XYZVector recoPos3D = rlWireHit.
reconstruct3D(trajectory2D);
78 double arcLength2D = trajectory2D.
calcArcLength2D(VectorUtil::getXYVector(recoPos3D));
89 return reconstruct(recoHit, trajectory2D, trajectorySZ);
98 double arcLength2D = 0;
99 if (stereoKind == EStereoKind::c_StereoU or stereoKind == EStereoKind::c_StereoV) {
106 ROOT::Math::XYZVector recoPos3D = recoHit2D.
reconstruct3D(trajectory2D);
107 arcLength2D = trajectory2D.
calcArcLength2D(VectorUtil::getXYVector(recoPos3D));
115 const double z = trajectorySZ.
mapSToZ(arcLength2D);
120 const ROOT::Math::XYVector correctedRecoPos2D = trajectory2D.
getClosest(recoWirePos2D);
121 const double correctedPerpS = trajectory2D.
calcArcLength2D(correctedRecoPos2D);
122 const double correctedZ = trajectorySZ.
mapSToZ(correctedPerpS);
123 const ROOT::Math::XYZVector correctedRecoPos3D(correctedRecoPos2D.X(), correctedRecoPos2D.Y(), correctedZ);
126 result.snapToDriftCircle();
133 B2ASSERT(
"This function can only be used with axial hits.", axialWireHit->isAxial());
134 ERightLeft rlInfo = trajectory2D.
isRightOrLeft(axialWireHit->getRefPos2D());
141 if (first.getRLWireHit() == second.getRLWireHit()) {
143 VectorUtil::average(first.getRecoPos3D(), second.getRecoPos3D()),
144 (first.getArcLength2D() + second.getArcLength2D()) / 2);
146 B2ERROR(
"Averaging three dimensional hits which are on different oriented wire hits. Return "
147 "first one unchanged");
158 ROOT::Math::XYVector disp2D = VectorUtil::getXYVector(
getRecoPos3D()) - wirePos;
178 ROOT::Math::XYVector disp2D = VectorUtil::getXYVector(
getRecoPos3D()) - wirePos;
180 if (disp2D.R() != 0.0) {
186 const auto& tmp = wirePos + disp2D;
187 m_recoPos3D = ROOT::Math::XYZVector(tmp.X(), tmp.Y(), recoPosZ);
192 double oldDriftLength =
m_rlWireHit.getRefDriftLength();
195 bool switchSide = sign(oldDriftLength) != sign(driftLength);
B2Vector3D getPosTrack() const
The method to get position on the track.
Class representing a sense wire in the central drift chamber.
ROOT::Math::XYVector getWirePos2DAtZ(const double z) const
Gives the xy projected position of the wire at the given z coordinate.
bool isInCellZBounds(const ROOT::Math::XYZVector &pos3D, const double factor=1) const
Checks whether the position is in the z bounds of the drift cell (scaled by the factor) surrounding t...
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
static CDCRLWireHit fromSimHit(const CDCWireHit *wirehit, const CDCSimHit &simhit)
Constructs an oriented wire hit from a CDCSimHit and the associated wirehit.
ROOT::Math::XYZVector reconstruct3D(const CDCTrajectory2D &trajectory2D, double z=0) const
Attempts to reconstruct a three dimensional position (especially of stereo hits).
Class representing a two dimensional reconstructed hit in the central drift chamber.
const CDCRLWireHit & getRLWireHit() const
Getter for the oriented wire hit associated with the reconstructed hit.
ROOT::Math::XYVector getRecoPos2D() const
Getter for the position in the reference plane.
const CDC::CDCWire & getWire() const
Getter for the wire the reconstructed hit associated to.
ROOT::Math::XYZVector reconstruct3D(const CDCTrajectory2D &trajectory2D, const double z=0) const
Reconstruct the three dimensional position (especially of stereo hits) by determining the z coordinat...
CDC::EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
static CDCRecoHit3D average(const CDCRecoHit3D &first, const CDCRecoHit3D &second)
Constructs the average of two reconstructed hit positions.
ROOT::Math::XYVector getRecoWirePos2D() const
Returns the position of the wire in the xy plain the reconstructed position is located in.
const ROOT::Math::XYZVector & getRecoPos3D() const
Getter for the 3d position of the hit.
double m_arcLength2D
Memory for the travel distance as see in the xy projection.
const CDCRLWireHit & getRLWireHit() const
Getter for the oriented wire hit.
CDCRecoHit3D()=default
Default constructor for ROOT.
void reverse()
Turns the orientation in place.
double getSignedRecoDriftLength() const
Returns the drift length next to the reconstructed position.
ROOT::Math::XYZVector m_recoPos3D
Memory for the reconstructed hit position.
static CDCRecoHit3D reconstruct(const CDCRecoHit2D &recoHit2D, const CDCTrajectory2D &trajectory2D)
Reconstructs the three dimensional hit from the two dimensional and the two dimensional trajectory.
const CDC::CDCWire & getWire() const
Getter for the wire.
CDCRecoHit2D getRecoHit2D() const
Constructs a two dimensional reconstructed hit by carrying out the stereo !
static CDCRecoHit3D fromSimHit(const CDCWireHit *wireHit, const CDCSimHit &simHit)
Constructs a three dimensional reconstructed hit from a sim hit and the associated wirehit.
void snapToDriftCircle(bool switchSide=false)
Scales the displacement vector in place to lie on the drift circle.
double getRecoZ() const
Getter for the z coordinate of the reconstructed position.
ROOT::Math::XYVector getRecoDisp2D() const
Gets the displacement from the wire position in the xy plain at the reconstructed position.
double getArcLength2D() const
Getter for the travel distance in the xy projection.
CDCRecoHit2D stereoProjectToRef() const
Constructs a two dimensional reconstructed hit by carrying out the stereo !
CDCRLWireHit m_rlWireHit
Memory for the oriented wire hit reference.
CDCRecoHit3D reversed() const
Returns the recohit with the opposite right left information.
void setRecoDriftLength(double driftLength, bool snapRecoPos)
Setter to update the drift length of the hit.
static CDCRecoHit3D reconstructNearest(const CDCWireHit *axialWireHit, const CDCTrajectory2D &trajectory2D)
Reconstruct a three dimensional hit from a wire hit (as in reconstruct(rlWireHit, trajectory2D)),...
bool isInCellZBounds(const double factor=1) const
Indicator if the hit is in the cdc (scaled by the factor) or already outside its boundaries.
Particle trajectory as it is seen in xy projection represented as a circle.
ROOT::Math::XYVector getClosest(const ROOT::Math::XYVector &point) const
Calculates the closest approach on the trajectory to the given point.
double calcArcLength2D(const ROOT::Math::XYVector &point) const
Calculate the travel distance from the start position of the trajectory.
ERightLeft isRightOrLeft(const ROOT::Math::XYVector &point) const
Checks if the given point is to the right or to the left of the trajectory.
Particle full three dimensional trajectory.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the sz trajectory.
Linear trajectory in sz space.
double mapSToZ(const double s=0) const
Translates the travel distance to the z coordinate.
Class representing a hit wire in the central drift chamber.
EStereoKind
Type for the stereo property of the wire.
Abstract base class for different kinds of events.