Boundary.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file Boundary.cxx
3 /// \brief Boundary for CVN PixelMap
4 /// \author Alexander Radovic - a.radovic@gmail.com
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include <iostream>
8 #include <ostream>
9 #include <utility>
10 #include <cassert>
11 
12 
14 
15 namespace cvn
16 {
17 
18  Boundary::Boundary(const int& nWire,
19  const double& tRes,
20  const int& minWireX,
21  const int& minWireY,
22  const int& minWireZ,
23  const double& centerTDCX,
24  const double& centerTDCY,
25  const double& centerTDCZ):
26  fFirstWire{minWireX,
27  minWireY,
28  minWireZ},
29  fLastWire{minWireX + nWire - 1,
30  minWireY + nWire - 1,
31  minWireZ + nWire - 1},
32  fFirstTDC{centerTDCX - tRes, // For odd nTDC, we will truncate 0.5,
33  centerTDCY - tRes,
34  centerTDCZ - tRes}, // but get it back in LastTDC
35  fLastTDC{centerTDCX + tRes,// Recover the trucated 0.5
36  centerTDCY + tRes,
37  centerTDCZ + tRes}// with nTDC % 2
38 
39  {
40  assert(fLastWire[0] - fFirstWire[0] == nWire - 1);
41  assert(fLastWire[1] - fFirstWire[1] == nWire - 1);
42  assert(fLastWire[2] - fFirstWire[2] == nWire - 1);
43  }
44 
45  bool Boundary::IsWithin(const unsigned int& wire, const double& cell, const unsigned int& view)
46  {
47  bool inWireRcvne = (int) wire >= fFirstWire[view] && (int) wire <= fLastWire[view];
48  bool inTDCRcvne = (double) cell >= fFirstTDC[view] &&
49  (double) cell <= fLastTDC[view];
50  return inWireRcvne && inTDCRcvne;
51  }
52 
53 
54  std::ostream& operator<<(std::ostream& os, const Boundary& b)
55  {
56  os<<"Boundary with "
57  <<"(first,last) wire X: (" << b.FirstWire(0)<<", "<< b.LastWire(0)
58  <<"(first,last) wire Y: (" << b.FirstWire(1)<<", "<< b.LastWire(1)
59  <<"(first,last) wire Z: (" << b.FirstWire(2)<<", "<< b.LastWire(2)
60  <<"), (first,last) tdc X: ("<<b.FirstTDC(0)<<", "<<b.LastTDC(0)<<")"
61  <<"), (first,last) tdc Y: ("<<b.FirstTDC(1)<<", "<<b.LastTDC(1)<<")"
62  <<"), (first,last) tdc Z: ("<<b.FirstTDC(2)<<", "<<b.LastTDC(2)<<")";
63 
64  return os;
65  }
66 }
double fFirstTDC[3]
Minimum cell in each view, inclusive.
Definition: Boundary.h:54
std::ostream & operator<<(std::ostream &os, const PixelMapProducer &p)
Utility class for truth labels.
double fLastTDC[3]
Maximum cell in each view, inclusive.
Definition: Boundary.h:55
int fFirstWire[3]
Minimum wire, inclusive.
Definition: Boundary.h:47
double FirstTDC(const unsigned int &view) const
Definition: Boundary.h:46
int FirstWire(const unsigned int &view) const
Definition: Boundary.h:44
int LastWire(const unsigned int &view) const
Definition: Boundary.h:45
static bool * b
Definition: config.cpp:1043
int fLastWire[3]
Maximum wire, inclusive.
Definition: Boundary.h:53
double LastTDC(const unsigned int &view) const
Definition: Boundary.h:47
Boundary for CVN PixelMap.
bool IsWithin(const unsigned int &wire, const double &cell, const unsigned int &view)
Definition: Boundary.cxx:45