ATLAS Offline Software
Loading...
Searching...
No Matches
runTgcGeoComparison.cxx
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4*/
13
17#include <GaudiKernel/SystemOfUnits.h>
18#include <string>
19#include <set>
20#include <vector>
21#include <map>
22#include <iostream>
23
25#include <TFile.h>
26#include <TTreeReader.h>
27
28#include "Acts/Utilities/UnitVectors.hpp"
29#include "Acts/Definitions/Units.hpp"
30
31#include "GeoModelHelpers/TransformToStringConverter.h"
32
33Amg::Vector3D makeDir(const double theta, const double phi) {
34 using namespace Acts::UnitLiterals;
35 return Acts::makeDirectionFromPhiTheta(phi *1._degree, theta* 1._degree);
36}
37
38constexpr double tolerance = 10 * Gaudi::Units::micrometer;
39
40using namespace MuonGMR4;
41using namespace ActsTrk;
45 TgcChamber() = default;
46
48 unsigned stIdx{0};
49 int eta{0};
50 unsigned phi{0};
51 unsigned nGasGaps{0};
52 std::string techName{};
54 float shortWidth{0.f};
55 float longWidth{0.f};
56 float height{0.f};
57 float thickness{0.f};
58
60 bool operator<(const TgcChamber& other) const {
61 if (stIdx != other.stIdx) return stIdx < other.stIdx;
62 if (eta != other.eta) return eta < other.eta;
63 return phi < other.phi;
64 }
65
66 Amg::Transform3D geoModelTransform{Amg::Transform3D::Identity()};
68 Amg::Transform3D alignableTransform{Amg::Transform3D::Identity()};
69
70 struct WireGang {
71 unsigned int numWires{0};
72 unsigned int gasGap{0};
73 unsigned int number{0};
74 Amg::Vector3D position{Amg::Vector3D::Zero()};
75 Amg::Vector2D localPos{Amg::Vector2D::Zero()};
76 float length{0.f};
77
78 bool operator<(const WireGang& other) const {
79 if (gasGap != other.gasGap) return gasGap < other.gasGap;
80 return number < other.number;
81 }
82 };
83
84 struct LayerTrans{
85 unsigned int gasGap{0};
86 bool measPhi{false};
87 Amg::Transform3D trans{Amg::Transform3D::Identity()};
88
89 float shortWidth{0.f};
90 float longWidth{0.f};
91 float height{0.f};
92
93 unsigned int numWires{0};
94
95 bool operator<(const LayerTrans& other) const{
96 if (gasGap!= other.gasGap) return gasGap < other.gasGap;
97 return measPhi < other.measPhi;
98 }
99 };
100
101 struct RadialStrip {
102 unsigned int gasGap{0};
103 unsigned int number{0};
104
106 Amg::Vector3D globCenter{Amg::Vector3D::Zero()};
107 Amg::Vector2D locCenter{Amg::Vector2D::Zero()};
108 // Strip bottom position
109 Amg::Vector3D globBottom{Amg::Vector3D::Zero()};
110 Amg::Vector2D locBottom{Amg::Vector2D::Zero()};
111 // Strip top position
112 Amg::Vector3D globTop{Amg::Vector3D::Zero()};
113 Amg::Vector2D locTop{Amg::Vector2D::Zero()};
114
115 bool operator<(const RadialStrip& other) const {
116 if (gasGap != other.gasGap) return gasGap < other.gasGap;
117 return number < other.number;
118 }
119
120 };
121 std::set<WireGang> etaWires{};
122 std::set<RadialStrip> strips{};
123 std::set<LayerTrans> transforms{};
124
125};
126
127std::ostream& operator<<(std::ostream& ostr, const TgcChamber::WireGang& gang) {
128 ostr<<"wire gang (gap/number/n-Wires/length): "<<gang.gasGap<<"/"<<std::setfill('0')<<std::setw(2)<<gang.number<<"/"<<std::setfill('0')<<std::setw(3)<<gang.numWires<<std::setw(-1)<<"/"<<gang.length;
129 // ostr<<" position: "<<Amg::toString(gang.position,2 );
130 return ostr;
131}
132std::ostream& operator<<(std::ostream& ostr, const TgcChamber::RadialStrip& strip) {
133 ostr<<"strip (gap/number): "<<strip.gasGap<<"/"<<std::setfill('0')<<std::setw(2)<<strip.number<<std::setw(-1);
134 return ostr;
135}
136std::ostream& operator<<(std::ostream& ostr, const TgcChamber::LayerTrans& lTrans) {
137 ostr<<"layer transform (gap/measPhi) "<<lTrans.gasGap<<"/"<<(lTrans.measPhi ? "si" : "no");
138 // ostr<<" "<<Amg::toString(lTrans.trans);
139 return ostr;
140}
141std::ostream& operator<<(std::ostream& ostr, const TgcChamber& chamb) {
142 static const std::map<int, std::string> stationDict{
143 {41, "T1F"}, {42, "T1E"},
144 {43, "T2F"}, {44, "T2E"},
145 {45, "T3F"}, {46, "T3E"},
146 {47, "T4F"}, {48, "T4E"},
147 };
148 ostr<<"tech: "<<chamb.techName<<", ";
149 ostr<<"eta: "<<std::setfill(' ')<<std::setw(2)<<chamb.eta<<", ";
150 ostr<<"phi: "<<std::setfill('0')<<std::setw(2)<<chamb.phi<<", ";
151 ostr<<"stName: "<<stationDict.at(chamb.stIdx);
152 ostr<<std::setw(-1);
153 return ostr;
154}
155
156
157std::set<TgcChamber> readTreeDump(const std::string& inputFile) {
158 std::set<TgcChamber> to_ret{};
159 std::cout<<"Read the Tgc geometry tree dump from "<<inputFile<<std::endl;
160 std::unique_ptr<TFile> inFile{TFile::Open(inputFile.c_str())};
161 if (!inFile || !inFile->IsOpen()) {
162 std::cerr<<"runTgcComparison() "<<__LINE__<<": Failed to open "<<inputFile<<std::endl;
163 return to_ret;
164 }
165 TTreeReader treeReader("TgcGeoModelTree", inFile.get());
166 if (treeReader.IsInvalid()) {
167 std::cerr<<"runTgcComparison() "<<__LINE__<<": The file "<<inputFile<<" does not contain the 'TgcGeoModelTree'"<<std::endl;
168 return to_ret;
169 }
171 TTreeReaderValue<unsigned short> stationIndex{treeReader, "stationIndex"};
172 TTreeReaderValue<short> stationEta{treeReader, "stationEta"};
173 TTreeReaderValue<short> stationPhi{treeReader, "stationPhi"};
174 TTreeReaderValue<std::string> stationDesign{treeReader, "stationDesign"};
175 TTreeReaderValue<uint8_t> nGasGaps{treeReader, "nGasGaps"};
176
177 TTreeReaderValue<float> shortWidth{treeReader, "ChamberWidthS"};
178 TTreeReaderValue<float> longWidth{treeReader, "ChamberWidthL"};
179 TTreeReaderValue<float> height{treeReader, "ChamberHeight"};
180 TTreeReaderValue<float> thickness{treeReader, "ChamberThickness"};
182 TTreeReaderValue<std::vector<float>> geoModelTransformX{treeReader, "GeoModelTransformX"};
183 TTreeReaderValue<std::vector<float>> geoModelTransformY{treeReader, "GeoModelTransformY"};
184 TTreeReaderValue<std::vector<float>> geoModelTransformZ{treeReader, "GeoModelTransformZ"};
185
186 TTreeReaderValue<std::vector<float>> alignableNodeX{treeReader, "AlignableNodeX"};
187 TTreeReaderValue<std::vector<float>> alignableNodeY{treeReader, "AlignableNodeY"};
188 TTreeReaderValue<std::vector<float>> alignableNodeZ{treeReader, "AlignableNodeZ"};
189
190
191 TTreeReaderValue<std::vector<float>> gangCenterX{treeReader, "gangCenterX"};
192 TTreeReaderValue<std::vector<float>> gangCenterY{treeReader, "gangCenterY"};
193 TTreeReaderValue<std::vector<float>> gangCenterZ{treeReader, "gangCenterZ"};
194
195 TTreeReaderValue<std::vector<float>> gangLocalPosX{treeReader, "gangLocalPosX"};
196 TTreeReaderValue<std::vector<float>> gangLocalPosY{treeReader, "gangLocalPosY"};
197
198
199 TTreeReaderValue<std::vector<float>> stripCenterX{treeReader, "stripCenterX"};
200 TTreeReaderValue<std::vector<float>> stripCenterY{treeReader, "stripCenterY"};
201 TTreeReaderValue<std::vector<float>> stripCenterZ{treeReader, "stripCenterZ"};
202
203 TTreeReaderValue<std::vector<float>> stripBottomX{treeReader, "stripBottomX"};
204 TTreeReaderValue<std::vector<float>> stripBottomY{treeReader, "stripBottomY"};
205 TTreeReaderValue<std::vector<float>> stripBottomZ{treeReader, "stripBottomZ"};
206
207 TTreeReaderValue<std::vector<float>> stripTopX{treeReader, "stripTopX"};
208 TTreeReaderValue<std::vector<float>> stripTopY{treeReader, "stripTopY"};
209 TTreeReaderValue<std::vector<float>> stripTopZ{treeReader, "stripTopZ"};
210
211 TTreeReaderValue<std::vector<float>> stripLocalCenterX{treeReader, "stripLocalCenterX"};
212 TTreeReaderValue<std::vector<float>> stripLocalCenterY{treeReader, "stripLocalCenterY"};
213 TTreeReaderValue<std::vector<float>> stripLocalBottomX{treeReader, "stripLocalBottomX"};
214 TTreeReaderValue<std::vector<float>> stripLocalBottomY{treeReader, "stripLocalBottomY"};
215 TTreeReaderValue<std::vector<float>> stripLocalTopX{treeReader, "stripLocalTopX"};
216 TTreeReaderValue<std::vector<float>> stripLocalTopY{treeReader, "stripLocalTopY"};
217
218 TTreeReaderValue<std::vector<uint8_t>> stripGasGap{treeReader, "stripGasGap"};
219 TTreeReaderValue<std::vector<unsigned int>> stripNum{treeReader, "stripNumber"};
220
221
222 TTreeReaderValue<std::vector<uint8_t>> gangGasGap{treeReader, "gangGasGap"};
223 TTreeReaderValue<std::vector<unsigned int>> gangNum{treeReader, "gangNumber"};
224 TTreeReaderValue<std::vector<uint8_t>> gangNumWires{treeReader, "gangNumWires"};
225 TTreeReaderValue<std::vector<float>> gangLength{treeReader, "gangLength"};
226
227 TTreeReaderValue<std::vector<float>> layerCol0Theta{treeReader, "layerLinearCol0Theta"};
228 TTreeReaderValue<std::vector<float>> layerCol0Phi{treeReader, "layerLinearCol0Phi"};
229
230 TTreeReaderValue<std::vector<float>> layerCol1Theta{treeReader, "layerLinearCol1Theta"};
231 TTreeReaderValue<std::vector<float>> layerCol1Phi{treeReader, "layerLinearCol1Phi"};
232
233 TTreeReaderValue<std::vector<float>> layerCol2Theta{treeReader, "layerLinearCol2Theta"};
234 TTreeReaderValue<std::vector<float>> layerCol2Phi{treeReader, "layerLinearCol2Phi"};
235
236 TTreeReaderValue<std::vector<float>> layerTransX{treeReader, "layerTranslationX"};
237 TTreeReaderValue<std::vector<float>> layerTransY{treeReader, "layerTranslationY"};
238 TTreeReaderValue<std::vector<float>> layerTransZ{treeReader, "layerTranslationZ"};
239
240 TTreeReaderValue<std::vector<bool>> layerMeasPhi{treeReader,"layerMeasPhi"};
241 TTreeReaderValue<std::vector<uint8_t>> layerNumber{treeReader,"layerNumber"};
242
243 TTreeReaderValue<std::vector<float>> layShortWidth{treeReader,"layerWidthS"};
244 TTreeReaderValue<std::vector<float>> layLongWidth{treeReader,"layerWidthL"};
245 TTreeReaderValue<std::vector<float>> layHeight{treeReader, "layerHeight"};
246 TTreeReaderValue<std::vector<uint16_t>> layerNumWires{treeReader, "layerNumWires"};
247
248 while (treeReader.Next()) {
249 TgcChamber newchamber{};
250
251 newchamber.stIdx = (*stationIndex);
252 newchamber.eta = (*stationEta);
253 newchamber.phi = (*stationPhi);
254 newchamber.techName = (*stationDesign);
255 newchamber.shortWidth = (*shortWidth);
256 newchamber.longWidth= (*longWidth);
257 newchamber.height = (*height);
258 newchamber.thickness = (*thickness);
259 newchamber.nGasGaps = (*nGasGaps);
260 Amg::Vector3D geoTrans{(*geoModelTransformX)[0], (*geoModelTransformY)[0], (*geoModelTransformZ)[0]};
261 Amg::RotationMatrix3D geoRot{Amg::RotationMatrix3D::Identity()};
262 geoRot.col(0) = Amg::Vector3D((*geoModelTransformX)[1], (*geoModelTransformY)[1], (*geoModelTransformZ)[1]);
263 geoRot.col(1) = Amg::Vector3D((*geoModelTransformX)[2], (*geoModelTransformY)[2], (*geoModelTransformZ)[2]);
264 geoRot.col(2) = Amg::Vector3D((*geoModelTransformX)[3], (*geoModelTransformY)[3], (*geoModelTransformZ)[3]);
265 newchamber.geoModelTransform = Amg::getTransformFromRotTransl(std::move(geoRot), std::move(geoTrans));
266
267 geoRot.col(0) = Amg::Vector3D((*alignableNodeX)[1], (*alignableNodeY)[1], (*alignableNodeZ)[1]);
268 geoRot.col(1) = Amg::Vector3D((*alignableNodeX)[2], (*alignableNodeY)[2], (*alignableNodeZ)[2]);
269 geoRot.col(2) = Amg::Vector3D((*alignableNodeX)[3], (*alignableNodeY)[3], (*alignableNodeZ)[3]);
270 geoTrans = Amg::Vector3D{(*alignableNodeX)[0], (*alignableNodeY)[0], (*alignableNodeZ)[0]};
271 newchamber.alignableTransform = Amg::getTransformFromRotTransl(std::move(geoRot), std::move(geoTrans));
272
273
274 for (size_t g = 0; g < gangGasGap->size(); ++g) {
275 TgcChamber::WireGang newGang{};
276 newGang.gasGap = (*gangGasGap)[g];
277 newGang.number = (*gangNum)[g];
278 newGang.numWires =(*gangNumWires)[g];
279 newGang.position = Amg::Vector3D{(*gangCenterX)[g], (*gangCenterY)[g], (*gangCenterZ)[g]};
280 newGang.localPos = Amg::Vector2D{(*gangLocalPosX)[g], (*gangLocalPosY)[g]};
281 newGang.length = (*gangLength)[g];
282 auto insert_itr = newchamber.etaWires.insert(std::move(newGang));
283 if (!insert_itr.second) {
284 std::stringstream err{};
285 err<<"runTgcComparison() "<<__LINE__<<": The wire "<<(*insert_itr.first)
286 <<" has already been inserted. "<<std::endl;
287 throw std::runtime_error(err.str());
288 }
289 }
290
291 for (size_t s = 0; s < stripNum->size(); ++s) {
293 strip.gasGap = (*stripGasGap)[s];
294 strip.number = (*stripNum) [s];
295
296 strip.globCenter = Amg::Vector3D{(*stripCenterX)[s], (*stripCenterY)[s], (*stripCenterZ)[s]};
297 strip.locCenter = Amg::Vector2D{(*stripLocalCenterX)[s], (*stripLocalCenterY)[s]};
298
299 strip.globBottom = Amg::Vector3D{(*stripBottomX)[s], (*stripBottomY)[s], (*stripBottomZ)[s]};
300 strip.locBottom = Amg::Vector2D{(*stripLocalBottomX)[s], (*stripLocalBottomY)[s]};
301
302 strip.globTop = Amg::Vector3D{(*stripTopX)[s], (*stripTopY)[s], (*stripTopZ)[s]};
303 strip.locTop = Amg::Vector2D{(*stripLocalTopX)[s], (*stripLocalTopY)[s]};
304
305 auto insert_itr = newchamber.strips.insert(std::move(strip));
306 if (!insert_itr.second) {
307 std::stringstream err{};
308 err<<"runTgcComparison() "<<__LINE__<<": The strip "<<(*insert_itr.first)
309 <<" has already been inserted. "<<std::endl;
310 throw std::runtime_error(err.str());
311 }
312 }
313 for (size_t l = 0 ; l < layerMeasPhi->size(); ++l) {
314 Amg::RotationMatrix3D layRot{Amg::RotationMatrix3D::Identity()};
315 layRot.col(0) = makeDir((*layerCol0Theta)[l], (*layerCol0Phi)[l]);
316 layRot.col(1) = makeDir((*layerCol1Theta)[l], (*layerCol1Phi)[l]);
317 layRot.col(2) = makeDir((*layerCol2Theta)[l], (*layerCol2Phi)[l]);
318 Amg::Vector3D trans{(*layerTransX)[l],(*layerTransY)[l],(*layerTransZ)[l]};
319 TgcChamber::LayerTrans layTrans{};
320 layTrans.trans = Amg::getTransformFromRotTransl(std::move(layRot), std::move(trans));
321 layTrans.gasGap = (*layerNumber)[l];
322 layTrans.measPhi = (*layerMeasPhi)[l];
323 layTrans.shortWidth = (*layShortWidth)[l];
324 layTrans.longWidth = (*layLongWidth)[l];
325 layTrans.height = (*layHeight)[l];
326 layTrans.numWires = (*layerNumWires)[l];
327 auto insert_itr = newchamber.transforms.insert(std::move(layTrans));
328 if (!insert_itr.second) {
329 std::stringstream err{};
330 err<<"runTgcComparison() "<<__LINE__<<": The layer transformation "<<(*insert_itr.first)
331 <<" has already been inserted. "<<std::endl;
332 throw std::runtime_error(err.str());
333 }
334 }
335
336 auto insert_itr = to_ret.insert(std::move(newchamber));
337 if (!insert_itr.second) {
338 std::stringstream err{};
339 err<<"runTgcComparison() "<<__LINE__<<": The chamber "<<(*insert_itr.first)
340 <<" has already been inserted. "<<std::endl;
341 throw std::runtime_error(err.str());
342 }
343 }
344 return to_ret;
345}
346
347#define TEST_BASICPROP(attribute, propName) \
348 if (std::abs(1.*test.attribute - 1.*ref.attribute) > tolerance) { \
349 std::cerr<<"runTgcComparison() "<<__LINE__<<": The chamber "<<test \
350 <<" differs w.r.t "<<propName<<" "<< ref.attribute \
351 <<" (ref) vs. " <<test.attribute << " (test)" << std::endl; \
352 chambOk = false; \
353 }
354
355#define TEST_LAYPROP(attribute, propName) \
356 if (std::abs(1.*refTrans.attribute - 1.*testTrans.attribute) > tolerance) { \
357 std::cerr<<"runTgcComparison() "<<__LINE__<<": The chamber "<<test \
358 <<" differs in "<<refTrans<<" w.r.t. "<<propName<<". " \
359 <<refTrans.attribute<<" (ref) vs. "<<testTrans.attribute \
360 <<" (test), delta: "<<(refTrans.attribute - testTrans.attribute) \
361 <<std::endl; \
362 chambOk = false; \
363 }
364
365int main1( int argc, char** argv ) {
366 std::string refFile{}, testFile{};
367
368 for (int arg = 1; arg < argc; ++arg) {
369 std::string the_arg{argv[arg]};
370 if (the_arg == "--refFile" && arg +1 < argc) {
371 refFile = std::string{argv[arg+1]};
372 ++arg;
373 } else if (the_arg == "--testFile" && arg + 1 < argc) {
374 testFile = std::string{argv[arg+1]};
375 ++arg;
376 }
377 }
378 if (refFile.empty()) {
379 std::cerr<<"Please parse the path of the reference file via --refFile "<<std::endl;
380 return EXIT_FAILURE;
381 }
382 if (testFile.empty()) {
383 std::cerr<<"Please parse the path of the test file via --testFile "<<std::endl;
384 return EXIT_FAILURE;
385 }
387 if (!refFile.starts_with( "root://")) refFile = PathResolver::FindCalibFile(refFile);
388 if (!testFile.starts_with( "root://")) testFile = PathResolver::FindCalibFile(testFile);
389
390 const std::set<TgcChamber> refChambers = readTreeDump(refFile);
391 if (refChambers.empty()) {
392 std::cerr<<"runTgcComparison() "<<__LINE__<<": No chambers in reference file."<<std::endl;
393 return EXIT_FAILURE;
394 }
395 const std::set<TgcChamber> testChambers = readTreeDump(testFile);
396 if (testChambers.empty()) {
397 std::cerr<<"runTgcComparison() "<<__LINE__<<": No chambers in test file."<<std::endl;
398 return EXIT_FAILURE;
399 }
400
401 int retCode{EXIT_SUCCESS};
402 for (const TgcChamber& ref : refChambers) {
403 std::set<TgcChamber>::const_iterator test_itr = testChambers.find(ref);
404 if (test_itr == testChambers.end()) {
405 std::cerr<<"runTgcComparison() "<<__LINE__<<": The chamber "<<ref<<" is not in the test geometry. "<<std::endl;
406 retCode = EXIT_FAILURE;
407 continue;
408 }
409 const TgcChamber& test{*test_itr};
410 bool chambOk{true};
412 TEST_BASICPROP(nGasGaps, "number of gasgaps");
413 TEST_BASICPROP(thickness, "chamber thickness");
414 TEST_BASICPROP(shortWidth, "chamber short width");
415 TEST_BASICPROP(longWidth, "chamber long width");
416 TEST_BASICPROP(height, "chamber height");
417
418 const Amg::Transform3D alignableDistort = test.alignableTransform.inverse()*(ref.alignableTransform );
419 if (!Amg::doesNotDeform(alignableDistort) || alignableDistort.translation().mag() > tolerance) {
420 std::cerr<<"runTgcComparison() "<<__LINE__<<": The alignable nodes are at differnt places for "
421 <<ref<<". " <<GeoTrf::toString(alignableDistort, true)<<std::endl;
422 chambOk = false;
423 }
424
425 chambOk = true;
427 for (const TgcChamber::LayerTrans& refTrans : ref.transforms) {
428 std::set<TgcChamber::LayerTrans>::const_iterator l_test_itr = test.transforms.find(refTrans);
429 if (l_test_itr == test.transforms.end()) {
430 std::cerr<<"runTgcComparison() "<<__LINE__<<": The layer "<<refTrans
431 <<" in chamber "<<ref <<" is not part of the test geometry. "<<std::endl;
432 chambOk = false;
433 break;
434 }
435 const TgcChamber::LayerTrans& testTrans{*l_test_itr};
437 const Amg::Transform3D layTest = testTrans.trans.inverse() * refTrans.trans;
438 if (!Amg::doesNotDeform(layTest)) {
439 std::cerr<<"runTgcComparison() "<<__LINE__<<": In "<<ref<<" "<<refTrans
440 <<", the transformations are orientated diffrently "<<Amg::toString(layTest)<<std::endl;
441 chambOk = false;
442 break;
443 }
444 if (layTest.translation().mag() > tolerance) {
445 std::cerr<<"runTgcComparison() "<<__LINE__<<": The transformations in layer "<<refTrans<<", "
446 <<ref<<" are pointing to different reference points "<<Amg::toString(layTest.translation(),2)<<std::endl;
447 chambOk = false;
448 break;
449 }
450 TEST_LAYPROP(numWires, "number of wires");
454 }
455 if (!chambOk) continue;
456 for (const TgcChamber::RadialStrip& refStrip : ref.strips) {
457 std::set<TgcChamber::RadialStrip>::const_iterator s_test_itr = test.strips.find(refStrip);
458 if (s_test_itr == test.strips.end()) {
459 std::cerr<<"runTgcComparison() "<<__LINE__<<": In chamber "<<ref
460 <<" "<<refStrip<<" is not part of the test geometry. "<<std::endl;
461 chambOk = false;
462 continue;
463 }
464 const TgcChamber::RadialStrip& testStrip{*s_test_itr};
465 if ( (testStrip.locCenter - refStrip.locCenter).mag() > tolerance) {
466 std::cerr<<"runTgcComparison() "<<__LINE__<<": In "<<ref<<", "
467 <<refStrip<<" should be located at "<<Amg::toString(refStrip.locCenter, 1)<<
468 ". Currently, it is at "<<Amg::toString(testStrip.locCenter, 1)<<std::endl;
469 chambOk = false;
470 continue;
471 }
472
473 if ( (testStrip.globCenter - refStrip.globCenter).mag() > tolerance) {
474 std::cerr<<"runTgcComparison() "<<__LINE__<<": In "<<ref
475 <<" " <<refStrip<<" should be located at "<<Amg::toString(refStrip.globCenter, 1)<<
476 ". Currently, it is at "<<Amg::toString(testStrip.globCenter, 1)<<std::endl;
477 chambOk = false;
478 }
479 }
480 if (!chambOk) {
481 retCode = EXIT_FAILURE;
482 continue;
483 }
485 for (const TgcChamber::WireGang& refGang : ref.etaWires) {
486 std::set<TgcChamber::WireGang>::const_iterator test_itr = test.etaWires.find(refGang);
487 if (test_itr == test.etaWires.end()) {
488 std::cerr<<"runTgcComparison() "<<__LINE__<<": "<<refGang<<" is not part of "
489 <<ref<<std::endl;
490 retCode = EXIT_FAILURE;
491 continue;
492 }
493 const TgcChamber::WireGang& testGang{*test_itr};
494 if (testGang.numWires != refGang.numWires) {
495 std::cerr<<"runTgcComparison() "<<__LINE__<<": "<<refGang<<" in "<<ref
496 <<" has different wires. "<<refGang.numWires<<" vs. "
497 <<testGang.numWires<<std::endl;
498 chambOk = false;
499 }
500
501 const Amg::Vector2D lDiffPos = refGang.localPos - testGang.localPos;
502 constexpr double halfPitch = 0.9 * Gaudi::Units::mm;
503 if (lDiffPos.mag() - halfPitch > tolerance) {
504 std::cerr<<"runTgcComparison() "<<__LINE__<<": In "<<ref<<" "<<testGang
505 <<" should be located at "<<Amg::toString(refGang.localPos,2)
506 <<" but is found at "<<Amg::toString(testGang.localPos, 2)
507 <<", mag="<<lDiffPos.mag()
508 <<" "<<lDiffPos.mag() / 1.8 <<std::endl;
509 chambOk = false;
510 continue;
511 }
512
513
514 const Amg::Vector3D diffPos = refGang.position - testGang.position;
515 if (diffPos.mag() - halfPitch > tolerance) {
516 std::cerr<<"runTgcComparison() "<<__LINE__<<": In "<<ref<<" "<<testGang
517 <<" is displaced by "<<Amg::toString(diffPos, 2)<<", mag="<<diffPos.mag()<<std::endl;
518 chambOk = false;
519 continue;
520 }
521
522 if (false && std::abs(refGang.length - testGang.length) > tolerance) {
523 std::cerr<<"runTgcComparison() "<<__LINE__<<": In "<<ref<<" "<<testGang<<" different length detected "
524 <<refGang.length<<" (ref) vs. "<<testGang.length<<" (test). Delta: "
525 <<(refGang.length - testGang.length) <<std::endl;
526 chambOk = false;
527 }
528 }
529 if (!chambOk) {
530 retCode = EXIT_FAILURE;
531 } else {
532 std::cout<<"runTgcComparison() "<<__LINE__<<": Agreement between ref & test for "<<ref<<std::endl;
533 }
534 }
535 return retCode;
536}
537
538
539int main (int argc, char** argv )
540{
541 int ret = 1;
542 try {
543 ret = main1 (argc, argv);
544 }
545 catch (const std::exception& e) {
546 std::cerr << e.what() << "\n";
547 }
548 return ret;
549}
const std::regex ref(r_ef)
Scalar phi() const
phi method
Scalar theta() const
theta method
static std::string FindCalibFile(const std::string &logical_file_name)
int main()
Definition hello.cxx:18
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
bool doesNotDeform(const Amg::Transform3D &trans)
Checks whether the linear part of the transformation rotates or stetches any of the basis vectors.
Amg::Transform3D getTransformFromRotTransl(Amg::RotationMatrix3D rot, Amg::Vector3D transl_vec)
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
#define TEST_BASICPROP(attribute, propName)
#define TEST_LAYPROP(attribute, propName)
std::set< TgcChamber > readTreeDump(const std::string &inputFile)
std::ostream & operator<<(std::ostream &ostr, const TgcChamber::WireGang &gang)
Amg::Vector3D makeDir(const double theta, const double phi)
Helper macro to compare the output from the readout geometry dumps: python -m MuonGeoModelTest....
bool operator<(const LayerTrans &other) const
Amg::Vector3D globCenter
Strip center.
bool operator<(const RadialStrip &other) const
bool operator<(const WireGang &other) const
Helper struct to represent a full Rpc chamber.
TgcChamber()=default
Default constructor.
std::set< WireGang > etaWires
std::set< RadialStrip > strips
std::string techName
Amg::Transform3D alignableTransform
Transformation of the underlying Alignable node.
Amg::Transform3D geoModelTransform
Transformation of the underlying GeoModel element.
unsigned stIdx
Identifier fields stationIndex / stationEta / stationPhi.
bool operator<(const TgcChamber &other) const
Sorting operator to insert the object into std::set.
std::set< LayerTrans > transforms
int main1()
Definition testRead.cxx:68