Belle II Software  release-08-01-10
WireID.h
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 #pragma once
10 
11 #include <framework/logging/Logger.h>
12 #include <TObject.h>
13 
14 namespace Belle2 {
34  class WireID : public TObject {
35  public:
36  //--- Constructors ---------------------------------------------
45  explicit WireID(unsigned short eWire = 65535)
46  {
47  m_eWire = eWire;
48  }
49 
51  WireID(const WireID& wireID) : TObject(wireID)
52  {
53  m_eWire = wireID.m_eWire;
54  }
55 
62  WireID(unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire);
63 
69  WireID(unsigned short iCLayer, unsigned short iWire);
70 
71 
72  //--- Operators for various purposes. ---------------------------------------------------------------------------------------
74  WireID& operator=(const WireID& wireID)
75  {
76  m_eWire = wireID.m_eWire;
77  static_cast<TObject>(*this) = wireID;
78  return *this;
79  }
80 
85  WireID& operator=(unsigned short eWire)
86  {
87  m_eWire = eWire;
88  return *this;
89  }
90 
92  operator unsigned short() const
93  {
94  return getEWire();
95  }
96 
98  bool operator==(const WireID& rhs) const
99  {
100  return getEWire() == rhs.getEWire();
101  }
102 
104  bool operator<(const WireID& rhs) const
105  {
106  return getEWire() < rhs.getEWire();
107  }
108 
109 
110  //--- Setters ---------------------------------------------------------------------------------------------------------------
112  void setWireID(unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire)
113  {
114  B2DEBUG(250, "setWireID called with " << iSuperLayer << ", " << iLayer << ", " << iWire);
115  m_eWire = iWire + 512 * iLayer + 4096 * iSuperLayer;
116  }
117 
119  void setWireID(unsigned short iCLayer, unsigned short iWire);
120 
122  void setWireID(unsigned short eWire)
123  {
124  B2DEBUG(250, "setWireID called with " << eWire);
125  m_eWire = eWire;
126  }
127 
128  //--- Getters -------------------------------------------------------------------------------------------------
130  unsigned short getISuperLayer() const
131  {
132  return (m_eWire / 4096);
133  }
134 
136  unsigned short getILayer() const
137  {
138  return ((m_eWire % 4096) / 512);
139  }
140 
145  unsigned short getIWire() const
146  {
147  return (m_eWire % 512);
148  }
149 
151  unsigned short getICLayer() const;
152 
154  unsigned short getEWire() const
155  {
156  return m_eWire;
157  }
158 
159  private:
161  unsigned short m_eWire;
162 
165  };
167 }
168 
Class to identify a wire inside the CDC.
Definition: WireID.h:34
WireID(const WireID &wireID)
Copy constructor.
Definition: WireID.h:51
unsigned short m_eWire
Internal storage for the wire identifier in the encoded form.
Definition: WireID.h:161
bool operator<(const WireID &rhs) const
Order by unique id.
Definition: WireID.h:104
WireID & operator=(const WireID &wireID)
Assignment operator.
Definition: WireID.h:74
bool operator==(const WireID &rhs) const
Check for equality.
Definition: WireID.h:98
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
ClassDef(WireID, 2)
ROOT Macro.
unsigned short getEWire() const
Getter for encoded wire number.
Definition: WireID.h:154
void setWireID(unsigned short eWire)
Setter using the encoded wire number.
Definition: WireID.h:122
unsigned short getISuperLayer() const
Getter for Super-Layer.
Definition: WireID.h:130
WireID(unsigned short eWire=65535)
Constructor taking the encoded wire number.
Definition: WireID.h:45
unsigned short getILayer() const
Getter for layer within the Super-Layer.
Definition: WireID.h:136
void setWireID(unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire)
Setter using official numbering.
Definition: WireID.h:112
WireID & operator=(unsigned short eWire)
Assignment from unsigned short.
Definition: WireID.h:85
Abstract base class for different kinds of events.