393 {
394
395 int maxPhi = 8;
396
397
398 const GeoModelExperiment * theExpt = nullptr;
400 ATH_MSG_ERROR(
"Could not retrieve the ATLAS GeoModelExperiment from detector store" );
401 return;
402 }
403
405 GeoVolumeCursor av(world);
406 while (!av.atEnd()) {
407 if ( av.getName()=="Muon") {
408 GeoVolumeCursor
pv(av.getVolume());
409 while (!
pv.atEnd()) {
410 if (
pv.getVolume()->getLogVol()->getName()==
"NewSmallWheel") {
412 GeoVolumeCursor pvnsw(
pv.getVolume());
413
414 while (!pvnsw.atEnd()){
415 std::string
stationName = pvnsw.getVolume()->getLogVol()->getName();
416
417
418 if (stationName=="NSW_MM"){
420
421 GeoVolumeCursor pvnswsub(pvnsw.getVolume());
422 bool newChamber = true;
423 std::string phiString = "";
424 std::string phiString_mirrorEta = "";
425 double dphi=0, shift=0, zi=0, zo=0, ri=0, ro=0, wi=0, wo=0;
426 std::string chamberName="";
427 HepGeom::Point3D<double> pos_rot;
428
429 while (!pvnswsub.atEnd()){
430 if (((pvnswsub.getVolume()->getLogVol())->getShape())->typeID() == GeoTrd::getClassTypeID() ) {
431
432 if (newChamber){
433
435 readNSWMMPars(&pvnswsub, maxPhi, chamberName, pos_rot, zi, zo, ri, ro, wi, wo, dphi, shift, phiIndex);
436 phiString =
DataType(phiIndex).toString();
437
438 newChamber = false;
439 pvnswsub.next();
440 }
441
442 else{
443 std::string chamberName2;
444 HepGeom::Point3D<double> pos_rot2;
445 double zi2, zo2, ri2, ro2, wi2, wo2, dphi2, shift2;
446 int phiIndex2;
447 readNSWMMPars(&pvnswsub, maxPhi, chamberName2, pos_rot2, zi2, zo2, ri2, ro2, wi2, wo2, dphi2, shift2, phiIndex2);
448
449 if (chamberName != chamberName2
456
457
458 newChamber = true;
459 }
463 ) {
464
466 if (phiString.find(stationPhi) == std::string::npos) phiString +=
" " +
stationPhi;
467 pvnswsub.next();
468 }
469 else if (pos_rot.distance(HepGeom::Point3D<double>(pos_rot2.x(), pos_rot2.y(), -pos_rot2.z())) <
m_smallDistance
472 ) {
473
475 if (phiString_mirrorEta.find(stationPhi) == std::string::npos){
476 if (not phiString_mirrorEta.empty()) phiString_mirrorEta += " ";
478 }
479 pvnswsub.next();
480 }
481 else {
482
483
484 newChamber = true;
485 }
486
487 }
488
489
490 if (phiString!="" && (newChamber || pvnswsub.atEnd())){
491
493
494 std::string stationTech = "MM";
495 std::string
stationName =
"MM"+chamberName.substr(7,1);
496 int eta = std::stoi(chamberName.substr(8,1));
497 writeATrd(out, stationTech, stationName, zi, zo, ri, ro, wi, wo,
eta, phiString, dphi, shift, 0);
498 if (phiString_mirrorEta!="") {
499 writeATrd(out, stationTech, stationName, -zi, -zo, ri, ro, wi, wo, -
eta, phiString_mirrorEta, dphi, shift, 0);
500 }
501
502 phiString = "";
503 phiString_mirrorEta = "";
504 }
505 }
506 else {
507 pvnswsub.next();
508 }
509
510 }
511 }
512
513
514 else if (stationName=="NSW_sTGC"){
515
517
518 GeoVolumeCursor pvnswsub(pvnsw.getVolume());
519 bool newChamber = true;
520 std::string phiString = "";
521 std::string phiString_mirrorEta = "";
522 int nvtx=0;
523 double dz=0, dphi=0, shift=0;
524 std::string chamberName="";
525 HepGeom::Point3D<double> pos_rot;
526 const GeoSimplePolygonBrep* theBrep = nullptr;
527
528 while (!pvnswsub.atEnd()){
529 if (((pvnswsub.getVolume()->getLogVol())->getShape())->typeID() == GeoShapeShift::getClassTypeID() ) {
530
531
532 if (newChamber){
533
535 readNSWSTGCPars(&pvnswsub, maxPhi, chamberName, pos_rot, theBrep, nvtx, dz, dphi, shift, phiIndex);
536 phiString =
DataType(phiIndex).toString();
537
538 newChamber = false;
539 pvnswsub.next();
540 }
541
542 else{
543
544 std::string chamberName2;
545 HepGeom::Point3D<double> pos_rot2;
546 const GeoSimplePolygonBrep* theBrep2;
547 int nvtx2, phiIndex2;
548 double dz2, dphi2, shift2;
549 readNSWSTGCPars(&pvnswsub, maxPhi, chamberName2, pos_rot2, theBrep2, nvtx2, dz2, dphi2, shift2, phiIndex2);
550
551
552 bool isSameShape = true;
554 for (
int i=0;
i<nvtx; ++
i){
555 if ( !
equalLength(theBrep->getXVertex(i), theBrep2->getXVertex(i))
556 || !
equalLength(theBrep->getYVertex(i), theBrep2->getYVertex(i)) )
557 {
558 isSameShape = false;
559 }
560 }
561 }
562 else {
563 isSameShape = false;
564 }
565
566
567 if (chamberName != chamberName2
570 || !isSameShape)
571 {
572
573
574 newChamber = true;
575 }
576
578
580 if (phiString.find(stationPhi) == std::string::npos) phiString +=
" " +
stationPhi;
581 pvnswsub.next();
582 }
583 else if (pos_rot.distance(HepGeom::Point3D<double>(pos_rot2.x(), pos_rot2.y(), -pos_rot2.z())) <
m_smallDistance) {
584
586 if (phiString_mirrorEta.find(stationPhi) == std::string::npos) {
587 if (not phiString_mirrorEta.empty()) phiString_mirrorEta += " ";
589 }
590 pvnswsub.next();
591 }
592 else {
593
594
595 newChamber = true;
596 }
597 }
598
599
600 if (phiString!="" && (newChamber || pvnswsub.atEnd())){
601
603
604 std::string stationTech = "STGC";
605 std::string
stationName =
"ST"+chamberName.substr(8,1);
606 int eta = std::stoi(chamberName.substr(9,1));
607 double signed_dz = dz;
608 if (pos_rot.z()<0) dz *= -1;
609 double zi = pos_rot.z() - signed_dz;
610 double zo = pos_rot.z() + signed_dz;
611 double rho = pos_rot.perp();
612 double ri, ro, wi, wo;
613
614 if (nvtx==4){
615
616
617
618 const int vtxList[] = {0, 1, 2, 3};
620 writeATrd(out, stationTech, stationName, zi, zo, ri, ro, wi, wo,
eta, phiString, dphi, shift, 0);
621 if (phiString_mirrorEta!="") {
622 writeATrd(out, stationTech, stationName, -zi, -zo, ri, ro, wi, wo, -
eta, phiString_mirrorEta, dphi, shift, 0);
623 }
624 }
625
626 else if (nvtx==6){
627
628
629
630
631
632
633
634 const int vtxList1[] = {5, 2, 3, 4};
636 writeATrd(out, stationTech, stationName, zi, zo, ri, ro, wi, wo,
eta, phiString, dphi, shift, 0);
637 if (phiString_mirrorEta!="") {
638 writeATrd(out, stationTech, stationName, -zi, -zo, ri, ro, wi, wo, -
eta, phiString_mirrorEta, dphi, shift, 0);
639 }
640
641
642 const int vtxList2[] = {0, 1, 2, 5};
644 writeATrd(out, stationTech, stationName, zi, zo, ri, ro, wi, wo,
eta, phiString, dphi, shift, 0);
645 if (phiString_mirrorEta!="") {
646 writeATrd(out, stationTech, stationName, -zi, -zo, ri, ro, wi, wo, -
eta, phiString_mirrorEta, dphi, shift, 0);
647 }
648
649 }
650
651 else{
652 ATH_MSG_ERROR(
"Shape not supported by GeometryJiveXML: polygon shape with "<<nvtx <<
" verticies in NSW sTGC." );
653 }
654 phiString = "";
655 phiString_mirrorEta = "";
656 }
657
658 }
659 else {
660 pvnswsub.next();
661 }
662
663 }
664 }
665 pvnsw.next();
666 }
667 return;
668 }
669
671 }
672 }
673 av.next();
674 }
675 }
Scalar eta() const
pseudorapidity method
const ServiceHandle< StoreGateSvc > & detStore() const
GeoPhysVol * getPhysVol()
Destructor.
void readNSWMMPars(const GeoVolumeCursor *pv, int maxPhi, std::string &chamberName, HepGeom::Point3D< double > &pos_rot, double &zi, double &zo, double &ri, double &ro, double &wi, double &wo, double &dphi, double &shift, int &phiIndex) const
Reads the geometry parameters of a NSW Micromegas chamber.
bool equalLength(double a, double b) const
Compares two coordinates or lenghts.
void readBrepAsATrd(const GeoSimplePolygonBrep *theBrep, double rho, const int *vtx, double &ri, double &ro, double &wi, double &wo) const
Takes four vetecies of a GeoSimplePolygonBrep to form a trapezoid shape and reads the parameters of t...
void readNSWSTGCPars(const GeoVolumeCursor *pv, int maxPhi, std::string &chamberName, HepGeom::Point3D< double > &pos_rot, const GeoSimplePolygonBrep *&theBrep, int &nvtx, double &dz, double &dphi, double &shift, int &phiIndex) const
Reads the geometry parameters of a NSW sTGC chamber.
void writeATrd(std::ofstream &out, const std::string &stationTech, const std::string &stationName, double zi, double zo, double ri, double ro, double wi, double wo, int eta, const std::string &phiString, double dphi, double shift, double alpha) const
Writes a trapezoid station in XML to a stream.
bool equalAngle(double a, double b) const
Compares two angles.
constexpr uint8_t stationPhi
station Phi 1 to 8
retrieve(aClass, aKey=None)