Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Geometry/MuonNumbering/interface/GEMNumberingScheme.h"
0002 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
0003 #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
0004 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 //#define EDM_ML_DEBUG
0008 
0009 GEMNumberingScheme::GEMNumberingScheme(const MuonGeometryConstants& muonConstants) { initMe(muonConstants); }
0010 
0011 void GEMNumberingScheme::initMe(const MuonGeometryConstants& muonConstants) {
0012   int theLevelPart = muonConstants.getValue("level");
0013   theRegionLevel = muonConstants.getValue("mg_region") / theLevelPart;
0014   theStationLevel = muonConstants.getValue("mg_station") / theLevelPart;
0015   theRingLevel = muonConstants.getValue("mg_ring") / theLevelPart;
0016   theSectorLevel = muonConstants.getValue("mg_sector") / theLevelPart;
0017   theRollLevel = muonConstants.getValue("mg_roll") / theLevelPart;
0018 #ifdef EDM_ML_DEBUG
0019   edm::LogVerbatim("MuonGeom") << "Initialize GEMNumberingScheme"
0020                                << "\ntheRegionLevel " << theRegionLevel << "\ntheStationLevel " << theStationLevel
0021                                << "\ntheRingLevel " << theRingLevel << "\ntheSectorLevel " << theSectorLevel
0022                                << "\ntheRollLevel " << theRollLevel;
0023 #endif
0024 }
0025 
0026 int GEMNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) const {
0027 #ifdef EDM_ML_DEBUG
0028   edm::LogVerbatim("MuonGeom") << "GEMNumbering " << num.getLevels();
0029   for (int level = 1; level <= num.getLevels(); level++) {
0030     edm::LogVerbatim("MuonGeom") << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
0031   }
0032 #endif
0033 
0034   int levels = num.getLevels();
0035 #ifdef EDM_ML_DEBUG
0036   if (levels != theRollLevel)
0037     edm::LogVerbatim("MuonGeom") << "MuonGEMNumberingScheme::BNToUN: BaseNumber has " << num.getLevels()
0038                                  << " levels, need at least till " << theRollLevel;
0039 #endif
0040 
0041   int region(GEMDetId::minRegionId), ring(GEMDetId::minRingId);
0042   int station(GEMDetId::minStationId0), layer(GEMDetId::minLayerId);
0043   int chamber(1 + GEMDetId::minChamberId), roll(GEMDetId::minRollId);
0044 
0045   //decode significant GEM levels
0046 
0047   if (levels >= theRegionLevel) {
0048     if (num.getBaseNo(theRegionLevel) == 0)
0049       region = 1;
0050     else
0051       region = -1;
0052   }
0053 
0054   // All GEM super chambers in stations 1 and 2 are on ring 1.
0055   // The long super chambers in station 2 are assigned *station 3* due
0056   // to the current limitation in the definition of the GEMDetId,
0057   // i.e. only 2 layers available per station.
0058   //  ring    = num.getSuperNo(theRingLevel);
0059   // GEM are only on the first ring
0060   ring = 1;
0061 
0062   // GE0 has the layer encoded in the ring level
0063   if (levels > theRingLevel) {
0064     if (num.getBaseNo(theRingLevel) == 0) {  // 0 => GE1/1, GE2/1
0065       station = num.getSuperNo(theStationLevel);
0066 #ifdef EDM_ML_DEBUG
0067       edm::LogVerbatim("MuonGeom") << "GEMNumbering: Ring " << ring << " Station " << num.getSuperNo(theStationLevel)
0068                                    << ":" << station;
0069 #endif
0070       if (levels >= theRollLevel)
0071         roll = num.getBaseNo(theRollLevel) + 1;
0072       if (levels >= theSectorLevel) {
0073         const int copyno = num.getBaseNo(theSectorLevel) + 1;
0074         // Half the chambers are flipped back to front, this is encoded in
0075         // the chamber number, which affects the layer numbering. Layer 1
0076         // is always the closest layer to the interaction point.
0077         const int layerDemarcation = 50;
0078         if (copyno < layerDemarcation) {
0079           if (copyno % 2 == 0) {
0080             layer = 2;
0081             chamber = copyno - 1;
0082           } else {
0083             layer = 1;
0084             chamber = copyno;
0085           }
0086         } else {
0087           int copynp = copyno - layerDemarcation;
0088           if (copynp % 2 != 0) {
0089             layer = 2;
0090             chamber = copynp - 1;
0091           } else {
0092             layer = 1;
0093             chamber = copynp;
0094           }
0095         }
0096       }
0097     } else {  // GE0 encodes the layer
0098       station = GEMDetId::minStationId0;
0099       layer = num.getBaseNo(theRingLevel);
0100       if (levels >= theSectorLevel)
0101         chamber = num.getBaseNo(theSectorLevel) + 1;
0102       if (levels >= theRollLevel)
0103         roll = num.getBaseNo(theRollLevel) + 1;
0104     }
0105   } else if (levels == theRingLevel) {
0106     station = GEMDetId::minStationId0;
0107     layer = 1;
0108   }
0109 
0110   // collect all info
0111 
0112 #ifdef EDM_ML_DEBUG
0113   edm::LogVerbatim("MuonGeom") << "GEMNumberingScheme: Region " << region << " Ring " << ring << " Station " << station
0114                                << " Layer " << layer << " Chamber " << chamber << " Roll " << roll;
0115 #endif
0116 
0117   // Build the actual numbering
0118   GEMDetId id(region, ring, station, layer, chamber, roll);
0119 
0120 #ifdef EDM_ML_DEBUG
0121   edm::LogVerbatim("MuonGeom") << id.rawId() << " DetId " << id;
0122 #endif
0123 
0124   return id.rawId();
0125 }