All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QLLMatch.cxx
Go to the documentation of this file.
1 #ifndef QLLMATCH_CXX
2 #define QLLMATCH_CXX
3 
4 #include "QLLMatch.h"
5 
6 using namespace std::chrono;
7 namespace flashmatch {
8 
10 
11  QLLMatch *QLLMatch::_me = nullptr;
12 
13  void MIN_vtx_qll(Int_t &, Double_t *, Double_t &, Double_t *, Int_t);
14 
15  QLLMatch::QLLMatch(const std::string name)
16  : BaseFlashMatch(name), _mode(kChi2), _record(false), _normalize(false), _minuit_ptr(nullptr)
17  { _current_llhd = _current_chi2 = -1.0; }
18 
20  { throw OpT0FinderException("Use QLLMatch::GetME() to obtain singleton pointer!"); }
21 
22  void QLLMatch::_Configure_(const Config_t &pset) {
23  _record = pset.get<bool>("RecordHistory");
24  _normalize = pset.get<bool>("NormalizeHypothesis");
25  _mode = (QLLMode_t)(pset.get<unsigned short>("QLLMode"));
26  _pe_observation_threshold = pset.get<double>("PEObservationThreshold", 0.0);
27  _pe_hypothesis_threshold = pset.get<double>("PEHypothesisThreshold", 0.0);
28  _migrad_tolerance = pset.get<double>("MIGRADTolerance", 0.1);
29 
30  this->set_verbosity((msg::Level_t)(pset.get<unsigned int>("Verbosity", 3)));
31 
32  _penalty_threshold_v = pset.get<std::vector<double> >("PEPenaltyThreshold");
33  _penalty_value_v = pset.get<std::vector<double> >("PEPenaltyValue");
34 
35  _recox_penalty_threshold = pset.get<double>("XPenaltyThreshold");
36  _recoz_penalty_threshold = pset.get<double>("ZPenaltyThreshold");
37 
38  _onepmt_score_threshold = pset.get<double>("OnePMTScoreThreshold");
39  _onepmt_xdiff_threshold = pset.get<double>("OnePMTXDiffThreshold");
40  _onepmt_pesum_threshold = pset.get<double>("OnePMTPESumThreshold");
41  _onepmt_pefrac_threshold = pset.get<double>("OnePMTPEFracThreshold");
42 
43  _xpos_v.resize(DetectorSpecs::GetME().NOpDets(),0.);
44  _ypos_v.resize(DetectorSpecs::GetME().NOpDets(),0.);
45  _zpos_v.resize(DetectorSpecs::GetME().NOpDets(),0.);
46  for(size_t ch=0; ch<DetectorSpecs::GetME().NOpDets(); ++ch) {
47  auto const& pmt_pos = DetectorSpecs::GetME().PMTPosition(ch);
48  _xpos_v[ch] = pmt_pos[0];
49  _ypos_v[ch] = pmt_pos[1];
50  _zpos_v[ch] = pmt_pos[2];
51  }
52  if(_tpc == -1 || _cryo == -1) {
53  auto const& bbox = DetectorSpecs::GetME().ActiveVolume();
54  _vol_xmax = bbox.Max()[0];
55  _vol_xmin = bbox.Min()[0];
56  } else {
57  auto const& bbox = DetectorSpecs::GetME().ActiveVolume(_tpc, _cryo);
58  _vol_xmax = bbox.Max()[0];
59  _vol_xmin = bbox.Min()[0];
60  }
61 
62  }
63 
64  void QLLMatch::SetTPCCryo(int tpc, int cryo) {
65  _tpc = tpc;
66  _cryo = cryo;
67 
68  auto const& bbox = DetectorSpecs::GetME().ActiveVolume(_tpc, _cryo);
69  _vol_xmax = bbox.Max()[0];
70  _vol_xmin = bbox.Min()[0];
71  }
72 
73 
74  FlashMatch_t QLLMatch::Match(const QCluster_t &pt_v, const Flash_t &flash) {
75 
77 
78  //
79  // Prepare TPC
80  //
81  _raw_trk.resize(pt_v.size());
82  double min_x = 1e20;
83  double max_x = -1e20;
84  for (size_t i = 0; i < pt_v.size(); ++i) {
85  auto const &pt = pt_v[i];
86  _raw_trk[i] = pt;
87  if (pt.x < min_x) { min_x = pt.x; _raw_xmin_pt = pt; }
88  if (pt.x > max_x) { max_x = pt.x; _raw_xmax_pt = pt; }
89  }
90  for (auto &pt : _raw_trk) pt.x -= min_x;
91 
92  auto res1 = PESpectrumMatch(pt_v,flash,true);
93  auto res2 = PESpectrumMatch(pt_v,flash,false);
94  FLASH_INFO() << "Using mid-x-init ... maximized 1/param Score=" << res1.score << " @ X=" << res1.tpc_point.x << " [cm]" << std::endl;
95  FLASH_INFO() << "Without mid-x-init ... maximized 1/param Score=" << res2.score << " @ X=" << res2.tpc_point.x << " [cm]" << std::endl;
96 
97  auto res = (res1.score > res2.score ? res1 : res2);
98  /*
99  if(res.score < _onepmt_score_threshold) {
100 
101  FLASH_INFO() << "Resulting score below OnePMTScoreThreshold... calling OnePMTMatch" << std::endl;
102  auto res_onepmt = OnePMTMatch(flash);
103 
104  if(res_onepmt.score >= 0.)
105  return res_onepmt;
106  }
107  */
108  FLASH_INFO() << "Time spent constructing hypotheses: " << _construct_hypo_time << " ns." << std::endl;
109  return res;
110  }
111 
113 
114  FlashMatch_t res;
115  res.score=-1;
116  res.num_steps = 1;
117  // Check if pesum threshold condition is met to use this method
118  double pesum = flash.TotalPE();
119  if(pesum < _onepmt_pesum_threshold) {
120  //std::cout <<"PESumThreshold not met (pesum=" << pesum << ")" << std::endl;
121  return res;
122  }
123 
124  // Check if pe max fraction condition is met to use this method
125  size_t maxpmt = 0;
126  double maxpe = 0.;
127  for(size_t pmt=0; pmt<flash.pe_v.size(); ++pmt) {
128  if(flash.pe_v[pmt] < maxpe) continue;
129  maxpe = flash.pe_v[pmt];
130  maxpmt = pmt;
131  }
132  if(maxpe / pesum < _onepmt_pefrac_threshold) {
133  //std::cout << "PERatioThreshold not met (peratio=" << maxpe/pesum << ")" << std::endl;
134  return res;
135  }
136 
137  // Now see if Flash T0 can be consistent with an assumption MinX @ X=0.
138  double xdiff = fabs(_raw_xmin_pt.x - flash.time * DetectorSpecs::GetME().DriftVelocity());
139  if( xdiff > _onepmt_xdiff_threshold ) {
140  //std::cout << "XDiffThreshold not met (xdiff=" << xdiff << ")" << std::endl;
141  return res;
142  }
143 
144  // Reaching this point means it is an acceptable match
145  _reco_x_offset = 0.;
146  _reco_x_offset_err = std::fabs(_xpos_v.at(maxpmt));
147 
148  // Compute hypothesis with MinX @ X=0 assumption.
149  _hypothesis = flash;
150  FillEstimate(_raw_trk,_hypothesis);
151  res.hypothesis = _hypothesis.pe_v;
152 
153  // Compute TPC point
154  res.tpc_point.x = res.tpc_point.y = res.tpc_point.z = 0;
155  double weight = 0;
156  for (size_t pmt_index = 0; pmt_index < DetectorSpecs::GetME().NOpDets(); ++pmt_index) {
157 
158  res.tpc_point.y += _ypos_v.at(pmt_index) * _hypothesis.pe_v[pmt_index];
159  res.tpc_point.z += _zpos_v.at(pmt_index) * _hypothesis.pe_v[pmt_index];
160 
161  weight += _hypothesis.pe_v[pmt_index];
162  }
163 
164  res.tpc_point.y /= weight;
165  res.tpc_point.z /= weight;
166 
167  res.tpc_point.x = _reco_x_offset;
169 
170  // Use MinX point YZ distance to the max PMT and X0 diff as weight
171  res.score = 1.;
172  // FIXME For now we do not have time distribution, so ignore this weighting
173  //res.score *= 1. / xdiff;
174  res.score *= 1. / (sqrt(pow(_raw_xmin_pt.y - _ypos_v.at(maxpmt),2) + pow(_raw_xmin_pt.z - _zpos_v.at(maxpmt),2)));
175 
176  return res;
177 
178  }
179 
180  FlashMatch_t QLLMatch::PESpectrumMatch(const QCluster_t &pt_v, const Flash_t &flash, const bool init_x0) {
181 
182  this->CallMinuit(pt_v, flash, init_x0);
183  // Shit happens line above in CallMinuit
184 
185  // Estimate position
186  FlashMatch_t res;
187  res.num_steps = _num_steps;
188  if (std::isnan(_qll) || std::isinf(_qll)) {
189  return res;
190  }
191 
192  res.tpc_point.x = res.tpc_point.y = res.tpc_point.z = 0;
193 
194  double weight = 0;
195 
196  for (size_t pmt_index = 0; pmt_index < DetectorSpecs::GetME().NOpDets(); ++pmt_index) {
197 
198  res.tpc_point.y += _ypos_v.at(pmt_index) * _hypothesis.pe_v[pmt_index];
199  res.tpc_point.z += _zpos_v.at(pmt_index) * _hypothesis.pe_v[pmt_index];
200 
201  weight += _hypothesis.pe_v[pmt_index];
202  }
203 
204  res.tpc_point.y /= weight;
205  res.tpc_point.z /= weight;
206 
207  res.tpc_point.x = _reco_x_offset;
209 
211 
212  //
213  // Compute score
214  //
215  if(_mode == kSimpleLLHD)
216  res.score = _qll * -1.;
217  else
218  res.score = 1. / _qll;
219 
220  // Compute X-weighting
221  /*
222  double x0 = _raw_xmin_pt.x - flash.time * DetectorSpecs::GetME().DriftVelocity();
223  if( fabs(_reco_x_offset - x0) > _recox_penalty_threshold )
224  res.score *= 1. / (1. + fabs(_reco_x_offset - x0) - _recox_penalty_threshold);
225  // Compute Z-weighting
226  double z0 = 0;
227  weight = 0;
228  for (size_t pmt_index = 0; pmt_index < DetectorSpecs::GetME().NOpDets(); ++pmt_index) {
229  z0 += _zpos_v.at(pmt_index) * flash.pe_v[pmt_index];
230  weight += flash.pe_v[pmt_index];
231  }
232  z0 /= weight;
233  if( fabs(res.tpc_point.z - z0) > _recoz_penalty_threshold )
234  res.score *= 1. / (1. + fabs(res.tpc_point.z - z0) - _recoz_penalty_threshold);
235  */
236  return res;
237  }
238 
239  const Flash_t &QLLMatch::ChargeHypothesis(const double xoffset) {
240  auto start = high_resolution_clock::now();
241  if (_hypothesis.pe_v.empty()) _hypothesis.pe_v.resize(DetectorSpecs::GetME().NOpDets(), 0.);
242  if (_hypothesis.pe_v.size() != DetectorSpecs::GetME().NOpDets()) {
243  throw OpT0FinderException("Hypothesis vector length != PMT count");
244  }
245 
246  for (auto &v : _hypothesis.pe_v) v = 0;
247 
248  // Apply xoffset
249  _var_trk.resize(_raw_trk.size());
250  for (size_t pt_index = 0; pt_index < _raw_trk.size(); ++pt_index) {
251  //std::cout << "x point : " << _raw_trk[pt_index].x << "\t offset : " << xoffset << std::endl;
252  _var_trk[pt_index].x = _raw_trk[pt_index].x + xoffset;
253  _var_trk[pt_index].y = _raw_trk[pt_index].y;
254  _var_trk[pt_index].z = _raw_trk[pt_index].z;
255  _var_trk[pt_index].q = _raw_trk[pt_index].q;
256  if (_raw_trk[pt_index].q > 1e20) std::cout << "[QLLMatch::ChargeHypothesis] n_original_photons " << _raw_trk[pt_index].q << std::endl;
257  }
258  //auto end = high_resolution_clock::now();
259  //auto duration = duration_cast<microseconds>(end - start);
260  //std::cout << "Duration ChargeHypothesis 1 = " << duration.count() << "us" << std::endl;
261 
262 
263  //start = high_resolution_clock::now();
264  // for ( size_t ipt = 0; ipt < trk.size(); ++ipt) {
265  // double n_original_photons = pt.q;
266  // if (n_original_photons > 1e20) std::cout << "n_original_photons " << n_original_photons << std::endl;
267  // }
269  // std::cout << "hypo pe: ";
270  // for (auto &v : _hypothesis.pe_v) std::cout << v << " ";
271  // std::cout << std::endl;;
272  //end = high_resolution_clock::now();
273  //duration = duration_cast<microseconds>(end - start);
274  //std::cout << "Duration ChargeHypothesis 2 = " << duration.count() << "us" << std::endl;
275 
276  //start = high_resolution_clock::now();
277  if (_normalize) {
278  double qsum = std::accumulate(std::begin(_hypothesis.pe_v),
280  0.0);
281  for (auto &v : _hypothesis.pe_v) v /= qsum;
282  }
284  auto duration = duration_cast<nanoseconds>(end - start);
285  _construct_hypo_time += duration.count();
286  //std::cout << "Duration ChargeHypothesis 3 = " << duration.count() << "us" << std::endl;
287 
288  return _hypothesis;
289  }
290 
291  const Flash_t &QLLMatch::Measurement() const { return _measurement; }
292 
293  double QLLMatch::QLL(const Flash_t &hypothesis,
294  const Flash_t &measurement) {
295 
296  // std::cout << "[QLLMatch] _mode " << _mode << std::endl;
297 
298  double nvalid_pmt = 0;
299 
300  double PEtot_Hyp = 0;
301  for (auto const &pe : hypothesis.pe_v)
302  PEtot_Hyp += pe;
303  double PEtot_Obs = 0;
304  for (auto const &pe : measurement.pe_v)
305  PEtot_Obs += pe;
306 
308 
309  if (measurement.pe_v.size() != hypothesis.pe_v.size())
310  throw OpT0FinderException("Cannot compute QLL for unmatched length!");
311 
312  double O, H, Error;
313 
314  for (size_t pmt_index = 0; pmt_index < hypothesis.pe_v.size(); ++pmt_index) {
315 
316  O = measurement.pe_v[pmt_index]; // observation
317  H = hypothesis.pe_v[pmt_index]; // hypothesis
318 
319  if( H < 0 ) throw OpT0FinderException("Cannot have hypothesis value < 0!");
320 
321  if(O < 0) {
322  if (!_penalty_value_v.empty()) {
323  O = _penalty_value_v[pmt_index];
324  }
325  else {
327  }
328  }
329  if (H <= _pe_hypothesis_threshold) {
330  if(!_penalty_threshold_v.empty()) {
331  H = _penalty_threshold_v[pmt_index];
332  }
333  else {
335  }
336  }
337 
338  if(_mode == kLLHD) {
339 
340  double arg = TMath::Poisson(O,H);
341  // std::cout << "[QLLMatch] pmt_index " << pmt_index << " - O: " << O << ", H: " << H << ", arg: " << arg << std::endl;
342  if(arg > 0. && !std::isnan(arg) && !std::isinf(arg)) {
343  _current_llhd -= std::log10(arg);
344  nvalid_pmt += 1;
345  if(_converged) FLASH_INFO() <<"PMT "<<pmt_index<<" O/H " << O << " / " << H << " LHD "<<arg << " -LLHD " << -1 * std::log10(arg) << std::endl;
346  }
347  } else if (_mode == kSimpleLLHD) {
348 
349  double arg = (H - O * std::log(H));
350  _current_llhd += arg;
351  if(_converged) FLASH_INFO() <<"PMT "<<pmt_index<<" O/H " << O << " / " << H << " ... -LLHD " << arg << std::endl;
352  //nvalid_pmt += 1;
353 
354  } else if (_mode == kChi2) {
355 
356  Error = O;
357  if( Error < 1.0 ) Error = 1.0;
358  _current_chi2 += std::pow((O - H), 2) / (Error);
359  nvalid_pmt += 1;
360 
361  } else {
362  FLASH_ERROR() << "Unexpected mode" << std::endl;
363  throw OpT0FinderException();
364  }
365 
366  }
367  //FLASH_DEBUG() <<"Mode " << (int)(_mode) << " Chi2 " << _current_chi2 << " LLHD " << _current_llhd << " nvalid " << nvalid_pmt << std::endl;
368 
369  _current_chi2 /= nvalid_pmt;
370  _current_llhd /= (nvalid_pmt +1);
371  if(_converged)
372  FLASH_INFO() << "Combined LLHD: " << _current_llhd << " (divided by nvalid_pmt+1 = " << nvalid_pmt+1<<")"<<std::endl;
373 
374  return (_mode == kChi2 ? _current_chi2 : _current_llhd);
375  }
376 
377  void MIN_vtx_qll(Int_t & /*Npar*/, // Number of parameters
378  Double_t * /*Grad*/, // Partial derivatives (return values)
379  Double_t &Fval, // Function value (return value)
380  Double_t *Xval, // Parameter values
381  Int_t) /*Flag*/{ // flag word
382  //std::cout << "minuit offset : " << Fval << std::endl;
383  //std::cout << "minuit Xval?? : " << *Xval << std::endl;
384 
385  //auto start = high_resolution_clock::now();
386  auto const &hypothesis = QLLMatch::GetME()->ChargeHypothesis(*Xval);
387  //auto end = high_resolution_clock::now();
388  //auto duration = duration_cast<microseconds>(end - start);
389  //std::cout << "Duration ChargeHypothesis = " << duration.count() << "us" << std::endl;
390 
391  //start = high_resolution_clock::now();
392  auto const &measurement = QLLMatch::GetME()->Measurement();
393  //end = high_resolution_clock::now();
394  //duration = duration_cast<microseconds>(end - start);
395  //std::cout << "Duration Measurement = " << duration.count() << "us" << std::endl;
396 
397  //start = high_resolution_clock::now();
398  Fval = QLLMatch::GetME()->QLL(hypothesis, measurement);
399  //end = high_resolution_clock::now();
400  //duration = duration_cast<microseconds>(end - start);
401  //std::cout << "Duration QLL = " << duration.count() << "us" << std::endl;
402 
403  QLLMatch::GetME()->Record(Xval[0]);
405 
406  return;
407  }
408 
409  double QLLMatch::CallMinuit(const QCluster_t &tpc, const Flash_t &pmt, const bool init_x0) {
410 
411  if (_measurement.pe_v.empty()) {
413  }
414  if (_measurement.pe_v.size() != pmt.pe_v.size()) {
415  std::cout << _measurement.pe_v.size() << " " << pmt.pe_v.size() << std::endl;
416  throw OpT0FinderException("PMT dimension has changed!");
417  }
418 
419  if (!_penalty_threshold_v.empty() && _penalty_threshold_v.size() != pmt.pe_v.size()) {
420  throw OpT0FinderException("Penalty threshold array has a different size than PMT array size!");
421  }
422 
423  if (!_penalty_value_v.empty() && _penalty_value_v.size() != pmt.pe_v.size()) {
424  throw OpT0FinderException("Penalty value array has a different size than PMT array size!");
425  }
426 
427  _converged = false;
428 
429  //
430  // Prepare PMT
431  //
432  double max_pe = 1.;
433 
434  // Debug: Print out expected PE spectrum
435  //for(size_t i=0; i<pmt.pe_v.size(); ++i) {
436  //std::cout << "PE meas: " << i << " " << pmt.pe_v[i] << std::endl;
437  //}
438 
439  if (_normalize) {
440  max_pe = 0;
441  for (auto const &v : pmt.pe_v) if (v > max_pe) max_pe = v;
442  }
443 
444  for (size_t i = 0; i < pmt.pe_v.size(); ++i) _measurement.pe_v[i] = pmt.pe_v[i] / max_pe;
445 
446  _minimizer_record_chi2_v.clear();
447  _minimizer_record_llhd_v.clear();
448  _minimizer_record_x_v.clear();
449  _num_steps = 0;
450 
451  if (!_minuit_ptr) _minuit_ptr = new TMinuit(4);
452 
453  double reco_x = _vol_xmin + 10;
454  if (!init_x0) {
455  //reco_x = ((_vol_xmax - _vol_xmin) - (_raw_xmax_pt.x - _raw_xmin_pt.x)) / 2. + _vol_xmin;
456  // Assume this is the right flash... then
458  if(reco_x < _vol_xmin || (reco_x + _raw_xmax_pt.x - _raw_xmin_pt.x) > _vol_xmax)
459  return kINVALID_DOUBLE;
460  }
461  double reco_x_err = ((_vol_xmax - _vol_xmin) - (_raw_xmax_pt.x - _raw_xmin_pt.x)) / 2.;
462  double xmin = _vol_xmin;
463  double xmax = (_vol_xmax - _vol_xmin) - (_raw_xmax_pt.x - _raw_xmin_pt.x) + _vol_xmin;
464 
465  FLASH_INFO() << "Running Minuit x: " << xmin << " => " << xmax
466  << " ... initial state x=" <<reco_x <<" x_err=" << reco_x_err << std::endl;
467  double MinFval;
468  int ierrflag, npari, nparx, istat;
469  double arglist[4], Fmin, Fedm, Errdef;
470  ierrflag = npari = nparx = istat = 0;
471 
472  assert(this == QLLMatch::GetME());
473 
474  _minuit_ptr->SetPrintLevel(-1);
475  arglist[0] = 2.0; // set strategy level
476  _minuit_ptr->mnexcm("SET STR", arglist, 1, ierrflag);
477 
478  _minuit_ptr->SetFCN(MIN_vtx_qll);
479 
480  _minuit_ptr->DefineParameter(0, "X", reco_x, reco_x_err, xmin, xmax);
481 
482  _minuit_ptr->Command("SET NOW");
483 
484  // use Migrad minimizer
485 
486  arglist[0] = 5000; // maxcalls
487  arglist[1] = _migrad_tolerance; // tolerance*1e-3 = convergence condition
488  _minuit_ptr->mnexcm("MIGRAD", arglist, 2, ierrflag);
489 
490  _converged = true;
491 
492  //arglist[0] = 5.0e+2;
493  //arglist[1] = 1.0e-6;
494  //_minuit_ptr->mnexcm ("simplex",arglist,2,ierrflag);
495 
496  _minuit_ptr->GetParameter(0, reco_x, reco_x_err);
497 
498  _minuit_ptr->mnstat(Fmin, Fedm, Errdef, npari, nparx, istat);
499 
500  // use this for debugging, maybe uncomment the actual minimzing function (MIGRAD / simplex calls)
501  // scanning the parameter set
502  //arglist[0] = 0; // Parameter No (in our case x is the only and therefore the 0th parameter)
503  //arglist[1] = 500; // Number of points
504  //arglist[2] = 0; // Start point of scan
505  //arglist[3] = 256; // End point of scan
506  //_minuit_ptr->mnexcm("scan", arglist,4, ierrflag);
507 
508  MinFval = Fmin;
509  double *grad = 0;
510  int nPar = 1;
511  double fValue[1];
512  fValue[0] = reco_x;
513  // Transfer the minimization variables:
514  MIN_vtx_qll(nPar, grad, Fmin, fValue, ierrflag);
515 
516  //static bool show = true;
517  /*
518  if(show){
519  if(Fmin!=MinFval)std::cout<<"Fmin "<<Fmin<<" not equall to "<<MinFval<<std::endl;
520  show=false;
521  }
522  */
523 
524  // Transfer the minimization variables:
525  _reco_x_offset = reco_x;
526  _reco_x_offset_err = reco_x_err;
527  _qll = MinFval;
528 
529  // Clear:
530  _minuit_ptr->mnexcm("clear", arglist, 0, ierrflag);
531 
532  if (_minuit_ptr) delete _minuit_ptr;
533  _minuit_ptr = 0;
534 
535  return _qll;
536  }
537 
538 }
539 #endif
QPoint_t _raw_xmin_pt
Definition: QLLMatch.h:133
void set_verbosity(::flashmatch::msg::Level_t level)
Verbosity level.
Definition: LoggerFeature.h:47
std::vector< double > hypothesis
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
const geoalgo::AABox & ActiveVolume() const
Detector active volume.
Definition: FMWKInterface.h:54
bool _record
Boolean switch to record minimizer history.
Definition: QLLMatch.h:124
void MIN_vtx_qll(Int_t &, Double_t *, Double_t &, Double_t *, Int_t)
Definition: QLLMatch.cxx:377
size_t NOpDets() const
of PMTs
Definition: FMWKInterface.h:60
double _pe_hypothesis_threshold
Definition: QLLMatch.h:129
std::vector< double > _zpos_v
Definition: QLLMatch.h:164
double score
floating point representing the &quot;goodness&quot; (algorithm dependent)
std::vector< double > _xpos_v
Definition: QLLMatch.h:164
const double kINVALID_DOUBLE
Utility: invalid value for double.
BEGIN_PROLOG MCQCluster QLLMatch
double z
Spatial position in [cm].
flashmatch::Flash_t _hypothesis
Hypothesis PE distribution over PMTs.
Definition: QLLMatch.h:136
double _normalize
Noramalize hypothesis PE spectrum.
Definition: QLLMatch.h:125
double TotalPE() const
Total PE calculation.
const Flash_t & ChargeHypothesis(const double)
Definition: QLLMatch.cxx:239
#define FLASH_INFO()
Compiler macro for INFO message.
std::vector< double > _penalty_value_v
Definition: QLLMatch.h:128
int _cryo
The Cryostat number to use.
fhicl::ParameterSet Config_t
Configuration object.
Definition: FMWKInterface.h:31
flashmatch::Flash_t _measurement
Flash PE distribution over PMTs.
Definition: QLLMatch.h:137
static DetectorSpecs & GetME(std::string filename="detector_specs.cfg")
Definition: FMWKInterface.h:44
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
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
const Flash_t & Measurement() const
Definition: QLLMatch.cxx:291
double _onepmt_pefrac_threshold
Definition: QLLMatch.h:161
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
std::vector< double > pe_v
PE distribution over photo-detectors.
unsigned int num_steps
Number of MIGRAD steps.
TMinuit * _minuit_ptr
Definition: QLLMatch.h:151
Class def header for a class QLLMatch.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
Collection of charge deposition 3D point (cluster)
QPoint_t tpc_point
estimated &amp; matched 3D flash hypothesis point from TPC information
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
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
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
double _recox_penalty_threshold
Definition: QLLMatch.h:155
std::vector< double > _minimizer_record_llhd_v
Minimizer record llhd value.
Definition: QLLMatch.h:142
int _tpc
The TPC number to use.
Level_t
Verbosity message level.
flashmatch::QCluster_t _var_trk
Definition: QLLMatch.h:135
#define FLASH_ERROR()
Compiler macro for ERROR message.
static QLLMatchFactory __global_QLLMatchFactory__
Definition: QLLMatch.cxx:9
const geoalgo::Point_t & PMTPosition(size_t opch)
PMT XYZ position filler.
Definition: FMWKInterface.h:51
double _onepmt_score_threshold
Definition: QLLMatch.h:158
QPoint_t tpc_point_err
error on the estimated point
double _migrad_tolerance
Definition: QLLMatch.h:152
then echo fcl name
void _Configure_(const Config_t &pset)
Definition: QLLMatch.cxx:22
std::vector< double > _penalty_threshold_v
Definition: QLLMatch.h:127
void FillEstimate(const QCluster_t &, Flash_t &) const
Method to simply fill provided reference of flashmatch::Flash_t.
double _recoz_penalty_threshold
Definition: QLLMatch.h:156
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
double DriftVelocity() const
Drift velocity.
Definition: FMWKInterface.h:63
double _qll
Minimizer return value.
Definition: QLLMatch.h:147
double _pe_observation_threshold
Definition: QLLMatch.h:130
BEGIN_PROLOG could also be cout
void SetTPCCryo(int tpc, int cryo)
Sets the TPC and Cryo numbers.
Definition: QLLMatch.cxx:64
double _onepmt_xdiff_threshold
Definition: QLLMatch.h:159
double time
Flash timing, a candidate T0.
nanosecond nanoseconds
Alias for common language habits.
Definition: spacetime.h:139
void Record(const double x)
Definition: QLLMatch.h:88