14 #include <GaudiKernel/SystemOfUnits.h>
25 #include <TTreeReader.h>
42 int stationMultilayer{0};
47 if (stationIndex !=
other.stationIndex)
return stationIndex <
other.stationIndex;
48 if (stationEta !=
other.stationEta)
return stationEta <
other.stationEta;
49 if (stationPhi !=
other.stationPhi)
return stationPhi <
other.stationPhi;
50 return stationMultilayer <
other.stationMultilayer;
62 double sChamberLength{0.f};
63 double lChamberLength{0.f};
64 double chamberHeight{0.f};
65 double sGapLength{0.f};
66 double lGapLength{0.f};
67 double gapHeight{0.f};
75 double wirePitch{0.f};
76 double wireWidth{0.f};
80 unsigned int numStrips{0};
81 double stripPitch{0.f};
82 double stripWidth{0.f};
92 unsigned int channelNumber{0};
96 unsigned int channelType{0};
102 if (channelType !=
other.channelType)
return channelType <
other.channelType;
103 return channelNumber <
other.channelNumber;
108 double sPadLength{0.f};
109 double lPadLength{0.f};
110 double anglePadPhi{0.f};
111 double beamlineRadius{0.f};
152 if (padPhi !=
other.padPhi)
return padPhi <
other.padPhi;
153 return padEta <
other.padEta;
169 std::set<sTgcPad> pads{};
178 static const std::map<int, std::string> stationDict{
179 {57,
"STS"}, {58,
"STL"}
186 ostr<<
"channel (gasGap/number): ";
188 ostr<<
channel.channelNumber<<
", ";
189 ostr<<
channel.channelType<<
", ";
196 ostr<<
"pad (gasGap/padEta/padPhi): ";
214 ostr<<
"stgclayer (gasGap/channelType): ";
215 ostr<<
layer.gasGap<<
", ";
221 std::set<sTgcChamber> to_ret{};
222 std::cout<<
"Read the sTgc geometry tree dump from "<<
inputFile<<std::endl;
225 std::cerr<<__FILE__<<
":"<<__LINE__<<
" Failed to open "<<
inputFile<<std::endl;
230 std::cerr<<__FILE__<<
":"<<__LINE__<<
" The file "<<
inputFile<<
" does not contain the 'sTgcGeoModelTree'"<<std::endl;
235 TTreeReaderValue<short> stationIndex{
treeReader,
"stationIndex"};
236 TTreeReaderValue<short> stationEta{
treeReader,
"stationEta"};
237 TTreeReaderValue<short> stationPhi{
treeReader,
"stationPhi"};
238 TTreeReaderValue<short> stationMultilayer{
treeReader,
"stationMultilayer"};
239 TTreeReaderValue<std::string> chamberDesign{
treeReader,
"chamberDesign"};
243 TTreeReaderValue<float> yCutout{
treeReader,
"yCutout"};
244 TTreeReaderValue<float> gasTck{
treeReader,
"gasTck"};
246 TTreeReaderValue<float> sChamberLength{
treeReader,
"sChamberLength"};
247 TTreeReaderValue<float> lChamberLength{
treeReader,
"lChamberLength"};
248 TTreeReaderValue<float> chamberHeight{
treeReader,
"chamberHeight"};
250 TTreeReaderValue<float> sGapLength{
treeReader,
"sGapLength"};
251 TTreeReaderValue<float> lGapLength{
treeReader,
"lGapLength"};
252 TTreeReaderValue<float> gapHeight{
treeReader,
"gapHeight"};
255 TTreeReaderValue<std::vector<uint>> numWires{
treeReader,
"numWires"};
256 TTreeReaderValue<std::vector<uint>> firstWireGroupWidth{
treeReader,
"firstWireGroupWidth"};
257 TTreeReaderValue<std::vector<uint>> numWireGroups{
treeReader,
"numWireGroups"};
258 TTreeReaderValue<std::vector<float>> wireCutout{
treeReader,
"wireCutout"};
259 TTreeReaderValue<float> wirePitch{
treeReader,
"wirePitch"};
260 TTreeReaderValue<float> wireWidth{
treeReader,
"wireWidth"};
261 TTreeReaderValue<uint> wireGroupWidth{
treeReader,
"wireGroupWidth"};
263 TTreeReaderValue<std::vector<float>> globalWireGroupPosX{
treeReader,
"globalWireGroupPosX"};
264 TTreeReaderValue<std::vector<float>> globalWireGroupPosY{
treeReader,
"globalWireGroupPosY"};
265 TTreeReaderValue<std::vector<float>> globalWireGroupPosZ{
treeReader,
"globalWireGroupPosZ"};
267 TTreeReaderValue<std::vector<float>> localWireGroupPosX{
treeReader,
"localWireGroupPosX"};
268 TTreeReaderValue<std::vector<float>> localWireGroupPosY{
treeReader,
"localWireGroupPosY"};
270 TTreeReaderValue<std::vector<uint8_t>> wireGroupNum{
treeReader,
"wireGroupNum"};
271 TTreeReaderValue<std::vector<uint8_t>> wireGroupGasGap{
treeReader,
"wireGroupGasGap"};
274 TTreeReaderValue<uint> numStrips{
treeReader,
"numStrips"};
275 TTreeReaderValue<float> stripPitch{
treeReader,
"stripPitch"};
276 TTreeReaderValue<float> stripWidth{
treeReader,
"stripWidth"};
278 TTreeReaderValue<std::vector<float>> globalStripPosX{
treeReader,
"globalStripPosX"};
279 TTreeReaderValue<std::vector<float>> globalStripPosY{
treeReader,
"globalStripPosY"};
280 TTreeReaderValue<std::vector<float>> globalStripPosZ{
treeReader,
"globalStripPosZ"};
282 TTreeReaderValue<std::vector<float>> localStripPosX{
treeReader,
"localStripPosX"};
283 TTreeReaderValue<std::vector<float>> localStripPosY{
treeReader,
"localStripPosY"};
285 TTreeReaderValue<std::vector<uint>> stripNum{
treeReader,
"stripNumber"};
286 TTreeReaderValue<std::vector<uint8_t>> stripGasGap{
treeReader,
"stripGasGap"};
287 TTreeReaderValue<std::vector<float>> stripLengths{
treeReader,
"stripLengths"};
290 TTreeReaderValue<float> sPadLength{
treeReader,
"sPadLength"};
291 TTreeReaderValue<float> lPadLength{
treeReader,
"lPadLength"};
292 TTreeReaderValue<float> anglePadPhi{
treeReader,
"anglePadPhi"};
293 TTreeReaderValue<float> beamlineRadius{
treeReader,
"beamlineRadius"};
294 TTreeReaderValue<std::vector<uint>> numPads{
treeReader,
"numPads"};
295 TTreeReaderValue<std::vector<uint>> numPadEta{
treeReader,
"numPadEta"};
296 TTreeReaderValue<std::vector<uint>> numPadPhi{
treeReader,
"numPadPhi"};
297 TTreeReaderValue<std::vector<float>> firstPadHeight{
treeReader,
"firstPadHeight"};
298 TTreeReaderValue<std::vector<float>> padHeight{
treeReader,
"padHeight"};
299 TTreeReaderValue<std::vector<float>> padPhiShift{
treeReader,
"padPhiShift"};
300 TTreeReaderValue<std::vector<float>> firstPadPhiDiv{
treeReader,
"firstPadPhiDiv"};
302 TTreeReaderValue<std::vector<float>> globalPadCornerBRX{
treeReader,
"globalPadCornerBRX"};
303 TTreeReaderValue<std::vector<float>> globalPadCornerBRY{
treeReader,
"globalPadCornerBRY"};
304 TTreeReaderValue<std::vector<float>> globalPadCornerBRZ{
treeReader,
"globalPadCornerBRZ"};
306 TTreeReaderValue<std::vector<float>> globalPadCornerBLX{
treeReader,
"globalPadCornerBLX"};
307 TTreeReaderValue<std::vector<float>> globalPadCornerBLY{
treeReader,
"globalPadCornerBLY"};
308 TTreeReaderValue<std::vector<float>> globalPadCornerBLZ{
treeReader,
"globalPadCornerBLZ"};
310 TTreeReaderValue<std::vector<float>> globalPadCornerTRX{
treeReader,
"globalPadCornerTRX"};
311 TTreeReaderValue<std::vector<float>> globalPadCornerTRY{
treeReader,
"globalPadCornerTRY"};
312 TTreeReaderValue<std::vector<float>> globalPadCornerTRZ{
treeReader,
"globalPadCornerTRZ"};
314 TTreeReaderValue<std::vector<float>> globalPadCornerTLX{
treeReader,
"globalPadCornerTLX"};
315 TTreeReaderValue<std::vector<float>> globalPadCornerTLY{
treeReader,
"globalPadCornerTLY"};
316 TTreeReaderValue<std::vector<float>> globalPadCornerTLZ{
treeReader,
"globalPadCornerTLZ"};
318 TTreeReaderValue<std::vector<float>> globalPadPosX{
treeReader,
"globalPadPosX"};
319 TTreeReaderValue<std::vector<float>> globalPadPosY{
treeReader,
"globalPadPosY"};
320 TTreeReaderValue<std::vector<float>> globalPadPosZ{
treeReader,
"globalPadPosZ"};
322 TTreeReaderValue<std::vector<float>> localPadCornerBRX{
treeReader,
"localPadCornerBRX"};
323 TTreeReaderValue<std::vector<float>> localPadCornerBRY{
treeReader,
"localPadCornerBRY"};
325 TTreeReaderValue<std::vector<float>> localPadCornerBLX{
treeReader,
"localPadCornerBLX"};
326 TTreeReaderValue<std::vector<float>> localPadCornerBLY{
treeReader,
"localPadCornerBLY"};
328 TTreeReaderValue<std::vector<float>> localPadCornerTRX{
treeReader,
"localPadCornerTRX"};
329 TTreeReaderValue<std::vector<float>> localPadCornerTRY{
treeReader,
"localPadCornerTRY"};
331 TTreeReaderValue<std::vector<float>> localPadCornerTLX{
treeReader,
"localPadCornerTLX"};
332 TTreeReaderValue<std::vector<float>> localPadCornerTLY{
treeReader,
"localPadCornerTLY"};
334 TTreeReaderValue<std::vector<float>> localPadPosX{
treeReader,
"localPadPosX"};
335 TTreeReaderValue<std::vector<float>> localPadPosY{
treeReader,
"localPadPosY"};
337 TTreeReaderValue<std::vector<float>> hitPositionX{
treeReader,
"hitPositionX"};
338 TTreeReaderValue<std::vector<float>> hitPositionY{
treeReader,
"hitPositionY"};
339 TTreeReaderValue<std::vector<int>> padNumber{
treeReader,
"padNumber"};
341 TTreeReaderValue<std::vector<uint8_t>> padGasGap{
treeReader,
"padGasGap"};
342 TTreeReaderValue<std::vector<uint>> padEta{
treeReader,
"padEtaNumber"};
343 TTreeReaderValue<std::vector<uint>> padPhi{
treeReader,
"padPhiNumber"};
346 TTreeReaderValue<std::vector<float>> geoModelTransformX{
treeReader,
"GeoModelTransformX"};
347 TTreeReaderValue<std::vector<float>> geoModelTransformY{
treeReader,
"GeoModelTransformY"};
348 TTreeReaderValue<std::vector<float>> geoModelTransformZ{
treeReader,
"GeoModelTransformZ"};
350 TTreeReaderValue<std::vector<float>> stripRotCol1X{
treeReader,
"stripRotLinearCol1X"};
351 TTreeReaderValue<std::vector<float>> stripRotCol1Y{
treeReader,
"stripRotLinearCol1Y"};
352 TTreeReaderValue<std::vector<float>> stripRotCol1Z{
treeReader,
"stripRotLinearCol1Z"};
354 TTreeReaderValue<std::vector<float>> stripRotCol2X{
treeReader,
"stripRotLinearCol2X"};
355 TTreeReaderValue<std::vector<float>> stripRotCol2Y{
treeReader,
"stripRotLinearCol2Y"};
356 TTreeReaderValue<std::vector<float>> stripRotCol2Z{
treeReader,
"stripRotLinearCol2Z"};
358 TTreeReaderValue<std::vector<float>> stripRotCol3X{
treeReader,
"stripRotLinearCol3X"};
359 TTreeReaderValue<std::vector<float>> stripRotCol3Y{
treeReader,
"stripRotLinearCol3Y"};
360 TTreeReaderValue<std::vector<float>> stripRotCol3Z{
treeReader,
"stripRotLinearCol3Z"};
362 TTreeReaderValue<std::vector<float>> stripRotTransX{
treeReader,
"stripRotTranslationX"};
363 TTreeReaderValue<std::vector<float>> stripRotTransY{
treeReader,
"stripRotTranslationY"};
364 TTreeReaderValue<std::vector<float>> stripRotTransZ{
treeReader,
"stripRotTranslationZ"};
366 TTreeReaderValue<std::vector<uint8_t>> stripRotGasGap{
treeReader,
"stripRotGasGap"};
369 TTreeReaderValue<std::vector<float>> wireGroupRotCol1X{
treeReader,
"wireGroupRotLinearCol1X"};
370 TTreeReaderValue<std::vector<float>> wireGroupRotCol1Y{
treeReader,
"wireGroupRotLinearCol1Y"};
371 TTreeReaderValue<std::vector<float>> wireGroupRotCol1Z{
treeReader,
"wireGroupRotLinearCol1Z"};
373 TTreeReaderValue<std::vector<float>> wireGroupRotCol2X{
treeReader,
"wireGroupRotLinearCol2X"};
374 TTreeReaderValue<std::vector<float>> wireGroupRotCol2Y{
treeReader,
"wireGroupRotLinearCol2Y"};
375 TTreeReaderValue<std::vector<float>> wireGroupRotCol2Z{
treeReader,
"wireGroupRotLinearCol2Z"};
377 TTreeReaderValue<std::vector<float>> wireGroupRotCol3X{
treeReader,
"wireGroupRotLinearCol3X"};
378 TTreeReaderValue<std::vector<float>> wireGroupRotCol3Y{
treeReader,
"wireGroupRotLinearCol3Y"};
379 TTreeReaderValue<std::vector<float>> wireGroupRotCol3Z{
treeReader,
"wireGroupRotLinearCol3Z"};
381 TTreeReaderValue<std::vector<float>> wireGroupRotTransX{
treeReader,
"wireGroupRotTranslationX"};
382 TTreeReaderValue<std::vector<float>> wireGroupRotTransY{
treeReader,
"wireGroupRotTranslationY"};
383 TTreeReaderValue<std::vector<float>> wireGroupRotTransZ{
treeReader,
"wireGroupRotTranslationZ"};
385 TTreeReaderValue<std::vector<uint8_t>> wireGroupRotGasGap{
treeReader,
"wireGroupRotGasGap"};
388 TTreeReaderValue<std::vector<float>> padRotCol1X{
treeReader,
"padRotLinearCol1X"};
389 TTreeReaderValue<std::vector<float>> padRotCol1Y{
treeReader,
"padRotLinearCol1Y"};
390 TTreeReaderValue<std::vector<float>> padRotCol1Z{
treeReader,
"padRotLinearCol1Z"};
392 TTreeReaderValue<std::vector<float>> padRotCol2X{
treeReader,
"padRotLinearCol2X"};
393 TTreeReaderValue<std::vector<float>> padRotCol2Y{
treeReader,
"padRotLinearCol2Y"};
394 TTreeReaderValue<std::vector<float>> padRotCol2Z{
treeReader,
"padRotLinearCol2Z"};
396 TTreeReaderValue<std::vector<float>> padRotCol3X{
treeReader,
"padRotLinearCol3X"};
397 TTreeReaderValue<std::vector<float>> padRotCol3Y{
treeReader,
"padRotLinearCol3Y"};
398 TTreeReaderValue<std::vector<float>> padRotCol3Z{
treeReader,
"padRotLinearCol3Z"};
400 TTreeReaderValue<std::vector<float>> padRotTransX{
treeReader,
"padRotTranslationX"};
401 TTreeReaderValue<std::vector<float>> padRotTransY{
treeReader,
"padRotTranslationY"};
402 TTreeReaderValue<std::vector<float>> padRotTransZ{
treeReader,
"padRotTranslationZ"};
404 TTreeReaderValue<std::vector<uint8_t>> padRotGasGap{
treeReader,
"padRotGasGap"};
411 newchamber.stationEta = (*stationEta);
412 newchamber.stationPhi = (*stationPhi);
413 newchamber.stationMultilayer = (*stationMultilayer);
414 newchamber.design = (*chamberDesign);
417 newchamber.numLayers = (*numLayers);
418 newchamber.yCutout = (*yCutout);
419 newchamber.gasTck = (*gasTck);
422 newchamber.sGapLength = (*sGapLength);
423 newchamber.lGapLength = (*lGapLength);
424 newchamber.gapHeight = (*gapHeight);
426 newchamber.sChamberLength = (*sChamberLength);
427 newchamber.lChamberLength = (*lChamberLength);
428 newchamber.chamberHeight = (*chamberHeight);
431 newchamber.numWires = (*numWires);
432 newchamber.firstWireGroupWidth = (*firstWireGroupWidth);
433 newchamber.numWireGroups = (*numWireGroups);
434 newchamber.wireCutout = (*wireCutout);
435 newchamber.wirePitch = (*wirePitch);
436 newchamber.wireWidth = (*wireWidth);
437 newchamber.wireGroupWidth = (*wireGroupWidth);
440 newchamber.numStrips = (*numStrips);
441 newchamber.stripPitch = (*stripPitch);
442 newchamber.stripWidth = (*stripWidth);
445 newchamber.sPadLength = (*sPadLength);
446 newchamber.lPadLength = (*lPadLength);
447 newchamber.anglePadPhi = (*anglePadPhi);
448 newchamber.beamlineRadius = (*beamlineRadius);
449 newchamber.numPads = (*numPads);
450 newchamber.numPadEta = (*numPadEta);
451 newchamber.numPadPhi = (*numPadPhi);
452 newchamber.firstPadHeight = (*firstPadHeight);
453 newchamber.padHeight = (*padHeight);
454 newchamber.padPhiShift = (*padPhiShift);
455 newchamber.firstPadPhiDiv = (*firstPadPhiDiv);
457 Amg::Vector3D geoTrans{(*geoModelTransformX)[0], (*geoModelTransformY)[0], (*geoModelTransformZ)[0]};
459 geoRot.col(0) =
Amg::Vector3D((*geoModelTransformX)[1], (*geoModelTransformY)[1], (*geoModelTransformZ)[1]);
460 geoRot.col(1) =
Amg::Vector3D((*geoModelTransformX)[2], (*geoModelTransformY)[2], (*geoModelTransformZ)[2]);
461 geoRot.col(2) =
Amg::Vector3D((*geoModelTransformX)[3], (*geoModelTransformY)[3], (*geoModelTransformZ)[3]);
465 for (
size_t wg = 0; wg < globalWireGroupPosX->size(); ++wg){
468 newWireGroup.globalPosition =
Amg::Vector3D{(*globalWireGroupPosX)[wg], (*globalWireGroupPosY)[wg], (*globalWireGroupPosZ)[wg]};
469 newWireGroup.gasGap = (*wireGroupGasGap)[wg];
470 newWireGroup.channelNumber = (*wireGroupNum)[wg];
471 newWireGroup.channelType = 2;
473 if (newWireGroup.channelNumber > 0)
continue;
474 newchamber.channels.insert(std::move(newWireGroup));
478 for (
size_t s = 0;
s < globalStripPosX->size(); ++
s){
481 newStrip.globalPosition =
Amg::Vector3D{(*globalStripPosX)[
s], (*globalStripPosY)[
s], (*globalStripPosZ)[
s]};
482 newStrip.gasGap = (*stripGasGap)[
s];
483 newStrip.channelNumber = (*stripNum)[
s];
484 newStrip.channelType = 1;
485 newStrip.channelLen = (*stripLengths)[
s];
487 if (newStrip.channelNumber > 0)
continue;
488 newchamber.channels.insert(std::move(newStrip));
493 for (
size_t p = 0;
p < globalPadPosX->size(); ++
p){
497 newPad.globalPadCornerBR =
Amg::Vector3D{(*globalPadCornerBRX)[
p], (*globalPadCornerBRY)[
p], (*globalPadCornerBRZ)[
p]};
498 newPad.globalPadCornerBL =
Amg::Vector3D{(*globalPadCornerBLX)[
p], (*globalPadCornerBLY)[
p], (*globalPadCornerBLZ)[
p]};
499 newPad.globalPadCornerTR =
Amg::Vector3D{(*globalPadCornerTRX)[
p], (*globalPadCornerTRY)[
p], (*globalPadCornerTRZ)[
p]};
500 newPad.globalPadCornerTL =
Amg::Vector3D{(*globalPadCornerTLX)[
p], (*globalPadCornerTLY)[
p], (*globalPadCornerTLZ)[
p]};
502 newPad.localPosition =
Amg::Vector2D{(*localPadPosX)[
p], (*localPadPosY)[
p]};
503 newPad.localPadCornerBR =
Amg::Vector2D{(*localPadCornerBRX)[
p], (*localPadCornerBRY)[
p]};
504 newPad.localPadCornerBL =
Amg::Vector2D{(*localPadCornerBLX)[
p], (*localPadCornerBLY)[
p]};
505 newPad.localPadCornerTR =
Amg::Vector2D{(*localPadCornerTRX)[
p], (*localPadCornerTRY)[
p]};
506 newPad.localPadCornerTL =
Amg::Vector2D{(*localPadCornerTLX)[
p], (*localPadCornerTLY)[
p]};
508 newPad.hitPosition =
Amg::Vector2D{(*hitPositionX)[
p], (*hitPositionY)[
p]};
509 newPad.padNumber = (*padNumber)[
p];
510 newPad.gasGap = (*padGasGap)[
p];
511 newPad.padEta = (*padEta)[
p];
512 newPad.padPhi = (*padPhi)[
p];
514 if (newPad.padEta > 1 || newPad.padPhi > 6)
continue;
515 newchamber.pads.insert(std::move(newPad));
518 for (
size_t l = 0;
l < stripRotGasGap->size(); ++
l){
520 stripLayer.
gasGap = (*stripRotGasGap)[
l];
522 stripRot.col(0) =
Amg::Vector3D((*stripRotCol1X)[
l],(*stripRotCol1Y)[
l], (*stripRotCol1Z)[
l]);
523 stripRot.col(1) =
Amg::Vector3D((*stripRotCol2X)[
l],(*stripRotCol2Y)[
l], (*stripRotCol2Z)[
l]);
524 stripRot.col(2) =
Amg::Vector3D((*stripRotCol3X)[
l],(*stripRotCol3Y)[
l], (*stripRotCol3Z)[
l]);
525 Amg::Vector3D layTrans{(*stripRotTransX)[
l], (*stripRotTransY)[
l], (*stripRotTransZ)[
l]};
527 newchamber.layers.insert(std::move(stripLayer));
530 for (
size_t l = 0;
l < wireGroupRotGasGap->size(); ++
l){
532 wireGroupLayer.
gasGap = (*wireGroupRotGasGap)[
l];
534 wireGroupRot.col(0) =
Amg::Vector3D((*wireGroupRotCol1X)[
l],(*wireGroupRotCol1Y)[
l], (*wireGroupRotCol1Z)[
l]);
535 wireGroupRot.col(1) =
Amg::Vector3D((*wireGroupRotCol2X)[
l],(*wireGroupRotCol2Y)[
l], (*wireGroupRotCol2Z)[
l]);
536 wireGroupRot.col(2) =
Amg::Vector3D((*wireGroupRotCol3X)[
l],(*wireGroupRotCol3Y)[
l], (*wireGroupRotCol3Z)[
l]);
537 Amg::Vector3D layTrans{(*wireGroupRotTransX)[
l], (*wireGroupRotTransY)[
l], (*wireGroupRotTransZ)[
l]};
539 newchamber.layers.insert(std::move(wireGroupLayer));
542 for (
size_t l = 0;
l < padRotGasGap->size(); ++
l){
544 padLayer.
gasGap = (*padRotGasGap)[
l];
546 padRot.col(0) =
Amg::Vector3D((*padRotCol1X)[
l],(*padRotCol1Y)[
l], (*padRotCol1Z)[
l]);
547 padRot.col(1) =
Amg::Vector3D((*padRotCol2X)[
l],(*padRotCol2Y)[
l], (*padRotCol2Z)[
l]);
548 padRot.col(2) =
Amg::Vector3D((*padRotCol3X)[
l],(*padRotCol3Y)[
l], (*padRotCol3Z)[
l]);
549 Amg::Vector3D layTrans{(*padRotTransX)[
l], (*padRotTransY)[
l], (*padRotTransZ)[
l]};
551 newchamber.layers.insert(std::move(padLayer));
554 auto insert_itr = to_ret.insert(std::move(newchamber));
555 if (!insert_itr.second) {
556 std::stringstream
err{};
557 err<<__FILE__<<
":"<<__LINE__<<
" The chamber "<<(*insert_itr.first).stationIndex
558 <<
" has already been inserted. "<<std::endl;
559 throw std::runtime_error(
err.str());
562 std::cout<<
"File parsing is finished. Found in total "<<to_ret.size()<<
" readout element dumps "<<std::endl;
566 #define TEST_BASICPROP(attribute, propName) \
567 if (std::abs(1.*test.attribute - 1.*reference.attribute) > tolerance) { \
568 std::cerr<<"sTgcGeoModelComparison() "<<__LINE__<<": The chamber "<<reference \
569 <<" differs w.r.t "<<propName<<" "<< reference.attribute \
570 <<" (ref) vs. " <<test.attribute << " (test)" << std::endl; \
571 chamberOkay = false; \
578 std::string the_arg{
argv[
arg]};
579 if (the_arg ==
"--refFile" &&
arg +1 <
argc) {
580 refFile = std::string{
argv[
arg+1]};
582 }
else if (the_arg ==
"--testFile" &&
arg + 1 <
argc) {
587 if (refFile.empty()) {
588 std::cerr<<
"Please parse the path of the reference file via --refFile "<<std::endl;
592 std::cerr<<
"Please parse the path of the test file via --testFile "<<std::endl;
599 std::set<sTgcChamber> refChambers =
readTreeDump(refFile);
600 if (refChambers.empty()) {
601 std::cerr<<
"The file "<<refFile<<
" should contain at least one chamber "<<std::endl;
605 if (testChambers.empty()) {
606 std::cerr<<
"The file "<<
testFile<<
" should contain at least one chamber "<<std::endl;
609 int return_code = EXIT_SUCCESS;
612 std::set<sTgcChamber>::const_iterator test_itr = testChambers.find(
reference);
614 if (test_itr == testChambers.end()) {
615 std::cerr<<
"The chamber "<<
reference<<
" is not part of the testing "<<std::endl;
616 return_code = EXIT_FAILURE;
619 bool chamberOkay =
true;
627 TEST_BASICPROP(sChamberLength,
"Chamber length on the short side");
628 TEST_BASICPROP(lChamberLength,
"Chamber length on the long side");
636 TEST_BASICPROP(wireGroupWidth,
"number of wires in a normal wiregroup");
641 TEST_BASICPROP(sPadLength,
"gasGap length on the short side for pads and wires");
642 TEST_BASICPROP(lPadLength,
"gasGap length on the long side for pads and wires");
643 TEST_BASICPROP(anglePadPhi,
"angular width of a pad in phi direction");
644 TEST_BASICPROP(beamlineRadius,
"distance from the gapCenter to beamline");
648 for (
const sTgcLayer& refLayer :
reference.layers) {
649 std::set<sTgcLayer>::const_iterator lay_itr =
test.layers.find(refLayer);
650 if (lay_itr ==
test.layers.end()) {
651 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
652 <<refLayer<<
" is not found. "<<std::endl;
656 const sTgcLayer& testLayer{*lay_itr};
660 TEST_BASICPROP(numWires[
c],
"number of wires in the layer "<<
c + 1 <<
" are ");
661 TEST_BASICPROP(firstWireGroupWidth[
c],
"number of wires in first wire group in the layer "<<
c + 1 <<
" are ");
663 TEST_BASICPROP(numPads[
c],
"number of pads in the layer "<<
c + 1 <<
" are ");
664 TEST_BASICPROP(numPadEta[
c],
"number of pads in the eta direction in the layer "<<
c + 1 <<
" are ");
665 TEST_BASICPROP(numPadPhi[
c],
"number of in the phi direction in the layer "<<
c + 1 <<
" are ");
666 TEST_BASICPROP(firstPadHeight[
c],
"height of the first pad row in the layer "<<
c + 1 <<
" are ");
667 TEST_BASICPROP(padHeight[
c],
"height of pads in the rest of the rows in the layer "<<
c + 1 <<
" are ");
668 TEST_BASICPROP(padPhiShift[
c],
"shift of inner pad edges in phi direction in the layer "<<
c + 1 <<
" are ");
669 TEST_BASICPROP(firstPadPhiDiv[
c],
"angular position of the outer edge of the first pad in the layer "<<
c + 1 <<
" are ");
673 std::cout <<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
674 <<
"The test layer transform for layer "<<
c <<
" is: " <<
Amg::toString(testLayer.transform)
675 <<
" and the reference layer transform is: " <<
Amg::toString(refLayer.transform) <<std::endl;
678 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
679 <<
"the layer "<<testLayer<<
" is misaligned w.r.t. reference by "
687 for (
const sTgcChannel& refChannel :
reference.channels) {
688 std::set<sTgcChannel>::const_iterator channel_itr =
test.channels.find(refChannel);
689 if (channel_itr ==
test.channels.end()) {
690 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
691 <<refChannel<<
" is not found. "<<std::endl;
695 const sTgcChannel& testChannel{*channel_itr};
697 const Amg::Vector3D diffGlobalPos{testChannel.globalPosition - refChannel.globalPosition};
698 const Amg::Vector2D diffLocalPos{testChannel.localPosition - refChannel.localPosition};
700 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
701 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" global position: "
703 <<
" displacement: "<<
Amg::toString(diffGlobalPos,2)<<std::endl;
707 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
708 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" local position: "
710 <<
" displacement: "<<
Amg::toString(diffLocalPos,2)<<std::endl;
713 const double diffChannelLen{testChannel.channelLen - refChannel.channelLen};
714 if (std::abs(diffChannelLen) >
tolerance) {
715 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
716 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" Run 4 strip Length: "
717 <<testChannel.channelLen<<
" Run 3 strip Length "<<refChannel.channelLen
718 <<
" displacement: "<<diffChannelLen<<std::endl;
724 for (
const sTgcPad& refPad :
reference.pads) {
725 std::set<sTgcPad>::const_iterator pad_itr =
test.pads.find(refPad);
726 if (pad_itr ==
test.pads.end()) {
727 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
728 <<refPad<<
" is not found. "<<std::endl;
732 const sTgcPad& testPad{*pad_itr};
734 const Amg::Vector2D diffLocalPadPos{testPad.localPosition - refPad.localPosition};
736 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
737 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" local position: "
739 <<
" displacement: "<<
Amg::toString(diffLocalPadPos,2)<<std::endl;
743 const Amg::Vector2D diffLocalPadCornerBL{testPad.localPadCornerBL - refPad.localPadCornerBL};
744 if (diffLocalPadCornerBL.mag() >
tolerance) {
745 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
746 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-left corner: "
748 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerBL,2)<<std::endl;
752 const Amg::Vector2D diffLocalPadCornerBR{testPad.localPadCornerBR - refPad.localPadCornerBR};
753 if (diffLocalPadCornerBR.mag() >
tolerance) {
754 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
755 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-right corner: "
757 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerBR,2)<<std::endl;
761 const Amg::Vector2D diffLocalPadCornerTL{testPad.localPadCornerTL - refPad.localPadCornerTL};
762 if (diffLocalPadCornerTL.mag() >
tolerance) {
763 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
764 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-left corner: "
766 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerTL,2)<<std::endl;
770 const Amg::Vector2D diffLocalPadCornerTR{testPad.localPadCornerTR - refPad.localPadCornerTR};
771 if (diffLocalPadCornerTR.mag() >
tolerance) {
772 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
773 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-right corner: "
775 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerTR,2)<<std::endl;
780 const Amg::Vector3D diffGlobalPadPos{testPad.globalPosition - refPad.globalPosition};
781 if (diffGlobalPadPos.mag() >
tolerance) {
782 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
783 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" global position: "
785 <<
" displacement: "<<
Amg::toString(diffGlobalPadPos,2)<<std::endl;
789 const Amg::Vector3D diffGlobalPadCornerBL{testPad.globalPadCornerBL - refPad.globalPadCornerBL};
790 if (diffGlobalPadCornerBL.mag() >
tolerance) {
791 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
792 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-left corner: "
794 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerBL,2)<<std::endl;
799 const Amg::Vector3D diffGlobalPadCornerBR{testPad.globalPadCornerBR - refPad.globalPadCornerBR};
800 if (diffGlobalPadCornerBR.mag() >
tolerance) {
801 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
802 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-right corner: "
804 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerBR,2)<<std::endl;
808 const Amg::Vector3D diffGlobalPadCornerTL{testPad.globalPadCornerTL - refPad.globalPadCornerTL};
809 if (diffGlobalPadCornerTL.mag() >
tolerance) {
810 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
811 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-left corner: "
813 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerTL,2)<<std::endl;
817 const Amg::Vector3D diffGlobalPadCornerTR{testPad.globalPadCornerTR - refPad.globalPadCornerTR};
818 if (diffGlobalPadCornerTR.mag() >
tolerance) {
819 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
820 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-right corner: "
822 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerTR,2)<<std::endl;
826 const Amg::Vector2D diffHitPosition{testPad.hitPosition - refPad.hitPosition};
828 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
829 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" Hit Position: "
834 const int diffPadNumber{testPad.padNumber - refPad.padNumber};
835 if (std::abs(diffPadNumber) > 0 || testPad.padNumber < 0 || refPad.padNumber < 0) {
836 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
837 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" padNumber: "
838 <<testPad.padNumber <<
" should be "<<refPad.padNumber <<
" displacement: "<< diffPadNumber
839 <<
" Hit Position: "<<
Amg::toString(testPad.hitPosition, 2) <<
" BL Corner: "
845 return_code = EXIT_FAILURE;