Belle II Software development
StereoHitContained.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/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
11#include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHit.h>
12#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
13
14#include <tracking/trackFindingCDC/topology/CDCWire.h>
15
16#include <tracking/trackFindingCDC/numerics/ESign.h>
17#include <tracking/trackFindingCDC/numerics/Weight.h>
18
19#include <numeric>
20
21namespace Belle2 {
26 namespace TrackFindingCDC {
27
34 template<class AInBox>
35 class StereoHitContained : public AInBox {
36
37 public:
39 using AInBox::AInBox;
40
42 using HoughBox = typename AInBox::HoughBox;
43
44
47 Weight operator()(const CDCSegment2D* segment2D,
48 const HoughBox* houghBox)
49 {
50 size_t nHits = segment2D->size();
51 auto weightOfHit = [this, &houghBox](const Weight & totalWeight,
52 const CDCRecoHit2D & recoHit2D) -> Weight {
53 Weight hitWeight = this->operator()(&recoHit2D, houghBox);
54 return std::isnan(hitWeight) ? totalWeight : totalWeight + hitWeight;
55 };
56
57 Weight totalWeight = std::accumulate(segment2D->begin(),
58 segment2D->end(),
59 static_cast<Weight>(0.0),
60 weightOfHit);
61
62 // Require a efficiency of 66%
63 constexpr const Weight minEfficiency = 2.0 / 3;
64 if (totalWeight > nHits * minEfficiency) {
65 return totalWeight;
66 } else {
67 return NAN;
68 }
69 }
70
74 Weight operator()(const CDCRecoHit2D* recoHit2D,
75 const HoughBox* houghBox)
76 {
77 const CDCWire& wire = recoHit2D->getWire();
78 const double signedDriftLength = recoHit2D->getSignedRefDriftLength();
79 bool isIn = contains(*houghBox, wire, signedDriftLength);
80 ERightLeft rlInfo = recoHit2D->getRLInfo();
81 return isIn ? 1.0 + isValid(rlInfo) * m_rlWeightGain : NAN;
82 }
83
84
90 Weight operator()(const CDCWireHit* wireHit,
91 const HoughBox* houghBox)
92 {
93 const CDCWire& wire = wireHit->getWire();
94 const double driftLength = wireHit->getRefDriftLength();
95
96 ERightLeft rlInfo = containsRightOrLeft(*houghBox, wire, driftLength);
97 return isValid(rlInfo) ? 1.0 + std::abs(rlInfo) * m_rlWeightGain : NAN;
98 }
99
111 Weight operator()(CDCRLWireHit& rlTaggedWireHit,
112 const HoughBox* houghBox)
113 {
114 const CDCWire& wire = rlTaggedWireHit.getWire();
115 const ERightLeft rlInfo = rlTaggedWireHit.getRLInfo();
116 const double driftLength = rlTaggedWireHit.getRefDriftLength();
117
118 ERightLeft newRLInfo =
119 containsRightOrLeft(*houghBox, wire, driftLength, rlInfo);
120
121 rlTaggedWireHit.setRLInfo(newRLInfo);
122 return isValid(newRLInfo) ? 1.0 + std::abs(newRLInfo) * m_rlWeightGain : NAN;
123 }
124
137 const CDCWire& wire,
138 double driftLength,
139 ERightLeft rlInfo = ERightLeft::c_Unknown)
140 {
141 bool isRightIn = rlInfo != ERightLeft::c_Left and contains(houghBox, wire, driftLength);
142 bool isLeftIn = rlInfo != ERightLeft::c_Right and contains(houghBox, wire, -driftLength);
143
144 if (isRightIn and isLeftIn) {
145 return ERightLeft::c_Unknown;
146 } else if (isRightIn) {
147 return ERightLeft::c_Right;
148 } else if (isLeftIn) {
149 return ERightLeft::c_Left;
150 } else {
151 return ERightLeft::c_Invalid;
152 }
153 }
154
156 bool contains(const HoughBox& houghBox, const CDCWire& wire, double signedDriftLength)
157 {
158 const Vector2D& pos2D = wire.getRefPos2D();
159 //const Vector2D& pos2D = wire.getWirePos2DAtZ(0);
160 const Vector2D& movePerZ = wire.getMovePerZ();
161 ILayer iCLayer(wire.getICLayer());
162 //B2INFO("movePerZ = " << movePerZ);
163 const ESign distSign = this->getDistanceSign(houghBox,
164 pos2D.x(), pos2D.y(),
165 signedDriftLength,
166 movePerZ.x(), movePerZ.y(),
167 iCLayer);
168 const bool isIn = distSign == ESign::c_Zero;
169 return isIn;
170 }
171
172 public:
174 void setRLWeightGain(float rlWeightGain)
175 { m_rlWeightGain = rlWeightGain;}
176
178 float setRLWeightGain() const
179 { return m_rlWeightGain; }
180
181 private:
183 float m_rlWeightGain = 0;
184 };
185
186 }
188}
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:204
const CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
void setRLInfo(const ERightLeft rlInfo)
Setter for the right left passage information.
Definition: CDCRLWireHit.h:240
ERightLeft getRLInfo() const
Getter for the right left passage information.
Definition: CDCRLWireHit.h:234
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
const CDCWire & getWire() const
Getter for the wire the reconstructed hit associated to.
Definition: CDCRecoHit2D.h:175
double getSignedRefDriftLength() const
Getter for the drift length at the wire reference position signed with the right left passage hypothe...
Definition: CDCRecoHit2D.h:226
ERightLeft getRLInfo() const
Getter for the right left passage information.
Definition: CDCRecoHit2D.h:205
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
Vector2D getMovePerZ() const
Getter for the vector describing the nominal positional change in the xy plane per unit z.
Definition: CDCWire.h:252
ILayer getICLayer() const
Getter for the continuous layer id ranging from 0 - 55.
Definition: CDCWire.h:150
const Vector2D & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition: CDCWire.h:229
Predicate class to check for the containment of axial and stereo hits in some hough space part.
Weight operator()(CDCRLWireHit &rlTaggedWireHit, const HoughBox *houghBox)
Checks if the wire hit is contained in a phi0 curv hough space.
bool contains(const HoughBox &houghBox, const CDCWire &wire, double signedDriftLength)
Checks if a wire hit at a signed drift length is contained in the hough space part.
typename AInBox::HoughBox HoughBox
The hough box which represents the hough space part to be investigated.
Weight operator()(const CDCSegment2D *segment2D, const HoughBox *houghBox)
Checks if more than 66% of the hits in this segment are contained in the phi0 curv hough space Return...
float m_rlWeightGain
Weight gain for a hit which right left passage hypotheses could be uniquely resolved.
Weight operator()(const CDCWireHit *wireHit, const HoughBox *houghBox)
Checks if the wire hit is contained in a phi0 curv hough space.
ERightLeft containsRightOrLeft(const HoughBox &houghBox, const CDCWire &wire, double driftLength, ERightLeft rlInfo=ERightLeft::c_Unknown)
Checks if a wire hit at a drift length is contained in the hough space part It investigates both righ...
Weight operator()(const CDCRecoHit2D *recoHit2D, const HoughBox *houghBox)
Checks if the two dimensional reconstructed hit is contained in a phi0 curv hough space.
void setRLWeightGain(float rlWeightGain)
Setter for the gain in weight for hits which rl passage could be uniquly resolved.
float setRLWeightGain() const
Getter for the gain in weight for hits which rl passage could be uniquly resolved.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
double x() const
Getter for the x coordinate.
Definition: Vector2D.h:595
double y() const
Getter for the y coordinate.
Definition: Vector2D.h:605
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:27
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.