All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QWeightPoint.cxx
Go to the documentation of this file.
1 #ifndef OPT0FINDER_QWEIGHTPOINT_CXX
2 #define OPT0FINDER_QWEIGHTPOINT_CXX
3 
4 #include "QWeightPoint.h"
5 
6 namespace flashmatch {
7 
9 
10  QWeightPoint::QWeightPoint(const std::string name)
11  : BaseFlashMatch(name)
12  , _x_step_size ( 0.5 )
13  , _zdiff_max ( 50*50 )
14  {}
15 
17  {
18  _x_step_size = pset.get<double>("XStepSize");
19  _zdiff_max = pset.get<double>("ZDiffMax" );
20  _zdiff_max *= _zdiff_max;
21  }
22 
24  {
25 
26  if(_vis_array.pe_v.empty())
28 
29  // Prepare the return values (Mostly QWeightPoint)
30  FlashMatch_t f;
31  if(pt_v.empty()){
32  std::cout<<"Not enough points!"<<std::endl;
33  return f;
34  }
35 
36  _tpc_qcluster.resize(pt_v.size());
37 
38  // Get min & max x value
39  double x_max = 0;
40  double x_min = 1e12;
41 
42  for(auto const& pt : pt_v) {
43  if(pt.x > x_max) x_max = pt.x;
44  if(pt.x < x_min) x_min = pt.x;
45  }
46 
47  double min_dz = 1e9;
48  for(double x_offset=0; x_offset<(256.35-(x_max-x_min)); x_offset+=_x_step_size) {
49 
50  // Create QCluster_t with this offset
51 
52  for(size_t i=0; i<_tpc_qcluster.size(); ++i) {
53  _tpc_qcluster[i].x = pt_v[i].x + x_offset - x_min;
54  _tpc_qcluster[i].y = pt_v[i].y;
55  _tpc_qcluster[i].z = pt_v[i].z;
56  _tpc_qcluster[i].q = pt_v[i].q;
57  }
58 
60 
61  // Calculate amplitudes corresponding to max opdet amplitudes
62  double vis_pe_sum = _vis_array.TotalPE();
63 
64  double weighted_z = 0;
65  for(size_t pmt_index=0; pmt_index<DetectorSpecs::GetME().NOpDets(); ++pmt_index) {
66 
67  if(_vis_array.pe_v[pmt_index]<0) continue;
68  weighted_z += DetectorSpecs::GetME().PMTPosition(pmt_index)[2] * _vis_array.pe_v[pmt_index] / vis_pe_sum;
69 
70  }
71 
72  double dz = std::fabs(weighted_z - flash.z);
73 
74  if(dz < min_dz) {
75 
76  min_dz = dz;
77 
78  f.score = 1./min_dz;
79  f.tpc_point.x = f.tpc_point.y = 0;
80  f.tpc_point.q = vis_pe_sum;
81 
82  f.tpc_point.x = x_offset;
83 
84  for(size_t pmt_index=0; pmt_index<DetectorSpecs::GetME().NOpDets(); ++pmt_index) {
85  if(_vis_array.pe_v[pmt_index]<0) continue;
86  f.tpc_point.y += DetectorSpecs::GetME().PMTPosition(pmt_index)[1] * _vis_array.pe_v[pmt_index] / vis_pe_sum;
87  }
88 
89  f.tpc_point.z = weighted_z;
90  }
91  }
92 
93  f.hypothesis.clear();
94 
95  FLASH_INFO() << "Best match Hypothesis: "
96  << f.tpc_point.x << " : "
97  << f.tpc_point.y << " : "
98  << f.tpc_point.z << " ... min dist : " << min_dz
99  << std::endl;
100 
101  // If min-diff is bigger than assigned max, return default match (score<0)
102  if( min_dz > _zdiff_max ) {
103  f.tpc_point.x = f.tpc_point.y = f.tpc_point.z = -1;
104  f.tpc_point.q = -1;
105  f.score = -1;
106  return f;
107  }
108 
110  return f;
111 
112  }
113 
114 
115 }
116 #endif
flashmatch::Flash_t _vis_array
Definition: QWeightPoint.h:73
static QWeightPointFactory __global_QWeightPointFactory__
Definition: QWeightPoint.cxx:8
std::vector< double > hypothesis
double _x_step_size
step size in x-direction
Definition: QWeightPoint.h:70
size_t NOpDets() const
of PMTs
Definition: FMWKInterface.h:60
double score
floating point representing the &quot;goodness&quot; (algorithm dependent)
double z
Spatial position in [cm].
double TotalPE() const
Total PE calculation.
#define FLASH_INFO()
Compiler macro for INFO message.
QWeightPoint(const std::string name="QWeightPoint")
Default constructor.
fhicl::ParameterSet Config_t
Configuration object.
Definition: FMWKInterface.h:31
static DetectorSpecs & GetME(std::string filename="detector_specs.cfg")
Definition: FMWKInterface.h:44
Struct to represent an optical flash.
std::vector< double > pe_v
PE distribution over photo-detectors.
Collection of charge deposition 3D point (cluster)
QPoint_t tpc_point
estimated &amp; matched 3D flash hypothesis point from TPC information
Class def header for a class QWeightPoint.
flashmatch::QCluster_t _tpc_qcluster
Definition: QWeightPoint.h:72
void _Configure_(const Config_t &pset)
const geoalgo::Point_t & PMTPosition(size_t opch)
PMT XYZ position filler.
Definition: FMWKInterface.h:51
then echo fcl name
void FillEstimate(const QCluster_t &, Flash_t &) const
Method to simply fill provided reference of flashmatch::Flash_t.
Flash-TPC match info.
FlashMatch_t Match(const QCluster_t &, const Flash_t &)
double z
Flash position.
BEGIN_PROLOG could also be cout
double _zdiff_max
allowed diff in z-direction to be considered as a match
Definition: QWeightPoint.h:71