Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
detectorfluxanalysis2d_tests.cpp
Go to the documentation of this file.
1/**
2 * @file detectorfluxanalysis2d_tests.cpp
3 * @brief Implements regression and invariant tests for detectorfluxanalysis2d tests.
4 * @ingroup qpe_tests
5 *
6 * Source: @c tests/detectorfluxanalysis2d_tests.cpp. This file is part of Quantum Phenomena Explorer (QPE),
7 * maintained by Officina Turini. See LICENSE_IT.txt / LICENSE.txt for the
8 * QPE freeware source-available terms and THIRD_PARTY_NOTICES.txt for
9 * third-party components.
10 */
11
13
15
16#include <cmath>
17#include <vector>
18
19namespace qpe { namespace tests {
20
21/**
22 * @brief Runs detector flux analysis2 d tests.
23 * @param error Output diagnostic text on failure.
24 */
25bool runDetectorFluxAnalysis2DTests(std::string &error)
26{
27 std::vector<double> profile(9u, 0.0);
28 profile[3] = 1.0;
29 profile[5] = 3.0;
30
31 const std::vector<double> rebinned =
33 if (rebinned.size() != 9u ||
34 std::fabs(rebinned[3] - 0.25) > 1.0e-12 ||
35 std::fabs(rebinned[5] - 0.75) > 1.0e-12) {
36 error = "detector flux profile rebin/normalization failed";
37 return false;
38 }
39
40 std::vector<PositionMeasurement2DPoint> hits;
41 for (int i = 0; i < 25; ++i) {
43 p.x = 8.0f;
44 p.y = -1.0f; // index 3 for dy=1 on 9 samples
45 hits.push_back(p);
46 }
47 for (int i = 0; i < 75; ++i) {
49 p.x = 8.0f;
50 p.y = 1.0f; // index 5
51 hits.push_back(p);
52 }
53
55 DetectorFluxAnalysis2D::analyze(profile, 1.0f, hits, 9u);
56 if (!match.expectedValid || !match.observedValid ||
57 std::fabs(match.totalVariationDistance) > 1.0e-12) {
58 error = "TVD should be zero for a matching arrival ensemble";
59 return false;
60 }
61
62 hits.clear();
63 for (int i = 0; i < 100; ++i) {
65 p.x = 8.0f;
66 p.y = -1.0f;
67 hits.push_back(p);
68 }
69 const DetectorFluxAnalysis2DResult mismatch =
70 DetectorFluxAnalysis2D::analyze(profile, 1.0f, hits, 9u);
71 if (!(mismatch.totalVariationDistance > 0.70 &&
72 mismatch.totalVariationDistance <= 1.0)) {
73 error = "TVD did not detect a strongly mismatched arrival ensemble";
74 return false;
75 }
76
77 error.clear();
78 return true;
79}
80
81} }
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.
Declares regression and invariant tests for detectorfluxanalysis2d tests.
bool runDetectorFluxAnalysis2DTests(std::string &error)
Runs detector flux analysis2 d tests.
Data record containing Detector Flux Analysis2D Result.
Data record containing Position Measurement2D Point.