Belle II Software development
CDCRecoHit3D.h
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#pragma once
9
10#include <tracking/trackingUtilities/eventdata/hits/CDCRLWireHit.h>
11
12#include <tracking/trackingUtilities/numerics/ERightLeft.h>
13#include <tracking/trackingUtilities/numerics/ERotation.h>
14
15#include <cdc/topology/EStereoKind.h>
16#include <cdc/topology/ISuperLayer.h>
17
18#include <framework/geometry/VectorUtil.h>
19#include <tracking/trackingUtilities/geometry/VectorUtil.h>
20
21#include <Math/Vector3D.h>
22#include <Math/Vector2D.h>
23#include <Math/VectorUtil.h>
24
25namespace Belle2 {
30 class CDCSimHit;
31 class CDCHit;
32
33 namespace CDC {
34 class CDCWire;
35 }
36
37 namespace TrackingUtilities {
38 // Forward declaration.
39 class CDCTrajectory3D;
40 class CDCTrajectory2D;
41 class CDCTrajectorySZ;
42 class CDCWireHit;
43 class CDCRecoHit2D;
44
60 public:
62 CDCRecoHit3D() = default;
63
65 CDCRecoHit3D(const CDCRLWireHit& rlWireHit, const ROOT::Math::XYZVector& recoPos3D, double arcLength2D = 0);
66
75 static CDCRecoHit3D fromSimHit(const CDCWireHit* wireHit, const CDCSimHit& simHit);
76
89 static CDCRecoHit3D reconstruct(const CDCRecoHit2D& recoHit2D,
90 const CDCTrajectory2D& trajectory2D);
91
97 static CDCRecoHit3D reconstruct(const CDCRLWireHit& rlWireHit,
98 const CDCTrajectory2D& trajectory2D);
99
105 static CDCRecoHit3D reconstruct(const CDCWireHit* wireHit,
106 ERightLeft rlInfo,
107 const CDCTrajectory2D& trajectory2D);
108
118 static CDCRecoHit3D reconstructNearest(const CDCWireHit* axialWireHit,
119 const CDCTrajectory2D& trajectory2D);
120
122 static CDCRecoHit3D reconstruct(const CDCRecoHit2D& recoHit,
123 const CDCTrajectory3D& trajectory3D);
124
141 static CDCRecoHit3D reconstruct(const CDCRecoHit2D& recoHit2D,
142 const CDCTrajectory2D& trajectory2D,
143 const CDCTrajectorySZ& trajectorySZ);
144
145 public:
152 static CDCRecoHit3D average(const CDCRecoHit3D& first,
153 const CDCRecoHit3D& second);
154
160 void reverse();
161
163 CDCRecoHit3D reversed() const;
164
166 operator const Belle2::CDCHit* () const
167 {
168 return static_cast<const CDCHit*>(getRLWireHit());
169 }
170
172 bool operator==(const CDCRecoHit3D& other) const
173 {
174 return getRLWireHit() == other.getRLWireHit() and
175 getRLInfo() == other.getRLInfo() and
176 getRecoPos3D() == other.getRecoPos3D();
177 }
178
183 bool operator<(const CDCRecoHit3D& other) const
184 {
185 return (getRLWireHit() < other.getRLWireHit() or
186 (getRLWireHit() == other.getRLWireHit() and
187 VectorUtil::smaller(getRecoPos3D(), other.getRecoPos3D())));
188 }
189
191 friend bool operator<(const CDCRecoHit3D& recoHit3D, const CDC::CDCWire& wire)
192 {
193 return recoHit3D.getRLWireHit() < wire;
194 }
195
197 friend bool operator<(const CDC::CDCWire& wire, const CDCRecoHit3D& recoHit3D)
198 {
199 return wire < recoHit3D.getRLWireHit();
200 }
201
203 friend bool operator<(const CDCRecoHit3D& recoHit3D, const CDCWireHit& wireHit)
204 {
205 return recoHit3D.getRLWireHit() < wireHit;
206 }
207
209 friend bool operator<(const CDCWireHit& wireHit, const CDCRecoHit3D& recoHit3D)
210 {
211 return wireHit < recoHit3D.getRLWireHit();
212 }
213
216 {
217 return getRLWireHit().getStereoKind();
218 }
219
221 bool isAxial() const
222 {
223 return getRLWireHit().isAxial();
224 }
225
228 {
229 return getRLWireHit().getISuperLayer();
230 }
231
233 const CDC::CDCWire& getWire() const
234 {
235 return getRLWireHit().getWire();
236 }
237
239 bool isOnWire(const CDC::CDCWire& wire) const
240 {
241 return getRLWireHit().isOnWire(wire);
242 }
243
245 const CDCWireHit& getWireHit() const
246 {
247 return getRLWireHit().getWireHit();
248 }
249
251 bool hasWireHit(const CDCWireHit& wireHit) const
252 {
253 return getRLWireHit().hasWireHit(wireHit);
254 }
255
258 {
259 return m_rlWireHit;
260 }
261
263 void setRLWireHit(const CDCRLWireHit& rlWireHit)
264 {
265 m_rlWireHit = rlWireHit;
266 }
267
274 ERightLeft getRLInfo() const
275 {
276 return getRLWireHit().getRLInfo();
277 }
278
280 void setRLInfo(ERightLeft rlInfo)
281 {
282 m_rlWireHit.setRLInfo(rlInfo);
283 }
284
286 const ROOT::Math::XYVector& getRefPos2D() const
287 {
288 return getRLWireHit().getRefPos2D();
289 }
290
292 const ROOT::Math::XYZVector& getRecoPos3D() const
293 {
294 return m_recoPos3D;
295 }
296
298 void setRecoPos3D(const ROOT::Math::XYZVector& recoPos3D)
299 {
300 m_recoPos3D = recoPos3D;
301 }
302
306 const ROOT::Math::XYVector getRecoPos2D() const
307 {
308 return VectorUtil::getXYVector(getRecoPos3D());
309 }
310
312 double getRecoZ() const
313 {
314 return getRecoPos3D().z();
315 }
316
318 ROOT::Math::XYVector getRecoDisp2D() const;
319
321 ROOT::Math::XYVector getFlightDirection2D() const
322 {
323 ERotation rotation = static_cast<ERotation>(-getRLInfo());
324 return VectorUtil::Orthogonal(getRecoDisp2D(), rotation);
325 }
326
328 double getAlpha() const
329 {
330 return ROOT::Math::VectorUtil::DeltaPhi(getRecoPos2D(), getFlightDirection2D());
331 }
332
338
344
346 ROOT::Math::XYVector getRecoWirePos2D() const;
347
349 void snapToDriftCircle(bool switchSide = false);
350
356 {
358 }
359
361 void setRecoDriftLength(double driftLength, bool snapRecoPos);
362
368 {
370 }
371
373 void shiftArcLength2D(double arcLength2DOffSet)
374 {
375 m_arcLength2D += arcLength2DOffSet;
376 }
377
379 double getArcLength2D() const
380 {
381 return m_arcLength2D;
382 }
383
385 void setArcLength2D(const double arcLength2D)
386 {
387 m_arcLength2D = arcLength2D;
388 }
389
394 bool isInCellZBounds(const double factor = 1) const;
395
396 private:
399
401 ROOT::Math::XYZVector m_recoPos3D;
402
404 double m_arcLength2D = 0;
405 };
406 }
408}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
Example Detector.
Definition CDCSimHit.h:21
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the oriented hit.
CDC::ISuperLayer getISuperLayer() const
Getter for the superlayer id.
double getRefDriftLengthVariance() const
Getter for the variance of the drift length at the reference position of the wire.
const ROOT::Math::XYVector & getRefPos2D() const
The two dimensional reference position of the underlying wire.
bool isAxial() const
Indicator if the underlying wire is axial.
const CDC::CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
bool hasWireHit(const CDCWireHit &wirehit) const
Checks if the oriented hit is associated with the give wire hit.
double getSignedRefDriftLength() const
Getter for the drift length at the reference position of the wire.
bool isOnWire(const CDC::CDCWire &wire) const
Checks if the oriented hit is associated with the give wire.
CDC::EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
ERightLeft getRLInfo() const
Getter for the right left passage information.
Class representing a two dimensional reconstructed hit in the central drift chamber.
static CDCRecoHit3D average(const CDCRecoHit3D &first, const CDCRecoHit3D &second)
Constructs the average of two reconstructed hit positions.
const CDCWireHit & getWireHit() const
Getter for the wire hit.
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.
void shiftArcLength2D(double arcLength2DOffSet)
Adjust the travel distance by the given value.
const CDCRLWireHit & getRLWireHit() const
Getter for the oriented wire hit.
CDCRecoHit3D()=default
Default constructor for ROOT.
void reverse()
Turns the orientation in place.
const ROOT::Math::XYVector & getRefPos2D() const
Getter for the reference position of the wire.
bool isAxial() const
Indicator if the underlying wire is axial.
double getSignedRecoDriftLength() const
Returns the drift length next to the reconstructed position.
ROOT::Math::XYVector getFlightDirection2D() const
Getter for the direction of flight.
ROOT::Math::XYZVector m_recoPos3D
Memory for the reconstructed hit position.
CDC::ISuperLayer getISuperLayer() const
Getter for the superlayer id.
friend bool operator<(const CDCWireHit &wireHit, const CDCRecoHit3D &recoHit3D)
Defines wire hits and the three dimensional reconstructed hits as coaligned.
bool operator<(const CDCRecoHit3D &other) const
Total ordering relation based on wire hit, right left passage information and position information in...
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.
double getAlpha() const
Getter for the direction of flight relative to the position.
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.
void setRLWireHit(const CDCRLWireHit &rlWireHit)
Setter for the oriented wire hit associated with the reconstructed hit.
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 getRecoDriftLengthVariance() const
Returns the drift length variance next to the reconstructed position.
double getArcLength2D() const
Getter for the travel distance in the xy projection.
friend bool operator<(const CDCRecoHit3D &recoHit3D, const CDCWireHit &wireHit)
Defines wire hits and the three dimensional reconstructed hits as coaligned.
bool hasWireHit(const CDCWireHit &wireHit) const
Checks if the reconstructed hit is associated with the give wire hit.
CDCRecoHit2D stereoProjectToRef() const
Constructs a two dimensional reconstructed hit by carrying out the stereo !
void setArcLength2D(const double arcLength2D)
Setter for the travel distance in the xy projection.
bool operator==(const CDCRecoHit3D &other) const
Equality comparison based on wire hit, right left passage information and reconstructed position.
CDCRLWireHit m_rlWireHit
Memory for the oriented wire hit reference.
bool isOnWire(const CDC::CDCWire &wire) const
Checks if the reconstructed hit is associated with the give wire.
CDC::EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
void setRLInfo(ERightLeft rlInfo)
Setter the right left passage information.
const ROOT::Math::XYVector getRecoPos2D() const
Getter for the 2d position of the hit.
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)),...
ERightLeft getRLInfo() const
Getter for the right left passage information.
void setRecoPos3D(const ROOT::Math::XYZVector &recoPos3D)
Setter for the 3d position of the hit.
friend bool operator<(const CDCRecoHit3D &recoHit3D, const CDC::CDCWire &wire)
Defines wires and the three dimensional reconstructed hits as coaligned.
friend bool operator<(const CDC::CDCWire &wire, const CDCRecoHit3D &recoHit3D)
Defines wires and the three dimensional reconstructed hits as coaligned.
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.
Particle full three dimensional trajectory.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:56
EStereoKind
Type for the stereo property of the wire.
Definition EStereoKind.h:20
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
Abstract base class for different kinds of events.