Belle II Software  release-05-02-19
WireID.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Heck *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/logging/Logger.h>
14 #include <TObject.h>
15 
16 namespace Belle2 {
36  class WireID : public TObject {
37  public:
38  //--- Constructors ---------------------------------------------
47  explicit WireID(unsigned short eWire = 65535)
48  {
49  m_eWire = eWire;
50  }
51 
53  WireID(const WireID& wireID) : TObject(wireID)
54  {
55  m_eWire = wireID.m_eWire;
56  }
57 
64  WireID(unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire);
65 
71  WireID(unsigned short iCLayer, unsigned short iWire);
72 
73 
74  //--- Operators for various purposes. ---------------------------------------------------------------------------------------
76  WireID& operator=(const WireID& wireID)
77  {
78  m_eWire = wireID.m_eWire;
79  static_cast<TObject>(*this) = wireID;
80  return *this;
81  }
82 
87  WireID& operator=(unsigned short eWire)
88  {
89  m_eWire = eWire;
90  return *this;
91  }
92 
94  operator unsigned short() const
95  {
96  return getEWire();
97  }
98 
100  bool operator==(const WireID& rhs) const
101  {
102  return getEWire() == rhs.getEWire();
103  }
104 
106  bool operator<(const WireID& rhs) const
107  {
108  return getEWire() < rhs.getEWire();
109  }
110 
111 
112  //--- Setters ---------------------------------------------------------------------------------------------------------------
114  void setWireID(unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire)
115  {
116  B2DEBUG(250, "setWireID called with " << iSuperLayer << ", " << iLayer << ", " << iWire);
117  m_eWire = iWire + 512 * iLayer + 4096 * iSuperLayer;
118  }
119 
121  void setWireID(unsigned short iCLayer, unsigned short iWire);
122 
124  void setWireID(unsigned short eWire)
125  {
126  B2DEBUG(250, "setWireID called with " << eWire);
127  m_eWire = eWire;
128  }
129 
130  //--- Getters -------------------------------------------------------------------------------------------------
132  unsigned short getISuperLayer() const
133  {
134  return (m_eWire / 4096);
135  }
136 
138  unsigned short getILayer() const
139  {
140  return ((m_eWire % 4096) / 512);
141  }
142 
147  unsigned short getIWire() const
148  {
149  return (m_eWire % 512);
150  }
151 
153  unsigned short getICLayer() const;
154 
156  unsigned short getEWire() const
157  {
158  return m_eWire;
159  }
160 
161  private:
163  unsigned short m_eWire;
164 
166  ClassDef(WireID, 2);
167  };
169 }
170 
Belle2::WireID::operator==
bool operator==(const WireID &rhs) const
Check for equality.
Definition: WireID.h:108
Belle2::WireID
Class to identify a wire inside the CDC.
Definition: WireID.h:44
Belle2::WireID::getILayer
unsigned short getILayer() const
Getter for layer within the Super-Layer.
Definition: WireID.h:146
Belle2::WireID::getEWire
unsigned short getEWire() const
Getter for encoded wire number.
Definition: WireID.h:164
Belle2::WireID::getISuperLayer
unsigned short getISuperLayer() const
Getter for Super-Layer.
Definition: WireID.h:140
Belle2::WireID::ClassDef
ClassDef(WireID, 2)
ROOT Macro.
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::WireID::operator=
WireID & operator=(const WireID &wireID)
Assignment operator.
Definition: WireID.h:84
Belle2::WireID::WireID
WireID(unsigned short eWire=65535)
Constructor taking the encoded wire number.
Definition: WireID.h:55
Belle2::WireID::setWireID
void setWireID(unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire)
Setter using official numbering.
Definition: WireID.h:122
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::WireID::m_eWire
unsigned short m_eWire
Internal storage for the wire identifier in the encoded form.
Definition: WireID.h:171
Belle2::WireID::operator<
bool operator<(const WireID &rhs) const
Order by unique id.
Definition: WireID.h:114