99// granted to it by virtue of its status as an Intergovernmental Organization
1010// or submit itself to any jurisdiction.
1111
12- #include " MCHMappingInterface/CathodeSegmentation.h"
1312#define BOOST_TEST_MODULE Test MCHGlobalMapping Mapper
1413#define BOOST_TEST_MAIN
1514#define BOOST_TEST_DYN_LINK
1615
1716#include < boost/test/unit_test.hpp>
17+ #include " MCHConditions/Chamber.h"
1818#include " MCHConditions/DCSAliases.h"
19+ #include " MCHGlobalMapping/DsIndex.h"
1920#include " MCHGlobalMapping/Mapper.h"
21+ #include " MCHMappingInterface/CathodeSegmentation.h"
2022#include " MCHMappingInterface/Segmentation.h"
2123#include " MCHRawElecMap/Mapper.h"
24+ #include < algorithm>
2225
2326using namespace o2 ::mch::dcs;
27+ using namespace o2 ::mch;
2428
2529namespace
2630{
2731
28- /* Build the list of expected dual sampa indices from a set of Cathodes */
29- std::set<int > getExpectedDualSampas (const std::set<Cathode>& cathodes)
30- {
31- std::set<int > expectedDualSampas;
32- for (const auto & expectedCathode : cathodes) {
33- auto deId = expectedCathode.deId ;
34- bool bending = expectedCathode.plane == Plane::Bending;
35- bool checkPlane = expectedCathode.plane != Plane::Both;
36- if (checkPlane) {
37- o2::mch::mapping::CathodeSegmentation cathode (deId, bending);
38- for (auto i = 0 ; i < cathode.nofDualSampas (); i++) {
39- int index = o2::mch::getDsIndex ({deId, cathode.dualSampaId (i)});
40- expectedDualSampas.emplace (index);
41- }
42- } else {
43- const o2::mch::mapping::Segmentation& seg = o2::mch::mapping::segmentation (deId);
44- seg.forEachDualSampa ([&expectedDualSampas, deId](int dualSampaId) {
45- int index = o2::mch::getDsIndex ({deId, dualSampaId});
46- expectedDualSampas.emplace (index);
47- });
48- }
49- }
50- return expectedDualSampas;
51- }
52-
53- /* Build the list of expected dual sampa indices from a set of solar Ids */
54- std::set<int > getExpectedDualSampas (const std::set<int >& solarIds)
55- {
56- std::set<int > expectedDualSampas;
57- for (const auto & solarId : solarIds) {
58- auto dsDetIds = o2::mch::raw::getDualSampas<o2::mch::raw::ElectronicMapperGenerated>(solarId);
59- for (const auto & dsDetId : dsDetIds) {
60- int index = o2::mch::getDsIndex (dsDetId);
61- expectedDualSampas.emplace (index);
62- }
63- }
64- return expectedDualSampas;
65- }
66-
6732std::string expandAlias (std::string_view shortAlias)
6833{
6934 std::string alias = shortAlias.find (" Left" ) != std::string::npos ? " MchHvLvLeft" : " MchHvLvRight" ;
@@ -86,7 +51,7 @@ void compareToExpectation(const std::map<std::string, std::set<T>>& expected)
8651 // this is the function we are testing
8752 auto dsix = o2::mch::dcs::aliasToDsIndices (alias);
8853
89- std::set<int > expectedDualSampas = getExpectedDualSampas (e.second );
54+ std::set<o2::mch::DsIndex > expectedDualSampas = getDsIndices (e.second );
9055
9156 BOOST_TEST_CONTEXT (fmt::format (" alias {}" , alias))
9257 {
@@ -100,6 +65,45 @@ void compareToExpectation(const std::map<std::string, std::set<T>>& expected)
10065
10166} // namespace
10267
68+ BOOST_AUTO_TEST_CASE (IncorrectCathodeShouldGetZeroIndices)
69+ {
70+ BOOST_CHECK_EQUAL (getDsIndices ({{10 , Plane::Both}}).size (), 0 );
71+ }
72+
73+ BOOST_AUTO_TEST_CASE (CheckDsIndexRangePerChamberPlane)
74+ {
75+ // note that indices in ranges might overlap, this is not an error
76+ std::vector<std::tuple<int , int , int , int >> vexpected = {
77+ {0 , 1578 , 226 , 1803 }, // chamber 1, min_bending, max_bending, min_nonBending, max_nonBending
78+ {1804 , 3382 , 2030 , 3607 }, // chamber 2
79+ {3608 , 5154 , 3829 , 5375 }, // chamber 3
80+ {5376 , 6922 , 5597 , 7143 }, // chamber 4
81+ {7144 , 8312 , 7190 , 8351 }, // chamber 5
82+ {8352 , 9539 , 8399 , 9579 }, // chamber 6
83+ {9580 , 11253 , 9630 , 11299 }, // chamber 7
84+ {11300 , 12973 , 11350 , 13019 }, // chamber 8
85+ {13020 , 14873 , 13070 , 14919 }, // chamber 9
86+ {14920 , 16773 , 14970 , 16819 }, // chamber 10
87+ };
88+ for (auto chamberId = 0 ; chamberId < 10 ; chamberId++) {
89+ BOOST_TEST_CONTEXT (fmt::format (" chamberId {}" , chamberId))
90+ {
91+ auto ch = chamber (chamberId).value ();
92+ const auto b = getDsIndices (ch, Plane::Bending);
93+ const auto nb = getDsIndices (ch, Plane::NonBending);
94+ BOOST_REQUIRE (b.size () > 0 );
95+ BOOST_REQUIRE (nb.size () > 0 );
96+ const auto [bmin, bmax] = std::minmax_element (b.begin (), b.end ());
97+ const auto [nbmin, nbmax] = std::minmax_element (nb.begin (), nb.end ());
98+ const auto expected = vexpected[chamberId];
99+ BOOST_REQUIRE_EQUAL (*bmin, std::get<0 >(expected));
100+ BOOST_REQUIRE_EQUAL (*bmax, std::get<1 >(expected));
101+ BOOST_REQUIRE_EQUAL (*nbmin, std::get<2 >(expected));
102+ BOOST_REQUIRE_EQUAL (*nbmax, std::get<3 >(expected));
103+ }
104+ }
105+ }
106+
103107BOOST_AUTO_TEST_CASE (HVSlatIDToDsIndex)
104108{
105109 std::map<std::string, std::set<Cathode>> expected = {
0 commit comments