All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
flashmatch::QWeightPoint Class Reference

#include <QWeightPoint.h>

Inheritance diagram for flashmatch::QWeightPoint:
flashmatch::BaseFlashMatch flashmatch::BaseAlgorithm flashmatch::LoggerFeature

Public Member Functions

 QWeightPoint (const std::string name="QWeightPoint")
 Default constructor. More...
 
 ~QWeightPoint ()
 Default destructor. More...
 
FlashMatch_t Match (const QCluster_t &, const Flash_t &)
 
void SetTPCCryo (int tpc, int cryo)
 Sets the TPC and Cryo numbers. More...
 
- Public Member Functions inherited from flashmatch::BaseFlashMatch
 BaseFlashMatch (const std::string name="noname")
 Default constructor. More...
 
virtual ~BaseFlashMatch ()
 Default destructor. More...
 
Flash_t GetEstimate (const QCluster_t &) const
 Method to call flash hypothesis. More...
 
void FillEstimate (const QCluster_t &, Flash_t &) const
 Method to simply fill provided reference of flashmatch::Flash_t. More...
 
- Public Member Functions inherited from flashmatch::BaseAlgorithm
 BaseAlgorithm (const Algorithm_t type, const std::string name)
 Default constructor. More...
 
 ~BaseAlgorithm ()
 Default destructor. More...
 
void Configure (const Config_t &pset)
 Function to accept configuration. More...
 
Algorithm_t AlgorithmType () const
 Algorithm type. More...
 
const std::string & AlgorithmName () const
 Algorithm name. More...
 
- Public Member Functions inherited from flashmatch::LoggerFeature
 LoggerFeature (const std::string logger_name="LoggerFeature")
 Default constructor. More...
 
 LoggerFeature (const LoggerFeature &original)
 Default copy constructor. More...
 
virtual ~LoggerFeature ()
 Default destructor. More...
 
const flashmatch::loggerlogger () const
 Logger getter. More...
 
void set_verbosity (::flashmatch::msg::Level_t level)
 Verbosity level. More...
 
const std::string & name () const
 Name getter, defined in a logger instance attribute. More...
 

Protected Member Functions

void _Configure_ (const Config_t &pset)
 

Private Attributes

double _x_step_size
 step size in x-direction More...
 
double _zdiff_max
 allowed diff in z-direction to be considered as a match More...
 
flashmatch::QCluster_t _tpc_qcluster
 
flashmatch::Flash_t _vis_array
 

Additional Inherited Members

- Protected Attributes inherited from flashmatch::BaseFlashMatch
int _tpc = 0
 The TPC number to use. More...
 
int _cryo = 0
 The Cryostat number to use. More...
 

Detailed Description

Implementation of flashmatch::BaseFlashHypothesis algorithm class.
Given a TPC object (flashmatch::QCluster_t), it calcultes a list of flash hypothesis
points based on charge deposition and its geometrical position. Each energy deposition
point is weighted by its charge and inverse-squared-x position. As the absolute
x-position is not known by a TPC object, it uses a relative position for each point
w.r.t. the closest point to the wire plane (x=0). The algorithm then assigns an overall
absolute x-position offset in a successive step of _x_step_size value, assigned by a user,
to compute possible flash hypothesis points.

Definition at line 51 of file QWeightPoint.h.

Constructor & Destructor Documentation

flashmatch::QWeightPoint::QWeightPoint ( const std::string  name = "QWeightPoint")

Default constructor.

Definition at line 10 of file QWeightPoint.cxx.

12  , _x_step_size ( 0.5 )
13  , _zdiff_max ( 50*50 )
14  {}
double _x_step_size
step size in x-direction
Definition: QWeightPoint.h:70
BaseFlashMatch(const std::string name="noname")
Default constructor.
const std::string & name() const
Name getter, defined in a logger instance attribute.
Definition: LoggerFeature.h:51
double _zdiff_max
allowed diff in z-direction to be considered as a match
Definition: QWeightPoint.h:71
flashmatch::QWeightPoint::~QWeightPoint ( )
inline

