Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Geometry/MuonNumbering/interface/ME0NumberingScheme.h"
0002 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
0003 #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
0004 #include "DataFormats/MuonDetId/interface/ME0DetId.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 
0008 //#define EDM_ML_DEBUG
0009 
0010 ME0NumberingScheme::ME0NumberingScheme(const MuonGeometryConstants& muonConstants) { initMe(muonConstants); }
0011 
0012 void ME0NumberingScheme::initMe(const MuonGeometryConstants& muonConstants) {
0013   int theLevelPart = muonConstants.getValue("level");
0014   theRegionLevel = muonConstants.getValue("m0_region") / theLevelPart;
0015   theLayerLevel = muonConstants.getValue("m0_layer") / theLevelPart;
0016   theSectorLevel = muonConstants.getValue("m0_sector") / theLevelPart;
0017   theRollLevel = muonConstants.getValue("m0_roll") / theLevelPart;
0018   theNEtaPart = muonConstants.getValue("m0_nroll");
0019 
0020   // Debug using EDM_ML_DEBUG
0021 #ifdef EDM_ML_DEBUG
0022   edm::LogVerbatim("MuonGeom") << "Initialize ME0NumberingScheme"
0023                                << "\ntheRegionLevel " << theRegionLevel << "\ntheLayerLevel " << theLayerLevel
0024                                << "\ntheSectorLevel " << theSectorLevel << "\ntheRollLevel " << theRollLevel
0025                                << "\ntheNEtaPart  " << theNEtaPart;
0026 #endif
0027   // -----------------------
0028 }
0029 
0030 int ME0NumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) const {
0031   // Debug using EDM_ML_DEBUG
0032 #ifdef EDM_ML_DEBUG
0033   edm::LogVerbatim("MuonGeom") << "ME0NumberingScheme::baseNumberToUnitNumber BEGIN ";
0034   edm::LogVerbatim("MuonGeom") << "ME0Numbering " << num.getLevels();
0035   for (int level = 1; level <= num.getLevels(); level++) {
0036     edm::LogVerbatim("MuonGeom") << "level " << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
0037   }
0038 #endif
0039   // -----------------------
0040 
0041 #ifdef EDM_ML_DEBUG
0042   if (num.getLevels() != theRollLevel)
0043     edm::LogVerbatim("MuonGeom") << "MuonME0NS::BNToUN BaseNumber has " << num.getLevels()
0044                                  << " levels which is less than " << theRollLevel;
0045 #endif
0046 
0047   int region(ME0DetId::minRegionId), layer(ME0DetId::minLayerId);
0048   int chamber(ME0DetId::minChamberId), roll(ME0DetId::minRollId);
0049 
0050   //decode significant ME0 levels
0051 
0052   if (num.getBaseNo(theRegionLevel) == 0)
0053     region = 1;
0054   else
0055     region = -1;
0056   if (num.getLevels() >= theLayerLevel)
0057     layer = num.getBaseNo(theLayerLevel) + 1;
0058   if (num.getLevels() >= theSectorLevel)
0059     chamber = num.getBaseNo(theSectorLevel) + 1;
0060   if (num.getLevels() >= theRollLevel)
0061     roll = num.getBaseNo(theRollLevel) + 1;
0062 
0063     // collect all info
0064 
0065     // Debug using EDM_ML_DEBUG
0066 #ifdef EDM_ML_DEBUG
0067   edm::LogVerbatim("MuonGeom") << "ME0NumberingScheme: Region " << region << " Layer " << layer << " Chamber "
0068                                << chamber << " Roll " << roll;
0069 #endif
0070   // -----------------------
0071 
0072   // Build the actual numbering
0073   ME0DetId id(region, layer, chamber, roll);
0074 
0075   // Debug using EDM_ML_DEBUG
0076 #ifdef EDM_ML_DEBUG
0077   edm::LogVerbatim("MuonGeom") << " DetId " << id;
0078 #endif
0079   // ---------------------
0080 
0081   return id.rawId();
0082 }