CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Geometry/MuonNumbering/src/GEMNumberingScheme.cc

Go to the documentation of this file.
00001 #include "Geometry/MuonNumbering/interface/GEMNumberingScheme.h"
00002 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
00003 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
00004 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
00005 #include <iostream>
00006 
00007 //#define LOCAL_DEBUG
00008 
00009 GEMNumberingScheme::GEMNumberingScheme( const MuonDDDConstants& muonConstants ) {
00010   initMe(muonConstants);
00011 }
00012 
00013 GEMNumberingScheme::GEMNumberingScheme( const DDCompactView& cpv ){
00014   MuonDDDConstants muonConstants(cpv);
00015   initMe(muonConstants);
00016 }
00017 
00018 void GEMNumberingScheme::initMe ( const MuonDDDConstants& muonConstants ) {
00019   int theLevelPart= muonConstants.getValue("level");
00020   theRegionLevel  = muonConstants.getValue("mg_region")/theLevelPart;
00021   theStationLevel = muonConstants.getValue("mg_station")/theLevelPart;
00022   theRingLevel    = muonConstants.getValue("mg_ring")/theLevelPart;
00023   theSectorLevel  = muonConstants.getValue("mg_sector")/theLevelPart;
00024   theRollLevel    = muonConstants.getValue("mg_roll")/theLevelPart;
00025 #ifdef LOCAL_DEBUG
00026   std::cout << "Initialize GEMNumberingScheme" <<std::endl;
00027   std::cout << "theRegionLevel " << theRegionLevel <<std::endl;
00028   std::cout << "theStationLevel "<< theStationLevel<<std::endl;
00029   std::cout << "theRingLevel "   << theRingLevel   <<std::endl;
00030   std::cout << "theSectorLevel " << theSectorLevel <<std::endl;
00031   std::cout << "theRollLevel "   << theRollLevel   <<std::endl;
00032 #endif
00033 }
00034 
00035 int GEMNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber num) {
00036 
00037 #ifdef LOCAL_DEBUG
00038   std::cout << "GEMNumbering "<<num.getLevels()<<std::endl;
00039   for (int level=1;level<=num.getLevels();level++) {
00040     std::cout << level << " " << num.getSuperNo(level)
00041               << " " << num.getBaseNo(level) << std::endl;
00042   }
00043 #endif
00044 
00045   int maxLevel = theRollLevel;
00046   if (num.getLevels()!=maxLevel) {
00047     std::cout << "MuonGEMNS::BNToUN "
00048               << "BaseNumber has " << num.getLevels() << " levels,"
00049               << "need "<<maxLevel<<std::endl;
00050     return 0;
00051   }
00052 
00053   int region(0), ring(0), station(0), layer(0), chamber(0), roll(0);
00054 
00055   //decode significant GEM levels
00056   
00057   if (num.getBaseNo(theRegionLevel) == 0) region = 1;
00058   else                                    region =-1;
00059   station = num.getBaseNo(theStationLevel)+1;
00060   ring    = num.getBaseNo(theRingLevel)+1;
00061   roll    = num.getBaseNo(theRollLevel)+1;
00062   const int copyno = num.getBaseNo(theSectorLevel) + 1;
00063   if (copyno < 50) {
00064     if (copyno%2 == 0) {
00065       layer   = 2;
00066       chamber = copyno-1;
00067     } else {
00068       layer   = 1;
00069       chamber = copyno;
00070     }
00071   } else {
00072     int copynp = copyno - 50;
00073     if (copynp%2 != 0) {
00074       layer   = 2;
00075       chamber = copynp-1;
00076     } else {
00077       layer   = 1;
00078       chamber = copynp;
00079     }
00080   }
00081 
00082   // collect all info
00083   
00084 #ifdef LOCAL_DEBUG
00085   std::cout << "GEMNumberingScheme: Region " << region << " Ring "
00086             << ring << " Station " << station << " Layer " << layer
00087             << " Chamber " << chamber << " Roll " << roll << std::endl;
00088 #endif
00089 
00090   // Build the actual numbering
00091   GEMDetId id(region,ring,station,layer,chamber, roll);
00092   
00093   
00094 #ifdef LOCAL_DEBUG
00095   std::cout << " DetId " << id << std::endl;
00096 #endif
00097       
00098   return id.rawId();
00099 }
00100 
00101 
00102 
00103