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/numerics/ERightLeft.h>
19
20#include <cdc/dataobjects/CDCSimHit.h>
21
22#include <framework/logging/Logger.h>
23
24#include <ostream>
25#include <type_traits>
26
27using namespace Belle2;
28using namespace CDC;
29using namespace TrackingUtilities;
30
31namespace Belle2 {
36 namespace CDC {
37 class WireLine;
38 }
40}
41CDCRLWireHit::CDCRLWireHit(const CDCWireHit* wireHit, ERightLeft rlInfo)
42 : CDCRLWireHit(wireHit, rlInfo, wireHit->getRefDriftLength(), wireHit->getRefDriftLengthVariance())
43{
44}
45
47 ERightLeft rlInfo,
48 double driftLength,
49 double driftLengthVariance)
50 : m_wireHit(wireHit)
51 , m_iHit(wireHit ? wireHit->getStoreIHit() : c_InvalidIndex)
52 , m_refDriftLength(driftLength)
53 , m_refDriftLengthVariance(driftLengthVariance)
54 , m_rlInfo(rlInfo)
55{
56}
57
59 const CDCRLWireHit& rlWireHit2)
60{
61 B2ASSERT("Average of two CDCRLWireHits with different wire hits requested.",
62 rlWireHit1.getWireHit() == rlWireHit2.getWireHit());
63
64 B2ASSERT("Average of two CDCRLWireHits with different right left passage information requested.",
65 rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo());
66
67 ERightLeft rlInfo = rlWireHit1.getRLInfo();
68 const CDCWireHit& wireHit = rlWireHit1.getWireHit();
69
70 double driftLength = (rlWireHit1.getRefDriftLength() +
71 rlWireHit2.getRefDriftLength()) / 2.0;
72
73 double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
74 rlWireHit2.getRefDriftLengthVariance()) / 2.0;
75
76 CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
77 return result;
78}
79
81 const CDCRLWireHit& rlWireHit2,
82 const CDCRLWireHit& rlWireHit3)
83{
84 B2ASSERT("Average of three CDCRLWireHits with different wire hits requested.",
85 rlWireHit1.getWireHit() == rlWireHit2.getWireHit() and
86 rlWireHit2.getWireHit() == rlWireHit3.getWireHit());
87
88 B2ASSERT("Average of three CDCRLWireHits with different right left passage information requested.",
89 rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo() and
90 rlWireHit2.getRLInfo() == rlWireHit3.getRLInfo());
91
92
93 ERightLeft rlInfo = rlWireHit1.getRLInfo();
94 const CDCWireHit& wireHit = rlWireHit1.getWireHit();
95
96 double driftLength = (rlWireHit1.getRefDriftLength() +
97 rlWireHit2.getRefDriftLength() +
98 rlWireHit3.getRefDriftLength()) / 3.0;
99
100 double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
101 rlWireHit2.getRefDriftLengthVariance() +
102 rlWireHit3.getRefDriftLengthVariance()) / 3.0;
103
104 CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
105 return result;
106}
107
108
110 const CDCSimHit& simhit)
111{
112 // find out if the wire is right or left of the track ( view in flight direction )
113 ROOT::Math::XYZVector trackPosToWire{simhit.getPosWire() - simhit.getPosTrack()};
114 ROOT::Math::XYZVector directionOfFlight{simhit.getMomentum()};
115
116 ERightLeft rlInfo = VectorUtil::isRightOrLeftOf(VectorUtil::getXYVector(trackPosToWire),
117 VectorUtil::getXYVector(directionOfFlight));
118
119 CDCRLWireHit rlWireHit(wirehit, rlInfo, simhit.getDriftLength(), CDCWireHit::c_simpleDriftLengthVariance);
120
121 return rlWireHit;
122}
123
125{
126 return getWireHit().getHit();
127}
128
130{
131 return getWireHit().getWire();
132}
133
135{
136 return getWire().getWireID();
137}
138
143
148
150{
151 return getWire().isAxial();
152}
153
154const ROOT::Math::XYVector& CDCRLWireHit::getRefPos2D() const
155{
156 return getWire().getRefPos2D();
157}
158
160{
161 return getWire().getRefCylindricalR();
162}
163
164ROOT::Math::XYVector CDCRLWireHit::reconstruct2D(const CDCTrajectory2D& trajectory2D) const
165{
166 const ROOT::Math::XYVector& refPos2D = getRefPos2D();
167 ROOT::Math::XYVector recoPos2D = trajectory2D.getClosest(refPos2D);
168
169 const ROOT::Math::XYVector& wirePos2D = getWire().getRefPos2D();
170 const double driftLength = getRefDriftLength();
171
172 ROOT::Math::XYVector disp2D = recoPos2D - wirePos2D;
173
174 // Fix the displacement to lie on the drift circle.
175 if (disp2D.R() != 0.0) {
176 disp2D *= (driftLength / disp2D.R());
177 }
178 return wirePos2D + disp2D;
179}
180
181ROOT::Math::XYZVector 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) ? static_cast<double>(rlInfo) * getRefDriftLength() : 0.0;
189 return trajectory2D.reconstruct3D(wireLine, signedDriftLength, z);
190
191 } else { /*if (stereoType == EStereoKind::c_Axial)*/
192 const ROOT::Math::XYVector 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 ROOT::Math::XYZVector(recoPos2D.X(), recoPos2D.Y(), z);
196 }
197}
198
199std::ostream& TrackingUtilities::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: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.
double m_refDriftLength
Memory for the reestimated drift length.
ROOT::Math::XYZVector reconstruct3D(const CDCTrajectory2D &trajectory2D, double z=0) const
Attempts to reconstruct a three dimensional position (especially of stereo hits).
Index getStoreIHit() const
Getter for the index of the underlying CDCHit in the StoreArray holding it.
double m_refDriftLengthVariance
Memory for the reestimated drift length variance.
ROOT::Math::XYVector reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
const CDCWireHit * m_wireHit
Memory for the reference to the assiziated wire hit - not streamed (ROOT would deep-copy the pointed ...
CDC::EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
ERightLeft getRLInfo() const
Getter for the right left passage information.
Index m_iHit
Index of the underlying CDCHit in its StoreArray, so the link survives serialisation.
Particle trajectory as it is seen in xy projection represented as a circle.
ROOT::Math::XYVector getClosest(const ROOT::Math::XYVector &point) const
Calculates the closest approach on the trajectory to the given point.
ROOT::Math::XYZVector 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:56
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:160
const CDC::CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition CDCWireHit.h:169
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:65
Class to identify a wire inside the CDC.
Definition WireID.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.