Belle II Software  release-06-02-00
CDCRLWireHit.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/eventdata/hits/CDCRLWireHit.h>
9 
10 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
13 
14 #include <tracking/trackFindingCDC/topology/CDCWire.h>
15 #include <tracking/trackFindingCDC/topology/EStereoKind.h>
16 #include <tracking/trackFindingCDC/topology/ISuperLayer.h>
17 
18 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
19 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
20 
21 #include <tracking/trackFindingCDC/numerics/ERightLeft.h>
22 
23 #include <cdc/dataobjects/CDCSimHit.h>
24 
25 #include <framework/logging/Logger.h>
26 
27 #include <TVector3.h>
28 
29 #include <ostream>
30 #include <type_traits>
31 
32 using namespace Belle2;
33 using namespace TrackFindingCDC;
34 
35 namespace Belle2 {
40  namespace TrackFindingCDC {
41  class WireLine;
42  }
44 }
46  : CDCRLWireHit(wireHit, rlInfo, wireHit->getRefDriftLength(), wireHit->getRefDriftLengthVariance())
47 {
48 }
49 
51  ERightLeft rlInfo,
52  double driftLength,
53  double driftLengthVariance)
54  : m_wireHit(wireHit)
55  , m_rlInfo(rlInfo)
56  , m_refDriftLength(driftLength)
57  , m_refDriftLengthVariance(driftLengthVariance)
58 {
59 }
60 
62  const CDCRLWireHit& rlWireHit2)
63 {
64  B2ASSERT("Average of two CDCRLWireHits with different wire hits requested.",
65  rlWireHit1.getWireHit() == rlWireHit2.getWireHit());
66 
67  B2ASSERT("Average of two CDCRLWireHits with different right left passage information requested.",
68  rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo());
69 
70  ERightLeft rlInfo = rlWireHit1.getRLInfo();
71  const CDCWireHit& wireHit = rlWireHit1.getWireHit();
72 
73  double driftLength = (rlWireHit1.getRefDriftLength() +
74  rlWireHit2.getRefDriftLength()) / 2.0;
75 
76  double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
77  rlWireHit2.getRefDriftLengthVariance()) / 2.0;
78 
79  CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
80  return result;
81 }
82 
84  const CDCRLWireHit& rlWireHit2,
85  const CDCRLWireHit& rlWireHit3)
86 {
87  B2ASSERT("Average of three CDCRLWireHits with different wire hits requested.",
88  rlWireHit1.getWireHit() == rlWireHit2.getWireHit() and
89  rlWireHit2.getWireHit() == rlWireHit3.getWireHit());
90 
91  B2ASSERT("Average of three CDCRLWireHits with different right left passage information requested.",
92  rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo() and
93  rlWireHit2.getRLInfo() == rlWireHit3.getRLInfo());
94 
95 
96  ERightLeft rlInfo = rlWireHit1.getRLInfo();
97  const CDCWireHit& wireHit = rlWireHit1.getWireHit();
98 
99  double driftLength = (rlWireHit1.getRefDriftLength() +
100  rlWireHit2.getRefDriftLength() +
101  rlWireHit3.getRefDriftLength()) / 3.0;
102 
103  double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
104  rlWireHit2.getRefDriftLengthVariance() +
105  rlWireHit3.getRefDriftLengthVariance()) / 3.0;
106 
107  CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
108  return result;
109 }
110 
111 
113  const CDCSimHit& simhit)
114 {
115  // find out if the wire is right or left of the track ( view in flight direction )
116  Vector3D trackPosToWire{simhit.getPosWire() - simhit.getPosTrack()};
117  Vector3D directionOfFlight{simhit.getMomentum()};
118 
119  ERightLeft rlInfo = trackPosToWire.xy().isRightOrLeftOf(directionOfFlight.xy());
120 
121  CDCRLWireHit rlWireHit(wirehit, rlInfo, simhit.getDriftLength(), CDCWireHit::c_simpleDriftLengthVariance);
122 
123  return rlWireHit;
124 }
125 
127 {
128  return getWireHit().getHit();
129 }
130 
132 {
133  return getWireHit().getWire();
134 }
135 
137 {
138  return getWire().getWireID();
139 }
140 
141 ISuperLayer CDCRLWireHit::getISuperLayer() const
142 {
143  return getWire().getISuperLayer();
144 }
145 
146 EStereoKind CDCRLWireHit::getStereoKind() const
147 {
148  return getWire().getStereoKind();
149 }
150 
152 {
153  return getWire().isAxial();
154 }
155 
157 {
158  return getWire().getRefPos2D();
159 }
160 
162 {
163  return getWire().getRefCylindricalR();
164 }
165 
167 {
168  const Vector2D& refPos2D = getRefPos2D();
169  Vector2D recoPos2D = trajectory2D.getClosest(refPos2D);
170 
171  const Vector2D& wirePos2D = getWire().getRefPos2D();
172  const double driftLength = getRefDriftLength();
173 
174  Vector2D disp2D = recoPos2D - wirePos2D;
175 
176  // Fix the displacement to lie on the drift circle.
177  disp2D.normalizeTo(driftLength);
178  return wirePos2D + disp2D;
179 }
180 
181 Vector3D CDCRLWireHit::reconstruct3D(const CDCTrajectory2D& trajectory2D, const double z) const
182 {
183  const EStereoKind stereoType = getStereoKind();
184  const ERightLeft rlInfo = getRLInfo();
185 
186  if (stereoType == EStereoKind::c_StereoV or stereoType == EStereoKind::c_StereoU) {
187  const WireLine& wireLine = getWire().getWireLine();
188  const double signedDriftLength = isValid(rlInfo) ? rlInfo * getRefDriftLength() : 0.0;
189  return trajectory2D.reconstruct3D(wireLine, signedDriftLength, z);
190 
191  } else { /*if (stereoType == EStereoKind::c_Axial)*/
192  const Vector2D recoPos2D = reconstruct2D(trajectory2D);
193  // for axial wire we can not determine the z coordinate by looking at the xy projection only
194  // we set it the basic assumption.
195  return Vector3D(recoPos2D, z);
196  }
197 }
198 
199 std::ostream& TrackFindingCDC::operator<<(std::ostream& output, const CDCRLWireHit& rlWireHit)
200 {
201  output << "CDCRLWireHit(" << rlWireHit.getWireHit() << ","
202  << static_cast<typename std::underlying_type<ERightLeft>::type>(rlWireHit.getRLInfo()) << ")" ;
203  return output;
204 }
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
Example Detector.
Definition: CDCSimHit.h:22
TVector3 getPosWire() const
The method to get position on wire.
Definition: CDCSimHit.h:205
TVector3 getMomentum() const
The method to get momentum.
Definition: CDCSimHit.h:199
double getDriftLength() const
The method to get drift length.
Definition: CDCSimHit.h:187
TVector3 getPosTrack() const
The method to get position on the track.
Definition: CDCSimHit.h:223
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
double getRefCylindricalR() const
The distance from the beam line at reference position of the underlying wire.
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
ISuperLayer getISuperLayer() const
Getter for the superlayer id.
double getRefDriftLengthVariance() const
Getter for the variance of the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:222
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:204
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
bool isAxial() const
Indicator if the underlying wire is axial.
CDCRLWireHit()=default
Default constructor for ROOT.
const CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
static CDCRLWireHit fromSimHit(const CDCWireHit *wirehit, const CDCSimHit &simhit)
Constructs an oriented wire hit from a CDCSimHit and the associated wirehit.
static CDCRLWireHit average(const CDCRLWireHit &rlWireHit1, const CDCRLWireHit &rlWireHit2)
Constructs the average of two wire hits with right left passage informations.
Definition: CDCRLWireHit.cc:61
Vector2D reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
const Vector2D & getRefPos2D() const
The two dimensional reference position of the underlying wire.
EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the oriented hit.
Definition: CDCRLWireHit.h:192
ERightLeft getRLInfo() const
Getter for the right left passage information.
Definition: CDCRLWireHit.h:234
Vector3D reconstruct3D(const CDCTrajectory2D &trajectory2D, double z=0) const
Attempts to reconstruct a three dimensional position (especially of stereo hits).
Particle trajectory as it is seen in xy projection represented as a circle.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
Vector3D reconstruct3D(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one three dimensional postions within the CDC closest to the given z where the given drift ...
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:159
static constexpr const double c_simpleDriftLengthVariance
A default value for the drift length variance if no variance from the drift length translation is ava...
Definition: CDCWireHit.h:64
const CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition: CDCWireHit.h:168
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
double getRefCylindricalR() const
Getter for the cylindrical radius at the wire reference position.
Definition: CDCWire.h:260
ISuperLayer getISuperLayer() const
Gives the superlayer id ranging from 0 - 8.
Definition: CDCWire.h:163
bool isAxial() const
Indicates if the wire is axial or stereo.
Definition: CDCWire.h:174
const WireLine & getWireLine() const
Getter for the wire line represenation of the wire.
Definition: CDCWire.h:188
const Vector2D & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition: CDCWire.h:229
const WireID & getWireID() const
Getter for the wire id.
Definition: CDCWire.h:122
EStereoKind getStereoKind() const
Getter for the stereo type of the wire.
Definition: CDCWire.h:184
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:35
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
Definition: Vector2D.h:325
A three dimensional vector.
Definition: Vector3D.h:32
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:31
Class to identify a wire inside the CDC.
Definition: WireID.h:34
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.