CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Geometry/MuonNumbering/src/DTNumberingScheme.cc

Go to the documentation of this file.
00001 #include "Geometry/MuonNumbering/interface/DTNumberingScheme.h"
00002 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00003 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
00004 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
00005 #include <iostream>
00006 
00007 //#define LOCAL_DEBUG
00008 
00009 DTNumberingScheme::DTNumberingScheme( const MuonDDDConstants& muonConstants ) {
00010   initMe(muonConstants);
00011 }
00012 
00013 DTNumberingScheme::DTNumberingScheme( const DDCompactView& cpv ) {
00014   MuonDDDConstants muonConstants(cpv);
00015   initMe(muonConstants);
00016 }
00017 
00018 void DTNumberingScheme::initMe ( const MuonDDDConstants& muonConstants ) {
00019   int theLevelPart=muonConstants.getValue("level");
00020   theRegionLevel=muonConstants.getValue("mb_region")/theLevelPart;
00021   theWheelLevel=muonConstants.getValue("mb_wheel")/theLevelPart;
00022   theStationLevel=muonConstants.getValue("mb_station")/theLevelPart;
00023   theSuperLayerLevel=muonConstants.getValue("mb_superlayer")/theLevelPart;
00024   theLayerLevel=muonConstants.getValue("mb_layer")/theLevelPart;
00025   theWireLevel=muonConstants.getValue("mb_wire")/theLevelPart;
00026  #ifdef LOCAL_DEBUG
00027    std::cout << "theRegionLevel " << theRegionLevel <<std::endl;
00028    std::cout << "theWheelLevel " << theWheelLevel <<std::endl;
00029    std::cout << "theStationLevel " << theStationLevel <<std::endl;
00030    std::cout << "theSuperLayerLevel " << theSuperLayerLevel <<std::endl;
00031    std::cout << "theLayerLevel " << theLayerLevel <<std::endl;
00032    std::cout << "theWireLevel " << theWireLevel <<std::endl;
00033  #endif
00034 
00035 }
00036 
00037 int DTNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber num){
00038   
00039 #ifdef LOCAL_DEBUG
00040   std::cout << "DTNumbering "<<num.getLevels()<<std::endl;
00041   for (int level=1;level<=num.getLevels();level++) {
00042     std::cout << level << " " << num.getSuperNo(level)
00043        << " " << num.getBaseNo(level) << std::endl;
00044   }
00045 #endif
00046   if (num.getLevels()!=theWireLevel) {
00047     std::cout << "DTNS::BNToUN "
00048        << "BaseNumber has " << num.getLevels() << " levels,"
00049        << "need "<<theWireLevel<<std::endl;
00050     return 0;
00051   }
00052   
00053 
00054 //   // Meaningful ranges are enforced by DTWireId, (which
00055 //   // however allows for 0 in wire, layer, superlayer!!!)
00056 // 
00057 //   if ((wire_id < 1) || (wire_id > 100)) {
00058 //     std::cout << "DTNumberingScheme: ";
00059 //     std::cout << "wire id out of range: ";
00060 //     std::cout << wire_id <<std::endl;
00061 //   }
00062     
00063 //   if ((layer_id < 1) || (layer_id > 4)) {
00064 //     std::cout << "DTNumberingScheme: ";
00065 //     std::cout << "layer id out of range: ";
00066 //     std::cout << layer_id <<std::endl;
00067 //   }
00068     
00069 //   if ((superlayer_id < 1) || (superlayer_id > 3)) {
00070 //     std::cout << "DTNumberingScheme: ";
00071 //     std::cout << "super-layer id out of range: ";
00072 //     std::cout << superlayer_id <<std::endl;
00073 //   }
00074 
00075 
00076   return getDetId(num);
00077 }
00078 
00079 int DTNumberingScheme::getDetId(const MuonBaseNumber num) const {
00080   
00081   int wire_id=0;
00082   int layer_id=0;
00083   int superlayer_id=0;
00084   int sector_id=0;
00085   int station_id=0;
00086   int wheel_id=0;
00087 
00088   //decode significant barrel levels
00089   decode(num,
00090          wire_id,
00091          layer_id,
00092          superlayer_id,
00093          sector_id,
00094          station_id,
00095          wheel_id);
00096   
00097 // These ranges are enforced by DTWireId
00098 //   if ((sector_id < 1) || (sector_id > 14)) {
00099 //     std::cout << "DTNumberingScheme: ";
00100 //     std::cout << "sector id out of range: ";
00101 //     std::cout << sector_id <<std::endl;
00102 //   }
00103     
00104 //   if ((station_id < 1) || (station_id > 4)) {
00105 //     std::cout << "DTNumberingScheme: ";
00106 //     std::cout << "station id out of range: ";
00107 //     std::cout << station_id <<std::endl;
00108 //   }
00109     
00110 //   if ((wheel_id < -2) || (wheel_id > 2)) {
00111 //     std::cout << "DTNumberingScheme: ";
00112 //     std::cout << "wheel id out of range: ";
00113 //     std::cout << wheel_id <<std::endl;
00114 //   }
00115     
00116   DTWireId id(wheel_id,station_id,sector_id,superlayer_id,layer_id,wire_id);
00117   
00118 #ifdef LOCAL_DEBUG
00119   std::cout << "DTNumberingScheme: " << id << std::endl;
00120 #endif
00121   
00122   return id.rawId();
00123 }
00124 
00125 void DTNumberingScheme::decode(const MuonBaseNumber& num,
00126                                        int& wire_id,
00127                                        int& layer_id,
00128                                        int& superlayer_id,
00129                                        int& sector_id,
00130                                        int& station_id,
00131                                        int& wheel_id) const {
00132   for (int level=1;level<=num.getLevels();level++) {
00133 
00134     //decode
00135     if (level==theWheelLevel) {
00136       const int copyno=num.getBaseNo(level);      
00137       wheel_id=copyno-2;
00138 
00139     } else if (level==theStationLevel) {
00140       const int station_tag = num.getSuperNo(level);
00141       const int copyno = num.getBaseNo(level);
00142       station_id=station_tag;
00143       sector_id=copyno+1;   
00144 
00145     } else if (level==theSuperLayerLevel) {
00146       const int copyno = num.getBaseNo(level);
00147       superlayer_id = copyno + 1;
00148 
00149     } else if (level==theLayerLevel) {
00150       const int copyno = num.getBaseNo(level);
00151       layer_id=copyno+1;
00152 
00153     } else if (level==theWireLevel) {
00154       const int copyno = num.getBaseNo(level);
00155       wire_id = copyno+1;
00156     }
00157   }
00158 }