Belle II Software development
HitGapSegmentRelationVarSet.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/segmentRelation/HitGapSegmentRelationVarSet.h>
9
10#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
11
12#include <tracking/trackFindingCDC/numerics/Angle.h>
13
14using namespace Belle2;
15using namespace TrackFindingCDC;
16
18{
19 if (not ptrSegmentRelation) return false;
20
21 const Relation<const CDCSegment2D>& segmentPair = *ptrSegmentRelation;
22
23 const CDCSegment2D* ptrFromSegment = segmentPair.getFrom();
24 const CDCSegment2D* ptrToSegment = segmentPair.getTo();
25
26 const CDCSegment2D& fromSegment = *ptrFromSegment;
27 const CDCSegment2D& toSegment = *ptrToSegment;
28
29 const CDCRecoHit2D& fromFirstHit = fromSegment.front();
30 const CDCRecoHit2D& fromLastHit = fromSegment.back();
31
32 const CDCRecoHit2D& toFirstHit = toSegment.front();
33 const CDCRecoHit2D& toLastHit = toSegment.back();
34
35 const Vector2D fromLastHitPos = fromLastHit.getRecoPos2D();
36 const Vector2D fromFirstHitPos = fromFirstHit.getRecoPos2D();
37
38 const Vector2D toFirstHitPos = toFirstHit.getRecoPos2D();
39 const Vector2D toLastHitPos = toLastHit.getRecoPos2D();
40
41 const Vector2D hitPosGap = toFirstHitPos - fromLastHitPos;
42 const Vector2D 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("hit_distance")>() = hitDistance;
58 finitevar<named("hit_long_distance")>() = longHitDistance;
59
60 finitevar<named("delta_hit_distance")>() = longHitDistance - hitDistance;
61
62 finitevar<named("from_hit_forward")>() = hitPosGap.dot(fromLastHitMom);
63 finitevar<named("to_hit_forward")>() = hitPosGap.dot(toFirstHitMom);
64 finitevar<named("hit_forward")>() = hitPosGap.dot(Vector2D::average(fromLastHitMom, toFirstHitMom));
65
66 const Vector2D fromStretch = fromLastHitPos - fromFirstHitPos;
67 const Vector2D toStretch = toLastHitPos - toFirstHitPos;
68
69 const double fromLength = fromStretch.norm();
70 const double toLength = toStretch.norm();
71
72 const Vector2D firstPosGap = toFirstHitPos - fromFirstHitPos;
73 const Vector2D lastPosGap = toLastHitPos - fromLastHitPos;
74
75 const double firstOffset = firstPosGap.norm();
76 const double lastOffset = lastPosGap.norm();
77
78 finitevar<named("hit_ptolemy")>() =
79 firstOffset * lastOffset - longHitDistance * hitDistance - fromLength * toLength;
80
81 return true;
82}
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
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
bool extract(const Relation< const CDCSegment2D > *ptrSegmentRelation) override
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
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:175
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