14 #include "ThirdParty/parallelstl/include/pstl/algorithm" 15 #include "ThirdParty/parallelstl/include/pstl/execution" 23 operator double()
const {
return sum; }
32 double t = accumulation.
sum + y;
38 std::pair<double, double>
42 std::accumulate(phspsample.
Weights.begin(), phspsample.
Weights.end(),
45 std::vector<double> Intensities = intensity.
evaluate(phspsample.
Data);
47 pstl::execution::par_unseq, Intensities.begin(), Intensities.end(),
48 phspsample.
Weights.begin(), Intensities.begin(),
49 [](
double intensity,
double weight) {
return intensity * weight; });
51 auto IntensitySum = std::accumulate(Intensities.begin(), Intensities.end(),
53 double AvgInt = IntensitySum / WeightSum;
54 double Integral = AvgInt * phspVolume;
57 std::transform(pstl::execution::par_unseq, Intensities.begin(),
58 Intensities.end(), Intensities.begin(),
59 [&AvgInt](
double intensity) {
60 return (intensity - AvgInt) * (intensity - AvgInt);
62 auto IntensityResidualsSum = std::accumulate(
64 double AvgIntResSq = IntensityResidualsSum / (WeightSum - 1);
65 double IntegralErrorSq = AvgIntResSq * phspVolume * phspVolume / WeightSum;
67 return std::make_pair(Integral, std::sqrt(IntegralErrorSq));
78 LOG(DEBUG) <<
"Tools::Maximum(): Maximum can not be determined since " 83 std::vector<double> Intensities = intensity.
evaluate(sample.
Data);
85 std::transform(Intensities.begin(), Intensities.end(), sample.
Weights.begin(),
86 Intensities.begin(), [](
double Intensity,
double Weight) {
87 return Intensity * Weight;
90 double max(*std::max_element(Intensities.begin(), Intensities.end()));
91 LOG(INFO) <<
"Tools::Maximum(): found maximum value of " << max;
std::vector< double > Weights
virtual OutputType evaluate(const InputTypes &... args) noexcept=0
Function< std::vector< double >, DataMap > Intensity
An Intensity is just a Function that takes a list of data vectors and returns a list of intensities (...
Interface template for a general Function of the form OutputType Function(InputTypes) The concept clo...