Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:19:38

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Utilities/Helpers.hpp"
0012 #include "ActsExamples/EventData/MuonSpacePoint.hpp"
0013 
0014 using Identifier = ActsExamples::MuonSpacePoint::MuonId;
0015 
0016 using TechField = Identifier::TechField;
0017 using StationName = Identifier::StationName;
0018 using DetSide = Identifier::DetSide;
0019 using namespace Acts;
0020 namespace ActsExamples {
0021 
0022 std::ostream& operator<<(std::ostream& ostr, const TechField& field) {
0023   ostr << Identifier::toString(field);
0024   return ostr;
0025 }
0026 std::ostream& operator<<(std::ostream& ostr, const StationName& field) {
0027   ostr << Identifier::toString(field);
0028   return ostr;
0029 }
0030 std::ostream& operator<<(std::ostream& ostr, const DetSide& field) {
0031   ostr << Identifier::toString(field);
0032   return ostr;
0033 }
0034 
0035 namespace Test {
0036 
0037 BOOST_AUTO_TEST_SUITE(MuonSpacePointIdTests)
0038 
0039 BOOST_AUTO_TEST_CASE(MainTest) {
0040   constexpr std::uint16_t sectorMax = 63;
0041   constexpr std::uint8_t layerMax = 15;
0042   constexpr std::uint16_t channelMax = 2;
0043   for (const auto tech : {TechField::Mm, TechField::sTgc, TechField::Mdt,
0044                           TechField::Rpc, TechField::Tgc}) {
0045     for (const auto side : {DetSide::A, DetSide::C}) {
0046       for (std::int8_t st = toUnderlying(StationName::UnDef) + 1;
0047            st < toUnderlying(StationName::MaxVal); ++st) {
0048         const auto stName = static_cast<StationName>(st);
0049         for (std::uint16_t sector = 1; sector <= sectorMax; ++sector) {
0050           /// Create a reference space point object
0051           Identifier refId{};
0052           refId.setChamber(stName, side, sector, tech);
0053           BOOST_CHECK_EQUAL(refId.msStation(), stName);
0054           BOOST_CHECK_EQUAL(refId.side(), side);
0055           BOOST_CHECK_EQUAL(refId.sector(), sector);
0056           BOOST_CHECK_EQUAL(refId.technology(), tech);
0057           for (const auto& [measEta, measPhi, measTime] :
0058                std::vector<std::tuple<bool, bool, bool>>{{false, false, false},
0059                                                          {true, false, false},
0060                                                          {true, true, false},
0061                                                          {true, false, true},
0062                                                          {false, true, false},
0063                                                          {false, true, true},
0064                                                          {false, false, true},
0065                                                          {true, true, true}}) {
0066             refId.setCoordFlags(measEta, measPhi, measTime);
0067             BOOST_CHECK_EQUAL(refId.measuresEta(), measEta);
0068             BOOST_CHECK_EQUAL(refId.measuresPhi(), measPhi);
0069             BOOST_CHECK_EQUAL(refId.measuresTime(), measTime);
0070 
0071             for (std::uint8_t layer = 1; layer <= layerMax; ++layer) {
0072               for (std::uint16_t ch = 1; ch <= channelMax; ++ch) {
0073                 refId.setLayAndCh(layer, ch);
0074                 BOOST_CHECK_EQUAL(refId.channel(), ch);
0075                 BOOST_CHECK_EQUAL(refId.detLayer(), layer);
0076 
0077                 Identifier testId{refId.toInt()};
0078                 BOOST_CHECK_EQUAL(refId.toInt(), testId.toInt());
0079                 BOOST_CHECK_EQUAL(testId.msStation(), refId.msStation());
0080                 BOOST_CHECK_EQUAL(testId.side(), refId.side());
0081                 BOOST_CHECK_EQUAL(testId.technology(), refId.technology());
0082                 BOOST_CHECK_EQUAL(testId.sector(), refId.sector());
0083 
0084                 BOOST_CHECK_EQUAL(refId.measuresEta(), testId.measuresEta());
0085                 BOOST_CHECK_EQUAL(refId.measuresPhi(), testId.measuresPhi());
0086                 BOOST_CHECK_EQUAL(refId.measuresTime(), testId.measuresTime());
0087                 BOOST_CHECK_EQUAL(testId.detLayer(), refId.detLayer());
0088                 BOOST_CHECK_EQUAL(refId.sameStation(testId), true);
0089                 BOOST_CHECK_EQUAL(testId.channel(), refId.channel());
0090               }
0091             }  /// layer flag
0092           }  // coord flag loop
0093         }  // sector loop
0094       }  // side loop
0095     }  // station index loop
0096   }  // tech index loop
0097 }
0098 
0099 BOOST_AUTO_TEST_SUITE_END()
0100 }  // namespace Test
0101 }  // namespace ActsExamples