14 #include <GaudiKernel/SystemOfUnits.h>
26 #include <TTreeReader.h>
42 int stationMultilayer{0};
50 if (stationIndex !=
other.stationIndex)
return stationIndex <
other.stationIndex;
51 if (stationEta !=
other.stationEta)
return stationEta <
other.stationEta;
52 if (stationPhi !=
other.stationPhi)
return stationPhi <
other.stationPhi;
53 return stationMultilayer <
other.stationMultilayer;
65 double sChamberLength{0.f};
66 double lChamberLength{0.f};
67 double chamberHeight{0.f};
68 double sGapLength{0.f};
69 double lGapLength{0.f};
70 double gapHeight{0.f};
78 double wirePitch{0.f};
79 double wireWidth{0.f};
83 unsigned int numStrips{0};
84 double stripPitch{0.f};
85 double stripWidth{0.f};
95 unsigned int channelNumber{0};
99 unsigned int channelType{0};
101 double channelLen{0};
105 if (channelType !=
other.channelType)
return channelType <
other.channelType;
106 return channelNumber <
other.channelNumber;
111 double sPadLength{0.f};
112 double lPadLength{0.f};
113 double anglePadPhi{0.f};
114 double beamlineRadius{0.f};
155 if (padPhi !=
other.padPhi)
return padPhi <
other.padPhi;
156 return padEta <
other.padEta;
176 std::set<sTgcPad> pads{};
185 static const std::map<int, std::string> stationDict{
186 {57,
"STS"}, {58,
"STL"}
194 ostr<<
"channel (gasGap/number): ";
196 ostr<<
channel.channelNumber<<
", ";
197 ostr<<
channel.channelType<<
", ";
204 ostr<<
"pad (gasGap/padEta/padPhi): ";
222 ostr<<
"(gasGap/channelType): ";
223 ostr<<
layer.gasGap<<
", ";
224 switch (
layer.chType) {
225 case sTgcIdHelper::sTgcChannelTypes::Pad:
228 case sTgcIdHelper::sTgcChannelTypes::Wire:
231 case sTgcIdHelper::sTgcChannelTypes::Strip:
241 std::set<sTgcChamber> to_ret{};
242 std::cout<<
"Read the sTgc geometry tree dump from "<<
inputFile<<std::endl;
245 std::cerr<<__FILE__<<
":"<<__LINE__<<
" Failed to open "<<
inputFile<<std::endl;
250 std::cerr<<__FILE__<<
":"<<__LINE__<<
" The file "<<
inputFile<<
" does not contain the 'sTgcGeoModelTree'"<<std::endl;
255 TTreeReaderValue<short> stationIndex{
treeReader,
"stationIndex"};
256 TTreeReaderValue<short> stationEta{
treeReader,
"stationEta"};
257 TTreeReaderValue<short> stationPhi{
treeReader,
"stationPhi"};
258 TTreeReaderValue<short> stationMultilayer{
treeReader,
"stationMultilayer"};
259 TTreeReaderValue<std::string> chamberDesign{
treeReader,
"chamberDesign"};
263 TTreeReaderValue<float> yCutout{
treeReader,
"yCutout"};
264 TTreeReaderValue<float> gasTck{
treeReader,
"gasTck"};
266 TTreeReaderValue<float> sChamberLength{
treeReader,
"sChamberLength"};
267 TTreeReaderValue<float> lChamberLength{
treeReader,
"lChamberLength"};
268 TTreeReaderValue<float> chamberHeight{
treeReader,
"chamberHeight"};
270 TTreeReaderValue<float> sGapLength{
treeReader,
"sGapLength"};
271 TTreeReaderValue<float> lGapLength{
treeReader,
"lGapLength"};
272 TTreeReaderValue<float> gapHeight{
treeReader,
"gapHeight"};
275 TTreeReaderValue<std::vector<uint>> numWires{
treeReader,
"numWires"};
276 TTreeReaderValue<std::vector<uint>> firstWireGroupWidth{
treeReader,
"firstWireGroupWidth"};
277 TTreeReaderValue<std::vector<uint>> numWireGroups{
treeReader,
"numWireGroups"};
278 TTreeReaderValue<std::vector<float>> wireCutout{
treeReader,
"wireCutout"};
279 TTreeReaderValue<float> wirePitch{
treeReader,
"wirePitch"};
280 TTreeReaderValue<float> wireWidth{
treeReader,
"wireWidth"};
281 TTreeReaderValue<uint> wireGroupWidth{
treeReader,
"wireGroupWidth"};
283 TTreeReaderValue<std::vector<float>> globalWireGroupPosX{
treeReader,
"globalWireGroupPosX"};
284 TTreeReaderValue<std::vector<float>> globalWireGroupPosY{
treeReader,
"globalWireGroupPosY"};
285 TTreeReaderValue<std::vector<float>> globalWireGroupPosZ{
treeReader,
"globalWireGroupPosZ"};
287 TTreeReaderValue<std::vector<float>> localWireGroupPosX{
treeReader,
"localWireGroupPosX"};
288 TTreeReaderValue<std::vector<float>> localWireGroupPosY{
treeReader,
"localWireGroupPosY"};
290 TTreeReaderValue<std::vector<uint8_t>> wireGroupNum{
treeReader,
"wireGroupNum"};
291 TTreeReaderValue<std::vector<uint8_t>> wireGroupGasGap{
treeReader,
"wireGroupGasGap"};
294 TTreeReaderValue<uint> numStrips{
treeReader,
"numStrips"};
295 TTreeReaderValue<float> stripPitch{
treeReader,
"stripPitch"};
296 TTreeReaderValue<float> stripWidth{
treeReader,
"stripWidth"};
298 TTreeReaderValue<std::vector<float>> globalStripPosX{
treeReader,
"globalStripPosX"};
299 TTreeReaderValue<std::vector<float>> globalStripPosY{
treeReader,
"globalStripPosY"};
300 TTreeReaderValue<std::vector<float>> globalStripPosZ{
treeReader,
"globalStripPosZ"};
302 TTreeReaderValue<std::vector<float>> localStripPosX{
treeReader,
"localStripPosX"};
303 TTreeReaderValue<std::vector<float>> localStripPosY{
treeReader,
"localStripPosY"};
305 TTreeReaderValue<std::vector<uint>> stripNum{
treeReader,
"stripNumber"};
306 TTreeReaderValue<std::vector<uint8_t>> stripGasGap{
treeReader,
"stripGasGap"};
307 TTreeReaderValue<std::vector<float>> stripLengths{
treeReader,
"stripLengths"};
310 TTreeReaderValue<float> sPadLength{
treeReader,
"sPadLength"};
311 TTreeReaderValue<float> lPadLength{
treeReader,
"lPadLength"};
312 TTreeReaderValue<float> anglePadPhi{
treeReader,
"anglePadPhi"};
313 TTreeReaderValue<float> beamlineRadius{
treeReader,
"beamlineRadius"};
314 TTreeReaderValue<std::vector<uint>> numPads{
treeReader,
"numPads"};
315 TTreeReaderValue<std::vector<uint>> numPadEta{
treeReader,
"numPadEta"};
316 TTreeReaderValue<std::vector<uint>> numPadPhi{
treeReader,
"numPadPhi"};
317 TTreeReaderValue<std::vector<float>> firstPadHeight{
treeReader,
"firstPadHeight"};
318 TTreeReaderValue<std::vector<float>> padHeight{
treeReader,
"padHeight"};
319 TTreeReaderValue<std::vector<float>> padPhiShift{
treeReader,
"padPhiShift"};
320 TTreeReaderValue<std::vector<float>> firstPadPhiDiv{
treeReader,
"firstPadPhiDiv"};
322 TTreeReaderValue<std::vector<float>> globalPadCornerBRX{
treeReader,
"globalPadCornerBRX"};
323 TTreeReaderValue<std::vector<float>> globalPadCornerBRY{
treeReader,
"globalPadCornerBRY"};
324 TTreeReaderValue<std::vector<float>> globalPadCornerBRZ{
treeReader,
"globalPadCornerBRZ"};
326 TTreeReaderValue<std::vector<float>> globalPadCornerBLX{
treeReader,
"globalPadCornerBLX"};
327 TTreeReaderValue<std::vector<float>> globalPadCornerBLY{
treeReader,
"globalPadCornerBLY"};
328 TTreeReaderValue<std::vector<float>> globalPadCornerBLZ{
treeReader,
"globalPadCornerBLZ"};
330 TTreeReaderValue<std::vector<float>> globalPadCornerTRX{
treeReader,
"globalPadCornerTRX"};
331 TTreeReaderValue<std::vector<float>> globalPadCornerTRY{
treeReader,
"globalPadCornerTRY"};
332 TTreeReaderValue<std::vector<float>> globalPadCornerTRZ{
treeReader,
"globalPadCornerTRZ"};
334 TTreeReaderValue<std::vector<float>> globalPadCornerTLX{
treeReader,
"globalPadCornerTLX"};
335 TTreeReaderValue<std::vector<float>> globalPadCornerTLY{
treeReader,
"globalPadCornerTLY"};
336 TTreeReaderValue<std::vector<float>> globalPadCornerTLZ{
treeReader,
"globalPadCornerTLZ"};
338 TTreeReaderValue<std::vector<float>> globalPadPosX{
treeReader,
"globalPadPosX"};
339 TTreeReaderValue<std::vector<float>> globalPadPosY{
treeReader,
"globalPadPosY"};
340 TTreeReaderValue<std::vector<float>> globalPadPosZ{
treeReader,
"globalPadPosZ"};
342 TTreeReaderValue<std::vector<float>> localPadCornerBRX{
treeReader,
"localPadCornerBRX"};
343 TTreeReaderValue<std::vector<float>> localPadCornerBRY{
treeReader,
"localPadCornerBRY"};
345 TTreeReaderValue<std::vector<float>> localPadCornerBLX{
treeReader,
"localPadCornerBLX"};
346 TTreeReaderValue<std::vector<float>> localPadCornerBLY{
treeReader,
"localPadCornerBLY"};
348 TTreeReaderValue<std::vector<float>> localPadCornerTRX{
treeReader,
"localPadCornerTRX"};
349 TTreeReaderValue<std::vector<float>> localPadCornerTRY{
treeReader,
"localPadCornerTRY"};
351 TTreeReaderValue<std::vector<float>> localPadCornerTLX{
treeReader,
"localPadCornerTLX"};
352 TTreeReaderValue<std::vector<float>> localPadCornerTLY{
treeReader,
"localPadCornerTLY"};
354 TTreeReaderValue<std::vector<float>> localPadPosX{
treeReader,
"localPadPosX"};
355 TTreeReaderValue<std::vector<float>> localPadPosY{
treeReader,
"localPadPosY"};
357 TTreeReaderValue<std::vector<float>> hitPositionX{
treeReader,
"hitPositionX"};
358 TTreeReaderValue<std::vector<float>> hitPositionY{
treeReader,
"hitPositionY"};
359 TTreeReaderValue<std::vector<int>> padNumber{
treeReader,
"padNumber"};
361 TTreeReaderValue<std::vector<uint8_t>> padGasGap{
treeReader,
"padGasGap"};
362 TTreeReaderValue<std::vector<uint>> padEta{
treeReader,
"padEtaNumber"};
363 TTreeReaderValue<std::vector<uint>> padPhi{
treeReader,
"padPhiNumber"};
366 TTreeReaderValue<std::vector<float>> geoModelTransformX{
treeReader,
"GeoModelTransformX"};
367 TTreeReaderValue<std::vector<float>> geoModelTransformY{
treeReader,
"GeoModelTransformY"};
368 TTreeReaderValue<std::vector<float>> geoModelTransformZ{
treeReader,
"GeoModelTransformZ"};
370 TTreeReaderValue<std::vector<float>> alignableNodeX{
treeReader,
"AlignableNodeX"};
371 TTreeReaderValue<std::vector<float>> alignableNodeY{
treeReader,
"AlignableNodeY"};
372 TTreeReaderValue<std::vector<float>> alignableNodeZ{
treeReader,
"AlignableNodeZ"};
374 TTreeReaderValue<std::vector<float>> stripRotCol1X{
treeReader,
"stripRotLinearCol1X"};
375 TTreeReaderValue<std::vector<float>> stripRotCol1Y{
treeReader,
"stripRotLinearCol1Y"};
376 TTreeReaderValue<std::vector<float>> stripRotCol1Z{
treeReader,
"stripRotLinearCol1Z"};
378 TTreeReaderValue<std::vector<float>> stripRotCol2X{
treeReader,
"stripRotLinearCol2X"};
379 TTreeReaderValue<std::vector<float>> stripRotCol2Y{
treeReader,
"stripRotLinearCol2Y"};
380 TTreeReaderValue<std::vector<float>> stripRotCol2Z{
treeReader,
"stripRotLinearCol2Z"};
382 TTreeReaderValue<std::vector<float>> stripRotCol3X{
treeReader,
"stripRotLinearCol3X"};
383 TTreeReaderValue<std::vector<float>> stripRotCol3Y{
treeReader,
"stripRotLinearCol3Y"};
384 TTreeReaderValue<std::vector<float>> stripRotCol3Z{
treeReader,
"stripRotLinearCol3Z"};
386 TTreeReaderValue<std::vector<float>> stripRotTransX{
treeReader,
"stripRotTranslationX"};
387 TTreeReaderValue<std::vector<float>> stripRotTransY{
treeReader,
"stripRotTranslationY"};
388 TTreeReaderValue<std::vector<float>> stripRotTransZ{
treeReader,
"stripRotTranslationZ"};
390 TTreeReaderValue<std::vector<uint8_t>> stripRotGasGap{
treeReader,
"stripRotGasGap"};
393 TTreeReaderValue<std::vector<float>> wireGroupRotCol1X{
treeReader,
"wireGroupRotLinearCol1X"};
394 TTreeReaderValue<std::vector<float>> wireGroupRotCol1Y{
treeReader,
"wireGroupRotLinearCol1Y"};
395 TTreeReaderValue<std::vector<float>> wireGroupRotCol1Z{
treeReader,
"wireGroupRotLinearCol1Z"};
397 TTreeReaderValue<std::vector<float>> wireGroupRotCol2X{
treeReader,
"wireGroupRotLinearCol2X"};
398 TTreeReaderValue<std::vector<float>> wireGroupRotCol2Y{
treeReader,
"wireGroupRotLinearCol2Y"};
399 TTreeReaderValue<std::vector<float>> wireGroupRotCol2Z{
treeReader,
"wireGroupRotLinearCol2Z"};
401 TTreeReaderValue<std::vector<float>> wireGroupRotCol3X{
treeReader,
"wireGroupRotLinearCol3X"};
402 TTreeReaderValue<std::vector<float>> wireGroupRotCol3Y{
treeReader,
"wireGroupRotLinearCol3Y"};
403 TTreeReaderValue<std::vector<float>> wireGroupRotCol3Z{
treeReader,
"wireGroupRotLinearCol3Z"};
405 TTreeReaderValue<std::vector<float>> wireGroupRotTransX{
treeReader,
"wireGroupRotTranslationX"};
406 TTreeReaderValue<std::vector<float>> wireGroupRotTransY{
treeReader,
"wireGroupRotTranslationY"};
407 TTreeReaderValue<std::vector<float>> wireGroupRotTransZ{
treeReader,
"wireGroupRotTranslationZ"};
409 TTreeReaderValue<std::vector<uint8_t>> wireGroupRotGasGap{
treeReader,
"wireGroupRotGasGap"};
412 TTreeReaderValue<std::vector<float>> padRotCol1X{
treeReader,
"padRotLinearCol1X"};
413 TTreeReaderValue<std::vector<float>> padRotCol1Y{
treeReader,
"padRotLinearCol1Y"};
414 TTreeReaderValue<std::vector<float>> padRotCol1Z{
treeReader,
"padRotLinearCol1Z"};
416 TTreeReaderValue<std::vector<float>> padRotCol2X{
treeReader,
"padRotLinearCol2X"};
417 TTreeReaderValue<std::vector<float>> padRotCol2Y{
treeReader,
"padRotLinearCol2Y"};
418 TTreeReaderValue<std::vector<float>> padRotCol2Z{
treeReader,
"padRotLinearCol2Z"};
420 TTreeReaderValue<std::vector<float>> padRotCol3X{
treeReader,
"padRotLinearCol3X"};
421 TTreeReaderValue<std::vector<float>> padRotCol3Y{
treeReader,
"padRotLinearCol3Y"};
422 TTreeReaderValue<std::vector<float>> padRotCol3Z{
treeReader,
"padRotLinearCol3Z"};
424 TTreeReaderValue<std::vector<float>> padRotTransX{
treeReader,
"padRotTranslationX"};
425 TTreeReaderValue<std::vector<float>> padRotTransY{
treeReader,
"padRotTranslationY"};
426 TTreeReaderValue<std::vector<float>> padRotTransZ{
treeReader,
"padRotTranslationZ"};
428 TTreeReaderValue<std::vector<uint8_t>> padRotGasGap{
treeReader,
"padRotGasGap"};
435 newchamber.stationEta = (*stationEta);
436 newchamber.stationPhi = (*stationPhi);
437 newchamber.stationMultilayer = (*stationMultilayer);
438 newchamber.design = (*chamberDesign);
441 newchamber.numLayers = (*numLayers);
442 newchamber.yCutout = (*yCutout);
443 newchamber.gasTck = (*gasTck);
446 newchamber.sGapLength = (*sGapLength);
447 newchamber.lGapLength = (*lGapLength);
448 newchamber.gapHeight = (*gapHeight);
450 newchamber.sChamberLength = (*sChamberLength);
451 newchamber.lChamberLength = (*lChamberLength);
452 newchamber.chamberHeight = (*chamberHeight);
455 newchamber.numWires = (*numWires);
456 newchamber.firstWireGroupWidth = (*firstWireGroupWidth);
457 newchamber.numWireGroups = (*numWireGroups);
458 newchamber.wireCutout = (*wireCutout);
459 newchamber.wirePitch = (*wirePitch);
460 newchamber.wireWidth = (*wireWidth);
461 newchamber.wireGroupWidth = (*wireGroupWidth);
464 newchamber.numStrips = (*numStrips);
465 newchamber.stripPitch = (*stripPitch);
466 newchamber.stripWidth = (*stripWidth);
469 newchamber.sPadLength = (*sPadLength);
470 newchamber.lPadLength = (*lPadLength);
471 newchamber.anglePadPhi = (*anglePadPhi);
472 newchamber.beamlineRadius = (*beamlineRadius);
473 newchamber.numPads = (*numPads);
474 newchamber.numPadEta = (*numPadEta);
475 newchamber.numPadPhi = (*numPadPhi);
476 newchamber.firstPadHeight = (*firstPadHeight);
477 newchamber.padHeight = (*padHeight);
478 newchamber.padPhiShift = (*padPhiShift);
479 newchamber.firstPadPhiDiv = (*firstPadPhiDiv);
481 Amg::Vector3D geoTrans{(*geoModelTransformX)[0], (*geoModelTransformY)[0], (*geoModelTransformZ)[0]};
483 geoRot.col(0) =
Amg::Vector3D((*geoModelTransformX)[1], (*geoModelTransformY)[1], (*geoModelTransformZ)[1]);
484 geoRot.col(1) =
Amg::Vector3D((*geoModelTransformX)[2], (*geoModelTransformY)[2], (*geoModelTransformZ)[2]);
485 geoRot.col(2) =
Amg::Vector3D((*geoModelTransformX)[3], (*geoModelTransformY)[3], (*geoModelTransformZ)[3]);
488 geoRot.col(0) =
Amg::Vector3D((*alignableNodeX)[1], (*alignableNodeY)[1], (*alignableNodeZ)[1]);
489 geoRot.col(1) =
Amg::Vector3D((*alignableNodeX)[2], (*alignableNodeY)[2], (*alignableNodeZ)[2]);
490 geoRot.col(2) =
Amg::Vector3D((*alignableNodeX)[3], (*alignableNodeY)[3], (*alignableNodeZ)[3]);
491 geoTrans =
Amg::Vector3D{(*alignableNodeX)[0], (*alignableNodeY)[0], (*alignableNodeZ)[0]};
494 for (
size_t wg = 0; wg < globalWireGroupPosX->size(); ++wg){
497 newWireGroup.globalPosition =
Amg::Vector3D{(*globalWireGroupPosX)[wg], (*globalWireGroupPosY)[wg], (*globalWireGroupPosZ)[wg]};
498 newWireGroup.gasGap = (*wireGroupGasGap)[wg];
499 newWireGroup.channelNumber = (*wireGroupNum)[wg];
500 newWireGroup.channelType = 2;
502 if (newWireGroup.channelNumber > 0)
continue;
503 newchamber.channels.insert(std::move(newWireGroup));
507 for (
size_t s = 0;
s < globalStripPosX->size(); ++
s){
510 newStrip.globalPosition =
Amg::Vector3D{(*globalStripPosX)[
s], (*globalStripPosY)[
s], (*globalStripPosZ)[
s]};
511 newStrip.gasGap = (*stripGasGap)[
s];
512 newStrip.channelNumber = (*stripNum)[
s];
513 newStrip.channelType = 1;
514 newStrip.channelLen = (*stripLengths)[
s];
516 if (newStrip.channelNumber > 0)
continue;
517 newchamber.channels.insert(std::move(newStrip));
522 for (
size_t p = 0;
p < globalPadPosX->size(); ++
p){
526 newPad.globalPadCornerBR =
Amg::Vector3D{(*globalPadCornerBRX)[
p], (*globalPadCornerBRY)[
p], (*globalPadCornerBRZ)[
p]};
527 newPad.globalPadCornerBL =
Amg::Vector3D{(*globalPadCornerBLX)[
p], (*globalPadCornerBLY)[
p], (*globalPadCornerBLZ)[
p]};
528 newPad.globalPadCornerTR =
Amg::Vector3D{(*globalPadCornerTRX)[
p], (*globalPadCornerTRY)[
p], (*globalPadCornerTRZ)[
p]};
529 newPad.globalPadCornerTL =
Amg::Vector3D{(*globalPadCornerTLX)[
p], (*globalPadCornerTLY)[
p], (*globalPadCornerTLZ)[
p]};
531 newPad.localPosition =
Amg::Vector2D{(*localPadPosX)[
p], (*localPadPosY)[
p]};
532 newPad.localPadCornerBR =
Amg::Vector2D{(*localPadCornerBRX)[
p], (*localPadCornerBRY)[
p]};
533 newPad.localPadCornerBL =
Amg::Vector2D{(*localPadCornerBLX)[
p], (*localPadCornerBLY)[
p]};
534 newPad.localPadCornerTR =
Amg::Vector2D{(*localPadCornerTRX)[
p], (*localPadCornerTRY)[
p]};
535 newPad.localPadCornerTL =
Amg::Vector2D{(*localPadCornerTLX)[
p], (*localPadCornerTLY)[
p]};
537 newPad.hitPosition =
Amg::Vector2D{(*hitPositionX)[
p], (*hitPositionY)[
p]};
538 newPad.padNumber = (*padNumber)[
p];
539 newPad.gasGap = (*padGasGap)[
p];
540 newPad.padEta = (*padEta)[
p];
541 newPad.padPhi = (*padPhi)[
p];
543 if (newPad.padEta > 1 || newPad.padPhi > 6)
continue;
544 newchamber.pads.insert(std::move(newPad));
547 for (
size_t l = 0;
l < stripRotGasGap->size(); ++
l){
549 stripLayer.
chType = sTgcIdHelper::sTgcChannelTypes::Strip;
550 stripLayer.gasGap = (*stripRotGasGap)[
l];
552 stripRot.col(0) =
Amg::Vector3D((*stripRotCol1X)[
l],(*stripRotCol1Y)[
l], (*stripRotCol1Z)[
l]);
553 stripRot.col(1) =
Amg::Vector3D((*stripRotCol2X)[
l],(*stripRotCol2Y)[
l], (*stripRotCol2Z)[
l]);
554 stripRot.col(2) =
Amg::Vector3D((*stripRotCol3X)[
l],(*stripRotCol3Y)[
l], (*stripRotCol3Z)[
l]);
555 Amg::Vector3D layTrans{(*stripRotTransX)[
l], (*stripRotTransY)[
l], (*stripRotTransZ)[
l]};
557 newchamber.layers.insert(std::move(stripLayer));
560 for (
size_t l = 0;
l < wireGroupRotGasGap->size(); ++
l){
562 wireGroupLayer.
chType = sTgcIdHelper::sTgcChannelTypes::Wire;
563 wireGroupLayer.gasGap = (*wireGroupRotGasGap)[
l];
565 wireGroupRot.col(0) =
Amg::Vector3D((*wireGroupRotCol1X)[
l],(*wireGroupRotCol1Y)[
l], (*wireGroupRotCol1Z)[
l]);
566 wireGroupRot.col(1) =
Amg::Vector3D((*wireGroupRotCol2X)[
l],(*wireGroupRotCol2Y)[
l], (*wireGroupRotCol2Z)[
l]);
567 wireGroupRot.col(2) =
Amg::Vector3D((*wireGroupRotCol3X)[
l],(*wireGroupRotCol3Y)[
l], (*wireGroupRotCol3Z)[
l]);
568 Amg::Vector3D layTrans{(*wireGroupRotTransX)[
l], (*wireGroupRotTransY)[
l], (*wireGroupRotTransZ)[
l]};
570 newchamber.layers.insert(std::move(wireGroupLayer));
573 for (
size_t l = 0;
l < padRotGasGap->size(); ++
l){
575 padLayer.
chType = sTgcIdHelper::sTgcChannelTypes::Pad;
576 padLayer.gasGap = (*padRotGasGap)[
l];
578 padRot.col(0) =
Amg::Vector3D((*padRotCol1X)[
l],(*padRotCol1Y)[
l], (*padRotCol1Z)[
l]);
579 padRot.col(1) =
Amg::Vector3D((*padRotCol2X)[
l],(*padRotCol2Y)[
l], (*padRotCol2Z)[
l]);
580 padRot.col(2) =
Amg::Vector3D((*padRotCol3X)[
l],(*padRotCol3Y)[
l], (*padRotCol3Z)[
l]);
581 Amg::Vector3D layTrans{(*padRotTransX)[
l], (*padRotTransY)[
l], (*padRotTransZ)[
l]};
583 newchamber.layers.insert(std::move(padLayer));
586 auto insert_itr = to_ret.insert(std::move(newchamber));
587 if (!insert_itr.second) {
588 std::stringstream
err{};
589 err<<__FILE__<<
":"<<__LINE__<<
" The chamber "<<(*insert_itr.first).stationIndex
590 <<
" has already been inserted. "<<std::endl;
591 throw std::runtime_error(
err.str());
594 std::cout<<
"File parsing is finished. Found in total "<<to_ret.size()<<
" readout element dumps "<<std::endl;
598 #define TEST_BASICPROP(attribute, propName) \
599 if (std::abs(1.*test.attribute - 1.*reference.attribute) > tolerance) { \
600 std::cerr<<"runsTgcGeoComparison() "<<__LINE__<<": The chamber "<<reference \
601 <<" differs w.r.t "<<propName<<" "<< reference.attribute \
602 <<" (ref) vs. " <<test.attribute << " (test)" << std::endl; \
603 chamberOkay = false; \
610 std::string the_arg{
argv[
arg]};
611 if (the_arg ==
"--refFile" &&
arg +1 <
argc) {
612 refFile = std::string{
argv[
arg+1]};
614 }
else if (the_arg ==
"--testFile" &&
arg + 1 <
argc) {
619 if (refFile.empty()) {
620 std::cerr<<
"Please parse the path of the reference file via --refFile "<<std::endl;
624 std::cerr<<
"Please parse the path of the test file via --testFile "<<std::endl;
631 std::set<sTgcChamber> refChambers =
readTreeDump(refFile);
632 if (refChambers.empty()) {
633 std::cerr<<
"The file "<<refFile<<
" should contain at least one chamber "<<std::endl;
637 if (testChambers.empty()) {
638 std::cerr<<
"The file "<<
testFile<<
" should contain at least one chamber "<<std::endl;
641 int return_code = EXIT_SUCCESS;
644 std::set<sTgcChamber>::const_iterator test_itr = testChambers.find(
reference);
646 if (test_itr == testChambers.end()) {
647 std::cerr<<
"The chamber "<<
reference<<
" is not part of the testing "<<std::endl;
648 return_code = EXIT_FAILURE;
651 bool chamberOkay =
true;
656 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": The alignable nodes are at differnt places for "
666 TEST_BASICPROP(sChamberLength,
"Chamber length on the short side");
667 TEST_BASICPROP(lChamberLength,
"Chamber length on the long side");
675 TEST_BASICPROP(wireGroupWidth,
"number of wires in a normal wiregroup");
680 TEST_BASICPROP(sPadLength,
"gasGap length on the short side for pads and wires");
681 TEST_BASICPROP(lPadLength,
"gasGap length on the long side for pads and wires");
682 TEST_BASICPROP(anglePadPhi,
"angular width of a pad in phi direction");
683 TEST_BASICPROP(beamlineRadius,
"distance from the gapCenter to beamline");
687 for (
const sTgcLayer& refLayer :
reference.layers) {
688 std::set<sTgcLayer>::const_iterator lay_itr =
test.layers.find(refLayer);
689 if (lay_itr ==
test.layers.end()) {
690 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
691 <<refLayer<<
" is not found. "<<std::endl;
695 const sTgcLayer& testLayer{*lay_itr};
700 std::cout <<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
701 <<
"The test layer transform for layer "<<
c <<
" is: " <<
Amg::toString(testLayer.transform)
702 <<
" and the reference layer transform is: " <<
Amg::toString(refLayer.transform)
706 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
707 <<
"the layer "<<testLayer<<
" is misaligned w.r.t. reference by "
713 TEST_BASICPROP(numWires[
c],
"number of wires in the layer "<<
c + 1 <<
" are ");
714 TEST_BASICPROP(firstWireGroupWidth[
c],
"number of wires in first wire group in the layer "<<
c + 1 <<
" are ");
716 TEST_BASICPROP(numPads[
c],
"number of pads in the layer "<<
c + 1 <<
" are ");
717 TEST_BASICPROP(numPadEta[
c],
"number of pads in the eta direction in the layer "<<
c + 1 <<
" are ");
718 TEST_BASICPROP(numPadPhi[
c],
"number of in the phi direction in the layer "<<
c + 1 <<
" are ");
719 TEST_BASICPROP(firstPadHeight[
c],
"height of the first pad row in the layer "<<
c + 1 <<
" are ");
720 TEST_BASICPROP(padHeight[
c],
"height of pads in the rest of the rows in the layer "<<
c + 1 <<
" are ");
721 TEST_BASICPROP(padPhiShift[
c],
"shift of inner pad edges in phi direction in the layer "<<
c + 1 <<
" are ");
722 TEST_BASICPROP(firstPadPhiDiv[
c],
"angular position of the outer edge of the first pad in the layer "<<
c + 1 <<
" are ");
727 for (
const sTgcChannel& refChannel :
reference.channels) {
728 std::set<sTgcChannel>::const_iterator channel_itr =
test.channels.find(refChannel);
729 if (channel_itr ==
test.channels.end()) {
730 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
731 <<refChannel<<
" is not found. "<<std::endl;
735 const sTgcChannel& testChannel{*channel_itr};
737 const Amg::Vector3D diffGlobalPos{testChannel.globalPosition - refChannel.globalPosition};
738 const Amg::Vector2D diffLocalPos{testChannel.localPosition - refChannel.localPosition};
740 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
741 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" global position: "
743 <<
" displacement: "<<
Amg::toString(diffGlobalPos,2)<<std::endl;
747 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
748 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" local position: "
750 <<
" displacement: "<<
Amg::toString(diffLocalPos,2)<<std::endl;
753 const double diffChannelLen{testChannel.channelLen - refChannel.channelLen};
754 if (std::abs(diffChannelLen) >
tolerance) {
755 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"channel (gasGap/number): "
756 <<testChannel.gasGap<<
"/"<<testChannel.channelNumber<<
", chType: "<<testChannel.channelType<<
", "<<
" Run 4 strip Length: "
757 <<testChannel.channelLen<<
" Run 3 strip Length "<<refChannel.channelLen
758 <<
" displacement: "<<diffChannelLen<<std::endl;
764 for (
const sTgcPad& refPad :
reference.pads) {
765 std::set<sTgcPad>::const_iterator pad_itr =
test.pads.find(refPad);
766 if (pad_itr ==
test.pads.end()) {
767 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "
768 <<refPad<<
" is not found. "<<std::endl;
772 const sTgcPad& testPad{*pad_itr};
774 const Amg::Vector2D diffLocalPadPos{testPad.localPosition - refPad.localPosition};
776 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
777 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" local position: "
779 <<
" displacement: "<<
Amg::toString(diffLocalPadPos,2)<<std::endl;
783 const Amg::Vector2D diffLocalPadCornerBL{testPad.localPadCornerBL - refPad.localPadCornerBL};
784 if (diffLocalPadCornerBL.mag() >
tolerance) {
785 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
786 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-left corner: "
788 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerBL,2)<<std::endl;
792 const Amg::Vector2D diffLocalPadCornerBR{testPad.localPadCornerBR - refPad.localPadCornerBR};
793 if (diffLocalPadCornerBR.mag() >
tolerance) {
794 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
795 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-right corner: "
797 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerBR,2)<<std::endl;
801 const Amg::Vector2D diffLocalPadCornerTL{testPad.localPadCornerTL - refPad.localPadCornerTL};
802 if (diffLocalPadCornerTL.mag() >
tolerance) {
803 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
804 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-left corner: "
806 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerTL,2)<<std::endl;
810 const Amg::Vector2D diffLocalPadCornerTR{testPad.localPadCornerTR - refPad.localPadCornerTR};
811 if (diffLocalPadCornerTR.mag() >
tolerance) {
812 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
813 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-right corner: "
815 <<
" displacement: "<<
Amg::toString(diffLocalPadCornerTR,2)<<std::endl;
820 const Amg::Vector3D diffGlobalPadPos{testPad.globalPosition - refPad.globalPosition};
821 if (diffGlobalPadPos.mag() >
tolerance) {
822 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
823 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" global position: "
825 <<
" displacement: "<<
Amg::toString(diffGlobalPadPos,2)<<std::endl;
829 const Amg::Vector3D diffGlobalPadCornerBL{testPad.globalPadCornerBL - refPad.globalPadCornerBL};
830 if (diffGlobalPadCornerBL.mag() >
tolerance) {
831 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
832 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-left corner: "
834 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerBL,2)<<std::endl;
839 const Amg::Vector3D diffGlobalPadCornerBR{testPad.globalPadCornerBR - refPad.globalPadCornerBR};
840 if (diffGlobalPadCornerBR.mag() >
tolerance) {
841 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
842 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" bottom-right corner: "
844 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerBR,2)<<std::endl;
848 const Amg::Vector3D diffGlobalPadCornerTL{testPad.globalPadCornerTL - refPad.globalPadCornerTL};
849 if (diffGlobalPadCornerTL.mag() >
tolerance) {
850 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
851 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-left corner: "
853 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerTL,2)<<std::endl;
857 const Amg::Vector3D diffGlobalPadCornerTR{testPad.globalPadCornerTR - refPad.globalPadCornerTR};
858 if (diffGlobalPadCornerTR.mag() >
tolerance) {
859 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
860 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" top-right corner: "
862 <<
" displacement: "<<
Amg::toString(diffGlobalPadCornerTR,2)<<std::endl;
866 const Amg::Vector2D diffHitPosition{testPad.hitPosition - refPad.hitPosition};
868 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
869 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" Hit Position: "
874 const int diffPadNumber{testPad.padNumber - refPad.padNumber};
875 if (std::abs(diffPadNumber) > 0 || testPad.padNumber < 0 || refPad.padNumber < 0) {
876 std::cerr<<
"runsTgcGeoComparison() "<<__LINE__<<
": in chamber "<<
test<<
" "<<
"pad (gasGap/(padEta, padPhi)): "
877 <<testPad.gasGap<<
"/("<<testPad.padEta<<
", "<<testPad.padPhi<<
"), "<<
" padNumber: "
878 <<testPad.padNumber <<
" should be "<<refPad.padNumber <<
" displacement: "<< diffPadNumber
879 <<
" Hit Position: "<<
Amg::toString(testPad.hitPosition, 2) <<
" BL Corner: "
885 return_code = EXIT_FAILURE;