CellHit.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief CellHit class
3 /// \author C. Backhouse - bckhouse@caltech.edu
4 /// \date
5 ////////////////////////////////////////////////////////////////////////
6 #include "RecoBase/CellHit.h"
7 
8 #include <algorithm>
9 #include <iomanip>
10 #include <iostream>
11 
12 
13 
14 namespace rb
15 {
16  //----------------------------------------------------------------------
18  RawDigit(),
19  fPlane(0),
20  fCell(0),
21  fView(geo::kXorY),
22  fPE(0),
23  fTNS(0),
24  fID(0),
25  fCoarseTiming(false)
26  {
27  }
28 
29  //----------------------------------------------------------------------
30  CellHit::CellHit(const rawdata::RawDigit& rd, int id) :
31  RawDigit(rd),
32  fPlane(0),
33  fCell(0),
34  fView(geo::kXorY),
35  fPE(0),
36  fTNS(0),
37  fID(id),
38  fCoarseTiming(false)
39  {
40  }
41 
42  //----------------------------------------------------------------------
44  {
45  }
46 
47  //----------------------------------------------------------------------
48  void CellHit::Print() const
49  {
50  std::cout << *this;
51  }
52 
53  //------------------------------------------------------------
54  bool CellHit::operator< (const CellHit& other) const
55  {
56  if(fPlane < other.Plane() ) return true;
57  else if(fPlane == other.Plane() && fCell < other.Cell() ) return true;
58  else if(fPlane == other.Plane() &&
59  fCell == other.Cell() &&
60  fTNS < other.TNS() ) return true;
61 
62  return false;
63  }
64 
65  //------------------------------------------------------------
66  std::ostream& operator<< (std::ostream& o, const CellHit& c)
67  {
68  o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
69  o << " View = " << std::setw(5) << std::right << c.View()
70  << " ID = " << std::setw(5) << std::right << c.ID()
71  << " Plane = " << std::setw(5) << std::right << c.Plane()
72  << " Cell = " << std::setw(5) << std::right << c.Cell()
73  << " Channel = "<< std::setw(5) << std::right << c.Channel()
74  << " TDC = " << std::setw(5) << std::right << c.TDC()
75  << " TNS = " << std::setw(5) << std::right << c.TNS()
76  << " ADC = " << std::setw(5) << std::right << c.ADC()
77  << " PE = " << std::setw(5) << std::right << c.PE();
78  return o;
79  }
80 
81  bool CellHit::operator== (const CellHit& other) const
82  {
83  if(fPlane == other.Plane() &&
84  fCell == other.Cell() &&
85  this->ADC() == other.ADC() &&
86  fTDC[0] == other.TDC() )
87  return true;
88  return false;
89  }
90 
91  //------------------------------------------------------------
93  const art::Ptr<rb::CellHit>& b)
94  {
95  return a->Plane() < b->Plane();
96  }
97 
98  //------------------------------------------------------------
100  const art::Ptr<rb::CellHit>& b)
101  {
102  return a->TNS() < b->TNS();
103  }
104 
105  //------------------------------------------------------------
107  const art::Ptr<rb::CellHit>& b)
108  {
109  return a->Cell() < b->Cell();
110  }
111 
112  //------------------------------------------------------------
114  const art::Ptr<rb::CellHit>& b)
115  {
116  if( a->Plane() < b->Plane() )
117  return true;
118  if( a->Plane() > b->Plane() )
119  return false;
120  return a->Cell() < b->Cell();
121  }
122 
123  //------------------------------------------------------------
124  void SortByPlane(std::vector<art::Ptr<rb::CellHit> >& c)
125  {
126  std::stable_sort(c.begin(), c.end(), CompareByPlane);
127  }
129  {
130  std::stable_sort(c.begin(), c.end(), CompareByPlane);
131  }
132 
133  //------------------------------------------------------------
134  void SortByTime(std::vector<art::Ptr<rb::CellHit> >& c)
135  {
136  std::stable_sort(c.begin(), c.end(), CompareByTime);
137  }
139  {
140  std::stable_sort(c.begin(), c.end(), CompareByTime);
141  }
142 
143  //------------------------------------------------------------
144 
145  void SortByCell(std::vector<art::Ptr<rb::CellHit> >& c)
146  {
147  std::stable_sort(c.begin(), c.end(), CompareByCell);
148  }
150  {
151  std::stable_sort(c.begin(), c.end(), CompareByCell);
152  }
153 
154  //------------------------------------------------------------
156  {
157  std::stable_sort(c.begin(), c.end(), CompareByPlaneAndCell);
158  }
160  {
161  std::stable_sort(c.begin(), c.end(), CompareByPlaneAndCell);
162  }
163 
164 } // end namespace rb
165 //////////////////////////////////////////////////////////////////////////////////////////
float TNS() const
Definition: CellHit.h:46
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
bool operator==(const CellHit &other) const
Returns true if the two cellhits have the same plane, cell, PE and TDC values.
Definition: CellHit.cxx:81
friend std::ostream & operator<<(std::ostream &o, const CellHit &c)
Definition: CellHit.cxx:66
unsigned short Plane() const
Definition: CellHit.h:39
bool operator<(const CellHit &other) const
Definition: CellHit.cxx:54
geo::View_t fView
view (geo::kX or geo::kY)
Definition: CellHit.h:69
iterator begin()
Definition: PtrVector.h:223
Definition: geo.h:1
geo::View_t View() const
Definition: CellHit.h:41
bool CompareByCell(const art::Ptr< rb::CellHit > &a, const art::Ptr< rb::CellHit > &b)
Helper for SortByCell. Is a on a lower cell number than b?
Definition: CellHit.cxx:106
void SortByTime(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in time order (earliest to latest).
Definition: CellHit.cxx:134
bool CompareByPlane(const art::Ptr< rb::CellHit > &a, const art::Ptr< rb::CellHit > &b)
Helper for SortByPlane. Is a on a lower number plane than b?
Definition: CellHit.cxx:92
bool CompareByTime(const art::Ptr< rb::CellHit > &a, const art::Ptr< rb::CellHit > &b)
Helper for SortByTime. Is a earlier than b?
Definition: CellHit.cxx:99
float fPE
after ADC–>PE gain applied
Definition: CellHit.h:71
unsigned short fCell
cell number
Definition: CellHit.h:68
unsigned short Cell() const
Definition: CellHit.h:40
int16_t ADC() const
Best estimator of the hit charge.
Definition: RawDigit.cxx:67
const double a
iterator end()
Definition: PtrVector.h:237
float PE() const
Definition: CellHit.h:42
std::vector< int32_t > fTDC
TDC(-like) time value. Event time is subtracted. Vector structure is a historical artifact...
Definition: RawDigit.h:50
Perform a "2 point" Hough transform on a collection of hits.
OStream cout
Definition: OStream.cxx:6
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
bool CompareByPlaneAndCell(const art::Ptr< rb::CellHit > &a, const art::Ptr< rb::CellHit > &b)
Definition: CellHit.cxx:113
const int ID() const
Definition: CellHit.h:47
bool fCoarseTiming
Was the timing fit bad?
Definition: CellHit.h:75
int16_t ADC(uint32_t i) const
Definition: RawDigit.cxx:58
void SortByCell(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in cell order (low to high)
Definition: CellHit.cxx:145
const hit & b
Definition: hits.cxx:21
float fTNS
time of hit in ns with channel differences removed
Definition: CellHit.h:72
uint32_t Channel() const
Definition: RawDigit.h:84
unsigned short fPlane
plane number
Definition: CellHit.h:67
void Print() const
Definition: CellHit.cxx:48
Helper for AttenCurve.
Definition: Path.h:10
int fID
ID for CellHit.
Definition: CellHit.h:73
void SortByPlane(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in plane order (low to high).
Definition: CellHit.cxx:124
void SortByPlaneAndCell(std::vector< art::Ptr< rb::CellHit > > &c)
Definition: CellHit.cxx:155