Belle II Software development
HitGapTrackRelationVarSet.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/trackRelation/HitGapTrackRelationVarSet.h>
9
10#include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
11
12#include <tracking/trackFindingCDC/numerics/Angle.h>
13
14using namespace Belle2;
15using namespace TrackFindingCDC;
16
18{
19 if (not ptrTrackRelation) return false;
20
21 const Relation<const CDCTrack>& trackPair = *ptrTrackRelation;
22
23 const CDCTrack* ptrFromTrack = trackPair.getFrom();
24 const CDCTrack* ptrToTrack = trackPair.getTo();
25
26 const CDCTrack& fromTrack = *ptrFromTrack;
27 const CDCTrack& toTrack = *ptrToTrack;
28
29 const CDCRecoHit3D& fromFirstHit = fromTrack.front();
30 const CDCRecoHit3D& fromLastHit = fromTrack.back();
31
32 const CDCRecoHit3D& toFirstHit = toTrack.front();
33 const CDCRecoHit3D& toLastHit = toTrack.back();
34
35 const Vector3D fromLastHitPos = fromLastHit.getRecoPos3D();
36 const Vector3D fromFirstHitPos = fromFirstHit.getRecoPos3D();
37
38 const Vector3D toFirstHitPos = toFirstHit.getRecoPos3D();
39 const Vector3D toLastHitPos = toLastHit.getRecoPos3D();
40
41 const Vector3D hitPosGap = toFirstHitPos - fromLastHitPos;
42 const Vector3D longHitPosGap = toLastHitPos - fromFirstHitPos;
43
44 const double hitDistance = hitPosGap.norm();
45 const double longHitDistance = longHitPosGap.norm();
46
47 const Vector2D fromLastHitMom = fromLastHit.getFlightDirection2D();
48 const Vector2D toFirstHitMom = toFirstHit.getFlightDirection2D();
49
50 finitevar<named("delta_hit_pos_phi")>() = fromLastHitPos.angleWith(toFirstHitPos);
51 finitevar<named("delta_hit_mom_phi")>() = fromLastHitMom.angleWith(toFirstHitMom);
52
53 double fromLastHitAlpha = fromLastHit.getAlpha();
54 double toFirstHitAlpha = toFirstHit.getAlpha();
55 finitevar<named("delta_hit_alpha")>() = AngleUtil::normalised(toFirstHitAlpha - fromLastHitAlpha);
56
57 finitevar<named("delta_hit_z")>() = fromLastHitPos.z() - toFirstHitPos.z();
58
59 finitevar<named("hit_distance")>() = hitDistance;
60 finitevar<named("hit_long_distance")>() = longHitDistance;
61
62 finitevar<named("delta_hit_distance")>() = longHitDistance - hitDistance;
63
64 finitevar<named("from_hit_forward")>() = hitPosGap.xy().dot(fromLastHitMom);
65 finitevar<named("to_hit_forward")>() = hitPosGap.xy().dot(toFirstHitMom);
66 finitevar<named("hit_forward")>() = hitPosGap.xy().dot(Vector2D::average(fromLastHitMom, toFirstHitMom));
67
68 const Vector3D fromStretch = fromLastHitPos - fromFirstHitPos;
69 const Vector3D toStretch = toLastHitPos - toFirstHitPos;
70
71 const double fromLength = fromStretch.norm();
72 const double toLength = toStretch.norm();
73
74 const Vector3D firstPosGap = toFirstHitPos - fromFirstHitPos;
75 const Vector3D lastPosGap = toLastHitPos - fromLastHitPos;
76
77 const double firstOffset = firstPosGap.norm();
78 const double lastOffset = lastPosGap.norm();
79
80 finitevar<named("hit_ptolemy")>() =
81 firstOffset * lastOffset - longHitDistance * hitDistance - fromLength * toLength;
82
83 return true;
84}
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:52
const Vector3D & getRecoPos3D() const
Getter for the 3d position of the hit.
Definition: CDCRecoHit3D.h:285
double getAlpha() const
Getter for the direction of flight relative to the position.
Definition: CDCRecoHit3D.h:319
Vector2D getFlightDirection2D() const
Getter for the direction of flight.
Definition: CDCRecoHit3D.h:312
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
bool extract(const Relation< const CDCTrack > *ptrTrackRelation) final
Generate and assign the contained variables.
Type for two related objects.
Definition: Relation.h:21
From * getFrom() const
Getter for the pointer to the from side object.
Definition: Relation.h:59
To * getTo() const
Getter for the pointer to the to side object.
Definition: Relation.h:65
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 handling of orientation relate...
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 angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:197
A three dimensional vector.
Definition: Vector3D.h:33
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:508
double angleWith(const Vector3D &rhs) const
The angle between this and rhs.
Definition: Vector3D.h:237
double norm() const
Calculates the length of the vector.
Definition: Vector3D.h:212
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496
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