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"};
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;