ModuleNumbering

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275
// -*- C++ -*-
//
/* 
 Description: <one line class summary>

 Implementation:
     <Notes on implementation>
*/

//
// Original Author:  Riccardo Ranieri
//         Created:  Tue Feb 27 22:22:22 CEST 2007
//
//

// system include files
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "Geometry/CommonTopologies/interface/PixelTopology.h"
#include "Geometry/CommonTopologies/interface/StripTopology.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"

#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "DataFormats/GeometrySurface/interface/BoundSurface.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/TrackerNumberingBuilder/interface/CmsTrackerStringToEnum.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"

// output
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <bitset>
//

//
// class decleration
//

//double PI = 3.141592654;

class ModuleNumbering : public edm::one::EDAnalyzer<> {
public:
  explicit ModuleNumbering(const edm::ParameterSet&);
  ~ModuleNumbering() override;

  void beginJob() override {}
  void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
  void endJob() override {}

private:
  // ----------member data ---------------------------
  void fillModuleVariables(const GeometricDet* module, double& polarRadius, double& phiRad, double& z);
  double changePhiRange_From_ZeroTwoPi_To_MinusPiPlusPi(double phiRad);
  double changePhiRange_From_MinusPiPlusPi_To_MinusTwoPiZero(double phiRad);
  double changePhiRange_From_MinusPiPlusPi_To_ZeroTwoPi(double phiRad);

  const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tokTopo_;
  const edm::ESGetToken<GeometricDet, IdealGeometryRecord> tokGeo_;

  //
  // counters
  unsigned int iOK;
  unsigned int iERROR;
  //
};

//
// constants, enums and typedefs
//

//
// static data member definitions
//
static const double tolerance_space = 1.000;  // 1.000 mm
static const double tolerance_angle = 0.001;  // 0.001 rad

//
// constructors and destructor
//
ModuleNumbering::ModuleNumbering(const edm::ParameterSet& iConfig)
    : tokTopo_(esConsumes<TrackerTopology, TrackerTopologyRcd>()),
      tokGeo_(esConsumes<GeometricDet, IdealGeometryRecord>()) {
  //now do what ever initialization is needed
}

ModuleNumbering::~ModuleNumbering() {
  // do anything here that needs to be done at desctruction time
  // (e.g. close files, deallocate resources etc.)
}

//
// member functions
//

void ModuleNumbering::fillModuleVariables(const GeometricDet* module, double& polarRadius, double& phiRad, double& z) {
  // module variables
  polarRadius = std::sqrt(module->translation().X() * module->translation().X() +
                          module->translation().Y() * module->translation().Y());
  phiRad = atan2(module->translation().Y(), module->translation().X());
  // tolerance near phi=0
  if (std::abs(phiRad) < tolerance_angle)
    phiRad = 0.0;
  // negative phi: from [-PI,+PI) to [0,2PI)
  if (phiRad < 0)
    phiRad += 2 * M_PI;
  //
  z = module->translation().Z();
  //
}

double ModuleNumbering::changePhiRange_From_ZeroTwoPi_To_MinusPiPlusPi(double phiRad) {
  double new_phiRad = phiRad;
  // tolerance near phi=PI
  if (std::abs(new_phiRad - M_PI) < tolerance_angle)
    new_phiRad = M_PI;
  // phi greater than PI: from [0,2PI) to [-PI,+PI)
  if (new_phiRad > M_PI)
    new_phiRad -= 2 * M_PI;
  //
  return new_phiRad;
}

double ModuleNumbering::changePhiRange_From_MinusPiPlusPi_To_MinusTwoPiZero(double phiRad) {
  double new_phiRad = phiRad;
  // tolerance near phi=PI
  if (std::abs(std::abs(new_phiRad) - M_PI) < tolerance_angle)
    new_phiRad = M_PI;
  // phi greater than PI: from [-PI,+PI) to [0,2PI)
  if (new_phiRad > 0)
    new_phiRad -= 2 * M_PI;
  //
  return new_phiRad;
}

double ModuleNumbering::changePhiRange_From_MinusPiPlusPi_To_ZeroTwoPi(double phiRad) {
  double new_phiRad = phiRad;
  // tolerance near phi=PI
  if (std::abs(std::abs(new_phiRad) - M_PI) < tolerance_angle)
    new_phiRad = M_PI;
  // phi greater than PI: from [-PI,+PI) to [0,2PI)
  if (new_phiRad < 0)
    new_phiRad += 2 * M_PI;
  //
  return new_phiRad;
}

