Boundary.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file Boundary.cxx
3 /// \brief Boundary for CVN PixelMap
4 /// \author Dominick Rocco - rocco@physics.umn.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include <iostream>
8 #include <utility>
9 #include <cassert>
10 
11 
12 #include "CVN/func/Boundary.h"
13 
14 namespace cvn
15 {
16 
17  Boundary::Boundary(const int& nPlane,
18  const int& nCell,
19  const int& minPlane,
20  const int& centerCellEven,
21  const int& centerCellOdd,
22  const unsigned int& firstView):
23  fFirstPlane(minPlane),
24  fLastPlane (minPlane + nPlane - 1),
25  fFirstCell{centerCellEven - nCell / 2, // For odd nCell, we will truncate 0.5,
26  centerCellOdd - nCell / 2}, // but get it back in LastCell
27  fLastCell{centerCellEven + nCell / 2 + nCell % 2 - 1,// Recover the trucated 0.5
28  centerCellOdd + nCell / 2 + nCell % 2 - 1 },// with nCell % 2
29  fFirstView(firstView)
30 
31  {
32  assert(fLastPlane - fFirstPlane == nPlane - 1);
33  assert(fLastCell[0] - fFirstCell[0] == nCell - 1);
34  assert(fLastCell[1] - fFirstCell[1] == nCell - 1);
35 
36  }
37 
38 
39 
40  bool Boundary::IsWithin(const unsigned int& plane, const unsigned int& cell, const unsigned int& view)
41  {
42  bool inPlaneRcvne = (int) plane >= fFirstPlane && (int) plane <= fLastPlane;
43  bool inCellRcvne = (int) cell >= fFirstCell[view] &&
44  (int) cell <= fLastCell[view];
45  return inPlaneRcvne && inCellRcvne;
46  }
47 
48 
49  std::ostream& operator<<(std::ostream& os, const Boundary& b)
50  {
51  os<<"Boundary with "
52  <<"(first,last) plane: (" << b.FirstPlane()<<", "<< b.LastPlane()
53  <<"), (first,last) cell even: ("<<b.FirstCell(0)<<", "<<b.LastCell(0)<<")"
54  <<"), (first,last) cell odd: ("<<b.FirstCell(1)<<", "<<b.LastCell(1)<<")";
55 
56  return os;
57  }
58 }
int FirstCell(const unsigned int &view) const
Definition: Boundary.h:44
int fLastCell[2]
Maximum cell in each view, inclusive.
Definition: Boundary.h:53
std::ostream & operator<<(std::ostream &os, const PixelMapProducer &p)
int fFirstPlane
Minimum plane, inclusive.
Definition: Boundary.h:46
int LastPlane() const
Definition: Boundary.h:43
Defines an enumeration for prong classification.
int fFirstCell[2]
Minimum cell in each view, inclusive.
Definition: Boundary.h:52
int LastCell(const unsigned int &view) const
Definition: Boundary.h:45
unsigned int fFirstView
View of first plane (0=XZ, 1=YZ)
Definition: Boundary.h:54
const hit & b
Definition: hits.cxx:21
assert(nhit_max >=nhit_nbins)
bool IsWithin(const unsigned int &plane, const unsigned int &cell, const unsigned int &view=0)
Definition: Boundary.cxx:40
int FirstPlane() const
Definition: Boundary.h:42
int fLastPlane
Maximum plane, inclusive.
Definition: Boundary.h:51