LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
opdet::FlashUtilities Class Reference

#include "FlashUtilities.h"

Public Member Functions

 FlashUtilities ()
 
float CompareByError (const FlashHypothesis &, const std::vector< float > &, std::vector< float > &)
 
float CompareByFraction (const FlashHypothesis &, const std::vector< float > &, std::vector< float > &)
 
float CompareByFraction (const std::vector< float > &, const std::vector< float > &, std::vector< float > &)
 
void GetPosition (const std::vector< float > &, const std::vector< float > &, float &, float &)
 
void GetPosition (const std::vector< float > &, const std::vector< float > &, double &, double &)
 

Detailed Description

Definition at line 21 of file FlashUtilities.h.

Constructor & Destructor Documentation

opdet::FlashUtilities::FlashUtilities ( )
inline

Definition at line 25 of file FlashUtilities.h.

References CompareByError(), CompareByFraction(), and GetPosition().

25 {}

Member Function Documentation

float opdet::FlashUtilities::CompareByError ( const FlashHypothesis fh,
const std::vector< float > &  compare_vector,
std::vector< float > &  result_vector 
)

Title: FlashUtilities Class Author: Wes Ketchum (wketc.nosp@m.hum@.nosp@m.lanl..nosp@m.gov)

Description: Class that contains utility functions for flash and flash hypotheses: — compare a flash hypothesis to a truth or reco vector — get an extent of a flash (central point, width) These classes should operate using simple objects, and will need other classes/functions to fill those vectors properly.

Definition at line 20 of file FlashUtilities.cxx.

References opdet::FlashHypothesis::GetHypothesisErrorVector(), opdet::FlashHypothesis::GetHypothesisVector(), opdet::FlashHypothesis::GetTotalPEs(), opdet::FlashHypothesis::GetTotalPEsError(), and opdet::FlashHypothesis::GetVectorSize().

Referenced by opdet::FlashHypothesisComparison::FillComparisonInfo(), and FlashUtilities().

23 {
24  if(compare_vector.size()!=fh.GetVectorSize())
25  throw std::runtime_error("ERROR in FlashUtilities Compare: Mismatching vector sizes.");
26 
27  result_vector.resize(fh.GetVectorSize());
28 
29  float result_total = 0;
30 
31  std::vector<float> const& NPEs_Vector(fh.GetHypothesisVector());
32  std::vector<float> const& NPEs_ErrorVector(fh.GetHypothesisErrorVector());
33 
34  for(size_t i=0; i<fh.GetVectorSize(); i++){
35  result_total += compare_vector[i];
36  float diff = NPEs_Vector[i]-compare_vector[i];
37  if( std::abs(diff)<std::numeric_limits<float>::epsilon())
38  result_vector[i]=0;
39  else if(NPEs_ErrorVector[i] < std::numeric_limits<float>::epsilon())
40  result_vector[i] = diff / std::numeric_limits<float>::epsilon();
41  else
42  result_vector[i] = diff / NPEs_ErrorVector[i];
43  }
44 
45  float total_error = fh.GetTotalPEsError();
46  float total_diff = fh.GetTotalPEs() - result_total;
47  if( std::abs(total_diff) < std::numeric_limits<float>::epsilon() )
48  result_total = 0;
49  else if( total_error < std::numeric_limits<float>::epsilon() )
50  result_total = total_diff / std::numeric_limits<float>::epsilon();
51  else
52  result_total = total_diff / total_error;
53 
54  return result_total;
55 }
float opdet::FlashUtilities::CompareByFraction ( const FlashHypothesis fh,
const std::vector< float > &  compare_vector,
std::vector< float > &  result_vector 
)

Definition at line 57 of file FlashUtilities.cxx.

References opdet::FlashHypothesis::GetHypothesisVector().

Referenced by FlashUtilities().

60 {
61  return CompareByFraction(fh.GetHypothesisVector(),compare_vector,result_vector);
62 }
float CompareByFraction(const FlashHypothesis &, const std::vector< float > &, std::vector< float > &)
float opdet::FlashUtilities::CompareByFraction ( const std::vector< float > &  NPEs_Vector,
const std::vector< float > &  compare_vector,
std::vector< float > &  result_vector 
)

Definition at line 64 of file FlashUtilities.cxx.

67 {
68  if(compare_vector.size()!=NPEs_Vector.size())
69  throw std::runtime_error("ERROR in FlashUtilities Compare: Mismatching vector sizes.");
70 
71  result_vector.resize(NPEs_Vector.size());
72 
73  float total_comp = 0;
74  float total_hyp = 0;
75  for(size_t i=0; i<NPEs_Vector.size(); i++){
76  total_comp += compare_vector[i];
77  total_hyp += NPEs_Vector[i];
78  float diff = NPEs_Vector[i]-compare_vector[i];
79  if( std::abs(diff)<std::numeric_limits<float>::epsilon())
80  result_vector[i]=0;
81  else if(compare_vector[i] < std::numeric_limits<float>::epsilon())
82  result_vector[i] = diff / std::numeric_limits<float>::epsilon();
83  else
84  result_vector[i] = diff / compare_vector[i];
85  }
86 
87  float result_total=0.0;
88  float total_diff = total_hyp - total_comp;
89  if( std::abs(total_diff) < std::numeric_limits<float>::epsilon() )
90  result_total = 0;
91  else if( total_comp < std::numeric_limits<float>::epsilon() )
92  result_total = total_diff / std::numeric_limits<float>::epsilon();
93  else
94  result_total = total_diff / total_comp;
95 
96  return result_total;
97 }
void opdet::FlashUtilities::GetPosition ( const std::vector< float > &  pe_vector,
const std::vector< float > &  pos_vector,
float &  mean,
float &  rms 
)

Definition at line 99 of file FlashUtilities.cxx.

References pmtana::mean().

Referenced by opdet::FlashHypothesisComparison::FillFlashHypothesisInfo(), opdet::FlashHypothesisComparison::FillSimPhotonCounterInfo(), FlashUtilities(), and GetPosition().

102 {
103  if(pe_vector.size()!=pos_vector.size())
104  throw std::runtime_error("ERROR in FlashUtilities GetPosition: Mismatchin vector sizes.");
105 
106  float sum = std::accumulate(pe_vector.begin(),pe_vector.end(),0.0);
107 
108  if(sum < std::numeric_limits<float>::epsilon()){
109  mean=0; rms=0; return;
110  }
111 
112  mean = std::inner_product(pe_vector.begin(),pe_vector.end(),pos_vector.begin(),0.0) / sum;
113 
114  rms=0;
115  for(size_t i=0; i<pe_vector.size(); i++)
116  rms += pe_vector[i]*(pos_vector[i] - mean)*(pos_vector[i] - mean);
117 
118  rms = std::sqrt(rms)/sum;
119 }
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:15
void opdet::FlashUtilities::GetPosition ( const std::vector< float > &  pe_vector,
const std::vector< float > &  pos_vector,
double &  mean,
double &  rms 
)

Definition at line 121 of file FlashUtilities.cxx.

References GetPosition().

124 {
125  float fmean,frms;
126  GetPosition(pe_vector,pos_vector,fmean,frms);
127  mean = double(fmean);
128  rms = double(frms);
129 }
void GetPosition(const std::vector< float > &, const std::vector< float > &, float &, float &)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:15

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