Skip to content

Commit

Permalink
fix: Adding another parameter in the json configuration (acts-project…
Browse files Browse the repository at this point in the history
…#3216)

This PR fixes the previous PR I opened with the straw surfaces smearing acts-project#3197 because I realized that the` forcePositiveValues` parameter from json is not parsed successfully, since I did not add them in the `JsonConfiguration`. I am fixing with this PR (hopefully).
  • Loading branch information
dimitra97 authored and EleniXoch committed May 31, 2024
1 parent a01b308 commit 09cbbf0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Examples/Io/Json/src/JsonDigitizationConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,16 @@ void from_json(
void ActsExamples::to_json(nlohmann::json& j,
const ActsExamples::ParameterSmearingConfig& psc) {
j["index"] = psc.index;
j["forcePositiveValues"] = psc.forcePositiveValues;
to_json(j, psc.smearFunction);
}

void ActsExamples::from_json(const nlohmann::json& j,
ActsExamples::ParameterSmearingConfig& psc) {
psc.index = static_cast<Acts::BoundIndices>(j["index"]);
if (j.find("forcePositiveValues") != j.end()) {
psc.forcePositiveValues = j["forcePositiveValues"];
}
from_json(j, psc.smearFunction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ BOOST_AUTO_TEST_CASE(GaussianSmearing) {

for (auto& el : digiConfig) {
for (auto& smearing : el.smearingDigiConfig) {
// check if the forcePositiveValue parameter is successfully parsed
BOOST_CHECK(smearing.forcePositiveValues);
std::fill(std::begin(s.indices), std::end(s.indices),
static_cast<Acts::BoundIndices>(smearing.index));
std::fill(std::begin(s.smearFunctions), std::end(s.smearFunctions),
Expand All @@ -349,7 +351,11 @@ BOOST_AUTO_TEST_CASE(GaussianSmearing) {
BOOST_TEST_INFO("Comparing smeared measurement "
<< i << " originating from bound parameter "
<< s.indices[i]);
CHECK_CLOSE_REL(par[i], f.boundParams[s.indices[i]], 0.15);
double ref = f.boundParams[s.indices[i]];
if (s.forcePositive[i]) {
ref = std::abs(ref);
}
CHECK_CLOSE_REL(par[i], ref, 0.15);
}
}

Expand Down

0 comments on commit 09cbbf0

Please sign in to comment.