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/trackFindingCDC/eventdata/tracks/CDCSegmentPair.h>
11#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
12
13#include <tracking/trackFindingCDC/topology/CDCWire.h>
14
15#include <tracking/trackFindingCDC/numerics/Angle.h>
16
17using namespace Belle2;
18using namespace TrackFindingCDC;
19
21{
22 if (not ptrSegmentPair) return false;
23
24 const CDCSegmentPair& segmentPair = *ptrSegmentPair;
25
26 const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
27 const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
28
29 const CDCSegment2D& fromSegment = *ptrFromSegment;
30 const CDCSegment2D& toSegment = *ptrToSegment;
31
32 const CDCRecoHit2D& fromFirstHit = fromSegment.front();
33 const CDCRecoHit2D& fromLastHit = fromSegment.back();
34
35 const CDCRecoHit2D& toFirstHit = toSegment.front();
36 const CDCRecoHit2D& toLastHit = toSegment.back();
37
38 const Vector2D fromLastHitPos = fromLastHit.getRecoPos2D();
39 const Vector2D fromFirstHitPos = fromFirstHit.getRecoPos2D();
40
41 const Vector2D toFirstHitPos = toFirstHit.getRecoPos2D();
42 const Vector2D toLastHitPos = toLastHit.getRecoPos2D();
43
44 const Vector2D hitPosGap = toFirstHitPos - fromLastHitPos;
45 const Vector2D longHitPosGap = toLastHitPos - fromFirstHitPos;
46
47 const double hitDistance = hitPosGap.norm();
48 const double longHitDistance = longHitPosGap.norm();
49
50 const Vector2D fromLastHitMom = fromLastHit.getFlightDirection2D();
51 const Vector2D toFirstHitMom = toFirstHit.getFlightDirection2D();
52
53 finitevar<named("delta_hit_pos_phi")>() = fromLastHitPos.angleWith(toFirstHitPos);
54 finitevar<named("delta_hit_mom_phi")>() = fromLastHitMom.angleWith(toFirstHitMom);
55
56 double fromLastHitAlpha = fromLastHit.getAlpha();
57 double toFirstHitAlpha = toFirstHit.getAlpha();
58 finitevar<named("delta_hit_alpha")>() = AngleUtil::normalised(toFirstHitAlpha - fromLastHitAlpha);
59
60 finitevar<named("hit_distance")>() = hitDistance;
61 finitevar<named("hit_long_distance")>() = longHitDistance;
62
63 finitevar<named("delta_hit_distance")>() = longHitDistance - hitDistance;
64
65 finitevar<named("from_hit_forward")>() = hitPosGap.dot(fromLastHitMom);
66 finitevar<named("to_hit_forward")>() = hitPosGap.dot(toFirstHitMom);
67 finitevar<named("hit_forward")>() = hitPosGap.dot(Vector2D::average(fromLastHitMom, toFirstHitMom));
68
69 const CDCRecoHit2D& axialHit = toFirstHit.isAxial() ? toFirstHit : fromLastHit;
70 const CDCRecoHit2D& stereoHit = not toFirstHit.isAxial() ? toFirstHit : fromLastHit;
71
72 const Vector2D axialHitPos = axialHit.getRecoPos2D();
73 const Vector2D axialHitMom = axialHit.getFlightDirection2D();
74
75 const CDCWire& stereoWire = stereoHit.getWire();
76 const WireLine& wireLine = stereoWire.getWireLine();
77
78 // Caluculate point were the wire is first method
79 Vector2D relRefPos = wireLine.refPos2D() - axialHitPos;
80 Vector2D movePerZ = wireLine.nominalMovePerZ();
81
82 double z = -relRefPos.cross(axialHitMom) / movePerZ.cross(axialHitMom);
83 Vector2D stereoHitPos = stereoHit.getRecoPos2D() + movePerZ * z;
84
85 finitevar<named("hit_reco_z")>() = z;
86 finitevar<named("hit_z_bound_factor")>() = wireLine.outOfZBoundsFactor(z);
87 double arcLengthGap = (stereoHitPos - axialHitPos).dot(axialHitMom);
88 finitevar<named("hit_arclength_gap")>() = toFirstHit.isAxial() ? -arcLengthGap : arcLengthGap;
89
90 // const Vector2D fromStretch = fromLastHitPos - fromFirstHitPos;
91 // const Vector2D toStretch = toLastHitPos - toFirstHitPos;
92
93 // const double fromLength = fromStretch.norm();
94 // const double toLength = toStretch.norm();
95
96 // const Vector2D firstPosGap = toFirstHitPos - fromFirstHitPos;
97 // const Vector2D lastPosGap = toLastHitPos - fromLastHitPos;
98
99 // const double firstOffset = firstPosGap.norm();
100 // const double lastOffset = lastPosGap.norm();
101
102 // finitevar<named("hit_ptolemy")>() =
103 // firstOffset * lastOffset - longHitDistance * hitDistance - fromLength * toLength;
104
105 return true;
106}
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
bool isAxial() const
Indicator if the underlying wire is axial.
Definition: CDCRecoHit2D.h:163
const CDCWire & getWire() const
Getter for the wire the reconstructed hit assoziated to.
Definition: CDCRecoHit2D.h:175
double getAlpha() const
Getter for the direction of flight relative to the position.
Definition: CDCRecoHit2D.h:263
Vector2D getFlightDirection2D() const
Getter for the direction of flight.
Definition: CDCRecoHit2D.h:256
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
Definition: CDCRecoHit2D.h:238
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a pair of one reconstructed axial segement and one stereo segment in adjacent supe...
const CDCSegment2D * getToSegment() const
Getter for the to segment.
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
const WireLine & getWireLine() const
Getter for the wire line represenation of the wire.
Definition: CDCWire.h:188
bool extract(const CDCSegmentPair *ptrSegmentPair) override
Generate and assign the contained variables.
AssignFinite< Float_t > finitevar()
Reference getter for the value of the ith variable. Transforms non-finite values to finite value.
Definition: VarSet.h:130
static constexpr int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:78
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:32
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition: Vector2D.h:158
static Vector2D average(const Vector2D &one, const Vector2D &two)
Constructs the average of two vectors.
Definition: Vector2D.h:84
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
Definition: Vector2D.h:163
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:197
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:175
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:31
const Vector2D & nominalMovePerZ() const
Gives the positional move in the xy projection per unit z.
Definition: WireLine.h:71
const Vector2D & refPos2D() const
Returns the xy vector of the reference position.
Definition: WireLine.h:223
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:142
T dot(GeneralVector< T > a, GeneralVector< T > b)
dot product of two general vectors
Definition: beamHelpers.h:163
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