Project
Loading...
Searching...
No Matches
testGeometryCreator.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#define BOOST_TEST_MODULE Test MCHSimulation Geometry
16#define BOOST_TEST_DYN_LINK
17#define BOOST_TEST_MAIN
18
19#include <boost/test/unit_test.hpp>
20
23#include "TGeoManager.h"
24#include "boost/format.hpp"
25#include <boost/test/data/test_case.hpp>
26#include <iomanip>
27#include <iostream>
28#include <fmt/format.h>
29
30namespace bdata = boost::unit_test::data;
31
32struct GEOMETRY {
34 {
35 if (!gGeoManager) {
38 }
39 };
40};
41
42const std::array<std::string, 8> quadrantChamberNames{"SC01I", "SC01O", "SC02I", "SC02O", "SC03I", "SC03O",
43 "SC04I", "SC04O"};
44
45const std::array<std::string, 12> slatChamberNames{"SC05I", "SC05O", "SC06I", "SC06O", "SC07I", "SC07O",
46 "SC08I", "SC08O", "SC09I", "SC09O", "SC10I", "SC10O"};
47
48const std::vector<std::vector<std::string>> deSymNames{
49 {"DE100", "DE103"},
50 {"DE101", "DE102"},
51 {"DE200", "DE203"},
52 {"DE201", "DE202"},
53 {"DE300", "DE303"},
54 {"DE301", "DE302"},
55 {"DE400", "DE403"},
56 {"DE401", "DE402"},
57 {"DE500", "DE501", "DE502", "DE503", "DE504", "DE514", "DE515", "DE516", "DE517"},
58 {"DE505", "DE506", "DE507", "DE508", "DE509", "DE510", "DE511", "DE512", "DE513"},
59 {"DE600", "DE601", "DE602", "DE603", "DE604", "DE614", "DE615", "DE616", "DE617"},
60 {"DE605", "DE606", "DE607", "DE608", "DE609", "DE610", "DE611", "DE612", "DE613"},
61 {"DE700", "DE701", "DE702", "DE703", "DE704", "DE705", "DE706", "DE720", "DE721", "DE722", "DE723", "DE724", "DE725"},
62 {"DE707", "DE708", "DE709", "DE710", "DE711", "DE712", "DE713", "DE714", "DE715", "DE716", "DE717", "DE718", "DE719"},
63 {"DE800", "DE801", "DE802", "DE803", "DE804", "DE805", "DE806", "DE820", "DE821", "DE822", "DE823", "DE824", "DE825"},
64 {"DE807", "DE808", "DE809", "DE810", "DE811", "DE812", "DE813", "DE814", "DE815", "DE816", "DE817", "DE818", "DE819"},
65 {"DE900", "DE901", "DE902", "DE903", "DE904", "DE905", "DE906", "DE920", "DE921", "DE922", "DE923", "DE924", "DE925"},
66 {"DE907", "DE908", "DE909", "DE910", "DE911", "DE912", "DE913", "DE914", "DE915", "DE916", "DE917", "DE918", "DE919"},
67 {"DE1000", "DE1001", "DE1002", "DE1003", "DE1004", "DE1005", "DE1006", "DE1020", "DE1021", "DE1022", "DE1023", "DE1024", "DE1025"},
68 {"DE1007", "DE1008", "DE1009", "DE1010", "DE1011", "DE1012", "DE1013", "DE1014", "DE1015", "DE1016", "DE1017", "DE1018", "DE1019"}};
69
70BOOST_FIXTURE_TEST_SUITE(geometrycreator, GEOMETRY)
71
72BOOST_AUTO_TEST_CASE(CanGetAllChambers)
73{
74 std::vector<std::string> chamberNames{quadrantChamberNames.begin(), quadrantChamberNames.end()};
75
76 chamberNames.insert(chamberNames.end(), slatChamberNames.begin(), slatChamberNames.end());
77
78 for (auto chname : chamberNames) {
79 auto vol = gGeoManager->GetVolume(chname.c_str());
80 BOOST_TEST_REQUIRE((vol != nullptr));
81 }
82}
83
84std::vector<TGeoNode*> getSlatNodes()
85{
86 std::vector<TGeoNode*> slats;
87 for (auto chname : slatChamberNames) {
88 auto vol = gGeoManager->GetVolume(chname.c_str());
89 TIter next(vol->GetNodes());
90 while (TGeoNode* node = static_cast<TGeoNode*>(next())) {
91 if (strstr(node->GetName(), "support") == nullptr) {
92 slats.push_back(node);
93 }
94 }
95 }
96 return slats;
97}
98
99std::vector<TGeoNode*> getQuadrantNodes()
100{
101 std::vector<TGeoNode*> quadrants;
102 for (auto chname : quadrantChamberNames) {
103 auto vol = gGeoManager->GetVolume(chname.c_str());
104 TIter next(vol->GetNodes());
105 while (TGeoNode* node = static_cast<TGeoNode*>(next())) {
106 quadrants.push_back(node);
107 }
108 }
109 return quadrants;
110}
111
112BOOST_AUTO_TEST_CASE(GetRightNumberOfSlats)
113{
114 auto slats = getSlatNodes();
115 BOOST_CHECK_EQUAL(slats.size(), 140);
116}
117
118BOOST_AUTO_TEST_CASE(GetRightNumberOfQuadrants)
119{
120 auto quadrants = getQuadrantNodes();
121 BOOST_CHECK_EQUAL(quadrants.size(), 16);
122}
123
124BOOST_AUTO_TEST_CASE(GetDetElemVolumePath, *boost::unit_test::disabled() * boost::unit_test::label("debug"))
125{
126 TIter next(gGeoManager->GetTopNode()->GetNodes());
127 TGeoNode* node;
128 TGeoNode* n2;
129
130 std::vector<std::string> codeLines;
131
132 while ((node = static_cast<TGeoNode*>(next()))) {
133 std::cout << node->GetName() << "\n";
134 TIter next2(node->GetNodes());
135 while ((n2 = static_cast<TGeoNode*>(next2()))) {
136 std::string n2name{n2->GetName()};
137 auto index = n2name.find_last_of('_');
138 int detElemId = std::atoi(n2name.substr(index + 1).c_str());
139 if (detElemId >= 100) {
140 std::stringstream s;
141 s << "if (detElemId==" << detElemId << ") {\n";
142 s << R"( return ")" << node->GetName() << "/" << n2name << "\";\n";
143 s << "}\n";
144 codeLines.push_back(s.str());
145 }
146 }
147 }
148
149 for (auto s : codeLines) {
150 std::cout << s;
151 }
152 BOOST_CHECK_EQUAL(codeLines.size(), 156);
153}
154
155BOOST_AUTO_TEST_CASE(TextualTreeDump)
156{
157 const std::string expected =
158 R"(cave_1
159├──SC01I_0
160│ ├──Quadrant (chamber 1)_100
161│ └──Quadrant (chamber 1)_103
162├──SC01O_1
163│ ├──Quadrant (chamber 1)_101
164│ └──Quadrant (chamber 1)_102
165├──SC02I_2
166│ ├──Quadrant (chamber 2)_200
167│ └──Quadrant (chamber 2)_203
168├──SC02O_3
169│ ├──Quadrant (chamber 2)_201
170│ └──Quadrant (chamber 2)_202
171├──SC03I_4
172│ ├──Station 2 quadrant_300
173│ └──Station 2 quadrant_303
174├──SC03O_5
175│ ├──Station 2 quadrant_301
176│ └──Station 2 quadrant_302
177├──SC04I_6
178│ ├──Station 2 quadrant_400
179│ └──Station 2 quadrant_403
180├──SC04O_7
181│ ├──Station 2 quadrant_401
182│ └──Station 2 quadrant_402
183├──SC05I_8
184│ ├──Chamber 5 support panel_8
185│ ├──122000SR1_500
186│ ├──112200SR2_501
187│ ├──122200S_502
188│ ├──222000N_503
189│ ├──220000N_504
190│ ├──220000N_514
191│ ├──222000N_515
192│ ├──122200S_516
193│ └──112200SR2_517
194├──SC05O_9
195│ ├──Chamber 5 support panel_9
196│ ├──220000N_505
197│ ├──222000N_506
198│ ├──122200S_507
199│ ├──112200SR2_508
200│ ├──122000SR1_509
201│ ├──112200SR2_510
202│ ├──122200S_511
203│ ├──222000N_512
204│ └──220000N_513
205├──SC06I_10
206│ ├──Chamber 6 support panel_10
207│ ├──122000NR1_600
208│ ├──112200NR2_601
209│ ├──122200N_602
210│ ├──222000N_603
211│ ├──220000N_604
212│ ├──220000N_614
213│ ├──222000N_615
214│ ├──122200N_616
215│ └──112200NR2_617
216├──SC06O_11
217│ ├──Chamber 6 support panel_11
218│ ├──220000N_605
219│ ├──222000N_606
220│ ├──122200N_607
221│ ├──112200NR2_608
222│ ├──122000NR1_609
223│ ├──112200NR2_610
224│ ├──122200N_611
225│ ├──222000N_612
226│ └──220000N_613
227├──SC07I_12
228│ ├──Chamber 7 support panel_12
229│ ├──122330N_700
230│ ├──112233NR3_701
231│ ├──112230N_702
232│ ├──222330N_703
233│ ├──223300N_704
234│ ├──333000N_705
235│ ├──330000N_706
236│ ├──330000N_720
237│ ├──333000N_721
238│ ├──223300N_722
239│ ├──222330N_723
240│ ├──112230N_724
241│ └──112233NR3_725
242├──SC07O_13
243│ ├──Chamber 7 support panel_13
244│ ├──330000N_707
245│ ├──333000N_708
246│ ├──223300N_709
247│ ├──222330N_710
248│ ├──112230N_711
249│ ├──112233NR3_712
250│ ├──122330N_713
251│ ├──112233NR3_714
252│ ├──112230N_715
253│ ├──222330N_716
254│ ├──223300N_717
255│ ├──333000N_718
256│ └──330000N_719
257├──SC08I_14
258│ ├──Chamber 8 support panel_14
259│ ├──122330N_800
260│ ├──112233NR3_801
261│ ├──112230N_802
262│ ├──222330N_803
263│ ├──223300N_804
264│ ├──333000N_805
265│ ├──330000N_806
266│ ├──330000N_820
267│ ├──333000N_821
268│ ├──223300N_822
269│ ├──222330N_823
270│ ├──112230N_824
271│ └──112233NR3_825
272├──SC08O_15
273│ ├──Chamber 8 support panel_15
274│ ├──330000N_807
275│ ├──333000N_808
276│ ├──223300N_809
277│ ├──222330N_810
278│ ├──112230N_811
279│ ├──112233NR3_812
280│ ├──122330N_813
281│ ├──112233NR3_814
282│ ├──112230N_815
283│ ├──222330N_816
284│ ├──223300N_817
285│ ├──333000N_818
286│ └──330000N_819
287├──SC09I_16
288│ ├──Chamber 9 support panel_16
289│ ├──122330N_900
290│ ├──112233NR3_901
291│ ├──112233N_902
292│ ├──222333N_903
293│ ├──223330N_904
294│ ├──333300N_905
295│ ├──333000N_906
296│ ├──333000N_920
297│ ├──333300N_921
298│ ├──223330N_922
299│ ├──222333N_923
300│ ├──112233N_924
301│ └──112233NR3_925
302├──SC09O_17
303│ ├──Chamber 9 support panel_17
304│ ├──333000N_907
305│ ├──333300N_908
306│ ├──223330N_909
307│ ├──222333N_910
308│ ├──112233N_911
309│ ├──112233NR3_912
310│ ├──122330N_913
311│ ├──112233NR3_914
312│ ├──112233N_915
313│ ├──222333N_916
314│ ├──223330N_917
315│ ├──333300N_918
316│ └──333000N_919
317├──SC10I_18
318│ ├──Chamber 10 support panel_18
319│ ├──122330N_1000
320│ ├──112233NR3_1001
321│ ├──112233N_1002
322│ ├──222333N_1003
323│ ├──223330N_1004
324│ ├──333300N_1005
325│ ├──333000N_1006
326│ ├──333000N_1020
327│ ├──333300N_1021
328│ ├──223330N_1022
329│ ├──222333N_1023
330│ ├──112233N_1024
331│ └──112233NR3_1025
332└──SC10O_19
333 ├──Chamber 10 support panel_19
334 ├──333000N_1007
335 ├──333300N_1008
336 ├──223330N_1009
337 ├──222333N_1010
338 ├──112233N_1011
339 ├──112233NR3_1012
340 ├──122330N_1013
341 ├──112233NR3_1014
342 ├──112233N_1015
343 ├──222333N_1016
344 ├──223330N_1017
345 ├──333300N_1018
346 └──333000N_1019
347)";
348
349 std::ostringstream str;
351 BOOST_CHECK(expected == str.str());
352}
353
354BOOST_AUTO_TEST_CASE(GetAlignableHalfChambers)
355{
356 BOOST_REQUIRE(gGeoManager != nullptr);
357
358 for (int i = 0; i < 20; i++) {
359 BOOST_CHECK((gGeoManager->GetAlignableEntry((fmt::format("MCH/HC{}", i)).c_str())));
360 }
361}
362
363BOOST_AUTO_TEST_CASE(GetAlignableDetectionElements)
364{
365 BOOST_REQUIRE(gGeoManager != nullptr);
366
367 for (int hc = 0; hc < 20; hc++) {
368 for (int de = 0; de < deSymNames[hc].size(); de++) {
369 BOOST_CHECK((gGeoManager->GetAlignableEntry((fmt::format("MCH/HC{}/{}", hc, deSymNames[hc][de].c_str())).c_str())));
370 }
371 }
372}
373BOOST_AUTO_TEST_SUITE_END()
std::unique_ptr< expressions::Node > node
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Interface for MCH geometry creation.
void addAlignableVolumes(TGeoManager &geom)
Definition Geometry.cxx:99
void showGeometryAsTextTree(const char *fromPath, int maxdepth, std::ostream &out)
tree like textual dump of the geometry nodes
Definition Helpers.cxx:92
void createStandaloneGeometry()
Definition Helpers.cxx:112
std::map< std::string, ID > expected
std::vector< TGeoNode * > getSlatNodes()
const std::vector< std::vector< std::string > > deSymNames
BOOST_AUTO_TEST_CASE(CanGetAllChambers)
const std::array< std::string, 12 > slatChamberNames
const std::array< std::string, 8 > quadrantChamberNames
std::vector< TGeoNode * > getQuadrantNodes()
uint16_t de
BOOST_CHECK(tree)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())
const std::string str