File indexing completed on 2025-01-18 09:13:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <boost/test/unit_test.hpp>
0012
0013 #include "Acts/Geometry/Extent.hpp"
0014 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0015 #include "Acts/Utilities/BinUtility.hpp"
0016 #include "Acts/Utilities/BinningData.hpp"
0017
0018 #include <iostream>
0019
0020 namespace Acts {
0021
0022
0023
0024
0025
0026
0027
0028
0029 inline static bool isEqual(const BinningData& ba, const BinningData& bb,
0030 float tolerance) {
0031 bool equalBool = (ba.type == bb.type) && (ba.option == bb.option) &&
0032 (ba.binvalue == bb.binvalue) && (ba.zdim == bb.zdim) &&
0033 (ba.subBinningAdditive == bb.subBinningAdditive);
0034
0035 BOOST_CHECK(equalBool);
0036 bool equalRange = (std::abs(ba.min - bb.min) < tolerance) &&
0037 (std::abs(ba.max - bb.max) < tolerance) &&
0038 (std::abs(ba.step - bb.step) < tolerance);
0039
0040 BOOST_CHECK(equalRange);
0041 bool euqalStructure =
0042 (ba.subBinningData != nullptr)
0043 ? isEqual(*ba.subBinningData, *bb.subBinningData, tolerance)
0044 : (bb.subBinningData == nullptr);
0045
0046 BOOST_CHECK(euqalStructure);
0047
0048 bool equalBoundaries = (ba.boundaries().size() == bb.boundaries().size());
0049 if (equalBoundaries) {
0050 for (std::size_t ib = 0; ib < ba.boundaries().size(); ++ib) {
0051 equalBoundaries =
0052 (std::abs(ba.boundaries()[ib] - bb.boundaries()[ib]) < tolerance);
0053 if (!equalBoundaries) {
0054 break;
0055 }
0056 }
0057 }
0058 BOOST_CHECK(equalBoundaries);
0059
0060 return equalBool && equalRange && euqalStructure;
0061 }
0062
0063
0064
0065
0066
0067
0068
0069
0070 inline static bool isEqual(const BinUtility& ba, const BinUtility& bb,
0071 float tolerance) {
0072 bool equal = (ba.binningData().size() == bb.binningData().size());
0073 BOOST_CHECK(equal);
0074 if (equal) {
0075 for (std::size_t ib = 0; ib < ba.binningData().size(); ++ib) {
0076 equal = isEqual(ba.binningData()[ib], bb.binningData()[ib], tolerance);
0077 BOOST_CHECK(equal);
0078 }
0079 }
0080 return equal;
0081 }
0082
0083
0084
0085
0086
0087
0088
0089
0090 inline static bool isEqual(const Acts::Extent& ea, const Acts::Extent& eb,
0091 double tolerance = 0.) {
0092 bool equalConstrains = true;
0093 bool equalRange = true;
0094 for (auto& bVal : allAxisDirections()) {
0095 equalConstrains =
0096 equalConstrains && (ea.constrains(bVal) == eb.constrains(bVal));
0097 BOOST_CHECK(equalConstrains);
0098 if (ea.constrains(bVal) && eb.constrains(bVal)) {
0099 equalRange =
0100 equalRange && std::abs(ea.min(bVal) - eb.min(bVal)) < tolerance;
0101 equalRange =
0102 equalRange && std::abs(ea.max(bVal) - eb.max(bVal)) < tolerance;
0103 BOOST_CHECK(equalRange);
0104 }
0105 }
0106 BOOST_CHECK(equalConstrains);
0107 BOOST_CHECK(equalRange);
0108 return equalRange && equalConstrains;
0109 }
0110
0111 }