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::CommonAmps Class Reference

#include <CommonAmps.h>

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

Public Member Functions

 CommonAmps (const std::string name="CommonAmps")
 Default constructor. More...
 
 ~CommonAmps ()
 Default destructor. More...
 
FlashMatch_t Match (const QCluster_t &, const Flash_t &)
 
- 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...
 
virtual void SetTPCCryo (int tpc, int cryo)=0
 Sets the TPC and Cryo numbers. 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

float _percent
 
float _score
 
float _x_step_size
 
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.
The goal of this algorithm is to compare the most prominent pieces of opflash spectra, and spectra produced by photon library given QCluster points. Tpc_point calculated as in QWeightPoint and stored based on the best match amplitudes.

Only works with Photon Library currently

Definition at line 32 of file CommonAmps.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 13 of file CommonAmps.cxx.

15  {
16  _percent = 0.5;
17  _score = 0.8;
18  }
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
flashmatch::CommonAmps::~CommonAmps ( )
inline

Default destructor.

Definition at line 40 of file CommonAmps.h.

40 {}

Member Function Documentation

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

Implements flashmatch::BaseAlgorithm.

Definition at line 20 of file CommonAmps.cxx.

21  {
22  _percent = pset.get<double>("QFracThreshold");
23  _score = pset.get<double>("ScoreThreshold");
24  _x_step_size = pset.get<double>("XStepSize");
25  }
FlashMatch_t flashmatch::CommonAmps::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 27 of file CommonAmps.cxx.

28  {
29 
30  double integral_op = std::accumulate(std::begin(flash.pe_v),
31  std::end(flash.pe_v),
32  0.0);
33  double maxRatio = -1;
34  //double maxX = 0;
35 
36  if(_vis_array.pe_v.empty())
37  _vis_array.pe_v.resize(OpDetXArray().size());
38 
39  // Create multimap to hold the largest amplitudes in the first slots of map
40  // Normalize each PE bin to the total # of PEs-- 1/x to put highest amps in front
41  std::multimap<double,int> ampToOpDet ;
42 
43  for(size_t k=0; k<32; k++)
44  ampToOpDet.emplace(1./(flash.pe_v[k]/integral_op),k);
45 
46 
47  // Now that opdet hits are normalized and ordered, store indices for PMTs which
48  // had the greatest hit amplitudes up to _percent of total PMT hits
49  double opAmpTotal = 0;
50  std::vector<int> ids ;
51  ids.resize(0);
52 
53  for( auto const & e : ampToOpDet ){
54  opAmpTotal += 1/e.first ;
55  ids.push_back(e.second) ;
56  if( opAmpTotal > _percent )
57  break;
58  }
59 
60  // Prepare the return values (Mostly QWeightPoint)
61  FlashMatch_t f;
62  if(pt_v.empty()){
63  std::cout<<"Not enough points!"<<std::endl;
64  return f;
65  }
66 
67  _tpc_qcluster.resize(pt_v.size());
68 
69  // Get min & max x value
70  double x_max = 0;
71  double x_min = 1e12;
72 
73  for(auto const& pt : pt_v) {
74  if(pt.x > x_max) x_max = pt.x;
75  if(pt.x < x_min) x_min = pt.x;
76  }
77 
78  for(double x_offset=0;
79  x_offset<(250.-(x_max-x_min));
80  x_offset+=_x_step_size) {
81 
82  // Create QCluster_t with this offset
83 
84  for(size_t i=0; i<_tpc_qcluster.size(); ++i) {
85  _tpc_qcluster[i].x = pt_v[i].x + x_offset - x_min;
86  _tpc_qcluster[i].y = pt_v[i].y;
87  _tpc_qcluster[i].z = pt_v[i].z;
88  _tpc_qcluster[i].q = pt_v[i].q;
89  }
90 
92 
93  // Calculate amplitudes corresponding to max opdet amplitudes
94  double visAmpTotal = 0;
95  double vis_pe_sum = _vis_array.TotalPE();
96 
97  for(size_t i=0; i<ids.size(); i++) {
98  if(_vis_array.pe_v[ids[i]]<0) continue;
99  visAmpTotal += _vis_array.pe_v[ids[i]] / vis_pe_sum ;
100  }
101 
102  double ratio = 0;
103  if(opAmpTotal > visAmpTotal )
104  ratio = visAmpTotal/opAmpTotal ;
105  else
106  ratio = opAmpTotal/visAmpTotal ;
107 
108  if(ratio > maxRatio) {
109  maxRatio = ratio;
110  //maxX = x_offset;
111 
112  f.score = ratio;
113  f.tpc_point.x = f.tpc_point.y = f.tpc_point.z = 0;
114  f.tpc_point.q = vis_pe_sum;
115 
116  for(size_t pmt_index=0; pmt_index<NOpDets(); ++pmt_index) {
117  double pe = _vis_array.pe_v[pmt_index];
118  if(pe<0) continue;
119  f.tpc_point.x += OpDetX(pmt_index) * pe / vis_pe_sum;
120  f.tpc_point.y += OpDetY(pmt_index) * pe / vis_pe_sum;
121  f.tpc_point.z += OpDetZ(pmt_index) * pe / vis_pe_sum;
122  }
123  }
124  }
125 
126  // If min-diff is bigger than assigned max, return default match (score<0)
127  if( maxRatio < _score ) {
128 
129  f.tpc_point.x = f.tpc_point.y = f.tpc_point.z = -1;
130  f.tpc_point.q = -1;
131  f.score = -1;
132  return f;
133  }
134 
135  f.hypothesis = _vis_array.pe_v;
136  return f;
137  }
double TotalPE() const
Total PE calculation.
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
flashmatch::QCluster_t _tpc_qcluster
Definition: CommonAmps.h:53
std::vector< double > pe_v
PE distribution over photo-detectors.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
flashmatch::Flash_t _vis_array
Definition: CommonAmps.h:54
do i e
void FillEstimate(const QCluster_t &, Flash_t &) const
Method to simply fill provided reference of flashmatch::Flash_t.
pdgs k
Definition: selectors.fcl:22
BEGIN_PROLOG could also be cout

Member Data Documentation

float flashmatch::CommonAmps::_percent
private

Definition at line 50 of file CommonAmps.h.

float flashmatch::CommonAmps::_score
private

Definition at line 51 of file CommonAmps.h.

flashmatch::QCluster_t flashmatch::CommonAmps::_tpc_qcluster
private

Definition at line 53 of file CommonAmps.h.

flashmatch::Flash_t flashmatch::CommonAmps::_vis_array
private

Definition at line 54 of file CommonAmps.h.

float flashmatch::CommonAmps::_x_step_size
private

Definition at line 52 of file CommonAmps.h.


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