21 const std::vector<float>& compare_vector,
22 std::vector<float>& result_vector)
25 throw std::runtime_error(
"ERROR in FlashUtilities Compare: Mismatching vector sizes.");
29 float result_total = 0;
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())
39 else if(NPEs_ErrorVector[i] < std::numeric_limits<float>::epsilon())
40 result_vector[i] = diff / std::numeric_limits<float>::epsilon();
42 result_vector[i] = diff / NPEs_ErrorVector[i];
47 if( std::abs(total_diff) < std::numeric_limits<float>::epsilon() )
49 else if( total_error < std::numeric_limits<float>::epsilon() )
50 result_total = total_diff / std::numeric_limits<float>::epsilon();
52 result_total = total_diff / total_error;
58 const std::vector<float>& compare_vector,
59 std::vector<float>& result_vector)
65 const std::vector<float>& compare_vector,
66 std::vector<float>& result_vector)
68 if(compare_vector.size()!=NPEs_Vector.size())
69 throw std::runtime_error(
"ERROR in FlashUtilities Compare: Mismatching vector sizes.");
71 result_vector.resize(NPEs_Vector.size());
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())
81 else if(compare_vector[i] < std::numeric_limits<float>::epsilon())
82 result_vector[i] = diff / std::numeric_limits<float>::epsilon();
84 result_vector[i] = diff / compare_vector[i];
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() )
91 else if( total_comp < std::numeric_limits<float>::epsilon() )
92 result_total = total_diff / std::numeric_limits<float>::epsilon();
94 result_total = total_diff / total_comp;
100 const std::vector<float>& pos_vector,
101 float&
mean,
float& rms)
103 if(pe_vector.size()!=pos_vector.size())
104 throw std::runtime_error(
"ERROR in FlashUtilities GetPosition: Mismatchin vector sizes.");
106 float sum = std::accumulate(pe_vector.begin(),pe_vector.end(),0.0);
108 if(sum < std::numeric_limits<float>::epsilon()){
109 mean=0; rms=0;
return;
112 mean = std::inner_product(pe_vector.begin(),pe_vector.end(),pos_vector.begin(),0.0) / sum;
115 for(
size_t i=0; i<pe_vector.size(); i++)
116 rms += pe_vector[i]*(pos_vector[i] - mean)*(pos_vector[i] -
mean);
118 rms = std::sqrt(rms)/sum;
122 const std::vector<float>& pos_vector,
123 double&
mean,
double& rms)
127 mean = double(fmean);
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