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