Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JsonDigitizationConfigTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JsonDigitizationConfigTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
19 
20 #include <fstream>
21 #include <string>
22 #include <vector>
23 
24 #include <nlohmann/json.hpp>
25 
26 using namespace Acts;
27 
28 BOOST_AUTO_TEST_SUITE(JsonDigitizationConfig)
29 
30 BOOST_AUTO_TEST_CASE(DigitizationConfigRoundTrip) {
31  std::ofstream out;
32 
33  // As all SurfaceBounds have the same streaming API only a one is
34  // tested here, all others are tests are identical
35 
37 
39 
40  Acts::BinUtility segmentation;
41  segmentation += Acts::BinUtility(336, -8.4, 8.4, Acts::open, Acts::binX);
42  segmentation += Acts::BinUtility(1280, -36, 36, Acts::open, Acts::binY);
43 
44  gdc.segmentation = segmentation;
45  gdc.threshold = 0.01;
46  gdc.thickness = 0.15;
49 
51  dcRef.geometricDigiConfig = gdc;
52 
53  nlohmann::json dcJsonOut(dcRef);
54  out.open("DigiComponentsConfig.json");
55  out << dcJsonOut.dump(2);
56  out.close();
57 
58  auto in = std::ifstream("DigiComponentsConfig.json",
59  std::ifstream::in | std::ifstream::binary);
60  BOOST_CHECK(in.good());
61  nlohmann::json dcJsonIn;
62  in >> dcJsonIn;
63  in.close();
64 
65  ActsExamples::DigiComponentsConfig dcTest(dcJsonIn);
66  BOOST_CHECK(dcTest.geometricDigiConfig.indices ==
68  BOOST_CHECK(dcTest.geometricDigiConfig.segmentation.dimensions() ==
70 }
71 
72 BOOST_AUTO_TEST_SUITE_END()