24bool normalize(std::vector<double> &values)
27 for (std::size_t i = 0u; i < values.size(); ++i) {
28 if (!std::isfinite(values[i]) || values[i] < 0.0) {
36 const double inv = 1.0 / sum;
37 for (std::size_t i = 0u; i < values.size(); ++i) {
44 std::size_t sampleCount,
47 if (sampleCount <= 1u || bins <= 1u) {
50 const double u =
static_cast<double>(index) /
51 static_cast<double>(sampleCount - 1u);
52 std::size_t bin =
static_cast<std::size_t
>(u *
static_cast<double>(bins));
62 const std::vector<double> &fluxProfile,
65 if (bins == 0u || fluxProfile.empty()) {
66 return std::vector<double>();
69 std::vector<double> result(bins, 0.0);
70 for (std::size_t i = 0u; i < fluxProfile.size(); ++i) {
71 const double v = fluxProfile[i];
72 if (std::isfinite(v) && v > 0.0) {
73 result[profileIndexToBin(i, fluxProfile.size(), bins)] += v;
76 if (!normalize(result)) {
83 const std::vector<double> &fluxProfile,
85 const std::vector<PositionMeasurement2DPoint> &hits,
89 if (bins == 0u || fluxProfile.empty() || !(dy > 0.0f)) {
98 const double yMin = -0.5 *
static_cast<double>(fluxProfile.size() - 1u) *
99 static_cast<double>(dy);
100 const double yMax = 0.5 *
static_cast<double>(fluxProfile.size() - 1u) *
101 static_cast<double>(dy);
102 const double span = yMax - yMin;
104 for (std::size_t i = 0u; i < hits.size(); ++i) {
105 const double y =
static_cast<double>(hits[i].y);
106 if (y < yMin || y > yMax) {
109 double u = (y - yMin) / span;
110 u = std::max(0.0, std::min(1.0, u));
111 std::size_t bin =
static_cast<std::size_t
>(u *
static_cast<double>(bins));
125 double distance = 0.0;
126 for (std::size_t i = 0u; i < bins; ++i) {
static DetectorFluxAnalysis2DResult analyze(const std::vector< double > &fluxProfile, float dy, const std::vector< PositionMeasurement2DPoint > &hits, std::size_t bins)
Performs analyze.
static std::vector< double > rebinNormalizedProfile(const std::vector< double > &fluxProfile, std::size_t bins)
Performs rebin normalized profile.
Declares the detectorfluxanalysis2d physics/numerical component used by QPE experiments.
std::size_t profileIndexToBin(std::size_t index, std::size_t sampleCount, std::size_t bins)
Data record containing Detector Flux Analysis2D Result.
std::vector< double > expectedProbability
double totalVariationDistance
std::vector< double > observedProbability