test_wireplaneid.cxx
Go to the documentation of this file.
1 
3 #include "WireCellUtil/Testing.h"
4 
5 #include <iostream>
6 
7 using namespace WireCell;
8 using namespace std;
9 
10 int main()
11 {
13 
14 
15  WirePlaneId u(kUlayer), v(kVlayer), w(kWlayer);
16 
17  cerr << "u.ident=" << u.ident() << " v.ident=" << v.ident() << " w.ident=" << w.ident() << endl;
18  cerr << "u=" << u << " v=" << v << " w=" << w << endl;
19 
20  Assert(u.ident() == 1);
21  Assert(v.ident() == 2);
22  Assert(w.ident() == 4);
23 
24  Assert(u.ilayer() == 1);
25  Assert(v.ilayer() == 2);
26  Assert(w.ilayer() == 4);
27 
28  Assert(u.layer() == kUlayer);
29  Assert(v.layer() == kVlayer);
30  Assert(w.layer() == kWlayer);
31 
32  Assert(u.index() == 0);
33  Assert(v.index() == 1);
34  Assert(w.index() == 2);
35 
36  for (int ilayer = 0; ilayer< 4; ++ilayer) {
37  WirePlaneLayer_t layer = layers[ilayer];
38  for (int face=0; face < 2 ; ++face) {
39  for (int apa = 0; apa < 3; ++apa) {
40 
41  cerr << "Raw: " << ilayer << " " << layer << " " << face << " " << apa << endl;
42 
43  WirePlaneId wpid(layer, face, apa);
44 
45  cerr << "\twpid=" << wpid << endl;
46 
47  cerr << "\tident=" << wpid.ident()
48  <<" ilayer=" << wpid.ilayer()
49  << " layer=" << wpid.layer()
50  << " index=" << wpid.index() << endl;
51 
52 
53  if (ilayer) { AssertMsg(wpid.valid(), "known layer should give true wpid"); }
54  else {AssertMsg(!wpid.valid(), "unknown layer should give false wpid");}
55 
56  Assert(ilayer-1 == wpid.index());
57  Assert(face == wpid.face());
58  Assert(apa == wpid.apa());
59  }
60  }
61 
62  }
63 
64 }
WirePlaneLayer_t layer() const
Layer as enum.
Definition: WirePlaneId.cxx:25
int ident() const
Unit ID as integer.
Definition: WirePlaneId.cxx:21
int main()
STL namespace.
#define Assert
Definition: Testing.h:7
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
int apa() const
APA number.
Definition: WirePlaneId.cxx:48
#define AssertMsg
Definition: Testing.h:8
WirePlaneLayer_t
Enumerate layer IDs. These are not indices!
Definition: WirePlaneId.h:13
int index() const
Layer as index number (0,1 or 2). -1 if unknown.
Definition: WirePlaneId.cxx:34
QTextStream & endl(QTextStream &s)
int face() const
APA face number.
Definition: WirePlaneId.cxx:44