Belle II Software development
HitGapSegmentPairVarSet.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/filters/segmentPair/HitGapSegmentPairVarSet.h>
9
10#include <tracking/trackingUtilities/eventdata/tracks/CDCSegmentPair.h>
11#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
12
13#include <cdc/topology/CDCWire.h>
14
15#include <tracking/trackingUtilities/numerics/Angle.h>
16
17using namespace Belle2;
18using namespace CDC;
19using namespace TrackFindingCDC;
20using namespace TrackingUtilities;
21
23{
24 if (not ptrSegmentPair) return false;
25
26 const CDCSegmentPair& segmentPair = *ptrSegmentPair;
27
28 const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
29 const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
30
31 const CDCSegment2D& fromSegment = *ptrFromSegment;
32 const CDCSegment2D& toSegment = *ptrToSegment;
33
34 const CDCRecoHit2D& fromFirstHit = fromSegment.front();
35 const CDCRecoHit2D& fromLastHit = fromSegment.back();
36
37 const CDCRecoHit2D& toFirstHit = toSegment.front();
38 const CDCRecoHit2D& toLastHit = toSegment.back();
39
40 const Vector2D fromLastHitPos = fromLastHit.getRecoPos2D();
41 const Vector2D fromFirstHitPos = fromFirstHit.getRecoPos2D();
42
43 const Vector2D toFirstHitPos = toFirstHit.getRecoPos2D();
44 const Vector2D toLastHitPos = toLastHit.getRecoPos2D();
45
46 const Vector2D hitPosGap = toFirstHitPos - fromLastHitPos;
47 const Vector2D longHitPosGap = toLastHitPos - fromFirstHitPos;
48
49 const double hitDistance = hitPosGap.norm();
50 const double longHitDistance = longHitPosGap.norm();
51
52 const Vector2D fromLastHitMom = fromLastHit.getFlightDirection2D();
53 const Vector2D toFirstHitMom = toFirstHit.getFlightDirection2D();
54
55 finitevar<named("delta_hit_pos_phi")>() = fromLastHitPos.angleWith(toFirstHitPos);
56 finitevar<named("delta_hit_mom_phi")>() = fromLastHitMom.angleWith(toFirstHitMom);
57
58 double fromLastHitAlpha = fromLastHit.getAlpha();
59 double toFirstHitAlpha = toFirstHit.getAlpha();
60 finitevar<named("delta_hit_alpha")>() = AngleUtil::normalised(toFirstHitAlpha - fromLastHitAlpha);
61
62 finitevar<named("hit_distance")>() = hitDistance;
63 finitevar<named("hit_long_distance")>() = longHitDistance;
64
65 finitevar<named("delta_hit_distance")>() = longHitDistance - hitDistance;
66
67 finitevar<named("from_hit_forward")>() = hitPosGap.dot(fromLastHitMom);
68 finitevar<named("to_hit_forward")>() = hitPosGap.dot(toFirstHitMom);
69 finitevar<named("hit_forward")>() = hitPosGap.dot(Vector2D::average(fromLastHitMom, toFirstHitMom));
70
71 const CDCRecoHit2D& axialHit = toFirstHit.isAxial() ? toFirstHit : fromLastHit;
72 const CDCRecoHit2D& stereoHit = not toFirstHit.isAxial() ? toFirstHit : fromLastHit;
73
74 const Vector2D axialHitPos = axialHit.getRecoPos2D();
75 const Vector2D axialHitMom = axialHit.getFlightDirection2D();
76
77 const CDCWire& stereoWire = stereoHit.getWire();
78 const WireLine& wireLine = stereoWire.getWireLine();
79
80 // Calculate point were the wire is first method
81 Vector2D relRefPos = wireLine.refPos2D() - axialHitPos;
82 Vector2D movePerZ = wireLine.nominalMovePerZ();
83
84 double z = -relRefPos.cross(axialHitMom) / movePerZ.cross(axialHitMom);
85 Vector2D stereoHitPos = stereoHit.getRecoPos2D() + movePerZ * z;
86
87 finitevar<named("hit_reco_z")>() = z;
88 finitevar<named("hit_z_bound_factor")>() = wireLine.outOfZBoundsFactor(z);
89 double arcLengthGap = (stereoHitPos - axialHitPos).dot(axialHitMom);
90 finitevar<named("hit_arclength_gap")>() = toFirstHit.isAxial() ? -arcLengthGap : arcLengthGap;
91
92 // const Vector2D fromStretch = fromLastHitPos - fromFirstHitPos;
93 // const Vector2D toStretch = toLastHitPos - toFirstHitPos;
94
95 // const double fromLength = fromStretch.norm();
96 // const double toLength = toStretch.norm();
97
98 // const Vector2D firstPosGap = toFirstHitPos - fromFirstHitPos;
99 // const Vector2D lastPosGap = toLastHitPos - fromLastHitPos;
100
101 // const double firstOffset = firstPosGap.norm();
102 // const double lastOffset = lastPosGap.norm();
103
104 // finitevar<named("hit_ptolemy")>() =
105 // firstOffset * lastOffset - longHitDistance * hitDistance - fromLength * toLength;
106
107 return true;
108}
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
const WireLine & getWireLine() const
Getter for the wire line representation of the wire.
Definition CDCWire.h:180
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition WireLine.h:33
const ROOT::Math::XYVector & nominalMovePerZ() const
Gives the positional move in the xy projection per unit z.
Definition WireLine.h:79
double outOfZBoundsFactor(double z) const
Returns the amount how much the given z position is outside the bounds in units of the wire length.
Definition WireLine.h:160
const ROOT::Math::XYVector & refPos2D() const
Returns the xy vector of the reference position.
Definition WireLine.h:241
bool extract(const TrackingUtilities::CDCSegmentPair *ptrSegmentPair) override
Generate and assign the contained variables.
Class representing a two dimensional reconstructed hit in the central drift chamber.
bool isAxial() const
Indicator if the underlying wire is axial.
const CDC::CDCWire & getWire() const
Getter for the wire the reconstructed hit associated to.
double getAlpha() const
Getter for the direction of flight relative to the position.
Vector2D getFlightDirection2D() const
Getter for the direction of flight.
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
A reconstructed sequence of two dimensional hits in one super layer.
Class representing a pair of one reconstructed axial segment and one stereo segment in adjacent super...
const CDCSegment2D * getToSegment() const
Getter for the to segment.
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
static constexpr int named(const char *name)
Definition VarSet.h:78
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition Vector2D.h:36
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition Vector2D.h:178
static Vector2D average(const Vector2D &one, const Vector2D &two)
Constructs the average of two vectors.
Definition Vector2D.h:104
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
Definition Vector2D.h:189
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition Vector2D.h:228
double norm() const
Calculates the length of the vector.
Definition Vector2D.h:206
T dot(GeneralVector< T > a, GeneralVector< T > b)
dot product of two general vectors
Abstract base class for different kinds of events.
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition Angle.h:33