WirePlaneId.cxx
Go to the documentation of this file.
2 
3 using namespace WireCell;
4 
5 static const int layer_mask = 0x7;
6 static const int face_shift = 3;
7 static const int apa_shift = 4;
8 
10  : m_pack( (((int)layer)&layer_mask) | (face << face_shift) | (apa<<apa_shift))
11 {
12 }
14  : m_pack(packed)
15 {
16  // It is very dubious that I allow this constructor. I do it for
17  // reading WireSchema files where the packing is done by the user.
18  // Very dubious indeed.
19 }
20 
22 {
23  return m_pack;
24 }
26 {
27  return WirePlaneLayer_t(ilayer());
28 }
30 {
31  return m_pack & layer_mask;
32 }
33 
35 {
36  switch (layer()) {
37  case kUlayer : return 0;
38  case kVlayer : return 1;
39  case kWlayer : return 2;
40  case kUnknownLayer: return -1;
41  }
42  return -1;
43 }
45 {
46  return (m_pack&(1<<face_shift))>>3;
47 }
49 {
50  return m_pack>>apa_shift;
51 }
52 
54 {
55  int ind = index();
56  return 0 <= ind && ind < 3;
57 }
58 
60 {
61  return m_pack == rhs.m_pack;
62 }
63 
65 {
66  return !(*this == rhs);
67 }
68 
70 {
71  if (!this->valid() || !rhs.valid()) { return false; }
72 
73  if (apa() == rhs.apa()) {
74  if (face() == rhs.face()) {
75  return index() < rhs.index();
76  }
77  return face() < rhs.face();
78  }
79  return apa() < rhs.apa();
80 }
81 
82 
83 std::ostream& WireCell::operator<<(std::ostream& o, const WireCell::WirePlaneId& wpid)
84 {
85  o << "[WirePlaneId "<< wpid.ident() << " ind:" << wpid.index() << " layer:" << wpid.layer() << " apa:" << wpid.apa() << " face:" << wpid.face();
86  if (!wpid.valid()) { o << " bogus"; }
87  o << "]";
88  return o;
89 }
90 
91 std::ostream& WireCell::operator<<(std::ostream& o, const WireCell::WirePlaneLayer_t& layer)
92 {
93  switch (layer) {
94  case WireCell::kUlayer : o << "<U>"; break;
95  case WireCell::kVlayer : o << "<V>"; break;
96  case WireCell::kWlayer : o << "<W>"; break;
97  default: o << "<?>"; break;
98  }
99  return o;
100 }
WirePlaneLayer_t layer() const
Layer as enum.
Definition: WirePlaneId.cxx:25
int ident() const
Unit ID as integer.
Definition: WirePlaneId.cxx:21
static const int face_shift
Definition: WirePlaneId.cxx:6
bool operator==(const WirePlaneId &rhs)
Definition: WirePlaneId.cxx:59
int ilayer() const
Layer as integer (not index!)
Definition: WirePlaneId.cxx:29
bool valid() const
return true if valid
Definition: WirePlaneId.cxx:53
Definition: Main.h:22
static const int apa_shift
Definition: WirePlaneId.cxx:7
std::ostream & operator<<(std::ostream &os, const WireCell::WirePlaneId &wpid)
Definition: WirePlaneId.cxx:83
int apa() const
APA number.
Definition: WirePlaneId.cxx:48
bool operator<(const WirePlaneId &rhs)
Definition: WirePlaneId.cxx:69
WirePlaneLayer_t
Enumerate layer IDs. These are not indices!
Definition: WirePlaneId.h:13
bool operator!=(const WirePlaneId &rhs)
Definition: WirePlaneId.cxx:64
static const int layer_mask
Definition: WirePlaneId.cxx:5
WirePlaneId(WirePlaneLayer_t layer, int face=0, int apa=0)
Definition: WirePlaneId.cxx:9
int index() const
Layer as index number (0,1 or 2). -1 if unknown.
Definition: WirePlaneId.cxx:34
int face() const
APA face number.
Definition: WirePlaneId.cxx:44