6 using namespace std::chrono;
13 void MIN_vtx_qll(Int_t &, Double_t *, Double_t &, Double_t *, Int_t);
23 _record = pset.get<
bool>(
"RecordHistory");
24 _normalize = pset.get<
bool>(
"NormalizeHypothesis");
84 for (
size_t i = 0; i < pt_v.size(); ++i) {
85 auto const &pt = pt_v[i];
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;
97 auto res = (res1.score > res2.score ? res1 : res2);
118 double pesum = flash.
TotalPE();
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];
161 weight += _hypothesis.pe_v[pmt_index];
188 if (std::isnan(
_qll) || std::isinf(
_qll)) {
250 for (
size_t pt_index = 0; pt_index <
_raw_trk.size(); ++pt_index) {
256 if (
_raw_trk[pt_index].
q > 1e20)
std::cout <<
"[QLLMatch::ChargeHypothesis] n_original_photons " <<
_raw_trk[pt_index].q << std::endl;
298 double nvalid_pmt = 0;
300 double PEtot_Hyp = 0;
301 for (
auto const &pe : hypothesis.
pe_v)
303 double PEtot_Obs = 0;
304 for (
auto const &pe : measurement.
pe_v)
309 if (measurement.
pe_v.size() != hypothesis.
pe_v.size())
314 for (
size_t pmt_index = 0; pmt_index < hypothesis.
pe_v.size(); ++pmt_index) {
316 O = measurement.
pe_v[pmt_index];
317 H = hypothesis.
pe_v[pmt_index];
340 double arg = TMath::Poisson(O,H);
342 if(arg > 0. && !std::isnan(arg) && !std::isinf(arg)) {
345 if(
_converged)
FLASH_INFO() <<
"PMT "<<pmt_index<<
" O/H " << O <<
" / " << H <<
" LHD "<<arg <<
" -LLHD " << -1 * std::log10(arg) << std::endl;
349 double arg = (H - O * std::log(H));
351 if(
_converged)
FLASH_INFO() <<
"PMT "<<pmt_index<<
" O/H " << O <<
" / " << H <<
" ... -LLHD " << arg << std::endl;
357 if( Error < 1.0 ) Error = 1.0;
372 FLASH_INFO() <<
"Combined LLHD: " <<
_current_llhd <<
" (divided by nvalid_pmt+1 = " << nvalid_pmt+1<<
")"<<std::endl;
420 throw OpT0FinderException(
"Penalty threshold array has a different size than PMT array size!");
424 throw OpT0FinderException(
"Penalty value array has a different size than PMT array size!");
441 for (
auto const &v : pmt.
pe_v)
if (v > max_pe) max_pe = v;
465 FLASH_INFO() <<
"Running Minuit x: " << xmin <<
" => " << xmax
466 <<
" ... initial state x=" <<reco_x <<
" x_err=" << reco_x_err << std::endl;
468 int ierrflag, npari, nparx, istat;
469 double arglist[4], Fmin, Fedm, Errdef;
470 ierrflag = npari = nparx = istat = 0;
476 _minuit_ptr->mnexcm(
"SET STR", arglist, 1, ierrflag);
480 _minuit_ptr->DefineParameter(0,
"X", reco_x, reco_x_err, xmin, xmax);
488 _minuit_ptr->mnexcm(
"MIGRAD", arglist, 2, ierrflag);
498 _minuit_ptr->mnstat(Fmin, Fedm, Errdef, npari, nparx, istat);
530 _minuit_ptr->mnexcm(
"clear", arglist, 0, ierrflag);
void set_verbosity(::flashmatch::msg::Level_t level)
Verbosity level.
std::vector< double > hypothesis
double CallMinuit(const QCluster_t &tpc, const Flash_t &pmt, const bool init_x0=true)
std::vector< double > _minimizer_record_x_v
Minimizer record X values.
const geoalgo::AABox & ActiveVolume() const
Detector active volume.
bool _record
Boolean switch to record minimizer history.
void MIN_vtx_qll(Int_t &, Double_t *, Double_t &, Double_t *, Int_t)
size_t NOpDets() const
of PMTs
double _pe_hypothesis_threshold
std::vector< double > _zpos_v
double score
floating point representing the "goodness" (algorithm dependent)
std::vector< double > _xpos_v
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.
double _normalize
Noramalize hypothesis PE spectrum.
double TotalPE() const
Total PE calculation.
const Flash_t & ChargeHypothesis(const double)
#define FLASH_INFO()
Compiler macro for INFO message.
std::vector< double > _penalty_value_v
int _cryo
The Cryostat number to use.
fhicl::ParameterSet Config_t
Configuration object.
flashmatch::Flash_t _measurement
Flash PE distribution over PMTs.
static DetectorSpecs & GetME(std::string filename="detector_specs.cfg")
Struct to represent an optical flash.
FlashMatch_t PESpectrumMatch(const QCluster_t &pt_v, const Flash_t &flash, const bool init_x0)
flashmatch::QCluster_t _raw_trk
FlashMatch_t OnePMTMatch(const Flash_t &flash)
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
const Flash_t & Measurement() const
double _onepmt_pefrac_threshold
double _reco_x_offset
reconstructed X offset (from wire-plane to min-x point)
double QLL(const flashmatch::Flash_t &, const flashmatch::Flash_t &)
std::vector< double > pe_v
PE distribution over photo-detectors.
unsigned int num_steps
Number of MIGRAD steps.
Class def header for a class QLLMatch.
auto end(FixedBins< T, C > const &) noexcept
Collection of charge deposition 3D point (cluster)
QPoint_t tpc_point
estimated & matched 3D flash hypothesis point from TPC information
std::vector< double > _ypos_v
std::vector< double > _minimizer_record_chi2_v
Minimizer record chi2 value.
double _reco_x_offset_err
reconstructed X offset w/ error
float _construct_hypo_time
Keeps track of the total time spent constructing hypotheses.
double _onepmt_pesum_threshold
static QLLMatch * GetME(std::string name="")
Singleton shared instance getter.
auto begin(FixedBins< T, C > const &) noexcept
double _recox_penalty_threshold
std::vector< double > _minimizer_record_llhd_v
Minimizer record llhd value.
int _tpc
The TPC number to use.
Level_t
Verbosity message level.
flashmatch::QCluster_t _var_trk
#define FLASH_ERROR()
Compiler macro for ERROR message.
static QLLMatchFactory __global_QLLMatchFactory__
size_t NOpDets(int cryostat)
const geoalgo::Point_t & PMTPosition(size_t opch)
PMT XYZ position filler.
double _onepmt_score_threshold
QPoint_t tpc_point_err
error on the estimated point
void _Configure_(const Config_t &pset)
std::vector< double > _penalty_threshold_v
void FillEstimate(const QCluster_t &, Flash_t &) const
Method to simply fill provided reference of flashmatch::Flash_t.
double _recoz_penalty_threshold
QLLMode_t _mode
Minimizer mode.
FlashMatch_t Match(const QCluster_t &, const Flash_t &)
Core function: execute matching.
QLLMatch()
Default ctor throws exception (singleton)
double DriftVelocity() const
Drift velocity.
double _qll
Minimizer return value.
double _pe_observation_threshold
BEGIN_PROLOG could also be cout
void SetTPCCryo(int tpc, int cryo)
Sets the TPC and Cryo numbers.
double _onepmt_xdiff_threshold
double time
Flash timing, a candidate T0.
nanosecond nanoseconds
Alias for common language habits.
void Record(const double x)