14 #include <GaudiKernel/SystemOfUnits.h>
26 #include <TTreeReader.h>
43 int stationMultilayer{0};
48 if (stationIndex !=
other.stationIndex)
return stationIndex <
other.stationIndex;
49 if (stationEta !=
other.stationEta)
return stationEta <
other.stationEta;
50 if (stationPhi !=
other.stationPhi)
return stationPhi <
other.stationPhi;
51 return stationMultilayer <
other.stationMultilayer;
63 double sChamberLength{0.f};
64 double lChamberLength{0.f};
65 double chamberHeight{0.f};
66 double sGapLength{0.f};
67 double lGapLength{0.f};
68 double gapHeight{0.f};
76 double wirePitch{0.f};
77 double wireWidth{0.f};
81 unsigned int numStrips{0};
82 double stripPitch{0.f};
83 double stripWidth{0.f};
93 unsigned int channelNumber{0};
97 unsigned int channelType{0};
103 if (channelType !=
other.channelType)
return channelType <
other.channelType;
104 return channelNumber <
other.channelNumber;
109 double sPadLength{0.f};
110 double lPadLength{0.f};
111 double anglePadPhi{0.f};
112 double beamlineRadius{0.f};
153 if (padPhi !=
other.padPhi)
return padPhi <
other.padPhi;
154 return padEta <
other.padEta;
170 std::set<sTgcPad> pads{};
179 static const std::map<int, std::string> stationDict{
180 {57,
"STS"}, {58,
"STL"}
187 ostr<<
"channel (gasGap/number): ";
189 ostr<<
channel.channelNumber<<
", ";
190 ostr<<
channel.channelType<<
", ";
197 ostr<<
"pad (gasGap/padEta/padPhi): ";
215 ostr<<
"stgclayer (gasGap/channelType): ";
216 ostr<<
layer.gasGap<<
", ";
222 std::set<sTgcChamber> to_ret{};
223 std::cout<<
"Read the sTgc geometry tree dump from "<<
inputFile<<std::endl;
226 std::cerr<<__FILE__<<
":"<<__LINE__<<
" Failed to open "<<
inputFile<<std::endl;
231 std::cerr<<__FILE__<<
":"<<__LINE__<<
" The file "<<
inputFile<<
" does not contain the 'sTgcGeoModelTree'"<<std::endl;
236 TTreeReaderValue<short> stationIndex{
treeReader,
"stationIndex"};
237 TTreeReaderValue<short> stationEta{
treeReader,
"stationEta"};
238 TTreeReaderValue<short> stationPhi{
treeReader,
"stationPhi"};
239 TTreeReaderValue<short> stationMultilayer{
treeReader,
"stationMultilayer"};
240 TTreeReaderValue<std::string> chamberDesign{
treeReader,
"chamberDesign"};
244 TTreeReaderValue<float> yCutout{
treeReader,
"yCutout"};
245 TTreeReaderValue<float> gasTck{
treeReader,
"gasTck"};
247 TTreeReaderValue<float> sChamberLength{
treeReader,
"sChamberLength"};
248 TTreeReaderValue<float> lChamberLength{
treeReader,
"lChamberLength"};
249 TTreeReaderValue<float> chamberHeight{
treeReader,
"chamberHeight"};
251 TTreeReaderValue<float> sGapLength{
treeReader,
"sGapLength"};
252 TTreeReaderValue<float> lGapLength{
treeReader,
"lGapLength"};
253 TTreeReaderValue<float> gapHeight{
treeReader,
"gapHeight"};
256 TTreeReaderValue<std::vector<uint>> numWires{
treeReader,
"numWires"};
257 TTreeReaderValue<std::vector<uint>> firstWireGroupWidth{
treeReader,
"firstWireGroupWidth"};
258 TTreeReaderValue<std::vector<uint>> numWireGroups{
treeReader,
"numWireGroups"};
259 TTreeReaderValue<std::vector<float>> wireCutout{
treeReader,
"wireCutout"};
260 TTreeReaderValue<float> wirePitch{
treeReader,
"wirePitch"};
261 TTreeReaderValue<float> wireWidth{
treeReader,
"wireWidth"};
262 TTreeReaderValue<uint> wireGroupWidth{
treeReader,
"wireGroupWidth"};
264 TTreeReaderValue<std::vector<float>> globalWireGroupPosX{
treeReader,
"globalWireGroupPosX"};
265 TTreeReaderValue<std::vector<float>> globalWireGroupPosY{
treeReader,
"globalWireGroupPosY"};
266 TTreeReaderValue<std::vector<float>> globalWireGroupPosZ{
treeReader,
"globalWireGroupPosZ"};
268 TTreeReaderValue<std::vector<float>> localWireGroupPosX{
treeReader,
"localWireGroupPosX"};
269 TTreeReaderValue<std::vector<float>> localWireGroupPosY{
treeReader,
"localWireGroupPosY"};
271 TTreeReaderValue<std::vector<uint8_t>> wireGroupNum{
treeReader,
"wireGroupNum"};
272 TTreeReaderValue<std::vector<uint8_t>> wireGroupGasGap{
treeReader,
"wireGroupGasGap"};
275 TTreeReaderValue<uint> numStrips{
treeReader,
"numStrips"};
276 TTreeReaderValue<float> stripPitch{
treeReader,
"stripPitch"};
277 TTreeReaderValue<float> stripWidth{
treeReader,
"stripWidth"};
279 TTreeReaderValue<std::vector<float>> globalStripPosX{
treeReader,
"globalStripPosX"};
280 TTreeReaderValue<std::vector<float>> globalStripPosY{
treeReader,
"globalStripPosY"};
281 TTreeReaderValue<std::vector<float>> globalStripPosZ{
treeReader,
"globalStripPosZ"};
283 TTreeReaderValue<std::vector<float>> localStripPosX{
treeReader,
"localStripPosX"};
284 TTreeReaderValue<std::vector<float>> localStripPosY{
treeReader,
"localStripPosY"};
286 TTreeReaderValue<std::vector<uint>> stripNum{
treeReader,
"stripNumber"};
287 TTreeReaderValue<std::vector<uint8_t>> stripGasGap{
treeReader,
"stripGasGap"};
288 TTreeReaderValue<std::vector<float>> stripLengths{
treeReader,
"stripLengths"};
291 TTreeReaderValue<float> sPadLength{
treeReader,
"sPadLength"};
292 TTreeReaderValue<float> lPadLength{
treeReader,
"lPadLength"};
293 TTreeReaderValue<float> anglePadPhi{
treeReader,
"anglePadPhi"};
294 TTreeReaderValue<float> beamlineRadius{
treeReader,
"beamlineRadius"};
295 TTreeReaderValue<std::vector<uint>> numPads{
treeReader,
"numPads"};
296 TTreeReaderValue<std::vector<uint>> numPadEta{
treeReader,
"numPadEta"};
297 TTreeReaderValue<std::vector<uint>> numPadPhi{
treeReader,
"numPadPhi"};
298 TTreeReaderValue<std::vector<float>> firstPadHeight{
treeReader,
"firstPadHeight"};
299 TTreeReaderValue<std::vector<float>> padHeight{
treeReader,
"padHeight"};
300 TTreeReaderValue<std::vector<float>> padPhiShift{
treeReader,
"padPhiShift"};
301 TTreeReaderValue<std::vector<float>> firstPadPhiDiv{
treeReader,
"firstPadPhiDiv"};
303 TTreeReaderValue<std::vector<float>> globalPadCornerBRX{
treeReader,
"globalPadCornerBRX"};
304 TTreeReaderValue<std::vector<float>> globalPadCornerBRY{
treeReader,
"globalPadCornerBRY"};
305 TTreeReaderValue<std::vector<float>> globalPadCornerBRZ{
treeReader,
"globalPadCornerBRZ"};
307 TTreeReaderValue<std::vector<float>> globalPadCornerBLX{
treeReader,
"globalPadCornerBLX"};
308 TTreeReaderValue<std::vector<float>> globalPadCornerBLY{
treeReader,
"globalPadCornerBLY"};
309 TTreeReaderValue<std::vector<float>> globalPadCornerBLZ{
treeReader,
"globalPadCornerBLZ"};
311 TTreeReaderValue<std::vector<float>> globalPadCornerTRX{
treeReader,
"globalPadCornerTRX"};
312 TTreeReaderValue<std::vector<float>> globalPadCornerTRY{
treeReader,
"globalPadCornerTRY"};
313 TTreeReaderValue<std::vector<float>> globalPadCornerTRZ{
treeReader,
"globalPadCornerTRZ"};
315 TTreeReaderValue<std::vector<float>> globalPadCornerTLX{
treeReader,
"globalPadCornerTLX"};
316 TTreeReaderValue<std::vector<float>> globalPadCornerTLY{
treeReader,
"globalPadCornerTLY"};
317 TTreeReaderValue<std::vector<float>> globalPadCornerTLZ{
treeReader,
"globalPadCornerTLZ"};
319 TTreeReaderValue<std::vector<float>> globalPadPosX{
treeReader,
"globalPadPosX"};
320 TTreeReaderValue<std::vector<float>> globalPadPosY{
treeReader,
"globalPadPosY"};
321 TTreeReaderValue<std::vector<float>> globalPadPosZ{
treeReader,
"globalPadPosZ"};
323 TTreeReaderValue<std::vector<float>> localPadCornerBRX{
treeReader,
"localPadCornerBRX"};
324 TTreeReaderValue<std::vector<float>> localPadCornerBRY{
treeReader,
"localPadCornerBRY"};
326 TTreeReaderValue<std::vector<float>> localPadCornerBLX{
treeReader,
"localPadCornerBLX"};
327 TTreeReaderValue<std::vector<float>> localPadCornerBLY{
treeReader,
"localPadCornerBLY"};
329 TTreeReaderValue<std::vector<float>> localPadCornerTRX{
treeReader,
"localPadCornerTRX"};
330 TTreeReaderValue<std::vector<float>> localPadCornerTRY{
treeReader,
"localPadCornerTRY"};
332 TTreeReaderValue<std::vector<float>> localPadCornerTLX{
treeReader,
"localPadCornerTLX"};
333 TTreeReaderValue<std::vector<float>> localPadCornerTLY{
treeReader,
"localPadCornerTLY"};
335 TTreeReaderValue<std::vector<float>> localPadPosX{
treeReader,
"localPadPosX"};
336 TTreeReaderValue<std::vector<float>> localPadPosY{
treeReader,
"localPadPosY"};
338 TTreeReaderValue<std::vector<float>> hitPositionX{
treeReader,
"hitPositionX"};
339 TTreeReaderValue<std::vector<float>> hitPositionY{
treeReader,
"hitPositionY"};
340 TTreeReaderValue<std::vector<int>> padNumber{
treeReader,
"padNumber"};
342 TTreeReaderValue<std::vector<uint8_t>> padGasGap{
treeReader,
"padGasGap"};
343 TTreeReaderValue<std::vector<uint>> padEta{
treeReader,
"padEtaNumber"};
344 TTreeReaderValue<std::vector<uint>> padPhi{
treeReader,
"padPhiNumber"};
347 TTreeReaderValue<std::vector<float>> geoModelTransformX{
treeReader,
"GeoModelTransformX"};
348 TTreeReaderValue<std::vector<float>> geoModelTransformY{
treeReader,
"GeoModelTransformY"};
349 TTreeReaderValue<std::vector<float>> geoModelTransformZ{
treeReader,
"GeoModelTransformZ"};
351 TTreeReaderValue<std::vector<float>> stripRotCol1X{
treeReader,
"stripRotLinearCol1X"};
352 TTreeReaderValue<std::vector<float>> stripRotCol1Y{
treeReader,
"stripRotLinearCol1Y"};
353 TTreeReaderValue<std::vector<float>> stripRotCol1Z{
treeReader,
"stripRotLinearCol1Z"};
355 TTreeReaderValue<std::vector<float>> stripRotCol2X{
treeReader,
"stripRotLinearCol2X"};
356 TTreeReaderValue<std::vector<float>> stripRotCol2Y{
treeReader,
"stripRotLinearCol2Y"};
357 TTreeReaderValue<std::vector<float>> stripRotCol2Z{
treeReader,
"stripRotLinearCol2Z"};
359 TTreeReaderValue<std::vector<float>> stripRotCol3X{
treeReader,
"stripRotLinearCol3X"};
360 TTreeReaderValue<std::vector<float>> stripRotCol3Y{
treeReader,
"stripRotLinearCol3Y"};
361 TTreeReaderValue<std::vector<float>> stripRotCol3Z{
treeReader,
"stripRotLinearCol3Z"};
363 TTreeReaderValue<std::vector<float>> stripRotTransX{
treeReader,
"stripRotTranslationX"};
364 TTreeReaderValue<std::vector<float>> stripRotTransY{
treeReader,
"stripRotTranslationY"};
365 TTreeReaderValue<std::vector<float>> stripRotTransZ{
treeReader,
"stripRotTranslationZ"};
367 TTreeReaderValue<std::vector<uint8_t>> stripRotGasGap{
treeReader,
"stripRotGasGap"};
370 TTreeReaderValue<std::vector<float>> wireGroupRotCol1X{
treeReader,
"wireGroupRotLinearCol1X"};
371 TTreeReaderValue<std::vector<float>> wireGroupRotCol1Y{
treeReader,
"wireGroupRotLinearCol1Y"};
372 TTreeReaderValue<std::vector<float>> wireGroupRotCol1Z{
treeReader,
"wireGroupRotLinearCol1Z"};
374 TTreeReaderValue<std::vector<float>> wireGroupRotCol2X{
treeReader,
"wireGroupRotLinearCol2X"};
375 TTreeReaderValue<std::vector<float>> wireGroupRotCol2Y{
treeReader,
"wireGroupRotLinearCol2Y"};
376 TTreeReaderValue<std::vector<float>> wireGroupRotCol2Z{
treeReader,
"wireGroupRotLinearCol2Z"};
378 TTreeReaderValue<std::vector<float>> wireGroupRotCol3X{
treeReader,
"wireGroupRotLinearCol3X"};
379 TTreeReaderValue<std::vector<float>> wireGroupRotCol3Y{
treeReader,
"wireGroupRotLinearCol3Y"};
380 TTreeReaderValue<std::vector<float>> wireGroupRotCol3Z{
treeReader,
"wireGroupRotLinearCol3Z"};
382 TTreeReaderValue<std::vector<float>> wireGroupRotTransX{
treeReader,
"wireGroupRotTranslationX"};
383 TTreeReaderValue<std::vector<float>> wireGroupRotTransY{
treeReader,
"wireGroupRotTranslationY"};
384 TTreeReaderValue<std::vector<float>> wireGroupRotTransZ{
treeReader,
"wireGroupRotTranslationZ"};
386 TTreeReaderValue<std::vector<uint8_t>> wireGroupRotGasGap{
treeReader,
"wireGroupRotGasGap"};
389 TTreeReaderValue<std::vector<float>> padRotCol1X{
treeReader,
"padRotLinearCol1X"};
390 TTreeReaderValue<std::vector<float>> padRotCol1Y{
treeReader,
"padRotLinearCol1Y"};
391 TTreeReaderValue<std::vector<float>> padRotCol1Z{
treeReader,
"padRotLinearCol1Z"};
393 TTreeReaderValue<std::vector<float>> padRotCol2X{
treeReader,
"padRotLinearCol2X"};
394 TTreeReaderValue<std::vector<float>> padRotCol2Y{
treeReader,
"padRotLinearCol2Y"};
395 TTreeReaderValue<std::vector<float>> padRotCol2Z{
treeReader,
"padRotLinearCol2Z"};
397 TTreeReaderValue<std::vector<float>> padRotCol3X{
treeReader,
"padRotLinearCol3X"};
398 TTreeReaderValue<std::vector<float>> padRotCol3Y{
treeReader,
"padRotLinearCol3Y"};
399 TTreeReaderValue<std::vector<float>> padRotCol3Z{
treeReader,
"padRotLinearCol3Z"};
401 TTreeReaderValue<std::vector<float>> padRotTransX{
treeReader,
"padRotTranslationX"};
402 TTreeReaderValue<std::vector<float>> padRotTransY{
treeReader,
"padRotTranslationY"};
403 TTreeReaderValue<std::vector<float>> padRotTransZ{
treeReader,
"padRotTranslationZ"};
405 TTreeReaderValue<std::vector<uint8_t>> padRotGasGap{
treeReader,
"padRotGasGap"};
412 newchamber.stationEta = (*stationEta);
413 newchamber.stationPhi = (*stationPhi);
414 newchamber.stationMultilayer = (*stationMultilayer);
415 newchamber.design = (*chamberDesign);
418 newchamber.numLayers = (*numLayers);
419 newchamber.yCutout = (*yCutout);
420 newchamber.gasTck = (*gasTck);
423 newchamber.sGapLength = (*sGapLength);
424 newchamber.lGapLength = (*lGapLength);
425 newchamber.gapHeight = (*gapHeight);
427 newchamber.sChamberLength = (*sChamberLength);
428 newchamber.lChamberLength = (*lChamberLength);
429 newchamber.chamberHeight = (*chamberHeight);
432 newchamber.numWires = (*numWires);
433 newchamber.firstWireGroupWidth = (*firstWireGroupWidth);
434 newchamber.numWireGroups = (*numWireGroups);
435 newchamber.wireCutout = (*wireCutout);
436 newchamber.wirePitch = (*wirePitch);
437 newchamber.wireWidth = (*wireWidth);
438 newchamber.wireGroupWidth = (*wireGroupWidth);
441 newchamber.numStrips = (*numStrips);
442 newchamber.stripPitch = (*stripPitch);
443 newchamber.stripWidth = (*stripWidth);
446 newchamber.sPadLength = (*sPadLength);
447 newchamber.lPadLength = (*lPadLength);
448 newchamber.anglePadPhi = (*anglePadPhi);
449 newchamber.beamlineRadius = (*beamlineRadius);
450 newchamber.numPads = (*numPads);
451 newchamber.numPadEta = (*numPadEta);
452 newchamber.numPadPhi = (*numPadPhi);
453 newchamber.firstPadHeight = (*firstPadHeight);
454 newchamber.padHeight = (*padHeight);
455 newchamber.padPhiShift = (*padPhiShift);
456 newchamber.firstPadPhiDiv = (*firstPadPhiDiv);
458 Amg::Vector3D geoTrans{(*geoModelTransformX)[0], (*geoModelTransformY)[0], (*geoModelTransformZ)[0]};
460 geoRot.col(0) =
Amg::Vector3D((*geoModelTransformX)[1], (*geoModelTransformY)[1], (*geoModelTransformZ)[1]);
461 geoRot.col(1) =
Amg::Vector3D((*geoModelTransformX)[2], (*geoModelTransformY)[2], (*geoModelTransformZ)[2]);
462 geoRot.col(2) =
Amg::Vector3D((*geoModelTransformX)[3], (*geoModelTransformY)[3], (*geoModelTransformZ)[3]);
466 for (
size_t wg = 0; wg < globalWireGroupPosX->size(); ++wg){
469 newWireGroup.globalPosition =
Amg::Vector3D{(*globalWireGroupPosX)[wg], (*globalWireGroupPosY)[wg], (*globalWireGroupPosZ)[wg]};
470 newWireGroup.gasGap = (*wireGroupGasGap)[wg];
471 newWireGroup.channelNumber = (*wireGroupNum)[wg];
472 newWireGroup.channelType = 2;
474 if (newWireGroup.channelNumber > 0)
continue;
475 newchamber.channels.insert(std::move(newWireGroup));
479 for (
size_t s = 0;
s < globalStripPosX->size(); ++
s){
482 newStrip.globalPosition =
Amg::Vector3D{(*globalStripPosX)[
s], (*globalStripPosY)[
s], (*globalStripPosZ)[
s]};
483 newStrip.gasGap = (*stripGasGap)[
s];
484 newStrip.channelNumber = (*stripNum)[
s];
485 newStrip.channelType = 1;
486 newStrip.channelLen = (*stripLengths)[
s];
488 if (newStrip.channelNumber > 0)
continue;
489 newchamber.channels.insert(std::move(newStrip));
494 for (
size_t p = 0;
p < globalPadPosX->size(); ++
p){
498 newPad.globalPadCornerBR =
Amg::Vector3D{(*globalPadCornerBRX)[
p], (*globalPadCornerBRY)[
p], (*globalPadCornerBRZ)[
p]};
499 newPad.globalPadCornerBL =
Amg::Vector3D{(*globalPadCornerBLX)[
p], (*globalPadCornerBLY)[
p], (*globalPadCornerBLZ)[
p]};
500 newPad.globalPadCornerTR =
Amg::Vector3D{(*globalPadCornerTRX)[
p], (*globalPadCornerTRY)[
p], (*globalPadCornerTRZ)[
p]};
501 newPad.globalPadCornerTL =
Amg::Vector3D{(*globalPadCornerTLX)[
p], (*globalPadCornerTLY)[
p], (*globalPadCornerTLZ)[
p]};
503 newPad.localPosition =
Amg::Vector2D{(*localPadPosX)[
p], (*localPadPosY)[
p]};
504 newPad.localPadCornerBR =
Amg::Vector2D{(*localPadCornerBRX)[
p], (*localPadCornerBRY)[
p]};
505 newPad.localPadCornerBL =
Amg::Vector2D{(*localPadCornerBLX)[
p], (*localPadCornerBLY)[
p]};
506 newPad.localPadCornerTR =
Amg::Vector2D{(*localPadCornerTRX)[
p], (*localPadCornerTRY)[
p]};
507 newPad.localPadCornerTL =
Amg::Vector2D{(*localPadCornerTLX)[
p], (*localPadCornerTLY)[
p]};
509 newPad.hitPosition =
Amg::Vector2D{(*hitPositionX)[
p], (*hitPositionY)[
p]};
510 newPad.padNumber = (*padNumber)[
p];
511 newPad.gasGap = (*padGasGap)[
p];
512 newPad.padEta = (*padEta)[
p];
513 newPad.padPhi = (*padPhi)[
p];
515 if (newPad.padEta > 1 || newPad.padPhi > 6)
continue;
516 newchamber.pads.insert(std::move(newPad));
519 for (
size_t l = 0;
l < stripRotGasGap->size(); ++
l){
521 stripLayer.
gasGap = (*stripRotGasGap)[
l];
523 stripRot.col(0) =
Amg::Vector3D((*stripRotCol1X)[
l],(*stripRotCol1Y)[
l], (*stripRotCol1Z)[
l]);
524 stripRot.col(1) =
Amg::Vector3D((*stripRotCol2X)[
l],(*stripRotCol2Y)[
l], (*stripRotCol2Z)[
l]);
525 stripRot.col(2) =
Amg::Vector3D((*stripRotCol3X)[
l],(*stripRotCol3Y)[
l], (*stripRotCol3Z)[
l]);
526 Amg::Vector3D layTrans{(*stripRotTransX)[
l], (*stripRotTransY)[
l], (*stripRotTransZ)[
l]};
528 newchamber.layers.insert(std::move(stripLayer));
531 for (
size_t l = 0;
l < wireGroupRotGasGap->size(); ++
l){
533 wireGroupLayer.
gasGap = (*wireGroupRotGasGap)[
l];
535 wireGroupRot.col(0) =
Amg::Vector3D((*wireGroupRotCol1X)[
l],(*wireGroupRotCol1Y)[
l], (*wireGroupRotCol1Z)[
l]);
536 wireGroupRot.col(1) =
Amg::Vector3D((*wireGroupRotCol2X)[
l],(*wireGroupRotCol2Y)[
l], (*wireGroupRotCol2Z)[
l]);
537 wireGroupRot.col(2) =
Amg::Vector3D((*wireGroupRotCol3X)[
l],(*wireGroupRotCol3Y)[
l], (*wireGroupRotCol3Z)[
l]);
538 Amg::Vector3D layTrans{(*wireGroupRotTransX)[
l], (*wireGroupRotTransY)[
l], (*wireGroupRotTransZ)[
l]};
540 newchamber.layers.insert(std::move(wireGroupLayer));
543 for (
size_t l = 0;
l < padRotGasGap->size(); ++
l){
545 padLayer.
gasGap = (*padRotGasGap)[
l];
547 padRot.col(0) =
Amg::Vector3D((*padRotCol1X)[
l],(*padRotCol1Y)[
l], (*padRotCol1Z)[
l]);
548 padRot.col(1) =
Amg::Vector3D((*padRotCol2X)[
l],(*padRotCol2Y)[
l], (*padRotCol2Z)[
l]);
549 padRot.col(2) =
Amg::Vector3D((*padRotCol3X)[
l],(*padRotCol3Y)[
l], (*padRotCol3Z)[
l]);
550 Amg::Vector3D layTrans{(*padRotTransX)[
l], (*padRotTransY)[
l], (*padRotTransZ)[
l]};
552 newchamber.layers.insert(std::move(padLayer));
555 auto insert_itr = to_ret.insert(std::move(newchamber));
556 if (!insert_itr.second) {
557 std::stringstream
err{};
558 err<<__FILE__<<
":"<<__LINE__<<
" The chamber "<<(*insert_itr.first).stationIndex
559 <<
" has already been inserted. "<<std::endl;
560 throw std::runtime_error(
err.str());
563 std::cout<<
"File parsing is finished. Found in total "<<to_ret.size()<<
" readout element dumps "<<std::endl;
567 #define TEST_BASICPROP(attribute, propName) \
568 if (std::abs(1.*test.attribute - 1.*reference.attribute) > tolerance) { \
569 std::cerr<<"sTgcGeoModelComparison() "<<__LINE__<<": The chamber "<<reference \
570 <<" differs w.r.t "<<propName<<" "<< reference.attribute \
571 <<" (ref) vs. " <<test.attribute << " (test)" << std::endl; \
572 chamberOkay = false; \
579 std::string the_arg{
argv[
arg]};
580 if (the_arg ==
"--refFile" &&
arg +1 <
argc) {
581 refFile = std::string{
argv[
arg+1]};
583 }
else if (the_arg ==
"--testFile" &&
arg + 1 <
argc) {
588 if (refFile.empty()) {
589 std::cerr<<
"Please parse the path of the reference file via --refFile "<<std::endl;
593 std::cerr<<
"Please parse the path of the test file via --testFile "<<std::endl;
600 std::set<sTgcChamber> refChambers =
readTreeDump(refFile);
601 if (refChambers.empty()) {
602 std::cerr<<
"The file "<<refFile<<
" should contain at least one chamber "<<std::endl;
606 if (testChambers.empty()) {
607 std::cerr<<
"The file "<<
testFile<<
" should contain at least one chamber "<<std::endl;
610 int return_code = EXIT_SUCCESS;
613 std::set<sTgcChamber>::const_iterator test_itr = testChambers.find(
reference);
615 if (test_itr == testChambers.end()) {
616 std::cerr<<
"The chamber "<<
reference<<
" is not part of the testing "<<std::endl;
617 return_code = EXIT_FAILURE;
620 bool chamberOkay =
true;
628 TEST_BASICPROP(sChamberLength,
"Chamber length on the short side");
629 TEST_BASICPROP(lChamberLength,
"Chamber length on the long side");
637 TEST_BASICPROP(wireGroupWidth,
"number of wires in a normal wiregroup");
642 TEST_BASICPROP(sPadLength,
"gasGap length on the short side for pads and wires");
643 TEST_BASICPROP(lPadLength,
"gasGap length on the long side for pads and wires");
644 TEST_BASICPROP(anglePadPhi,
"angular width of a pad in phi direction");
645 TEST_BASICPROP(beamlineRadius,
"distance from the gapCenter to beamline");
649 for (
const sTgcLayer& refLayer :
reference.layers) {
650 std::set<sTgcLayer>::const_iterator lay_itr =
test.layers.find(refLayer);
651 if (lay_itr ==
test.layers.end()) {
652 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
653 <<refLayer<<
" is not found. "<<std::endl;
657 const sTgcLayer& testLayer{*lay_itr};
661 TEST_BASICPROP(numWires[
c],
"number of wires in the layer "<<
c + 1 <<
" are ");
662 TEST_BASICPROP(firstWireGroupWidth[
c],
"number of wires in first wire group in the layer "<<
c + 1 <<
" are ");
664 TEST_BASICPROP(numPads[
c],
"number of pads in the layer "<<
c + 1 <<
" are ");
665 TEST_BASICPROP(numPadEta[
c],
"number of pads in the eta direction in the layer "<<
c + 1 <<
" are ");
666 TEST_BASICPROP(numPadPhi[
c],
"number of in the phi direction in the layer "<<
c + 1 <<
" are ");
667 TEST_BASICPROP(firstPadHeight[
c],
"height of the first pad row in the layer "<<
c + 1 <<
" are ");
668 TEST_BASICPROP(padHeight[
c],
"height of pads in the rest of the rows in the layer "<<
c + 1 <<
" are ");
669 TEST_BASICPROP(padPhiShift[
c],
"shift of inner pad edges in phi direction in the layer "<<
c + 1 <<
" are ");
670 TEST_BASICPROP(firstPadPhiDiv[
c],
"angular position of the outer edge of the first pad in the layer "<<
c + 1 <<
" are ");
674 std::cout <<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
675 <<
"The test layer transform for layer "<<
c <<
" is: " <<
Amg::toString(testLayer.transform)
676 <<
" and the reference layer transform is: " <<
Amg::toString(refLayer.transform) <<std::endl;
679 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
680 <<
"the layer "<<testLayer<<
" is misaligned w.r.t. reference by "
688 for (
const sTgcChannel& refChannel :
reference.channels) {
689 std::set<sTgcChannel>::const_iterator channel_itr =
test.channels.find(refChannel);
690 if (channel_itr ==
test.channels.end()) {
691 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
692 <<refChannel<<
" is not found. "<<std::endl;
696 const sTgcChannel& testChannel{*channel_itr};
698 const Amg::Vector3D diffGlobalPos{testChannel.globalPosition - refChannel.globalPosition};
699 const Amg::Vector2D diffLocalPos{testChannel.localPosition - refChannel.localPosition};
701 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
702 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" global position: "
704 <<
" displacement: "<<
Amg::toString(diffGlobalPos,2)<<std::endl;
708 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
709 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" local position: "
711 <<
" displacement: "<<
Amg::toString(diffLocalPos,2)<<std::endl;
714 const double diffChannelLen{testChannel.channelLen - refChannel.channelLen};
715 if (std::abs(diffChannelLen) >
tolerance) {
716 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
717 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" Run 4 strip Length: "
718 <<testChannel.channelLen<<
" Run 3 strip Length "<<refChannel.channelLen
719 <<
" displacement: "<<diffChannelLen<<std::endl;
725 for (
const sTgcPad& refPad :
reference.pads) {
726 std::set<sTgcPad>::const_iterator pad_itr =
test.pads.find(refPad);
727 if (pad_itr ==
test.pads.end()) {
728 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
729 <<refPad<<
" is not found. "<<std::endl;
733 const sTgcPad& testPad{*pad_itr};
735 const Amg::Vector2D diffLocalPadPos{testPad.localPosition - refPad.localPosition};
737 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
738 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" local position: "
740 <<
" displacement: "<<
Amg::toString(diffLocalPadPos,2)<<std::endl;
744 const Amg::Vector2D diffLocalPadCornerBL{testPad.localPadCornerBL - refPad.localPadCornerBL};
745 if (diffLocalPadCornerBL.mag() >
tolerance) {
746 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
747 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-left corner: "
749 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerBL,2)<<std::endl;
753 const Amg::Vector2D diffLocalPadCornerBR{testPad.localPadCornerBR - refPad.localPadCornerBR};
754 if (diffLocalPadCornerBR.mag() >
tolerance) {
755 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
756 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-right corner: "
758 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerBR,2)<<std::endl;
762 const Amg::Vector2D diffLocalPadCornerTL{testPad.localPadCornerTL - refPad.localPadCornerTL};
763 if (diffLocalPadCornerTL.mag() >
tolerance) {
764 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
765 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-left corner: "
767 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerTL,2)<<std::endl;
771 const Amg::Vector2D diffLocalPadCornerTR{testPad.localPadCornerTR - refPad.localPadCornerTR};
772 if (diffLocalPadCornerTR.mag() >
tolerance) {
773 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
774 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-right corner: "
776 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerTR,2)<<std::endl;
781 const Amg::Vector3D diffGlobalPadPos{testPad.globalPosition - refPad.globalPosition};
782 if (diffGlobalPadPos.mag() >
tolerance) {
783 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
784 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" global position: "
786 <<
" displacement: "<<
Amg::toString(diffGlobalPadPos,2)<<std::endl;
790 const Amg::Vector3D diffGlobalPadCornerBL{testPad.globalPadCornerBL - refPad.globalPadCornerBL};
791 if (diffGlobalPadCornerBL.mag() >
tolerance) {
792 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
793 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-left corner: "
795 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerBL,2)<<std::endl;
800 const Amg::Vector3D diffGlobalPadCornerBR{testPad.globalPadCornerBR - refPad.globalPadCornerBR};
801 if (diffGlobalPadCornerBR.mag() >
tolerance) {
802 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
803 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-right corner: "
805 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerBR,2)<<std::endl;
809 const Amg::Vector3D diffGlobalPadCornerTL{testPad.globalPadCornerTL - refPad.globalPadCornerTL};
810 if (diffGlobalPadCornerTL.mag() >
tolerance) {
811 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
812 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-left corner: "
814 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerTL,2)<<std::endl;
818 const Amg::Vector3D diffGlobalPadCornerTR{testPad.globalPadCornerTR - refPad.globalPadCornerTR};
819 if (diffGlobalPadCornerTR.mag() >
tolerance) {
820 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
821 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-right corner: "
823 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerTR,2)<<std::endl;
827 const Amg::Vector2D diffHitPosition{testPad.hitPosition - refPad.hitPosition};
829 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
830 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" Hit Position: "
835 const int diffPadNumber{testPad.padNumber - refPad.padNumber};
836 if (std::abs(diffPadNumber) > 0 || testPad.padNumber < 0 || refPad.padNumber < 0) {
837 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
838 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" padNumber: "
839 <<testPad.padNumber <<
" should be "<<refPad.padNumber <<
" displacement: "<< diffPadNumber
840 <<
" Hit Position: "<<
Amg::toString(testPad.hitPosition, 2) <<
" BL Corner: "
846 return_code = EXIT_FAILURE;