Belle II Software development
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/trackingUtilities/eventdata/hits/CDCRLWireHit.h>
9
10#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
11
12#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
13
14#include <cdc/topology/CDCWire.h>
15#include <cdc/topology/EStereoKind.h>
16#include <cdc/topology/ISuperLayer.h>
17
18#include <tracking/trackingUtilities/geometry/Vector3D.h>
19#include <tracking/trackingUtilities/geometry/Vector2D.h>
20
21#include <tracking/trackingUtilities/numerics/ERightLeft.h>
22
23#include <cdc/dataobjects/CDCSimHit.h>
24
25#include <framework/logging/Logger.h>
26
27#include <ostream>
28#include <type_traits>
29
30using namespace Belle2;
31using namespace CDC;
32using namespace TrackingUtilities;
33
34namespace Belle2 {
39 namespace CDC {
40 class WireLine;
41 }
43}
44CDCRLWireHit::CDCRLWireHit(const CDCWireHit* wireHit, ERightLeft rlInfo)
45 : CDCRLWireHit(wireHit, rlInfo, wireHit->getRefDriftLength(), wireHit->getRefDriftLengthVariance())
46{
47}
48
50 ERightLeft rlInfo,
51 double driftLength,
52 double driftLengthVariance)
53 : m_wireHit(wireHit)
54 , m_refDriftLength(driftLength)
55 , m_refDriftLengthVariance(driftLengthVariance)
56 , m_rlInfo(rlInfo)
57{
58}
59
61 const CDCRLWireHit& rlWireHit2)
62{
63 B2ASSERT("Average of two CDCRLWireHits with different wire hits requested.",
64 rlWireHit1.getWireHit() == rlWireHit2.getWireHit());
65
66 B2ASSERT("Average of two CDCRLWireHits with different right left passage information requested.",
67 rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo());
68
69 ERightLeft rlInfo = rlWireHit1.getRLInfo();
70 const CDCWireHit& wireHit = rlWireHit1.getWireHit();
71
72 double driftLength = (rlWireHit1.getRefDriftLength() +
73 rlWireHit2.getRefDriftLength()) / 2.0;
74
75 double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
76 rlWireHit2.getRefDriftLengthVariance()) / 2.0;
77
78 CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
79 return result;
80}
81
83 const CDCRLWireHit& rlWireHit2,
84 const CDCRLWireHit& rlWireHit3)
85{
86 B2ASSERT("Average of three CDCRLWireHits with different wire hits requested.",
87 rlWireHit1.getWireHit() == rlWireHit2.getWireHit() and
88 rlWireHit2.getWireHit() == rlWireHit3.getWireHit());
89
90 B2ASSERT("Average of three CDCRLWireHits with different right left passage information requested.",
91 rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo() and
92 rlWireHit2.getRLInfo() == rlWireHit3.getRLInfo());
93
94
95 ERightLeft rlInfo = rlWireHit1.getRLInfo();
96 const CDCWireHit& wireHit = rlWireHit1.getWireHit();
97
98 double driftLength = (rlWireHit1.getRefDriftLength() +
99 rlWireHit2.getRefDriftLength() +
100 rlWireHit3.getRefDriftLength()) / 3.0;
101
102 double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
103 rlWireHit2.getRefDriftLengthVariance() +
104 rlWireHit3.getRefDriftLengthVariance()) / 3.0;
105
106 CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
107 return result;
108}
109
110
112 const CDCSimHit& simhit)
113{
114 // find out if the wire is right or left of the track ( view in flight direction )
115 Vector3D trackPosToWire{simhit.getPosWire() - simhit.getPosTrack()};
116 Vector3D directionOfFlight{simhit.getMomentum()};
117
118 ERightLeft rlInfo = trackPosToWire.xy().isRightOrLeftOf(directionOfFlight.xy());
119
120 CDCRLWireHit rlWireHit(wirehit, rlInfo, simhit.getDriftLength(), CDCWireHit::c_simpleDriftLengthVariance);
121
122 return rlWireHit;
123}
124
126{
127 return getWireHit().getHit();
128}
129
131{
132 return getWireHit().getWire();
133}
134
136{
137 return getWire().getWireID();
138}
139
144
149
151{
152 return getWire().isAxial();
153}
154
155const ROOT::Math::XYVector& CDCRLWireHit::getRefPos2D() const
156{
157 return getWire().getRefPos2D();
158}
159
161{
162 return getWire().getRefCylindricalR();
163}
164
166{
167 const Vector2D& refPos2D = getRefPos2D();
168 Vector2D recoPos2D = trajectory2D.getClosest(refPos2D);
169
170 const Vector2D& wirePos2D = getWire().getRefPos2D();
171 const double driftLength = getRefDriftLength();
172
173 Vector2D disp2D = recoPos2D - wirePos2D;
174
175 // Fix the displacement to lie on the drift circle.
176 disp2D.normalizeTo(driftLength);
177 return wirePos2D + disp2D;
178}
179
180Vector3D CDCRLWireHit::reconstruct3D(const CDCTrajectory2D& trajectory2D, const double z) const
181{
182 const EStereoKind stereoType = getStereoKind();
183 const ERightLeft rlInfo = getRLInfo();
184
185 if (stereoType == EStereoKind::c_StereoV or stereoType == EStereoKind::c_StereoU) {
186 const WireLine& wireLine = getWire().getWireLine();
187 const double signedDriftLength = isValid(rlInfo) ? static_cast<double>(rlInfo) * getRefDriftLength() : 0.0;
188 return trajectory2D.reconstruct3D(wireLine, signedDriftLength, z);
189
190 } else { /*if (stereoType == EStereoKind::c_Axial)*/
191 const Vector2D recoPos2D = reconstruct2D(trajectory2D);
192 // for axial wire we can not determine the z coordinate by looking at the xy projection only
193 // we set it the basic assumption.
194 return Vector3D(recoPos2D, z);
195 }
196}
197
198std::ostream& TrackingUtilities::operator<<(std::ostream& output, const CDCRLWireHit& rlWireHit)
199{
200 output << "CDCRLWireHit(" << rlWireHit.getWireHit() << ","
201 << static_cast<typename std::underlying_type<ERightLeft>::type>(rlWireHit.getRLInfo()) << ")" ;
202 return output;
203}
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:21
B2Vector3D getPosWire() const
The method to get position on wire.
Definition CDCSimHit.h:198
B2Vector3D getPosTrack() const
The method to get position on the track.
Definition CDCSimHit.h:216
double getDriftLength() const
The method to get drift length.
Definition CDCSimHit.h:180
B2Vector3D getMomentum() const
The method to get momentum.
Definition CDCSimHit.h:192
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
double getRefCylindricalR() const
Getter for the cylindrical radius at the wire reference position.
Definition CDCWire.h:252
ISuperLayer getISuperLayer() const
Gives the superlayer id ranging from 0 - 8.
Definition CDCWire.h:155
const ROOT::Math::XYVector & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition CDCWire.h:221
const WireID & getWireID() const
Getter for the wire id.
Definition CDCWire.h:114
bool isAxial() const
Indicates if the wire is axial or stereo.
Definition CDCWire.h:166
EStereoKind getStereoKind() const
Getter for the stereo type of the wire.
Definition CDCWire.h:176
const WireLine & getWireLine() const
Getter for the wire line representation of the wire.
Definition CDCWire.h:180
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition WireLine.h:33
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
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.
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the oriented hit.
CDC::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.
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
const ROOT::Math::XYVector & getRefPos2D() const
The two dimensional reference position of the underlying wire.
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.
ERightLeft m_rlInfo
Memory for the right left passage information of the oriented wire hit.
const CDC::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 information.
Vector2D reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
double m_refDriftLength
Memory for the reestimated drift length.
double m_refDriftLengthVariance
Memory for the reestimated drift length variance.
const CDCWireHit * m_wireHit
Memory for the reference to the assiziated wire hit.
CDC::EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
ERightLeft getRLInfo() const
Getter for the right left passage information.
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 CDC::WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one three dimensional positions 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:58
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:162
const CDC::CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition CDCWireHit.h:171
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:67
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition Vector2D.h:36
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
Definition Vector2D.h:344
ERightLeft isRightOrLeftOf(const Vector2D &rhs) const
Indicates if the given vector is more left or more right if you looked in the direction of this vecto...
Definition Vector2D.h:484
A three dimensional vector.
Definition Vector3D.h:34
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition Vector3D.h:513
Class to identify a wire inside the CDC.
Definition WireID.h:34
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition Cell.h:34
EStereoKind
Type for the stereo property of the wire.
Definition EStereoKind.h:20
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
Abstract base class for different kinds of events.