Belle II Software development
CDCWire.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
9#include <tracking/trackFindingCDC/topology/CDCWire.h>
10
11#include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
12#include <tracking/trackFindingCDC/topology/CDCWireSuperLayer.h>
13#include <tracking/trackFindingCDC/topology/CDCWireLayer.h>
14
15#include <tracking/trackFindingCDC/topology/EWirePositionToCDC.h>
16#include <tracking/trackFindingCDC/topology/EWirePosition.h>
17
18#include <cdc/geometry/CDCGeometryPar.h>
19#include <cdc/dataobjects/CDCHit.h>
20
21using namespace Belle2;
22using namespace TrackFindingCDC;
23
24const CDCWire* CDCWire::getInstance(const WireID& wireID)
25{
26 return &(CDCWireTopology::getInstance().getWire(wireID));
27}
28
29const CDCWire* CDCWire::getInstance(ISuperLayer iSuperLayer, ILayer iLayer, IWire iWire)
30{
31 return &(CDCWireTopology::getInstance().getWire(iSuperLayer, iLayer, iWire));
32}
33
35{
36 if (not CDCWireTopology::getInstance().isValidWireID(WireID(hit.getID()))) {
37 WireID wireID(hit.getID());
38 B2ERROR("Invalid encoded wire id of cdc hit " << wireID);
39 B2ERROR("Superlayer id: " << wireID.getISuperLayer());
40 B2ERROR("Layer cid: " << wireID.getICLayer());
41 B2ERROR("Layer id: " << wireID.getILayer());
42 B2ERROR("Wire id: " << wireID.getIWire());
43 B2FATAL("Do not continue with wrong wire id");
44 return nullptr;
45 }
46
47 const CDCWire& wire = CDCWireTopology::getInstance().getWire(WireID(hit.getID()));
48
49 if (wire.getEWire() != hit.getID()) {
50 B2ERROR("WireID.getEWire() differs from CDCHit.getID()");
51 B2ERROR("WireID.getEWire() : " << wire.getEWire());
52 B2ERROR("CDCHit.getEWire() : " << hit.getID());
53 }
54 return &wire;
55}
56
58 : m_wireID(wireID)
59{
60 EWirePosition wirePosition = EWirePosition::c_Base;
61 initialize(wirePosition, false);
62}
63
64CDCWire::CDCWire(ISuperLayer iSuperLayer, ILayer iLayer, IWire iWire)
65 : CDCWire(WireID(iSuperLayer, iLayer, iWire))
66{
67}
68
69void CDCWire::initialize(EWirePosition wirePosition, bool ignoreWireSag)
70{
72 CDC::CDCGeometryPar::EWirePosition wirePosSet = toCDC(wirePosition);
73
74 IWire iWire = getIWire();
75 ILayer iCLayer = getICLayer();
76
77 Vector3D forwardPos{cdcgp.wireForwardPosition(iCLayer, iWire, wirePosSet)};
78 Vector3D backwardPos{cdcgp.wireBackwardPosition(iCLayer, iWire, wirePosSet)};
79 double sagCoeff = ignoreWireSag ? 0 : cdcgp.getWireSagCoef(wirePosSet, iCLayer, iWire);
80
81 m_wireLine = WireLine(forwardPos, backwardPos, sagCoeff);
83
85 if (not isAxial() and (m_wireLine.tanTheta() == 0)) {
86 B2WARNING("Odd wire " << *this);
87 B2WARNING("wireForwardPosition " << forwardPos);
88 B2WARNING("wireBackwardPosition " << backwardPos);
89 B2WARNING("forward " << m_wireLine.forward3D());
90 B2WARNING("backward " << m_wireLine.backward3D());
91 B2WARNING("ref " << m_wireLine.refPos3D());
92 B2WARNING("tan theta " << m_wireLine.tanTheta());
93 }
94}
95
96bool CDCWire::isInCell(const Vector3D& pos3D) const
97{
98 bool inZ = getBackwardZ() < pos3D.z() and pos3D.z() < getForwardZ();
99 if (not inZ) return false;
100
101 ILayer iCLayer = getICLayer();
102 const CDCWireLayer& wireLayer = getWireLayer();
103 double innerCylindricalR = wireLayer.getInnerCylindricalR();
104 double outerCylindricalR = wireLayer.getOuterCylindricalR();
105 double cylindricalR = pos3D.cylindricalR();
106
107 bool inCylindricalR = innerCylindricalR < cylindricalR and cylindricalR < outerCylindricalR;
108 if (not inCylindricalR) return false;
109
110 IWire iWire = CDC::CDCGeometryPar::Instance().cellId(iCLayer, pos3D);
111 // Safety measure against error in the cellId function
112 iWire %= wireLayer.size();
113 bool inPhi = iWire == getIWire();
114 return inPhi;
115}
116
118{
120}
121
123{
125}
126
128{
129 ILayer iCLayer = getICLayer();
131}
132
134{
135 ISuperLayer iSuperLayer = getISuperLayer();
137}
138
140{
142}
143
145{
147}
148
150{
152}
153
155{
157}
158
159MayBePtr<const CDCWire> CDCWire::getNeighborCCW() const
160{
162}
163
164MayBePtr<const CDCWire> CDCWire::getNeighborCW() const
165{
167}
168
169MayBePtr<const CDCWire> CDCWire::getNeighborCCWInwards() const
170{
172}
173
174MayBePtr<const CDCWire> CDCWire::getNeighborCWInwards() const
175{
177}
178
179MayBePtr<const CDCWire> CDCWire::getNeighborCCWOutwards() const
180{
182}
183
184MayBePtr<const CDCWire> CDCWire::getNeighborCWOutwards() const
185{
187}
188
189MayBePtr<const CDCWire> CDCWire::getSecondaryNeighbor(short oClockDirection) const
190{
192}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
The Class for CDC Geometry Parameters.
EWirePosition
Wire position set.
unsigned cellId(unsigned layerId, const B2Vector3D &position) const
The method to get cell id based on given layer id and the position.
const B2Vector3D wireForwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the forward position of the input sense wire.
const B2Vector3D wireBackwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
double getWireSagCoef(EWirePosition set, uint layerId, int cellId) const
Returns coefficient for the sense wire sag.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
Class representating a sense wire layer in the central drift chamber.
Definition: CDCWireLayer.h:42
double getInnerCylindricalR() const
Getter for inner radius of the layer as taken from the CDCGeometryPar.
Definition: CDCWireLayer.h:245
double getLateralCellWidth() const
Getter for the width of the wire layer in the lateral direction.
Definition: CDCWireLayer.h:262
double getOuterCylindricalR() const
Getter for outer radius of the layer as taken from the CDCGeometryPar.
Definition: CDCWireLayer.h:249
double getRadialCellWidth() const
Getter for the width of the wire layer in the radial direction.
Definition: CDCWireLayer.h:253
Class representating a sense wire superlayer in the central drift chamber.
MayBePtr< const CDCWire > getNeighborCCWInwards(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor in the next layer outwards.
const CDCWire & getWire(const WireID &wireId) const
Getter for wire getter by wireID object.
WireNeighborKind getNeighborKind(const WireID &wireID, const WireID &otherWireID) const
Checks if two wires are closest neighbors.
bool arePrimaryNeighbors(const WireID &wireID, const WireID &otherWireID) const
Checks if two wires are primary neighbors.
MayBePtr< const CDCWire > getSecondaryNeighbor(short oClockDirection, const WireID &wireID) const
Getter for the secondary neighbor of the given wire id.
MayBePtr< const CDCWire > getNeighborCCWOutwards(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor in the next layer outwards.
const CDCWireSuperLayer & getWireSuperLayer(const WireID &wireID) const
Getter for wire superlayer getter by wireID object.
WireNeighborPair getNeighborsOutwards(const WireID &wireID) const
Getter for the two closest neighbors in the layer outwards.
MayBePtr< const CDCWire > getNeighborCWInwards(const WireID &wireID) const
Getter for the nearest clockwise neighbor in the next layer outwards.
MayBePtr< const CDCWire > getNeighborCCW(const WireID &wireID) const
Getter for the nearest counterclockwise neighbor.
MayBePtr< const CDCWire > getNeighborCWOutwards(const WireID &wireID) const
Getter for the nearest clockwise neighbor in the next layer outwards.
const CDCWireLayer & getWireLayer(const WireID &wireId) const
Getter for wire layer getter by wireID object.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
MayBePtr< const CDCWire > getNeighborCW(const WireID &wireID) const
Getter for the nearest clockwise neighbor.
WireNeighborPair getNeighborsInwards(const WireID &wireID) const
Getter for the two closest neighbors in the layer inwards.
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
CDCWire(const WireID &wireID)
Constructor taking the combined wire id convenience object.
Definition: CDCWire.cc:57
ISuperLayer getISuperLayer() const
Gives the superlayer id ranging from 0 - 8.
Definition: CDCWire.h:163
MayBePtr< const CDCWire > getNeighborCWOutwards() const
Gives the closest neighbor in the clockwise outwards direction This does not cross superlayer boundar...
Definition: CDCWire.cc:184
WireNeighborKind getNeighborKind(const CDCWire &wire) const
Returns gives the kind of neighborhood relation from this wire to the given wire.
Definition: CDCWire.cc:139
bool isInCell(const Vector3D &pos3D) const
Checks whether the position is in the drift cell surrounding the wire.
Definition: CDCWire.cc:96
WireLine m_wireLine
The line representation of the wire.
Definition: CDCWire.h:413
const WireID & getWireID() const
Getter for the wire id.
Definition: CDCWire.h:122
bool isAxial() const
Indicates if the wire is axial or stereo.
Definition: CDCWire.h:174
MayBePtr< const CDCWire > getNeighborCCWOutwards() const
Gives the closest neighbor in the countclockwise outwards direction This does not cross superlayer bo...
Definition: CDCWire.cc:179
MayBePtr< const CDCWire > getNeighborCCW() const
Gives the closest neighbor in the counterclockwise direction - always exists.
Definition: CDCWire.cc:159
MayBePtr< const CDCWire > getSecondaryNeighbor(short oClockDirection) const
Getter for the secondary neighbors of this wire id following the direction on the clock.
Definition: CDCWire.cc:189
double getForwardZ() const
Getter for the z coordinate at the forward joint points of the wires.
Definition: CDCWire.h:276
WireNeighborPair getNeighborsOutwards() const
Gives the two wires in the next layer outward.
Definition: CDCWire.cc:154
IWire getIWire() const
Getter for the wire id within its layer.
Definition: CDCWire.h:146
bool isPrimaryNeighborWith(const CDCWire &wire) const
Returns whether the give wire is a neighbor of this wire.
Definition: CDCWire.cc:144
void initialize(EWirePosition wirePosition, bool ignoreWireSag)
(Re)load all geometry parameters form the CDCGeometryPar to adjust to changes in geometry.
Definition: CDCWire.cc:69
unsigned short getEWire() const
Getter for the encoded wire number.
Definition: CDCWire.h:131
static const CDCWire * getInstance(const WireID &wireID)
Getter from the wireID convinience object. Does not construct a new object.
Definition: CDCWire.cc:24
ILayer getICLayer() const
Getter for the continious layer id ranging from 0 - 55.
Definition: CDCWire.h:150
MayBePtr< const CDCWire > getNeighborCWInwards() const
Gives the closest neighbor in the clockwise inwards direction This does not cross superlayer boundari...
Definition: CDCWire.cc:174
MayBePtr< const CDCWire > getNeighborCW() const
Gives the closest neighbor in the clockwise direction - always exists.
Definition: CDCWire.cc:164
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 CDCWireLayer & getWireLayer() const
Getter for the wire layer.
Definition: CDCWire.cc:127
double getLateralCellWidth() const
Getter for the cell widths in lateral direction.
Definition: CDCWire.cc:122
MayBePtr< const CDCWire > getNeighborCCWInwards() const
Gives the closest neighbor in the countclockwise inwards direction This does not cross superlayer bou...
Definition: CDCWire.cc:169
double m_refCylindricalR
Precomputed distance to the beam line at the reference position.
Definition: CDCWire.h:416
WireNeighborPair getNeighborsInwards() const
Gives the two wires in the next layer inward.
Definition: CDCWire.cc:149
const CDCWireSuperLayer & getWireSuperLayer() const
Getter for the wire super layer.
Definition: CDCWire.cc:133
double getBackwardZ() const
Getter for the z coordinate at the backward joint points of the wires.
Definition: CDCWire.h:280
double getRadialCellWidth() const
Getter for the cell widths in radial direction.
Definition: CDCWire.cc:117
std::size_t size() const
Returns the total number of objects in this range.
Definition: Range.h:76
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:175
A three dimensional vector.
Definition: Vector3D.h:33
double cylindricalR() const
Getter for the cylindrical radius ( xy projected norm )
Definition: Vector3D.h:534
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:31
const Vector3D & refPos3D() const
Returns the reference position.
Definition: WireLine.h:227
double tanTheta() const
Returns the tangent of the opening angle between tangential vector and the z axes Also know as ds / d...
Definition: WireLine.h:187
Vector3D backward3D() const
Gives the position of the backward point.
Definition: WireLine.h:118
Vector3D forward3D() const
Gives the position of the forward point.
Definition: WireLine.h:110
Type for the neighbor relationship from one wire to another.
Class representing a pair of neighbors in the CDC in a single layer For certain circumstances it is a...
Class to identify a wire inside the CDC.
Definition: WireID.h:34
unsigned short getICLayer() const
Getter for continuous layer numbering.
Definition: WireID.cc:24
unsigned short getIWire() const
Getter for wire within the layer.
Definition: WireID.h:145
unsigned short getISuperLayer() const
Getter for Super-Layer.
Definition: WireID.h:130
unsigned short getILayer() const
Getter for layer within the Super-Layer.
Definition: WireID.h:136
Abstract base class for different kinds of events.