Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class DTNumberingScheme
0002  *
0003  * implementation of MuonNumberingScheme for muon barrel,
0004  * converts the MuonBaseNumber to a unit id
0005  *  
0006  * Original \author Arno Straessner, CERN <arno.straessner@cern.ch>
0007  *         Modified by Sunanda B. in different PRs (the last one is #30971)
0008  *
0009  */
0010 
0011 #include "Geometry/MuonNumbering/interface/DTNumberingScheme.h"
0012 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0013 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
0014 #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 
0017 //#define EDM_ML_DEBUG
0018 
0019 DTNumberingScheme::DTNumberingScheme(const MuonGeometryConstants& muonConstants) { initMe(muonConstants); }
0020 
0021 void DTNumberingScheme::initMe(const MuonGeometryConstants& muonConstants) {
0022   int theLevelPart = muonConstants.getValue("level");
0023   theRegionLevel = muonConstants.getValue("mb_region") / theLevelPart;
0024   theWheelLevel = muonConstants.getValue("mb_wheel") / theLevelPart;
0025   theStationLevel = muonConstants.getValue("mb_station") / theLevelPart;
0026   theSuperLayerLevel = muonConstants.getValue("mb_superlayer") / theLevelPart;
0027   theLayerLevel = muonConstants.getValue("mb_layer") / theLevelPart;
0028   theWireLevel = muonConstants.getValue("mb_wire") / theLevelPart;
0029 #ifdef EDM_ML_DEBUG
0030   edm::LogVerbatim("MuonGeom") << "Initialize DTNumberingScheme\ntheRegionLevel " << theRegionLevel
0031                                << "\ntheWheelLevel " << theWheelLevel << "\ntheStationLevel " << theStationLevel
0032                                << "\ntheSuperLayerLevel " << theSuperLayerLevel << "\ntheLayerLevel " << theLayerLevel
0033                                << "\ntheWireLevel " << theWireLevel;
0034 #endif
0035 }
0036 
0037 int DTNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) const {
0038 #ifdef EDM_ML_DEBUG
0039   edm::LogVerbatim("MuonGeom") << "DTNumbering " << num.getLevels();
0040   for (int level = 1; level <= num.getLevels(); level++) {
0041     edm::LogVerbatim("MuonGeom") << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
0042   }
0043 #endif
0044   if (num.getLevels() < theStationLevel) {  // it was  if (num.getLevels() != theWireLevel) {
0045     edm::LogWarning("MuonGeom") << "DTNumberingScheme::BNToUN: BaseNumber has " << num.getLevels() << " levels, need "
0046                                 << theStationLevel;  //it was theWireLevel;
0047     return 0;
0048   }
0049 
0050   //   // Meaningful ranges are enforced by DTWireId, (which
0051   //   // however allows for 0 in wire, layer, superlayer!!!)
0052   //
0053   //   if ((wire_id < 1) || (wire_id > 100)) {
0054   //     std::cout << "DTNumberingScheme: ";
0055   //     std::cout << "wire id out of range: ";
0056   //     std::cout << wire_id <<std::endl;
0057   //   }
0058 
0059   //   if ((layer_id < 1) || (layer_id > 4)) {
0060   //     std::cout << "DTNumberingScheme: ";
0061   //     std::cout << "layer id out of range: ";
0062   //     std::cout << layer_id <<std::endl;
0063   //   }
0064 
0065   //   if ((superlayer_id < 1) || (superlayer_id > 3)) {
0066   //     std::cout << "DTNumberingScheme: ";
0067   //     std::cout << "super-layer id out of range: ";
0068   //     std::cout << superlayer_id <<std::endl;
0069   //   }
0070 
0071   return getDetId(num);
0072 }
0073 
0074 int DTNumberingScheme::getDetId(const MuonBaseNumber& num) const {
0075   int wire_id = 0;
0076   int layer_id = 0;
0077   int superlayer_id = 0;
0078   int sector_id = 0;
0079   int station_id = 0;
0080   int wheel_id = 0;
0081 
0082   //decode significant barrel levels
0083   decode(num, wire_id, layer_id, superlayer_id, sector_id, station_id, wheel_id);
0084 
0085   // These ranges are enforced by DTWireId
0086   //   if ((sector_id < 1) || (sector_id > 14)) {
0087   //     std::cout << "DTNumberingScheme: ";
0088   //     std::cout << "sector id out of range: ";
0089   //     std::cout << sector_id <<std::endl;
0090   //   }
0091 
0092   //   if ((station_id < 1) || (station_id > 4)) {
0093   //     std::cout << "DTNumberingScheme: ";
0094   //     std::cout << "station id out of range: ";
0095   //     std::cout << station_id <<std::endl;
0096   //   }
0097 
0098   //   if ((wheel_id < -2) || (wheel_id > 2)) {
0099   //     std::cout << "DTNumberingScheme: ";
0100   //     std::cout << "wheel id out of range: ";
0101   //     std::cout << wheel_id <<std::endl;
0102   //   }
0103 
0104   DTWireId id(wheel_id, station_id, sector_id, superlayer_id, layer_id, wire_id);
0105 
0106 #ifdef EDM_ML_DEBUG
0107   edm::LogVerbatim("MuonGeom") << "DTNumberingScheme: " << id;
0108 #endif
0109 
0110   return id.rawId();
0111 }
0112 
0113 void DTNumberingScheme::decode(const MuonBaseNumber& num,
0114                                int& wire_id,
0115                                int& layer_id,
0116                                int& superlayer_id,
0117                                int& sector_id,
0118                                int& station_id,
0119                                int& wheel_id) const {
0120   for (int level = 1; level <= num.getLevels(); level++) {
0121     //decode
0122     if (level == theWheelLevel) {
0123       const int copyno = num.getBaseNo(level);
0124       wheel_id = copyno - 2;
0125 
0126     } else if (level == theStationLevel) {
0127       const int station_tag = num.getSuperNo(level);
0128       const int copyno = num.getBaseNo(level);
0129       station_id = station_tag;
0130       sector_id = copyno + 1;
0131 
0132     } else if (level == theSuperLayerLevel) {
0133       const int copyno = num.getBaseNo(level);
0134       superlayer_id = copyno + 1;
0135 
0136     } else if (level == theLayerLevel) {
0137       const int copyno = num.getBaseNo(level);
0138       layer_id = copyno + 1;
0139 
0140     } else if (level == theWireLevel) {
0141       const int copyno = num.getBaseNo(level);
0142       wire_id = copyno + 1;
0143     }
0144   }
0145 }