Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-05 04:09:54

0001 #include "Geometry/MuonNumbering/interface/RPCNumberingScheme.h"
0002 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
0003 #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
0004 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 //#define EDM_ML_DEBUG
0008 
0009 RPCNumberingScheme::RPCNumberingScheme(const MuonGeometryConstants& muonConstants) { initMe(muonConstants); }
0010 
0011 void RPCNumberingScheme::initMe(const MuonGeometryConstants& muonConstants) {
0012   int theLevelPart = muonConstants.getValue("level");
0013   theRegionLevel = muonConstants.getValue("mr_region") / theLevelPart;
0014   theBWheelLevel = muonConstants.getValue("mr_bwheel") / theLevelPart;
0015   theBStationLevel = muonConstants.getValue("mr_bstation") / theLevelPart;
0016   theBPlaneLevel = muonConstants.getValue("mr_bplane") / theLevelPart;
0017   theBChamberLevel = muonConstants.getValue("mr_bchamber") / theLevelPart;
0018   theEPlaneLevel = muonConstants.getValue("mr_eplane") / theLevelPart;
0019   theESectorLevel = muonConstants.getValue("mr_esector") / theLevelPart;
0020   theERollLevel = muonConstants.getValue("mr_eroll") / theLevelPart;
0021 #ifdef EDM_ML_DEBUG
0022   edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme::theRegionLevel " << theRegionLevel << "\ntheBWheelLevel "
0023                                << theBWheelLevel << "\ntheBStationLevel " << theBStationLevel << "\ntheBPlaneLevel "
0024                                << theBPlaneLevel << "\ntheBChamberLevel " << theBChamberLevel << "\ntheEPlaneLevel "
0025                                << theEPlaneLevel << "\ntheESectorLevel " << theESectorLevel << "\ntheERollLevel "
0026                                << theERollLevel;
0027 #endif
0028 }
0029 
0030 int RPCNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) const {
0031 #ifdef EDM_ML_DEBUG
0032   edm::LogVerbatim("MuonGeom") << "RPCNumbering " << num.getLevels();
0033   for (int level = 1; level <= num.getLevels(); level++) {
0034     edm::LogVerbatim("MuonGeom") << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
0035   }
0036 #endif
0037 
0038   const int barrel = num.getSuperNo(theRegionLevel);
0039   bool barrel_muon = (barrel == 1);
0040   int maxLevel;
0041   if (barrel_muon) {
0042     maxLevel = theBChamberLevel;
0043   } else {
0044     maxLevel = theERollLevel;
0045   }
0046 
0047   if (num.getLevels() != maxLevel) {
0048     edm::LogWarning("MuonGeom") << "RPCNumberingScheme::BNToUN: BaseNumber has " << num.getLevels() << " levels, need "
0049                                 << maxLevel;
0050     return 0;
0051   }
0052 
0053   int plane_id = 0;
0054   int sector_id = 0;
0055   int copy_id = 0;
0056   int roll_id = 0;
0057   int eta_id = 0;
0058   int rr12_id = 0;
0059   bool forward = false;
0060 
0061   int sector_copy = 0;
0062 
0063   //decode significant rpc levels
0064 
0065   for (int level = 1; level <= maxLevel; level++) {
0066     //decode
0067     if (level == theRegionLevel) {
0068       if (barrel_muon) {
0069         roll_id = 0;
0070       } else {
0071         copy_id = 1;
0072       }
0073     }
0074     if (barrel_muon) {
0075       if (level == theBWheelLevel) {
0076         const int copyno = num.getBaseNo(level);
0077         eta_id = 4 + copyno;  //copyno= [0,4]
0078       } else if (level == theBStationLevel) {
0079         //- const int station_tag = num.getSuperNo(level);
0080         const int copyno = num.getBaseNo(level);
0081 
0082         sector_id = copyno + 1;
0083         if (sector_id == 13) {
0084           sector_id = 4;
0085           sector_copy = 1;
0086         } else if (sector_id == 14) {
0087           sector_id = 10;
0088           sector_copy = 1;
0089         }
0090         // mltiply by 3 to merge with endcaps
0091         sector_id *= 3;
0092 
0093       } else if (level == theBPlaneLevel) {
0094         const int plane_tag = num.getSuperNo(level);
0095         //        const int copyno = num.getBaseNo(level);
0096         if (plane_tag == 1) {
0097           plane_id = 1;
0098         } else if (plane_tag == 2) {
0099           plane_id = 5;
0100         } else if (plane_tag == 3) {
0101           //          if(copyno == 1) {
0102           //if(eta_id == 4 || eta_id == 8) {
0103           //  plane_id=6;
0104 
0105           plane_id = 2;
0106           // }
0107 
0108           //          std::cout<<" KONTROLA w RPCNumberingScheme: eta_id: "<<eta_id<<", plane_tag: "<<plane_tag<<", plane_id: "<<plane_id<<std::endl;
0109         } else if (plane_tag == 4) {
0110           //          if(copyno == 1) {
0111           // if(eta_id == 4 || eta_id == 8) {
0112           //  plane_id=2;
0113           //} else {
0114           plane_id = 6;
0115           //}
0116           //          std::cout<<" KONTROLA w RPCNumberingScheme: eta_id: "<<eta_id<<", plane_tag: "<<plane_tag<<", plane_id: "<<plane_id<<std::endl;
0117         } else if (plane_tag == 5) {
0118           plane_id = 3;
0119         } else {
0120           plane_id = 4;
0121         }
0122 
0123       } else if (level == theBChamberLevel) {
0124         const int copyno = num.getBaseNo(level);
0125         if ((plane_id == 4) && (sector_id == 4 * 3)) {
0126           copy_id = sector_copy * 2 + copyno + 1;
0127         } else if ((plane_id == 4) && (sector_id == 10 * 3)) {
0128           copy_id = sector_copy + 1;
0129         } else {
0130           copy_id = copyno + 1;
0131         }
0132         const int rollno = num.getSuperNo(level);
0133         roll_id = rollno;
0134       }
0135 
0136     } else {
0137       if (level == theRegionLevel) {
0138         const int copyno = num.getBaseNo(level);
0139         forward = (copyno == 0);
0140       } else if (level == theEPlaneLevel) {
0141         const int plane_tag = num.getSuperNo(level);
0142         const int rr12_tag = num.getBaseNo(level);
0143         plane_id = plane_tag;
0144         rr12_id = rr12_tag;
0145       } else if (level == theESectorLevel) {
0146         const int copyno = num.getBaseNo(level);
0147         sector_id = copyno + 1;
0148         if (rr12_id == 1) {
0149           sector_id = sector_id * 2 - 1;
0150         } else if (rr12_id == 2) {
0151           sector_id = sector_id * 2;
0152         }
0153       } else if (level == theERollLevel) {
0154         const int copyno = num.getBaseNo(level);
0155         const int eta_tag = num.getSuperNo(level);
0156 
0157         if ((eta_tag == 1) || (eta_tag == 4) || (eta_tag == 7) || (eta_tag == 8)) {
0158           eta_id = 1;
0159         } else if ((eta_tag == 2) || (eta_tag == 5)) {
0160           eta_id = 2;
0161         } else if ((eta_tag == 3) || (eta_tag == 6)) {
0162           eta_id = 3;
0163         }
0164 
0165         if (forward)
0166           eta_id = 12 - eta_id;
0167 
0168         // increase sector id for 20 degree chambers
0169 
0170         if ((eta_tag == 4) || (eta_tag == 7) || (eta_tag == 8)) {
0171           sector_id *= 2;
0172         }
0173 
0174         roll_id = copyno + 1;
0175       }
0176     }
0177   }
0178 
0179   // collect all info
0180 
0181   int trIndex = (eta_id * 10000 + plane_id * 1000 + sector_id * 10 + copy_id) * 10 + roll_id;
0182 
0183 #ifdef EDM_ML_DEBUG
0184   if (barrel_muon) {
0185     edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (barrel): ";
0186   } else {
0187     if (forward) {
0188       edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (forward): ";
0189     } else {
0190       edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (backward): ";
0191     }
0192   }
0193   edm::LogVerbatim("MuonGeom") << " roll " << roll_id << " copy " << copy_id << " sector " << sector_id << " plane "
0194                                << plane_id << " eta " << eta_id << " rr12 " << rr12_id;
0195 #endif
0196 
0197   // Build the actual numbering
0198   RPCDetId id;
0199   id.buildfromTrIndex(trIndex);
0200 
0201 #ifdef EDM_ML_DEBUG
0202   edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme:: DetId " << id;
0203 #endif
0204 
0205   return id.rawId();
0206 }