Default destructor.

Definition at line 59 of file QWeightPoint.h.

59 {}

Member Function Documentation

void flashmatch::QWeightPoint::_Configure_ ( const Config_t pset)
protectedvirtual

Implements flashmatch::BaseAlgorithm.

Definition at line 16 of file QWeightPoint.cxx.

17  {
18  _x_step_size = pset.get<double>("XStepSize");
19  _zdiff_max = pset.get<double>("ZDiffMax" );
20  _zdiff_max *= _zdiff_max;
21  }
double _x_step_size
step size in x-direction
Definition: QWeightPoint.h:70
double _zdiff_max
allowed diff in z-direction to be considered as a match
Definition: QWeightPoint.h:71
FlashMatch_t flashmatch::QWeightPoint::Match ( const QCluster_t ,
const Flash_t  
)
virtual

CORE FUNCTION: takes in flashmatch::QCluster_t (TPC object) and flashmatch::Flash_t (flash)
and inspect if two are consistent (i.t. matched) or not. Returns flashmatch::FlashMatch_t
which represents the compatibility of two inputs. In particular the algorithm needs to
set the "score" and "QPoint_t" of the return object. The former represents the goodness
of a match with a value larger than 0. Negative value is interpreted as no match.
The latter represents the matched TPC 3D point. The "tpc_id and "flash_id" of the return
object is set by flashmatch::FlashMatchManager, the caller of the algorithm, as it manages
the overall collection of user input flash and TPC objects.

Note it is flashmatch::FlashMatchManager configuration option to allow an assignment of the
same flash to multiple TPC object or not. If not allowed, a match with a higher "score"
in the return object is chosen.

Implements flashmatch::BaseFlashMatch.

Definition at line 23 of file QWeightPoint.cxx.

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 
109  f.hypothesis = _vis_array.pe_v;
110  return f;
111 
112  }
flashmatch::Flash_t _vis_array
Definition: QWeightPoint.h:73
double _x_step_size
step size in x-direction
Definition: QWeightPoint.h:70
size_t NOpDets() const
of PMTs
Definition: FMWKInterface.h:60
double TotalPE() const
Total PE calculation.
#define FLASH_INFO()
Compiler macro for INFO message.
static DetectorSpecs & GetME(std::string filename="detector_specs.cfg")
Definition: FMWKInterface.h:44
std::vector< double > pe_v
PE distribution over photo-detectors.
flashmatch::QCluster_t _tpc_qcluster
Definition: QWeightPoint.h:72
const geoalgo::Point_t & PMTPosition(size_t opch)
PMT XYZ position filler.
Definition: FMWKInterface.h:51
void FillEstimate(const QCluster_t &, Flash_t &) const
Method to simply fill provided reference of flashmatch::Flash_t.
BEGIN_PROLOG could also be cout
double _zdiff_max
allowed diff in z-direction to be considered as a match
Definition: QWeightPoint.h:71
void flashmatch::QWeightPoint::SetTPCCryo ( int  tpc,
int  cryo 
)
inlinevirtual

Sets the TPC and Cryo numbers.

Implements flashmatch::BaseFlashMatch.

Definition at line 63 of file QWeightPoint.h.

63 {};

Member Data Documentation

flashmatch::QCluster_t flashmatch::QWeightPoint::_tpc_qcluster
private

Definition at line 72 of file QWeightPoint.h.

flashmatch::Flash_t flashmatch::QWeightPoint::_vis_array
private

Definition at line 73 of file QWeightPoint.h.

double flashmatch::QWeightPoint::_x_step_size
private

step size in x-direction

Definition at line 70 of file QWeightPoint.h.

double flashmatch::QWeightPoint::_zdiff_max
private

allowed diff in z-direction to be considered as a match

Definition at line 71 of file QWeightPoint.h.


The documentation for this class was generated from the following files: