22 const std::vector<float>& compare_vector,
23 std::vector<float>& result_vector)
26 throw std::runtime_error(
"ERROR in FlashUtilities Compare: Mismatching vector sizes.");
30 float result_total = 0;
36 result_total += compare_vector[i];
37 float diff = NPEs_Vector[i]-compare_vector[i];
38 if(
std::abs(diff)<std::numeric_limits<float>::epsilon())
40 else if(NPEs_ErrorVector[i] < std::numeric_limits<float>::epsilon())
41 result_vector[i] = diff / std::numeric_limits<float>::epsilon();
43 result_vector[i] = diff / NPEs_ErrorVector[i];
48 if(
std::abs(total_diff) < std::numeric_limits<float>::epsilon() )
50 else if( total_error < std::numeric_limits<float>::epsilon() )
51 result_total = total_diff / std::numeric_limits<float>::epsilon();
53 result_total = total_diff / total_error;
59 const std::vector<float>& compare_vector,
60 std::vector<float>& result_vector)
66 const std::vector<float>& compare_vector,
67 std::vector<float>& result_vector)
69 if(compare_vector.size()!=NPEs_Vector.size())
70 throw std::runtime_error(
"ERROR in FlashUtilities Compare: Mismatching vector sizes.");
72 result_vector.resize(NPEs_Vector.size());
76 for(
size_t i=0; i<NPEs_Vector.size(); i++){
77 total_comp += compare_vector[i];
78 total_hyp += NPEs_Vector[i];
79 float diff = NPEs_Vector[i]-compare_vector[i];
80 if(
std::abs(diff)<std::numeric_limits<float>::epsilon())
82 else if(compare_vector[i] < std::numeric_limits<float>::epsilon())
83 result_vector[i] = diff / std::numeric_limits<float>::epsilon();
85 result_vector[i] = diff / compare_vector[i];
88 float result_total=0.0;
89 float total_diff = total_hyp - total_comp;
90 if(
std::abs(total_diff) < std::numeric_limits<float>::epsilon() )
92 else if( total_comp < std::numeric_limits<float>::epsilon() )
93 result_total = total_diff / std::numeric_limits<float>::epsilon();
95 result_total = total_diff / total_comp;
101 const std::vector<float>& pos_vector,
102 float&
mean,
float& rms)
104 if(pe_vector.size()!=pos_vector.size())
105 throw std::runtime_error(
"ERROR in FlashUtilities GetPosition: Mismatchin vector sizes.");
107 float sum = std::accumulate(pe_vector.begin(),pe_vector.end(),0.0);
109 if(sum < std::numeric_limits<float>::epsilon()){
110 mean=0; rms=0;
return;
113 mean = std::inner_product(pe_vector.begin(),pe_vector.end(),pos_vector.begin(),0.0) / sum;
116 for(
size_t i=0; i<pe_vector.size(); i++)
117 rms += pe_vector[i]*(pos_vector[i] - mean)*(pos_vector[i] -
mean);
119 rms = std::sqrt(rms)/sum;
123 const std::vector<float>& pos_vector,
124 double&
mean,
double& rms)
127 GetPosition(pe_vector,pos_vector,fmean,frms);
128 mean = double(fmean);
Class def header for a class FlashHypothesis.
size_t GetVectorSize() const
float GetTotalPEsError() const
std::vector< float > const & GetHypothesisErrorVector() const
float CompareByFraction(const FlashHypothesis &, const std::vector< float > &, std::vector< float > &)
float GetTotalPEs() const
void GetPosition(const std::vector< float > &, const std::vector< float > &, float &, float &)
float CompareByError(const FlashHypothesis &, const std::vector< float > &, std::vector< float > &)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
std::vector< float > const & GetHypothesisVector() const