// ------------ method called to produce the data  ------------
void ModuleNumbering::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  //Retrieve tracker topology from geometry
  const TrackerTopology* tTopo = &iSetup.getData(tokTopo_);

  edm::LogInfo("ModuleNumbering") << "begins";

  // reset counters
  iOK = 0;
  iERROR = 0;
  //

  //
  // get the GeometricDet
  //
  auto const& rDD = iSetup.getHandle(tokGeo_);
  edm::LogInfo("ModuleNumbering") << " Top node is  " << rDD.product() << " " << rDD.product()->name() << std::endl;
  edm::LogInfo("ModuleNumbering") << "    radLength " << rDD.product()->radLength() << "\n"
                                  << "           xi " << rDD.product()->xi() << "\n"
                                  << " PixelROCRows " << rDD.product()->pixROCRows() << "\n"
                                  << "   PixROCCols " << rDD.product()->pixROCCols() << "\n"
                                  << "   PixelROC_X " << rDD.product()->pixROCx() << "\n"
                                  << "   PixelROC_Y " << rDD.product()->pixROCy() << "\n"
                                  << "TrackerStereoDetectors " << (rDD.product()->stereo() ? "true" : "false") << "\n"
                                  << "SiliconAPVNumber " << rDD.product()->siliconAPVNum() << "\n";
  std::vector<int> nv = rDD.product()->navType();
  edm::LogInfo("ModuleNumbering").log([&](auto& log) {
    for (auto it : nv)
      log << it << ", ";
  });

  edm::LogInfo("ModuleNumbering") << " And Contains  Daughters: " << rDD.product()->deepComponents().size()
                                  << std::endl;
  // output file
  const std::string& outputFileName =
      (!rDD.product()->isFromDD4hep() ? "ModuleNumbering.log" : "ModuleNumbering_dd4hep.log");
  std::ofstream Output(outputFileName, std::ios::out);

  //
  //first instance tracking geometry
  //

  std::vector<const GeometricDet*> modules = (*rDD).deepComponents();
  std::map<uint32_t, const GeometricDet*> mapDetIdToGeometricDet;

  for (auto& module : modules) {
    mapDetIdToGeometricDet[module->geographicalId().rawId()] = module;
  }

  // Debug variables
  //
  uint32_t myDetId = 0;
  unsigned int iDetector = 1;
  unsigned int nSubDetectors = 6;
  //
  double polarRadius = 0.0;
  double phiRad = 0.0;
  double z = 0.0;
  //

  Output << "************************ List of modules with positions ************************" << std::endl;
  Output << std::fixed << std::setprecision(4);  // set as default 4 decimal digits (0.1 um or 0.1 rad)

  for (unsigned int iSubDetector = 1; iSubDetector <= nSubDetectors; iSubDetector++) {
    // modules
    switch (iSubDetector) {
        // PXB
      case 1: {
        break;
      }

        // PXF
      case 2: {
        break;
      }

        // TIB
      case 3: {
        // TIB loop
        // number of strings per layer 1/4 int/ext
        unsigned int string_int_ext_TIB[8] = {26, 30, 34, 38, 44, 46, 52, 56};
        unsigned int mod_type_TIB[8] = {1, 2, 1, 2, 0, 0, 0, 0};  // first and last type for module type loop
        unsigned int nLayers = 4;
        unsigned int nModules = 3;
        // debug variables
        double layer_R = 0.0;
        double layer_R_previous = 0.0;
        double side_z = 0.0;
        double side_z_previous = -10000.0;
        double part_R = 0.0;
        double part_R_previous = 0.0;
        double string_phi = 0.0;
        double string_phi_previous = 0.0;
        double module_z = 0.0;
        double module_z_previous = 0.0;
        //
        for (unsigned int iLayer = 1; iLayer <= nLayers; iLayer++) {  // Layer: 1,...,nLayers
          for (unsigned int iSide = 1; iSide <= 2; iSide++) {         // Side: 1:- 2:+
            for (unsigned int iPart = 1; iPart <= 2; iPart++) {       // Part: 1:int 2:ext
              unsigned int jString = (2 * (iLayer - 1)) + (iPart - 1);
              for (unsigned int iString = 1; iString <= string_int_ext_TIB[jString];
                   iString++) {                                                   // String: 1,...,nStrings
                for (unsigned int iModule = 1; iModule <= nModules; iModule++) {  // Module: 1,...,nModules
                  for (unsigned int iType = mod_type_TIB[2 * (iLayer - 1)]; iType <= mod_type_TIB[2 * (iLayer - 1) + 1];
                       iType++) {  // Module Type: 0 (ss) 1-2 (ds stereo and rphi)

                    myDetId = 0;
                    // detector
                    myDetId <<= 4;
                    myDetId |= iDetector;
                    // subdetector
                    myDetId <<= 3;
                    myDetId |= iSubDetector;
                    // not used
                    myDetId <<= 8;
                    myDetId |= 0;
                    // layer
                    myDetId <<= 3;
                    myDetId |= iLayer;
                    // side
                    myDetId <<= 2;
                    myDetId |= iSide;
                    // part
                    myDetId <<= 2;
                    myDetId |= iPart;
                    // string number
                    myDetId <<= 6;
                    myDetId |= iString;
                    // module number
                    myDetId <<= 2;
                    myDetId |= iModule;
                    // module type
                    myDetId <<= 2;
                    myDetId |= iType;
                    //
                    std::bitset<32> binary_myDetId(myDetId);
                    Output << std::endl << std::endl;
                    Output << " ******** myDet Id = " << myDetId << " (" << binary_myDetId << ")" << std::endl;
                    //
                    unsigned int rawid = mapDetIdToGeometricDet[myDetId]->geographicalId().rawId();
                    std::bitset<32> binary_detid(rawid);
                    GeometricDet::nav_type detNavType = mapDetIdToGeometricDet[myDetId]->navType();
                    //
                    Output << "            raw Id = " << rawid << " (" << binary_detid << ")"
                           << "\t nav type = " << GeometricDet::printNavType(&detNavType.front(), detNavType.size())
                           << std::endl;

                    // variables
                    fillModuleVariables(mapDetIdToGeometricDet[myDetId], polarRadius, phiRad, z);
                    layer_R = polarRadius;
                    side_z = z;
                    part_R = polarRadius;
                    string_phi = phiRad;
                    module_z = z;
                    //

                    Output << "\t R = " << polarRadius << "\t phi = " << phiRad << "\t z = " << z << std::endl;

                    // Module Info

                    std::string name = mapDetIdToGeometricDet[myDetId]->name();
                    unsigned int theLayer = tTopo->tibLayer(rawid);
                    std::vector<unsigned int> theString = tTopo->tibStringInfo(rawid);
                    unsigned int theModule = tTopo->tibModule(rawid);
                    std::string side;
                    std::string part;
                    side = (theString[0] == 1) ? "-" : "+";
                    part = (theString[1] == 1) ? "int" : "ext";
                    Output << " TIB" << side << "\t"
                           << "Layer " << theLayer << " " << part << "\t"
                           << "string " << theString[2] << "\t"
                           << " module " << theModule << " " << name << std::endl;
                    //

                    // module: |z| check
                    Output << "\t # ";
                    if ((std::abs(module_z) - std::abs(module_z_previous)) < (0 + tolerance_space)) {
                      Output << "\t ERROR |z| ordering not respected in module ";
                      iERROR++;
                    } else {
                      Output << "\t OK"
                             << " |z| ordering in module ";
                      iOK++;
                    }
                    Output << iModule - 1 << " to " << iModule << " (" << module_z_previous << " --> " << module_z
                           << ")" << std::endl;
                    //
                  }  // type loop

                  //
                  module_z_previous = module_z;
                  //
                }  // module loop

                // string: phi check
                Output << "\t ## ";
                if ((string_phi - string_phi_previous) < (0 - tolerance_angle)) {
                  Output << "\t ERROR phi ordering not respected in string ";
                  iERROR++;
                } else {
                  Output << "\t OK"
                         << " phi ordering in string ";
                  iOK++;
                }
                Output << iString - 1 << " to " << iString << " (" << string_phi_previous << " --> " << string_phi
                       << ")" << std::endl;
                //
                string_phi_previous = string_phi;
                module_z_previous = 0.0;
                //
              }  // string loop

              // part: R check
              Output << "\t ### ";
              if ((part_R - part_R_previous) < (0 + tolerance_space)) {
                Output << "\t ERROR R ordering (part int/ext) not respected in layer ";
                iERROR++;
              } else {
                Output << "\t OK"
                       << " R ordering (part int/ext) in layer ";
                iOK++;
              }
              Output << iLayer << " part " << iPart - 1 << " to " << iPart << " (" << part_R_previous << " --> "
                     << part_R << ")" << std::endl;
              //
              part_R_previous = part_R;
              string_phi_previous = 0.0;
              module_z_previous = 0.0;
              //
            }  // part loop

            // side: z check
            Output << "\t #### ";
            if ((side_z - side_z_previous) < (0 + tolerance_space)) {
              Output << "\t ERROR z ordering (side -/+) not respected in layer ";
              iERROR++;
            } else {
              Output << "\t OK"
                     << " z ordering (side -/+) in layer ";
              iOK++;
            }
            Output << iLayer << " side " << iSide - 1 << " to " << iSide << " (" << side_z_previous << " --> " << side_z
                   << ")" << std::endl;
            //
            side_z_previous = side_z;
            part_R_previous = 0.0;
            string_phi_previous = 0.0;
            module_z_previous = 0.0;
            //
          }  // side loop

          // layer: R check
          Output << "\t ##### ";
          if ((layer_R - layer_R_previous) < (0 + tolerance_space)) {
            Output << "\t ERROR R ordering not respected from layer ";
            iERROR++;
          } else {
            Output << "\t OK"
                   << " R ordering in layer ";
            iOK++;
          }
          Output << iLayer - 1 << " to " << iLayer << " (" << layer_R_previous << " --> " << layer_R << ")"
                 << std::endl;
          //
          layer_R_previous = layer_R;
          side_z_previous = -10000.0;
          part_R_previous = 0.0;
          string_phi_previous = 0.0;
          module_z_previous = 0.0;
          //
        }  // layer loop

        break;
      }

        // TID
      case 4: {
        // TID loop
        unsigned int modules_TID[3] = {12, 12, 20};               // number of modules per disk
        unsigned int mod_type_TID[8] = {1, 2, 1, 2, 0, 0, 0, 0};  // first and last type for module type loop
        unsigned int nDisks = 3;
        unsigned int nRings = 3;
        // debug variables
        double side_z = 0.0;
        double side_z_previous = 10000.0;
        double disk_z = 0.0;
        double disk_z_previous = 0.0;
        double ring_R = 0.0;
        double ring_R_previous = 0.0;
        double part_z = 0.0;
        double part_z_previous = 0.0;
        double module_phi = 0.0;
        double module_phi_previous = -M_PI;
        //
        for (unsigned int iSide = 2; iSide >= 1; iSide--) {           // Side: 1:- 2:+
          for (unsigned int iDisk = 1; iDisk <= nDisks; iDisk++) {    // Disk: 1,...,nDisks
            for (unsigned int iRing = 1; iRing <= nRings; iRing++) {  // Ring: 1,...,nRings
              for (int iPart = 2; iPart >= 1; iPart--) {              // Part: 1:back 2:front
                for (unsigned int iModule = 1; iModule <= modules_TID[iRing - 1];
                     iModule++) {  // Module: 1,...,modules in ring
                  for (unsigned int iType = mod_type_TID[2 * (iRing - 1)]; iType <= mod_type_TID[2 * (iRing - 1) + 1];
                       iType++) {  // Module Type: 0 (ss) 1-2 (ds stereo and rphi)

                    myDetId = 0;
                    // detector
                    myDetId <<= 4;
                    myDetId |= iDetector;
                    // subdetector
                    myDetId <<= 3;
                    myDetId |= iSubDetector;
                    // not used
                    myDetId <<= 10;
                    myDetId |= 0;
                    // side
                    myDetId <<= 2;
                    myDetId |= iSide;
                    // disk number
                    myDetId <<= 2;
                    myDetId |= iDisk;
                    // ring number
                    myDetId <<= 2;
                    myDetId |= iRing;
                    // part
                    myDetId <<= 2;
                    myDetId |= iPart;
                    // module number
                    myDetId <<= 5;
                    myDetId |= iModule;
                    // module type
                    myDetId <<= 2;
                    myDetId |= iType;
                    //
                    std::bitset<32> binary_myDetId(myDetId);
                    Output << std::endl << std::endl;
                    Output << " ******** myDet Id = " << myDetId << " (" << binary_myDetId << ")" << std::endl;
                    //
                    unsigned int rawid = mapDetIdToGeometricDet[myDetId]->geographicalId().rawId();
                    std::bitset<32> binary_detid(rawid);
                    GeometricDet::nav_type detNavType = mapDetIdToGeometricDet[myDetId]->navType();
                    //
                    Output << "            raw Id = " << rawid << " (" << binary_detid << ")"
                           << "\t nav type = " << GeometricDet::printNavType(&detNavType.front(), detNavType.size())
                           << std::endl;

                    // variables
                    fillModuleVariables(mapDetIdToGeometricDet[myDetId], polarRadius, phiRad, z);
                    side_z = z;
                    disk_z = z;
                    ring_R = polarRadius;
                    part_z = z;
                    module_phi = phiRad;
                    //

                    Output << "\t R = " << polarRadius << "\t phi = " << phiRad << "\t z = " << z << std::endl;

                    // Module Info

                    std::string name = mapDetIdToGeometricDet[myDetId]->name();
                    unsigned int theDisk = tTopo->tidWheel(rawid);
                    unsigned int theRing = tTopo->tidRing(rawid);
                    std::vector<unsigned int> theModule = tTopo->tidModuleInfo(rawid);
                    std::string side;
                    std::string part;
                    side = (tTopo->tidSide(rawid) == 1) ? "-" : "+";
                    part = (theModule[0] == 1) ? "back" : "front";
                    Output << " TID" << side << "\t"
                           << "Disk " << theDisk << " Ring " << theRing << " " << part << "\t"
                           << " module " << theModule[1] << "\t" << name << std::endl;
                    //

                    // module: phi check
                    Output << "\t # ";
                    if ((module_phi - module_phi_previous) < (0 - tolerance_angle)) {
                      Output << "\t ERROR phi ordering not respected in module ";
                      iERROR++;
                    } else {
                      Output << "\t OK"
                             << " phi ordering in module ";
                      iOK++;
                    }
                    Output << iModule - 1 << " to " << iModule << " (" << module_phi_previous << " --> " << module_phi
                           << ")" << std::endl;
                    //
                  }  // type loop

                  //
                  module_phi_previous = module_phi;
                  //
                }  // module loop

                // part: |z| check
                Output << "\t ## ";
                if ((std::abs(part_z) - std::abs(part_z_previous)) < (0 + tolerance_space)) {
                  Output << "\t ERROR |z| ordering (front/back) not respected in ring ";
                  iERROR++;
                } else {
                  Output << "\t OK"
                         << " |z| ordering (front/back) in ring ";
                  iOK++;
                }
                Output << iRing << " part " << iPart + 1 << " to " << iPart << " (" << part_z_previous << " --> "
                       << part_z << ")" << std::endl;
                //
                part_z_previous = part_z;
                module_phi_previous = -M_PI;
                //
              }  // part loop

              // ring: R check
              Output << "\t ### ";
              if ((ring_R - ring_R_previous) < (0 + tolerance_space)) {
                Output << "\t ERROR R ordering not respected in disk ";
                iERROR++;
              } else {
                Output << "\t OK"
                       << " R ordering in disk ";
                iOK++;
              }
              Output << iDisk << " ring " << iRing - 1 << " to " << iRing << " (" << ring_R_previous << " --> "
                     << ring_R << ")" << std::endl;
              //
              ring_R_previous = ring_R;
              part_z_previous = 0.0;
              module_phi_previous = -M_PI;
              //
            }  // ring loop

            // disk: |z| check
            Output << "\t #### ";
            if ((std::abs(disk_z) - std::abs(disk_z_previous)) < (0 + tolerance_space)) {
              Output << "\t ERROR |z| ordering not respected in disk ";
              iERROR++;
            } else {
              Output << "\t OK"
                     << " |z| ordering in disk ";
              iOK++;
            }
            Output << iDisk - 1 << " to " << iDisk << " (" << disk_z_previous << " --> " << disk_z << ")" << std::endl;
            //
            disk_z_previous = disk_z;
            ring_R_previous = 0.0;
            part_z_previous = 0.0;
            module_phi_previous = -M_PI;
            //
          }  // disk loop

          // side: z check
          Output << "\t ##### ";
          if ((side_z - side_z_previous) > (0 + tolerance_space)) {
            Output << "\t ERROR z ordering (side -/+) not respected in TID side ";
            iERROR++;
          } else {
            Output << "\t OK"
                   << " z ordering (side -/+) in TID side ";
            iOK++;
          }
          Output << iSide + 1 << " to " << iSide << " (" << side_z_previous << " --> " << side_z << ")" << std::endl;
          //
          side_z_previous = side_z;
          disk_z_previous = 0.0;
          ring_R_previous = 0.0;
          part_z_previous = 0.0;
          module_phi_previous = -M_PI;
          //
        }  // side loop

        break;
      }

        // TOB
      case 5: {
        // TOB loop
        unsigned int rod_TOB[8] = {42, 48, 54, 60, 66, 74};  // number of rods per layer 1/6
        unsigned int mod_type_TOB[12] = {
            1, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0};  // first and last type for module type loop
        unsigned int nLayers = 6;
        unsigned int nModules = 6;
        // debug variables
        double layer_R = 0.0;
        double layer_R_previous = 0.0;
        double side_z = 0.0;
        double side_z_previous = -10000.0;
        double rod_phi = 0.0;
        double rod_phi_previous = 0.0;
        double module_z = 0.0;
        double module_z_previous = 0.0;
        //
        for (unsigned int iLayer = 1; iLayer <= nLayers; iLayer++) {            // Layer: 1,...,nLayers
          for (unsigned int iSide = 1; iSide <= 2; iSide++) {                   // Side: 1:- 2:+
            for (unsigned int iRod = 1; iRod <= rod_TOB[iLayer - 1]; iRod++) {  // Rod: 1,...,nRods
              for (unsigned int iModule = 1; iModule <= nModules; iModule++) {  // Module: 1,...,nModules
                for (unsigned int iType = mod_type_TOB[2 * (iLayer - 1)]; iType <= mod_type_TOB[2 * (iLayer - 1) + 1];
                     iType++) {  // Module Type: 0 (ss) 1-2 (ds stereo and rphi)

                  myDetId = 0;
                  // detector
                  myDetId <<= 4;
                  myDetId |= iDetector;
                  // subdetector
                  myDetId <<= 3;
                  myDetId |= iSubDetector;
                  // not used
                  myDetId <<= 8;
                  myDetId |= 0;
                  // layer
                  myDetId <<= 3;
                  myDetId |= iLayer;
                  // side
                  myDetId <<= 2;
                  myDetId |= iSide;
                  // rod number
                  myDetId <<= 7;
                  myDetId |= iRod;
                  // module number
                  myDetId <<= 3;
                  myDetId |= iModule;
                  // module type
                  myDetId <<= 2;
                  myDetId |= iType;
                  //
                  std::bitset<32> binary_myDetId(myDetId);
                  Output << std::endl << std::endl;
                  Output << " ******** myDet Id = " << myDetId << " (" << binary_myDetId << ")" << std::endl;
                  //
                  unsigned int rawid = mapDetIdToGeometricDet[myDetId]->geographicalId().rawId();
                  std::bitset<32> binary_detid(rawid);
                  GeometricDet::nav_type detNavType = mapDetIdToGeometricDet[myDetId]->navType();
                  //
                  Output << "            raw Id = " << rawid << " (" << binary_detid << ")"
                         << "\t nav type = " << GeometricDet::printNavType(&detNavType.front(), detNavType.size())
                         << std::endl;

                  // variables
                  fillModuleVariables(mapDetIdToGeometricDet[myDetId], polarRadius, phiRad, z);
                  layer_R = polarRadius;
                  side_z = z;
                  rod_phi = phiRad;
                  module_z = z;
                  //

                  Output << "\t R = " << polarRadius << "\t phi = " << phiRad << "\t z = " << z << std::endl;

                  // Module Info

                  std::string name = mapDetIdToGeometricDet[myDetId]->name();
                  unsigned int theLayer = tTopo->tobLayer(rawid);
                  std::vector<unsigned int> theRod = tTopo->tobRodInfo(rawid);
                  unsigned int theModule = tTopo->tobModule(rawid);
                  std::string side;
                  std::string part;
                  side = (theRod[0] == 1) ? "-" : "+";
                  Output << " TOB" << side << "\t"
                         << "Layer " << theLayer << "\t"
                         << "rod " << theRod[1] << " module " << theModule << "\t" << name << std::endl;
                  //

                  // module: |z| check
                  Output << "\t # ";
                  if ((std::abs(module_z) - std::abs(module_z_previous)) < (0 + tolerance_space)) {
                    Output << "\t ERROR |z| ordering not respected in module ";
                    iERROR++;
                  } else {
                    Output << "\t OK"
                           << " |z| ordering in module ";
                    iOK++;
                  }
                  Output << iModule - 1 << " to " << iModule << " (" << module_z_previous << " --> " << module_z << ")"
                         << std::endl;
                  //
                }  // type loop

                //
                module_z_previous = module_z;
                //
              }  // module loop

              // rod: phi check
              Output << "\t ## ";
              if ((rod_phi - rod_phi_previous) < (0 - tolerance_angle)) {
                Output << "\t ERROR phi ordering not respected in rod ";
                iERROR++;
              } else {
                Output << "\t OK"
                       << " phi ordering in rod ";
                iOK++;
              }
              Output << iRod - 1 << " to " << iRod << " (" << rod_phi_previous << " --> " << rod_phi << ")"
                     << std::endl;
              //
              rod_phi_previous = rod_phi;
              module_z_previous = 0.0;
              //
            }  // rod loop

            // side: z check
            Output << "\t ### ";
            if ((side_z - side_z_previous) < (0 + tolerance_space)) {
              Output << "\t ERROR z ordering (side -/+) not respected in layer ";
              iERROR++;
            } else {
              Output << "\t OK"
                     << " z ordering (side -/+) in layer ";
              iOK++;
            }
            Output << iLayer << " side " << iSide - 1 << " to " << iSide << " (" << side_z_previous << " --> " << side_z
                   << ")" << std::endl;
            //
            side_z_previous = side_z;
            rod_phi_previous = 0.0;
            module_z_previous = 0.0;
            //
          }  // side loop

          // layer: R check
          Output << "\t #### ";
          if ((layer_R - layer_R_previous) < (0 + tolerance_space)) {
            Output << "\t ERROR R ordering not respected from layer ";
            iERROR++;
          } else {
            Output << "\t OK"
                   << " R ordering in layer ";
            iOK++;
          }
          Output << iLayer - 1 << " to " << iLayer << " (" << layer_R_previous << " --> " << layer_R << ")"
                 << std::endl;
          //
          layer_R_previous = layer_R;
          side_z_previous = -10000.0;
          rod_phi_previous = 0.0;
          module_z_previous = 0.0;
          //
        }  // layer loop

        break;
      }

        // TEC
      case 6: {
        // TEC loop
        unsigned int nWheels = 9;
        unsigned int nPetals = 8;
        unsigned int nRings = 7;
        unsigned int first_ring_TEC[9] = {1, 1, 1, 2, 2, 2, 3, 3, 4};  // first ring of the wheel
        unsigned int modules_ring_TEC[14] = {
            1, 2, 1, 2, 2, 3, 3, 4, 3, 2, 3, 4, 5, 5};  // number of modules ring=1,...,nRings back/front
        unsigned int mod_type_TEC[14] = {
            1, 2, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0};  // first and last type for module type loop (per ring)
        // debug variables
        double side_z = 0.0;
        double side_z_previous = 10000.0;
        double wheel_z = 0.0;
        double wheel_z_previous = 0.0;
        double part_z = 0.0;
        double part_z_previous = 0.0;
        double petal_phi = 0.0;
        double petal_phi_previous = 0.0;
        double ring_R = 0.0;
        double ring_R_previous = 0.0;
        double module_phi = 0.0;
        double module_phi_previous = -M_PI;
        //
        for (unsigned int iSide = 2; iSide >= 1; iSide--) {  // Side: 1:- 2:+
          switch (iSide) {
              // TEC+
            case 2: {
              side_z = 0.0;
              side_z_previous = 10000.0;
              wheel_z = 0.0;
              wheel_z_previous = 0.0;
              part_z = 0.0;
              part_z_previous = 0.0;
              petal_phi = 0.0;
              petal_phi_previous = 0.0;
              ring_R = 0.0;
              ring_R_previous = 0.0;
              module_phi = 0.0;
              module_phi_previous = -M_PI;
              break;
            }
              // TEC-
            case 1: {
              wheel_z = 0.0;
              wheel_z_previous = 0.0;
              part_z = 0.0;
              part_z_previous = 0.0;
              petal_phi = 0.0;
              petal_phi_previous = 0.0;
              ring_R = 0.0;
              ring_R_previous = 0.0;
              module_phi = 0.0;
              module_phi_previous = 2 * M_PI;
              break;
            }
            default: {
              // do nothing
            }
          }
          //
          for (unsigned int iWheel = 1; iWheel <= nWheels; iWheel++) {      // Wheel: 1,...,nWheels
            for (int iPart = 2; iPart >= 1; iPart--) {                      // Part: 1:back 2:front
              for (unsigned int iPetal = 1; iPetal <= nPetals; iPetal++) {  // Petal: 1,...,nPetals
                for (unsigned int iRing = first_ring_TEC[iWheel - 1]; iRing <= nRings;
                     iRing++) {  // Ring: first,...,nRings
                  unsigned int nModules = modules_ring_TEC[2 * (iRing - 1) + (iPart - 1)];
                  for (unsigned int iModule = 1; iModule <= nModules;
                       iModule++) {  // Module: 1,...,modules in ring of petal
                    for (unsigned int iType = mod_type_TEC[2 * (iRing - 1)]; iType <= mod_type_TEC[2 * (iRing - 1) + 1];
                         iType++) {  // Module Type: 0 (ss) 1-2 (ds stereo and rphi)

                      myDetId = 0;
                      // detector
                      myDetId <<= 4;
                      myDetId |= iDetector;
                      // subdetector
                      myDetId <<= 3;
                      myDetId |= iSubDetector;
                      // not used
                      myDetId <<= 5;
                      myDetId |= 0;
                      // side
                      myDetId <<= 2;
                      myDetId |= iSide;
                      // wheel number
                      myDetId <<= 4;
                      myDetId |= iWheel;
                      // part
                      myDetId <<= 2;
                      myDetId |= iPart;
                      // petal number
                      myDetId <<= 4;
                      myDetId |= iPetal;
                      // ring number
                      myDetId <<= 3;
                      myDetId |= iRing;
                      // module number
                      myDetId <<= 3;
                      myDetId |= iModule;
                      // module type
                      myDetId <<= 2;
                      myDetId |= iType;
                      //
                      std::bitset<32> binary_myDetId(myDetId);
                      Output << std::endl << std::endl;
                      Output << " ******** myDet Id = " << myDetId << " (" << binary_myDetId << ")" << std::endl;
                      //
                      unsigned int rawid = mapDetIdToGeometricDet[myDetId]->geographicalId().rawId();
                      std::bitset<32> binary_detid(rawid);
                      GeometricDet::nav_type detNavType = mapDetIdToGeometricDet[myDetId]->navType();
                      //
                      Output << "            raw Id = " << rawid << " (" << binary_detid << ")"
                             << "\t nav type = " << GeometricDet::printNavType(&detNavType.front(), detNavType.size())
                             << std::endl;

                      // variables
                      fillModuleVariables(mapDetIdToGeometricDet[myDetId], polarRadius, phiRad, z);
                      side_z = z;
                      wheel_z = z;
                      part_z = z;
                      switch (iSide) {
                          // TEC+
                        case 2: {
                          //do not change phiRad
                          break;
                        }
                          // TEC-
                        case 1: {
                          phiRad = changePhiRange_From_ZeroTwoPi_To_MinusPiPlusPi(phiRad);
                          break;
                        }
                        default: {
                          // do nothing
                        }
                      }

                      // petal must be ordered inside [0,2PI) for TEC+, [PI,-PI) for TEC-, take the phi of the central module in a ring with (2n+1) modules
                      if ((nModules % 2) && (iModule == (int)(nModules / 2) + (nModules % 2))) {
                        switch (iSide) {
                            // TEC+
                          case 2: {
                            petal_phi = phiRad;
                            break;
                          }
                            // TEC-
                          case 1: {
                            petal_phi = changePhiRange_From_MinusPiPlusPi_To_ZeroTwoPi(phiRad);
                            break;
                          }
                          default: {
                            // do nothing
                          }
                        }
                      }

                      ring_R = polarRadius;
                      //
                      // modules must be ordered inside petals [0,2PI)-->[-PI,PI) if the petal is near phi~0  TEC+ (petal number 1)
                      // modules must be ordered inside petals [PI,-PI)-->[2PI,0) if the petal is near phi~PI TEC- (petal number 5)
                      switch (iSide) {
                          // TEC+
                        case 2: {
                          if (iPetal == 1) {  // it is the request of the petal at phi = 0, always the first
                            module_phi = changePhiRange_From_ZeroTwoPi_To_MinusPiPlusPi(phiRad);
                          } else {
                            module_phi = phiRad;
                          }
                          break;
                        }
                          // TEC-
                        case 1: {
                          if (iPetal == 5) {  // it is the request of the petal at phi = PI, always the fifth
                            module_phi = changePhiRange_From_MinusPiPlusPi_To_MinusTwoPiZero(phiRad);
                          } else {
                            module_phi = phiRad;
                          }
                          break;
                        }
                        default: {
                          // do nothing
                        }
                      }

                      //

                      Output << "\t R = " << polarRadius << "\t phi = " << phiRad << "\t z = " << z << std::endl;

                      // Module Info

                      std::string name = mapDetIdToGeometricDet[myDetId]->name();
                      unsigned int theWheel = tTopo->tecWheel(rawid);
                      unsigned int theModule = tTopo->tecModule(rawid);
                      std::vector<unsigned int> thePetal = tTopo->tecPetalInfo(rawid);
                      unsigned int theRing = tTopo->tecRing(rawid);
                      std::string side;
                      std::string petal;
                      side = (tTopo->tecSide(rawid) == 1) ? "-" : "+";
                      petal = (thePetal[0] == 1) ? "back" : "front";
                      Output << " TEC" << side << "\t"
                             << "Wheel " << theWheel << " Petal " << thePetal[1] << " " << petal << " Ring " << theRing
                             << "\t"
                             << "\t"
                             << " module " << theModule << "\t" << name << std::endl;
                      //

                      // module: phi check
                      Output << "\t # ";
                      switch (iSide) {
                          // TEC+
                        case 2: {
                          if ((module_phi - module_phi_previous) < (0 - tolerance_angle)) {
                            Output << "\t ERROR phi ordering not respected in module ";
                            iERROR++;
                          } else {
                            Output << "\t OK"
                                   << " phi ordering in module ";
                            iOK++;
                          }
                          Output << iModule - 1 << " to " << iModule << " (" << module_phi_previous << " --> "
                                 << module_phi << ")" << std::endl;
                          break;
                        }
                          // TEC-
                        case 1: {
                          if ((module_phi - module_phi_previous) > (0 + tolerance_angle)) {
                            Output << "\t ERROR phi ordering not respected in module ";
                            iERROR++;
                          } else {
                            Output << "\t OK"
                                   << " phi ordering in module ";
                            iOK++;
                          }
                          Output << iModule - 1 << " to " << iModule << " (" << module_phi_previous << " --> "
                                 << module_phi << ")" << std::endl;
                          break;
                        }
                        default: {
                          // do nothing
                        }
                      }
                      //
                    }  // type loop

                    //
                    module_phi_previous = module_phi;
                    //
                  }  // module loop

                  // ring: R check
                  Output << "\t ## ";
                  if ((ring_R - ring_R_previous) < (0 + tolerance_space)) {
                    Output << "\t ERROR R ordering not respected in petal ";
                    iERROR++;
                  } else {
                    Output << "\t OK"
                           << " R ordering in petal ";
                    iOK++;
                  }
                  Output << iPetal << " ring " << iRing - 1 << " to " << iRing << " (" << ring_R_previous << " --> "
                         << ring_R << ")" << std::endl;
                  //
                  switch (iSide) {
                      // TEC+
                    case 2: {
                      ring_R_previous = ring_R;
                      module_phi_previous = -M_PI;
                      break;
                    }
                      // TEC-
                    case 1: {
                      ring_R_previous = ring_R;
                      module_phi_previous = 2 * M_PI;
                      break;
                    }
                    default: {
                      // do nothing
                    }
                  }
                  //
                }  // ring loop

                // petal: phi check
                Output << "\t ### ";
                switch (iSide) {
                    // TEC+
                  case 2: {
                    if ((petal_phi - petal_phi_previous) < (0 - tolerance_angle)) {
                      Output << "\t ERROR phi ordering not respected in petal ";
                      iERROR++;
                    } else {
                      Output << "\t OK"
                             << " phi ordering in petal ";
                      iOK++;
                    }
                    Output << iPetal - 1 << " to " << iPetal << " (" << petal_phi_previous << " --> " << petal_phi
                           << ")" << std::endl;
                    //
                    petal_phi_previous = petal_phi;
                    ring_R_previous = 0.0;
                    module_phi_previous = -M_PI;
                    //
                    break;
                  }
                    // TEC-
                  case 1: {
                    if ((petal_phi - petal_phi_previous) < (0 - tolerance_angle)) {
                      Output << "\t ERROR phi ordering not respected in petal ";
                      iERROR++;
                    } else {
                      Output << "\t OK"
                             << " phi ordering in petal ";
                      iOK++;
                    }
                    Output << iPetal - 1 << " to " << iPetal << " (" << petal_phi_previous << " --> " << petal_phi
                           << ")" << std::endl;
                    //
                    petal_phi_previous = petal_phi;
                    ring_R_previous = 0.0;
                    module_phi_previous = 2 * M_PI;
                    //
                    break;
                  }
                  default: {
                    // do nothing
                  }
                }
                //
              }  // petal loop

              // part: |z| check
              Output << "\t #### ";
              if ((std::abs(part_z) - std::abs(part_z_previous)) < (0 + tolerance_space)) {
                Output << "\t ERROR |z| ordering (front/back) not respected in wheel ";
                iERROR++;
              } else {
                Output << "\t OK"
                       << " |z| (front/back) ordering in wheel ";
                iOK++;
              }
              Output << iWheel << " part " << iPart + 1 << " to " << iPart << " (" << part_z_previous << " --> "
                     << part_z << ")" << std::endl;
              //
              switch (iSide) {
                  // TEC+
                case 2: {
                  part_z_previous = part_z;
                  petal_phi_previous = 0.0;
                  ring_R_previous = 0.0;
                  module_phi_previous = -M_PI;
                  break;
                }
                  // TEC-
                case 1: {
                  part_z_previous = part_z;
                  petal_phi_previous = 0.0;
                  ring_R_previous = 0.0;
                  module_phi_previous = 2 * M_PI;
                  break;
                }
                default: {
                  // do nothing
                }
              }
              //
            }  // part loop

            // wheel: |z| check
            Output << "\t ##### ";
            if ((std::abs(wheel_z) - std::abs(wheel_z_previous)) < (0 + tolerance_space)) {
              Output << "\t ERROR |z| ordering not respected in wheel ";
              iERROR++;
            } else {
              Output << "\t OK"
                     << " |z| ordering in wheel ";
              iOK++;
            }
            Output << iWheel - 1 << " to " << iWheel << " (" << wheel_z_previous << " --> " << wheel_z << ")"
                   << std::endl;
            //
            switch (iSide) {
                // TEC+
              case 2: {
                wheel_z_previous = wheel_z;
                part_z_previous = 0.0;
                petal_phi_previous = 0.0;
                ring_R_previous = 0.0;
                module_phi_previous = -M_PI;
                break;
              }
                // TEC-
              case 1: {
                wheel_z_previous = wheel_z;
                part_z_previous = 0.0;
                petal_phi_previous = 0.0;
                ring_R_previous = 0.0;
                module_phi_previous = 2 * M_PI;
                break;
              }
              default: {
                // do nothing
              }
            }
            //
          }  // wheel loop

          // side: z check
          Output << "\t ###### ";
          if ((side_z - side_z_previous) > (0 + tolerance_space)) {
            Output << "\t ERROR z ordering (side -/+) not respected in TEC side ";
            iERROR++;
          } else {
            Output << "\t OK"
                   << " z ordering (side -/+) in TEC side ";
            iOK++;
          }
          Output << iSide + 1 << " to " << iSide << " (" << side_z_previous << " --> " << side_z << ")" << std::endl;
          //
          switch (iSide) {
              // TEC+
            case 2: {
              side_z_previous = side_z;
              wheel_z_previous = 0.0;
              part_z_previous = 0.0;
              petal_phi_previous = 0.0;
              ring_R_previous = 0.0;
              module_phi_previous = -M_PI;
              break;
            }
              // TEC-
            case 1: {
              side_z_previous = side_z;
              wheel_z_previous = 0.0;
              part_z_previous = 0.0;
              petal_phi_previous = 0.0;
              ring_R_previous = 0.0;
              module_phi_previous = 2 * M_PI;
              break;
            }
            default: {
              // do nothing
            }
          }
          //
        }  // side loop

        break;
      }
      default:
        Output << " WARNING no Silicon Strip subdetector, I got a " << iSubDetector << std::endl;
        ;
    }

  }  // subdetector loop

  // summary
  unsigned int iChecks = iOK + iERROR;
  Output << std::endl << std::endl;
  Output << "-------------------------------------" << std::endl;
  Output << " Module Numbering Check Summary      " << std::endl;
  Output << "-------------------------------------" << std::endl;
  Output << " Number of checks:   " << std::setw(6) << iChecks << std::endl;
  Output << "               OK:   " << std::setw(6) << iOK << " (" << std::fixed << std::setprecision(2)
         << ((double)iOK / (double)iChecks) * 100 << "%) " << std::endl;
  Output << "           ERRORS:   " << std::setw(6) << iERROR << " (" << std::fixed << std::setprecision(2)
         << ((double)iERROR / (double)iChecks) * 100 << "%) " << std::endl;
  Output << "-------------------------------------" << std::endl;
}

//define this as a plug-in
DEFINE_FWK_MODULE(ModuleNumbering);