9 #include <boost/test/unit_test.hpp>
23 #include <system_error>
26 namespace ActsFatras {
28 BOOST_AUTO_TEST_SUITE(Digitization)
37 std::make_pair<double, double>(value + 1., 3.));
41 struct SterileSmearer {
44 std::make_pair<double, double>(value + 0., 0.));
48 struct InvalidSmearer {
51 ActsFatras::DigitizationError::SmearError);
55 const auto pid = Barcode().setVertexPrimary(12).setParticle(23);
59 auto rec = std::make_shared<Acts::RectangleBounds>(1000, 1000);
60 auto tSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(
61 Acts::Transform3D::Identity(), rec);
72 auto hit =
Hit(gid,
pid, p4, m4, m4, 12
u);
77 SterileSmearer tSterileFnc;
78 InvalidSmearer tInvalidFnc;
81 auto oneDim = oneDimSmearer(sInput, {tAddFnc});
83 BOOST_CHECK(oneDim.ok());
85 const auto& smearedOne = oneDim.value();
88 const auto& sParametersOne = smearedOne.getParameters();
89 const auto& sCovarianceOne = smearedOne.getCovariance().value();
95 auto twoDim = twoDimSmearer(sInput, {tAddFnc, tAddFnc});
97 BOOST_CHECK(twoDim.ok());
98 const auto& smearedTwo = twoDim.value();
102 const auto& sParametersTwo = smearedTwo.getParameters();
103 const auto& sCovarianceTwo = smearedTwo.getCovariance().value();
112 auto locYTime = locYTimeSmearer(sInput, {tAddFnc, tAddFnc});
113 BOOST_CHECK(locYTime.ok());
114 const auto& smearedLocyTime = locYTime.value();
125 auto phiTheta = phiThetaSmearer(sInput, {tSterileFnc, tSterileFnc});
126 BOOST_CHECK(phiTheta.ok());
127 auto phiThetaParSet = phiTheta.value();
139 invalidHitFirstSmearer;
140 auto invalidHitFirst =
141 invalidHitFirstSmearer(sInput, {tInvalidFnc, tSterileFnc});
142 BOOST_CHECK(not invalidHitFirst.ok());
146 invalidHitMiddleSmearer;
148 auto invalidHitMiddle = invalidHitMiddleSmearer(
149 sInput, {tSterileFnc, tSterileFnc, tInvalidFnc, tSterileFnc});
150 BOOST_CHECK(not invalidHitMiddle.ok());
153 invalidHitLastSmearer;
154 auto invalidHitLast =
155 invalidHitLastSmearer(sInput, {tSterileFnc, tInvalidFnc});
156 BOOST_CHECK(not invalidHitLast.ok());
159 using StripSmearer = std::pair<BoundParametersSmearer<Acts::eBoundLoc0>,
160 std::array<SmearFunction, 1>>;
163 std::pair<BoundParametersSmearer<Acts::eBoundLoc0, Acts::eBoundLoc1>,
164 std::array<SmearFunction, 2>>;
166 using SiliconSmearer = std::variant<StripSmearer, PixelSmearer>;
168 using SiliconParSets =
169 std::variant<Acts::ParameterSet<Acts::BoundIndices, Acts::eBoundLoc0>,
173 StripSmearer stripSmearer(oneDimSmearer, {tAddFnc});
174 PixelSmearer pixelSmearer(twoDimSmearer, {tAddFnc, tAddFnc});
176 std::map<std::string, SiliconSmearer> siSmearers;
177 siSmearers[
"pixel"] = pixelSmearer;
178 siSmearers[
"strip"] = stripSmearer;
180 std::map<std::string, Hit> siHits;
181 siHits[
"pixel"] = hit;
182 siHits[
"strip"] = hit;
184 std::vector<SiliconParSets> siParSets;
186 for (
auto& [key,
value] : siHits) {
187 std::string key_id = key;
190 auto sParSet = sm.first(sInput, sm.second);
192 siParSets.push_back(sParSet.value());
194 std::cout <<
"Smearing a hit for " << key_id << std::endl;
195 std::cout <<
" - contains loc0 : "
196 << sParSet.value().template contains<Acts::eBoundLoc0>()
198 std::cout <<
" - contains loc1 : "
199 << sParSet.value().template contains<Acts::eBoundLoc1>()
206 BOOST_CHECK_EQUAL(siParSets.size(), 2
u);
215 FreeSmearer freeSmearer;
221 auto hit =
Hit(gid,
pid, p4, m4, m4, 12
u);
224 SterileSmearer tSterileFnc;
227 freeSmearer({hit, geoCtx}, {tSterileFnc, tAddFnc, tSterileFnc});
229 BOOST_CHECK(freeSmearing.ok());
230 const auto& freeSet = freeSmearing.value();
239 BOOST_AUTO_TEST_SUITE_END()