All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpT0FinderTypes.h
Go to the documentation of this file.
1 #ifndef OPT0FINDER_OPT0FINDERTYPES_H
2 #define OPT0FINDER_OPT0FINDERTYPES_H
3 
4 #include <vector>
5 #include <numeric>
6 #include "OpT0FinderConstants.h"
7 #include <string>
8 #include <cmath>
9 namespace flashmatch {
10 
11  /// Index used to identify Flash_t/QPointCollection_t uniquely in an event
12  typedef size_t ID_t;
13  /// Invalid ID
15 
16  /// Enumerator for different types of algorithm
17  enum Algorithm_t {
18  kTPCFilter, ///< Algorithm type to filter out TPC objects from matching candidate list
19  kFlashFilter, ///< Algorithm type to filter out flash from matching candidate list
20  kFlashMatch, ///< Algorithm type to match flash hypothesis and reconstructed flash
21  kMatchProhibit, ///< Algorithm type to prohibit a match between a flash and a cluster
22  kFlashHypothesis, ///< Algorithm type to make QCluster_t => Flash_t hypothesis
23  kCustomAlgo, ///< Algorithm type that does not play a role in the framework execution but inherits from BaseAlgorithm
24  kAlgorithmTypeMax ///< enum flag for algorithm type count & invalid type
25  };
26 
27  /// Struct to represent an optical flash
28  struct Flash_t {
29  public:
30 
31  std::vector<double> pe_v; ///< PE distribution over photo-detectors
32  std::vector<double> pe_true_v; ///< PE distribution over photo-detectors of MCFlash
33  std::vector<double> pe_err_v; ///< PE value error
34  double x,y,z; ///< Flash position
35  double x_err,y_err,z_err; ///< Flash position error
36  double time; ///< Flash timing, a candidate T0
37  ID_t idx; ///< index from original larlite vector
38  /// Default ctor assigns invalid values
39  Flash_t() : pe_v(), pe_true_v() {
40  x = y = z = kINVALID_DOUBLE;
43  idx = kINVALID_ID;
44  }
45  /// Total PE calculation
46  double TotalPE() const {
47  double res=0.;
48  for(auto const& v : pe_v) if(v>=0.) res+=v;
49  return res;
50  }
51  /// Total true PE calculation
52  double TotalTruePE() const {
53  double res=0.;
54  for (auto const& v : pe_true_v) if (v>=0.) res+=v;
55  return res;
56  }
57  /// Check validity
58  bool Valid(size_t nopdet=0) const {
59  return (nopdet ? (pe_v.size() == nopdet && pe_err_v.size() == nopdet) : (pe_v.size() == pe_err_v.size()));
60  }
61  //double TotalPE() const{ return std::accumulate(pe_v.begin(),pe_v.end(),0.0);}
62  };
63 
64  /// Struct to represent an energy deposition point in 3D space
65  struct QPoint_t{
66 
67  double x,y,z; ///< Spatial position in [cm]
68  double q; ///< Charge in an arbitrary unit
69  /// Default ctor assigns invalid values
75  {}
76  /// Alternative ctor
77  QPoint_t(double xvalue,
78  double yvalue,
79  double zvalue,
80  double qvalue)
81  : x(xvalue)
82  , y(yvalue)
83  , z(zvalue)
84  , q(qvalue)
85  {}
86  /// distance
87  inline double dist(const QPoint_t& pt)
88  { return sqrt(pow(pt.x-x,2)+pow(pt.y-y,2)+pow(pt.z-z,2)); }
89  };
90 
91  /// Collection of charge deposition 3D point (cluster)
92  class QCluster_t : public std::vector<QPoint_t>{
93  public:
94  ID_t idx; ///< index from original larlite vector
95  double time; ///< assumed time w.r.t. trigger for reconstruction
96 
97  /// Default constructor
100 
101  /// returns the sum of "q" from QPoint_t
102  double sum() const;
103 
104  /// returns the total trajectory length
105  double length() const;
106 
107  /// drop points outside the x range specified
108  void drop(double xmin, double xmax);
109 
110  /// minimum x
111  inline double min_x() const
112  { double x=flashmatch::kINVALID_DOUBLE; for(auto const& pt : (*this)) x = std::min(x,pt.x); return x; }
113 
114  /// maximum x
115  inline double max_x() const
116  { double x=flashmatch::kINVALID_DOUBLE; for(auto const& pt : (*this)) x = std::max(x,pt.x); return x; }
117 
118  inline QCluster_t& operator+=(const double shift)
119  { for(auto& pt : (*this)) pt.x += shift; return (*this); }
120 
121  inline QCluster_t operator+(const double shift)
122  { auto result = (*this); result += shift; return result; }
123 
124  inline QCluster_t& operator+=(const QCluster_t& rhs) {
125  this->reserve(rhs.size() + this->size());
126  for(auto const& pt : rhs) this->push_back(pt);
127  return (*this);
128  }
129 
130  inline QCluster_t operator+(const QCluster_t& rhs) const {
131  QCluster_t res((*this));
132  res += rhs;
133  return res;
134  }
135 
136  };
137  std::ostream& operator << (std::ostream& out, const flashmatch::QCluster_t& obj);
138 
139  /// Collection of 3D point clusters (one use case is TPC object representation for track(s) and shower(s))
140  typedef std::vector<flashmatch::QCluster_t> QClusterArray_t;
141  /// Collection of Flash objects
142  typedef std::vector<flashmatch::Flash_t> FlashArray_t;
143 
144  /// Index collection
145  typedef std::vector<flashmatch::ID_t> IDArray_t;
146 
147  /// Flash-TPC match info
148  struct FlashMatch_t {
149  ID_t tpc_id; ///< matched TPC object ID
150  ID_t flash_id; ///< matched Flash ID
151  double score; ///< floating point representing the "goodness" (algorithm dependent)
152  QPoint_t tpc_point; ///< estimated & matched 3D flash hypothesis point from TPC information
153  QPoint_t tpc_point_err; ///< error on the estimated point
154  unsigned int duration; ///< Computation time of the match algorithm on this match (ns)
155  unsigned int num_steps; ///< Number of MIGRAD steps
156  std::vector<double> hypothesis; ///< Hypothesis flash object
157  /// Default ctor assigns invalid values
160  /// Alternative ctor
161  FlashMatch_t(const ID_t& tpc_id_value,
162  const ID_t& flash_id_value,
163  const double& score_value) : hypothesis()
164  { tpc_id = tpc_id_value; flash_id = flash_id_value; score = score_value; }
165 #ifndef __CINT__ // hyde move from fucking CINT cuz it's fucked
166  /// Alternative ctor
167  FlashMatch_t(const ID_t& tpc_id_value,
168  const ID_t& flash_id_value,
169  const double& score_value,
170  std::vector<double>&& hypo) : hypothesis(std::move(hypo))
171  { tpc_id = tpc_id_value; flash_id = flash_id_value; score = score_value; }
172 #endif
173  };
174 
175  /// Enum to define MC source type (MCTrack or MCShower) for a given QCluster
180  };
181 
182  /// Struct to represent the ancestor information for a specific interaction (QCluster)
183  struct MCSource_t {
184  int index_id; ///< MCTrac/MCShower collection index ID of the ancestor
185  double g4_time; ///< Interaction G4 time in micro-seconds
186  double energy_deposit; ///< Deposited energy total
187  MCAncestor_t source_type; ///< Ancestor source type
189  {
190  index_id = -1;
193  }
194  };
195 
196  namespace msg {
197  /// Verbosity message level
198  enum Level_t {
206  };
207 
208  const std::string kStringPrefix[kMSG_TYPE_MAX] =
209  {
210  "\033[94m [DEBUG] \033[00m", ///< DEBUG message prefix
211  "\033[92m [INFO] \033[00m", ///< INFO message prefix
212  "\033[95m [NORMAL] \033[00m", ///< NORMAL message prefix
213  "\033[93m [WARNING] \033[00m", ///< WARNING message prefix
214  "\033[91m [ERROR] \033[00m", ///< ERROR message prefix
215  "\033[5;1;33;41m [EXCEPTION] \033[00m" ///< CRITICAL message prefix
216  };
217  ///< Prefix of message
218  }
219 }
220 #endif
Algorithm type to make QCluster_t =&gt; Flash_t hypothesis.
Algorithm_t
Enumerator for different types of algorithm.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
MCAncestor_t
Enum to define MC source type (MCTrack or MCShower) for a given QCluster.
std::vector< double > hypothesis
std::vector< flashmatch::QCluster_t > QClusterArray_t
Collection of 3D point clusters (one use case is TPC object representation for track(s) and shower(s)...
double time
assumed time w.r.t. trigger for reconstruction
Algorithm type to match flash hypothesis and reconstructed flash.
double sum() const
returns the sum of &quot;q&quot; from QPoint_t
const ID_t kINVALID_ID
Invalid ID.
process_name opflash particleana ie x
FlashMatch_t()
Default ctor assigns invalid values.
QCluster_t & operator+=(const QCluster_t &rhs)
Struct to represent an energy deposition point in 3D space.
double score
floating point representing the &quot;goodness&quot; (algorithm dependent)
double energy_deposit
Deposited energy total.
const double kINVALID_DOUBLE
Utility: invalid value for double.
double min_x() const
minimum x
double z
Spatial position in [cm].
Algorithm type to filter out TPC objects from matching candidate list.
double TotalPE() const
Total PE calculation.
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
QCluster_t operator+(const QCluster_t &rhs) const
Algorithm type to filter out flash from matching candidate list.
double TotalTruePE() const
Total true PE calculation.
shift
Definition: fcl_checks.sh:26
double g4_time
Interaction G4 time in micro-seconds.
const std::string kStringPrefix[kMSG_TYPE_MAX]
Prefix of message.
std::vector< double > pe_true_v
PE distribution over photo-detectors of MCFlash.
Struct to represent an optical flash.
double max_x() const
maximum x
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
QCluster_t()
Default constructor.
int index_id
MCTrac/MCShower collection index ID of the ancestor.
std::vector< double > pe_v
PE distribution over photo-detectors.
unsigned int num_steps
Number of MIGRAD steps.
Struct to represent the ancestor information for a specific interaction (QCluster) ...
const size_t kINVALID_SIZE
Utility: invalid value for size.
QPoint_t()
Default ctor assigns invalid values.
MCAncestor_t source_type
Ancestor source type.
Collection of charge deposition 3D point (cluster)
QPoint_t tpc_point
estimated &amp; matched 3D flash hypothesis point from TPC information
Algorithm type to prohibit a match between a flash and a cluster.
enum flag for algorithm type count &amp; invalid type
unsigned int duration
Computation time of the match algorithm on this match (ns)
FlashMatch_t(const ID_t &tpc_id_value, const ID_t &flash_id_value, const double &score_value, std::vector< double > &&hypo)
Alternative ctor.
Algorithm type that does not play a role in the framework execution but inherits from BaseAlgorithm...
double length() const
returns the total trajectory length
QPoint_t(double xvalue, double yvalue, double zvalue, double qvalue)
Alternative ctor.
ID_t flash_id
matched Flash ID
Level_t
Verbosity message level.
FlashMatch_t(const ID_t &tpc_id_value, const ID_t &flash_id_value, const double &score_value)
Alternative ctor.
ID_t tpc_id
matched TPC object ID
std::vector< flashmatch::ID_t > IDArray_t
Index collection.
QPoint_t tpc_point_err
error on the estimated point
size_t ID_t
Index used to identify Flash_t/QPointCollection_t uniquely in an event.
std::vector< flashmatch::Flash_t > FlashArray_t
Collection of Flash objects.
Flash-TPC match info.
Flash_t()
Default ctor assigns invalid values.
double dist(const QPoint_t &pt)
distance
std::ostream & operator<<(std::ostream &out, const flashmatch::QCluster_t &obj)
streamer override
std::vector< double > pe_err_v
PE value error.
QCluster_t operator+(const double shift)
double z
Flash position.
ID_t idx
index from original larlite vector
double time
Flash timing, a candidate T0.
double z_err
Flash position error.
void drop(double xmin, double xmax)
drop points outside the x range specified
bool Valid(size_t nopdet=0) const
Check validity.
QCluster_t & operator+=(const double shift)