LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
OpFlash.cxx
Go to the documentation of this file.
1 //
3 // \brief Definition of OpFlash reconstruction object
4 //
5 // \author bjpjones@mit.edu
6 // cschiu@mit.edu
7 //
9 
11 
12 #include <algorithm> // std::max()
13 #include <numeric> // std::accumulate()
14 #include <ostream>
15 #include <utility> // std::move()
16 
17 namespace recob {
18 
19  //----------------------------------------------------------------------
20  OpFlash::OpFlash(double time,
21  double timewidth,
22  double abstime,
23  unsigned int frame,
24  std::vector<double> PEperOpDet,
25  bool InBeamFrame,
26  int onBeamTime,
27  double FastToTotal,
28  double xCenter,
29  double xWidth,
30  double yCenter,
31  double yWidth,
32  double zCenter,
33  double zWidth,
34  std::vector<double> WireCenters,
35  std::vector<double> WireWidths)
36  : fTime{time}
37  , fTimeWidth{timewidth}
38  , fAbsTime{abstime}
39  , fFrame{frame}
40  , fPEperOpDet{std::move(PEperOpDet)}
41  , fWireCenters{std::move(WireCenters)}
42  , fWireWidths{std::move(WireWidths)}
43  , fXCenter{xCenter}
44  , fXWidth{xWidth}
45  , fYCenter{yCenter}
46  , fYWidth{yWidth}
47  , fZCenter{zCenter}
48  , fZWidth{zWidth}
51  , fOnBeamTime{onBeamTime}
52  {}
53 
54  //----------------------------------------------------------------------
55  OpFlash::OpFlash(double time,
56  double timewidth,
57  double abstime,
58  unsigned int frame,
59  std::vector<double> PEperOpDet,
60  bool InBeamFrame,
61  int onBeamTime,
62  double FastToTotal,
63  double yCenter,
64  double yWidth,
65  double zCenter,
66  double zWidth,
67  std::vector<double> WireCenters,
68  std::vector<double> WireWidths)
69  : OpFlash{time,
70  timewidth,
71  abstime,
72  frame,
73  std::move(PEperOpDet),
75  onBeamTime,
77  NoCenter,
78  NoCenter,
79  yCenter,
80  yWidth,
81  zCenter,
82  zWidth,
83  std::move(WireCenters),
84  std::move(WireWidths)}
85  {}
86 
87  //----------------------------------------------------------------------
88  bool operator<(const OpFlash& a, const OpFlash& b)
89  {
90  return a.Time() < b.Time();
91  }
92 
93  //----------------------------------------------------------------------
94  double OpFlash::TotalPE() const
95  {
96  return std::accumulate(fPEperOpDet.begin(), fPEperOpDet.end(), 0.0);
97  }
98 
99  //----------------------------------------------------------------------
100  std::ostream& operator<<(std::ostream& out, OpFlash const& flash)
101  {
102 
103  out << "Optical flash at " << flash.Time() << " us (absolute: " << flash.AbsTime() << " us) "
104  << flash.TimeWidth() << " us long, centered at (";
105  if (flash.hasXCenter())
106  out << flash.XCenter();
107  else
108  out << "?";
109  out << ", " << flash.YCenter() << ", " << flash.ZCenter() << ") cm of extension +/- (";
110  if (flash.hasXCenter())
111  out << flash.XWidth();
112  else
113  out << "?";
114  out << ", " << flash.YWidth() << ", " << flash.ZWidth() << ") cm ";
115  if (!flash.hasXCenter()) out << " (x: n/a)";
116 
117  out << "\n " << (flash.InBeamFrame() ? "" : "not ")
118  << "in beam frame (on beam time: " << flash.OnBeamTime() << ")";
119 
120  out << "\n total p.e.: " << flash.TotalPE() << " (fast/total fraction: " << flash.FastToTotal()
121  << ")";
122  std::size_t const nPEs = flash.PEs().size();
123  if (nPEs > 0) {
124  out << " across " << nPEs << " channels; non-empty:";
125  constexpr unsigned int pageSize = 8;
126  unsigned int line = 0;
127  for (std::size_t i = 0; i < nPEs; ++i) {
128  double const pe = flash.PE(i);
129  if (pe == 0.0) continue;
130  if (line-- == 0) {
131  line = pageSize;
132  out << "\n ";
133  }
134  out << " [" << i << "] " << pe;
135  }
136  }
137  else {
138  out << ", no channels recorded;";
139  }
140 
141  std::size_t const nWireCenters = flash.WireCenters().size();
142  std::size_t const nWireWidths = flash.WireWidths().size();
143  std::size_t const nWires = std::max(nWireCenters, nWireWidths);
144  out << "\n ";
145  if (nWires) {
146  out << nWires << " wires recorded (center +/- width):";
147  constexpr unsigned int pageSize = 5;
148  unsigned int line = 0;
149  for (std::size_t i = 0; i < nWires; ++i) {
150  if (line-- == 0) {
151  line = pageSize;
152  out << "\n ";
153  }
154  out << " [" << i << "] (";
155  if (i < nWireCenters)
156  out << flash.WireCenters()[i];
157  else
158  out << "n/a";
159  out << " +/- ";
160  if (i < nWireWidths)
161  out << flash.WireWidths()[i];
162  else
163  out << "n/a";
164  out << ")";
165  }
166  }
167  else
168  out << "no wire information recorded";
169 
170  return out;
171  } // std::ostream& operator<<(std::ostream&, OpFlash const&)
172 
173  //----------------------------------------------------------------------
174 
175 }
std::vector< double > const & WireCenters() const
Definition: OpFlash.h:174
double XWidth() const
Definition: OpFlash.h:150
double fYCenter
Geometric center in y [cm].
Definition: OpFlash.h:37
static constexpr double NoCenter
Special value used for absence of center location information.
Definition: OpFlash.h:23
Reconstruction base classes.
double FastToTotal() const
Definition: OpFlash.h:170
bool operator<(Cluster const &a, Cluster const &b)
Definition: Cluster.cxx:188
double TimeWidth() const
Definition: OpFlash.h:122
double fZCenter
Geometric center in z [cm].
Definition: OpFlash.h:39
std::vector< double > fPEperOpDet
Number of PE on each PMT.
Definition: OpFlash.h:32
double PE(unsigned int i) const
Definition: OpFlash.h:134
double fXWidth
Estimated width in x [cm].
Definition: OpFlash.h:36
double fZWidth
Geometric width in z [cm].
Definition: OpFlash.h:40
bool hasXCenter() const
Returns whether the estimated center on x direction is available.
Definition: OpFlash.h:142
double ZCenter() const
Definition: OpFlash.h:162
double Time() const
Definition: OpFlash.h:118
double fYWidth
Geometric width in y [cm].
Definition: OpFlash.h:38
int OnBeamTime() const
Definition: OpFlash.h:186
unsigned int fFrame
Frame number.
Definition: OpFlash.h:31
std::vector< double > fWireCenters
Geometric center in each view.
Definition: OpFlash.h:33
std::vector< double > fWireWidths
Geometric width in each view.
Definition: OpFlash.h:34
double fFastToTotal
Fast to total light ratio.
Definition: OpFlash.h:41
double fAbsTime
Time by PMT readout clock.
Definition: OpFlash.h:30
double fXCenter
Estimated center in x [cm].
Definition: OpFlash.h:35
std::vector< double > const & WireWidths() const
Definition: OpFlash.h:178
double YWidth() const
Definition: OpFlash.h:158
std::vector< double > const & PEs() const
Returns a vector with a number of photoelectrons per channel.
Definition: OpFlash.h:138
bool fInBeamFrame
Is this in the beam frame?
Definition: OpFlash.h:42
double TotalPE() const
Definition: OpFlash.cxx:94
double XCenter() const
Returns the estimated center on x direction (.
Definition: OpFlash.h:146
OpFlash()=default
double YCenter() const
Definition: OpFlash.h:154
int fOnBeamTime
Is this in time with beam?
Definition: OpFlash.h:43
double AbsTime() const
Definition: OpFlash.h:126
double fTimeWidth
Width of the flash in time [us].
Definition: OpFlash.h:29
double ZWidth() const
Definition: OpFlash.h:166
std::ostream & operator<<(std::ostream &o, Cluster const &c)
Definition: Cluster.cxx:168
bool InBeamFrame() const
Definition: OpFlash.h:182