All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpT0FinderTypes.cxx
Go to the documentation of this file.
1 #ifndef __OPT0FINDERTYPES_CXX__
2 #define __OPT0FINDERTYPES_CXX__
3 
4 #include <iostream>
5 #include "OpT0FinderTypes.h"
6 
7 namespace flashmatch {
8 
9  double QCluster_t::sum() const
10  { double sum=0; for(auto const& pt : (*this)) sum += pt.q; return sum; }
11 
12  double QCluster_t::length() const
13  {
14  double len=0.;
15  for(size_t idx=1; idx<this->size(); ++idx) {
16  auto const& pt0 = (*this)[idx-1];
17  auto const& pt1 = (*this)[idx];
18  len += sqrt(pow(pt0.x - pt1.x,2)+pow(pt0.y - pt1.y,2)+pow(pt0.z - pt1.z,2));
19  }
20  return len;
21  }
22 
23  void QCluster_t::drop(double x_min, double x_max)
24  {
25  QCluster_t another;
26  another.reserve(this->size());
27  for(auto const& pt : (*this)) {
28  if(pt.x < x_min) continue;
29  if(pt.x > x_max) continue;
30  another.push_back(pt);
31  }
32  (*this) = another;
33  }
34 
35  /// streamer override
36  std::ostream& operator << (std::ostream& out, const flashmatch::QCluster_t& obj) {
37  out << "QCluster_t " << obj.size() << " points length=" << obj.length() << " qsum=" << obj.sum() << std::endl;
38  return out;
39  }
40 
41 
42 
43 
44 }
45 
46 #endif
double sum() const
returns the sum of &quot;q&quot; from QPoint_t
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
Collection of charge deposition 3D point (cluster)
double length() const
returns the total trajectory length
std::ostream & operator<<(std::ostream &out, const flashmatch::QCluster_t &obj)
streamer override
ID_t idx
index from original larlite vector
void drop(double xmin, double xmax)
drop points outside the x range specified