All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QLLMatch.h
Go to the documentation of this file.
1 /**
2  * \file QLLMatch.h
3  *
4  * \ingroup Algorithms
5  *
6  * \brief Class def header for a class QLLMatch
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup Algorithms
12 
13  @{*/
14 #ifndef QLLMATCH_H
15 #define QLLMATCH_H
16 
17 #ifndef USING_LARSOFT
18 #define USING_LARSOFT 1
19 #endif
20 
21 #if USING_LARSOFT == 0
26 #else
31 #endif
32 
33 #include <iostream>
34 #include <cmath>
35 #include <numeric>
36 #include <cassert>
37 #include <chrono>
38 #include <climits>
39 #include <TMath.h>
40 #include <TMinuit.h>
41 
42 
43 namespace flashmatch {
44  /**
45  \class QLLMatch
46  User defined class QLLMatch ... these comments are used to generate
47  doxygen documentation!
48  */
49  class QLLMatch : public BaseFlashMatch {
50 
51  public:
52 
54 
55  private:
56  /// Valid ctor hidden (singleton)
57  QLLMatch(const std::string);
58 
59  public:
60 
61  /// Default ctor throws exception (singleton)
62  QLLMatch();
63 
64  /// Default destructor
66 
67  /// Singleton shared instance getter
68  static QLLMatch* GetME(std::string name="")
69  {
70  if(!_me) _me = new QLLMatch(name);
71  else if(!name.empty() && name != _me->AlgorithmName()) {
72  std::cerr << "QLLMatch instance must be uniquely named. Requested: "
73  << name << " vs. Existing: " << _me->AlgorithmName() << std::endl;
74  throw std::exception();
75  }
76  return _me;
77  }
78 
79  /// Core function: execute matching
80  FlashMatch_t Match(const QCluster_t&, const Flash_t&);
81 
82  const Flash_t& ChargeHypothesis(const double);
83  const Flash_t& Measurement() const;
84 
85  double QLL(const flashmatch::Flash_t&,
86  const flashmatch::Flash_t&);
87 
88  void Record(const double x)
89  {
90  if(_record) {
93  _minimizer_record_x_v.push_back(x);
94  }
95  }
96 
97  void OneStep() {
98  _num_steps = _num_steps + 1;
99  }
100 
101  double CallMinuit(const QCluster_t& tpc,
102  const Flash_t& pmt,
103  const bool init_x0=true);
104 
105  const std::vector<double>& HistoryLLHD() const { return _minimizer_record_llhd_v; }
106  const std::vector<double>& HistoryChi2() const { return _minimizer_record_chi2_v; }
107  const std::vector<double>& HistoryX() const { return _minimizer_record_x_v; }
108 
109  void SetTPCCryo(int tpc, int cryo);
110 
111  protected:
112 
113  void _Configure_(const Config_t &pset);
114 
115  private:
116 
117  FlashMatch_t PESpectrumMatch(const QCluster_t &pt_v, const Flash_t &flash, const bool init_x0);
118 
119  FlashMatch_t OnePMTMatch(const Flash_t &flash);
120 
121  static QLLMatch* _me;
122 
123  QLLMode_t _mode; ///< Minimizer mode
124  bool _record; ///< Boolean switch to record minimizer history
125  double _normalize; ///< Noramalize hypothesis PE spectrum
126 
127  std::vector<double> _penalty_threshold_v;
128  std::vector<double> _penalty_value_v;
131 
136  flashmatch::Flash_t _hypothesis; ///< Hypothesis PE distribution over PMTs
137  flashmatch::Flash_t _measurement; ///< Flash PE distribution over PMTs
138 
141  std::vector<double> _minimizer_record_chi2_v; ///< Minimizer record chi2 value
142  std::vector<double> _minimizer_record_llhd_v; ///< Minimizer record llhd value
143  std::vector<double> _minimizer_record_x_v; ///< Minimizer record X values
144 
145  double _reco_x_offset; ///< reconstructed X offset (from wire-plane to min-x point)
146  double _reco_x_offset_err; ///< reconstructed X offset w/ error
147  double _qll; ///< Minimizer return value
148 
150 
151  TMinuit* _minuit_ptr;
154 
157 
162 
164  std::vector<double> _xpos_v, _ypos_v, _zpos_v;
165 
166  float _construct_hypo_time; ///< Keeps track of the total time spent constructing hypotheses
167 
168  };
169 
170  /**
171  \class flashmatch::QLLMatchFactory
172  */
174  public:
175  /// ctor
177  /// dtor
179  /// creation method
180  BaseFlashMatch* create(const std::string instance_name) { return QLLMatch::GetME(instance_name); }
181  };
182 
183 }
184 
185 #endif
186 /** @} */ // end of doxygen group
QPoint_t _raw_xmin_pt
Definition: QLLMatch.h:133
~QLLMatch()
Default destructor.
Definition: QLLMatch.h:65
double CallMinuit(const QCluster_t &tpc, const Flash_t &pmt, const bool init_x0=true)
Definition: QLLMatch.cxx:409
std::vector< double > _minimizer_record_x_v
Minimizer record X values.
Definition: QLLMatch.h:143
bool _record
Boolean switch to record minimizer history.
Definition: QLLMatch.h:124
process_name opflash particleana ie x
BEGIN_PROLOG could also be cerr
double _pe_hypothesis_threshold
Definition: QLLMatch.h:129
std::vector< double > _zpos_v
Definition: QLLMatch.h:164
Struct to represent an energy deposition point in 3D space.
Abstract base class for factory (to be implemented per flash)
std::vector< double > _xpos_v
Definition: QLLMatch.h:164
static FlashMatchFactory & get()
Static sharable instance getter.
flashmatch::Flash_t _hypothesis
Hypothesis PE distribution over PMTs.
Definition: QLLMatch.h:136
double _normalize
Noramalize hypothesis PE spectrum.
Definition: QLLMatch.h:125
void add_factory(const std::string name, flashmatch::FlashMatchFactoryBase *factory)
Factory registration method (should be called by global factory instance in algorithm header) ...
const Flash_t & ChargeHypothesis(const double)
Definition: QLLMatch.cxx:239
std::vector< double > _penalty_value_v
Definition: QLLMatch.h:128
fhicl::ParameterSet Config_t
Configuration object.
Definition: FMWKInterface.h:31
flashmatch::Flash_t _measurement
Flash PE distribution over PMTs.
Definition: QLLMatch.h:137
const std::vector< double > & HistoryChi2() const
Definition: QLLMatch.h:106
Struct to represent an optical flash.
FlashMatch_t PESpectrumMatch(const QCluster_t &pt_v, const Flash_t &flash, const bool init_x0)
Definition: QLLMatch.cxx:180
flashmatch::QCluster_t _raw_trk
Definition: QLLMatch.h:132
FlashMatch_t OnePMTMatch(const Flash_t &flash)
Definition: QLLMatch.cxx:112
const Flash_t & Measurement() const
Definition: QLLMatch.cxx:291
double _onepmt_pefrac_threshold
Definition: QLLMatch.h:161
const std::string & AlgorithmName() const
Algorithm name.
double _reco_x_offset
reconstructed X offset (from wire-plane to min-x point)
Definition: QLLMatch.h:145
double QLL(const flashmatch::Flash_t &, const flashmatch::Flash_t &)
Definition: QLLMatch.cxx:293
Class def header for a class FlashMatchFactory.
TMinuit * _minuit_ptr
Definition: QLLMatch.h:151
Collection of charge deposition 3D point (cluster)
std::vector< double > _ypos_v
Definition: QLLMatch.h:164
std::vector< double > _minimizer_record_chi2_v
Minimizer record chi2 value.
Definition: QLLMatch.h:141
double _reco_x_offset_err
reconstructed X offset w/ error
Definition: QLLMatch.h:146
float _construct_hypo_time
Keeps track of the total time spent constructing hypotheses.
Definition: QLLMatch.h:166
Class def header for exception classes in OpT0Finder package.
double _onepmt_pesum_threshold
Definition: QLLMatch.h:160
QPoint_t _raw_xmax_pt
Definition: QLLMatch.h:134
static QLLMatch * GetME(std::string name="")
Singleton shared instance getter.
Definition: QLLMatch.h:68
BaseFlashMatch * create(const std::string instance_name)
creation method
Definition: QLLMatch.h:180
double _recox_penalty_threshold
Definition: QLLMatch.h:155
std::vector< double > _minimizer_record_llhd_v
Minimizer record llhd value.
Definition: QLLMatch.h:142
flashmatch::QCluster_t _var_trk
Definition: QLLMatch.h:135
const std::vector< double > & HistoryX() const
Definition: QLLMatch.h:107
static QLLMatch * _me
Definition: QLLMatch.h:121
double _onepmt_score_threshold
Definition: QLLMatch.h:158
double _migrad_tolerance
Definition: QLLMatch.h:152
const std::vector< double > & HistoryLLHD() const
Definition: QLLMatch.h:105
void _Configure_(const Config_t &pset)
Definition: QLLMatch.cxx:22
std::vector< double > _penalty_threshold_v
Definition: QLLMatch.h:127
double _recoz_penalty_threshold
Definition: QLLMatch.h:156
Class def header for a class BaseFlashMatch.
QLLMode_t _mode
Minimizer mode.
Definition: QLLMatch.h:123
Flash-TPC match info.
FlashMatch_t Match(const QCluster_t &, const Flash_t &)
Core function: execute matching.
Definition: QLLMatch.cxx:74
QLLMatch()
Default ctor throws exception (singleton)
Definition: QLLMatch.cxx:19
const std::string & name() const
Name getter, defined in a logger instance attribute.
Definition: LoggerFeature.h:51
double _qll
Minimizer return value.
Definition: QLLMatch.h:147
double _pe_observation_threshold
Definition: QLLMatch.h:130
void SetTPCCryo(int tpc, int cryo)
Sets the TPC and Cryo numbers.
Definition: QLLMatch.cxx:64
double _onepmt_xdiff_threshold
Definition: QLLMatch.h:159
void Record(const double x)
Definition: QLLMatch.h:88