Belle II Software development
CDCRecoHit3D.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/eventdata/hits/CDCRecoHit3D.h>
9
10#include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit2D.h>
11#include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHit.h>
12#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
13
14#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
15#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
16#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
17
18#include <tracking/trackFindingCDC/topology/CDCWire.h>
19#include <tracking/trackFindingCDC/topology/EStereoKind.h>
20
21#include <tracking/trackFindingCDC/geometry/Vector3D.h>
22#include <tracking/trackFindingCDC/geometry/Vector2D.h>
23
24#include <tracking/trackFindingCDC/numerics/ERightLeft.h>
25
26#include <tracking/trackFindingCDC/numerics/ESign.h>
27
28#include <cdc/dataobjects/CDCSimHit.h>
29
30#include <framework/logging/Logger.h>
31
32#include <cmath>
33
34using namespace Belle2;
35using namespace TrackFindingCDC;
36
38 const Vector3D& recoPos3D,
39 double arcLength2D)
40 : m_rlWireHit(rlWireHit)
41 , m_recoPos3D(recoPos3D)
42 , m_arcLength2D(arcLength2D)
43{
44}
45
47{
48 // arc length cannot be deduced from the flightTime in this context
49 double arcLength2D = std::numeric_limits<double>::quiet_NaN();
50
51 return CDCRecoHit3D(CDCRLWireHit::fromSimHit(wireHit, simHit),
52 Vector3D{simHit.getPosTrack()},
53 arcLength2D);
54}
55
57 const CDCTrajectory2D& trajectory2D)
58{
59 Vector3D recoPos3D = recoHit2D.reconstruct3D(trajectory2D);
60 double arcLength2D = trajectory2D.calcArcLength2D(recoPos3D.xy());
61 return CDCRecoHit3D(recoHit2D.getRLWireHit(), recoPos3D, arcLength2D);
62}
63
65 ERightLeft rlInfo,
66 const CDCTrajectory2D& trajectory2D)
67{
68 Vector3D recoPos3D = wireHit->reconstruct3D(trajectory2D, rlInfo);
69 double arcLength2D = trajectory2D.calcArcLength2D(recoPos3D.xy());
70 CDCRLWireHit rlWireHit(wireHit, rlInfo);
71 return CDCRecoHit3D(rlWireHit, recoPos3D, arcLength2D);
72}
73
75 const CDCTrajectory2D& trajectory2D)
76{
77 Vector3D recoPos3D = rlWireHit.reconstruct3D(trajectory2D);
78 double arcLength2D = trajectory2D.calcArcLength2D(recoPos3D.xy());
79 return CDCRecoHit3D(rlWireHit, recoPos3D, arcLength2D);
80}
81
83 const CDCTrajectory3D& trajectory3D)
84{
85 // This this is quite legacy behaviour - do something smarter.
86 CDCTrajectory2D trajectory2D = trajectory3D.getTrajectory2D();
87 CDCTrajectorySZ trajectorySZ = trajectory3D.getTrajectorySZ();
88
89 return reconstruct(recoHit, trajectory2D, trajectorySZ);
90}
91
93 const CDCTrajectory2D& trajectory2D,
94 const CDCTrajectorySZ& trajectorySZ)
95{
96 EStereoKind stereoKind = recoHit2D.getStereoKind();
97
98 double arcLength2D = 0;
99 if (stereoKind == EStereoKind::c_StereoU or stereoKind == EStereoKind::c_StereoV) {
100 //the closest approach of a wire line to a helix
101 //( in this case represented by the two trajectories )
102 //can not be solved as a closed expression
103 //in the common case the z fit has been derived from the reconstructed points generated
104 //with the reconstruct method above in the other reconstruct method.
105 //sticking to that method but using the average z from the sz fit
106 Vector3D recoPos3D = recoHit2D.reconstruct3D(trajectory2D);
107 arcLength2D = trajectory2D.calcArcLength2D(recoPos3D.xy());
108
109 } else { /* if (stereoKind == EStereoKind::c_Axial)*/
110 Vector2D recoPos2D = trajectory2D.getClosest(recoHit2D.getRecoPos2D());
111 arcLength2D = trajectory2D.calcArcLength2D(recoPos2D);
112
113 }
114
115 const double z = trajectorySZ.mapSToZ(arcLength2D);
116
117 // Reevaluating the z position eventually accounts for wire sag.
118 const CDCWire& wire = recoHit2D.getWire();
119 const Vector2D recoWirePos2D = wire.getWirePos2DAtZ(z);
120 const Vector2D correctedRecoPos2D = trajectory2D.getClosest(recoWirePos2D);
121 const double correctedPerpS = trajectory2D.calcArcLength2D(correctedRecoPos2D);
122 const double correctedZ = trajectorySZ.mapSToZ(correctedPerpS);
123 const Vector3D correctedRecoPos3D(correctedRecoPos2D, correctedZ);
124
125 CDCRecoHit3D result(recoHit2D.getRLWireHit(), correctedRecoPos3D, correctedPerpS);
126 result.snapToDriftCircle();
127 return result;
128}
129
131 const CDCTrajectory2D& trajectory2D)
132{
133 B2ASSERT("This function can only be used with axial hits.", axialWireHit->isAxial());
134 ERightLeft rlInfo = trajectory2D.isRightOrLeft(axialWireHit->getRefPos2D());
135 CDCRLWireHit rlWireHit(axialWireHit, rlInfo);
136 return CDCRecoHit3D::reconstruct(rlWireHit, trajectory2D);
137}
138
140{
141 if (first.getRLWireHit() == second.getRLWireHit()) {
142 return CDCRecoHit3D(first.getRLWireHit(),
143 Vector3D::average(first.getRecoPos3D(), second.getRecoPos3D()),
144 (first.getArcLength2D() + second.getArcLength2D()) / 2);
145 } else {
146 B2ERROR("Averaging three dimensional hits which are on different oriented wire hits. Return "
147 "first one unchanged");
148 return first;
149 }
150}
151
153{
154 const CDCWire& wire = getWire();
155 const double recoPosZ = getRecoPos3D().z();
156
157 Vector2D wirePos = wire.getWirePos2DAtZ(recoPosZ);
158 Vector2D disp2D = getRecoPos3D().xy() - wirePos;
159 return disp2D;
160}
161
163{
165}
166
168{
170}
171
173{
174 const CDCWire& wire = getWire();
175 const double recoPosZ = getRecoPos3D().z();
176
177 Vector2D wirePos = wire.getWirePos2DAtZ(recoPosZ);
178 Vector2D disp2D = getRecoPos3D().xy() - wirePos;
179
181 if (switchSide) {
182 disp2D = -disp2D;
183 }
184 m_recoPos3D = Vector3D(wirePos + disp2D, recoPosZ);
185}
186
187void CDCRecoHit3D::setRecoDriftLength(double driftLength, bool snapRecoPos)
188{
189 double oldDriftLength = m_rlWireHit.getRefDriftLength();
190 m_rlWireHit.setRefDriftLength(driftLength);
191 if (snapRecoPos) {
192 bool switchSide = sign(oldDriftLength) != sign(driftLength);
193 snapToDriftCircle(switchSide);
194 }
195}
196
198{
200}
201
203{
204 return getRecoHit2D();
205}
206
208{
209 return getWire().getWirePos2DAtZ(getRecoZ());
210}
211
212bool CDCRecoHit3D::isInCellZBounds(const double factor) const
213{
214 return getWire().isInCellZBounds(getRecoPos3D(), factor);
215}
Example Detector.
Definition: CDCSimHit.h:21
B2Vector3D getPosTrack() const
The method to get position on the track.
Definition: CDCSimHit.h:217
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
void reverse()
Switches the right left passage to its opposite in place.
Definition: CDCRLWireHit.h:98
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:204
void setRefDriftLength(double driftLength)
Setter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:210
static CDCRLWireHit fromSimHit(const CDCWireHit *wirehit, const CDCSimHit &simhit)
Constructs an oriented wire hit from a CDCSimHit and the associated wirehit.
Vector3D 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.
Definition: CDCRecoHit2D.h:47
const CDCRLWireHit & getRLWireHit() const
Getter for the oriented wire hit associated with the reconstructed hit.
Definition: CDCRecoHit2D.h:281
Vector3D reconstruct3D(const CDCTrajectory2D &trajectory2D, const double z=0) const
Reconstruct the three dimensional position (especially of stereo hits) by determining the z coordinat...
const CDCWire & getWire() const
Getter for the wire the reconstructed hit associated to.
Definition: CDCRecoHit2D.h:175
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
Definition: CDCRecoHit2D.h:238
EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
Definition: CDCRecoHit2D.h:157
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:52
static CDCRecoHit3D average(const CDCRecoHit3D &first, const CDCRecoHit3D &second)
Constructs the average of two reconstructed hit positions.
const Vector3D & getRecoPos3D() const
Getter for the 3d position of the hit.
Definition: CDCRecoHit3D.h:285
const CDCRLWireHit & getRLWireHit() const
Getter for the oriented wire hit.
Definition: CDCRecoHit3D.h:250
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.
Definition: CDCRecoHit3D.h:346
static CDCRecoHit3D reconstruct(const CDCRecoHit2D &recoHit2D, const CDCTrajectory2D &trajectory2D)
Reconstructs the three dimensional hit from the two dimensional and the two dimensional trajectory.
Definition: CDCRecoHit3D.cc:56
const CDCWire & getWire() const
Getter for the wire.
Definition: CDCRecoHit3D.h:226
CDCRecoHit2D getRecoHit2D() const
Constructs a two dimensional reconstructed hit by carrying out the stereo ! projection to the wire re...
Vector2D getRecoWirePos2D() const
Returns the position of the wire in the xy plain the reconstructed position is located in.
static CDCRecoHit3D fromSimHit(const CDCWireHit *wireHit, const CDCSimHit &simHit)
Constructs a three dimensional reconstructed hit from a sim hit and the associated wirehit.
Definition: CDCRecoHit3D.cc:46
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.
Definition: CDCRecoHit3D.h:303
double getArcLength2D() const
Getter for the travel distance in the xy projection.
Definition: CDCRecoHit3D.h:370
CDCRecoHit2D stereoProjectToRef() const
Constructs a two dimensional reconstructed hit by carrying out the stereo ! projection to the wire re...
CDCRLWireHit m_rlWireHit
Memory for the oriented wire hit reference.
Definition: CDCRecoHit3D.h:389
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)),...
Vector2D getRecoDisp2D() const
Gets the displacement from the wire position in the xy plain at the reconstructed position.
Vector3D m_recoPos3D
Memory for the reconstructed hit position.
Definition: CDCRecoHit3D.h:392
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.
double calcArcLength2D(const Vector2D &point) const
Calculate the travel distance from the start position of the trajectory.
ERightLeft isRightOrLeft(const Vector2D &point) const
Checks if the given point is to the right or to the left of the trajectory.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
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.
Definition: CDCWireHit.h:55
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
bool isInCellZBounds(const Vector3D &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...
Definition: CDCWire.h:295
Vector2D getWirePos2DAtZ(const double z) const
Gives the xy projected position of the wire at the given z coordinate.
Definition: CDCWire.h:192
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
Definition: Vector2D.h:313
A three dimensional vector.
Definition: Vector3D.h:33
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:508
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.