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