Go to the documentation of this file.00001 #include "Geometry/MuonNumbering/interface/RPCNumberingScheme.h"
00002 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
00003 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
00004 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00005 #include <iostream>
00006
00007
00008
00009 RPCNumberingScheme::RPCNumberingScheme( const MuonDDDConstants& muonConstants ) {
00010 initMe(muonConstants);
00011 }
00012
00013 RPCNumberingScheme::RPCNumberingScheme( const DDCompactView& cpv ){
00014 MuonDDDConstants muonConstants(cpv);
00015 initMe(muonConstants);
00016 }
00017
00018 void RPCNumberingScheme::initMe ( const MuonDDDConstants& muonConstants ) {
00019 int theLevelPart=muonConstants.getValue("level");
00020 theRegionLevel=muonConstants.getValue("mr_region")/theLevelPart;
00021 theBWheelLevel=muonConstants.getValue("mr_bwheel")/theLevelPart;
00022 theBStationLevel=muonConstants.getValue("mr_bstation")/theLevelPart;
00023 theBPlaneLevel=muonConstants.getValue("mr_bplane")/theLevelPart;
00024 theBChamberLevel=muonConstants.getValue("mr_bchamber")/theLevelPart;
00025 theEPlaneLevel=muonConstants.getValue("mr_eplane")/theLevelPart;
00026 theESectorLevel=muonConstants.getValue("mr_esector")/theLevelPart;
00027 theERollLevel=muonConstants.getValue("mr_eroll")/theLevelPart;
00028 #ifdef LOCAL_DEBUG
00029 std::cout << "theRegionLevel " << theRegionLevel <<std::endl;
00030 std::cout << "theBWheelLevel " << theBWheelLevel <<std::endl;
00031 std::cout << "theBStationLevel " << theBStationLevel <<std::endl;
00032 std::cout << "theBPlaneLevel " << theBPlaneLevel <<std::endl;
00033 std::cout << "theBChamberLevel " << theBChamberLevel <<std::endl;
00034 std::cout << "theEPlaneLevel " << theEPlaneLevel <<std::endl;
00035 std::cout << "theESectorLevel " << theESectorLevel <<std::endl;
00036 std::cout << "theERollLevel " << theERollLevel <<std::endl;
00037 #endif
00038 }
00039
00040 int RPCNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber num) {
00041
00042 #ifdef LOCAL_DEBUG
00043 std::cout << "RPCNumbering "<<num.getLevels()<<std::endl;
00044 for (int level=1;level<=num.getLevels();level++) {
00045 std::cout << level << " " << num.getSuperNo(level)
00046 << " " << num.getBaseNo(level) << std::endl;
00047 }
00048 #endif
00049
00050 const int barrel = num.getSuperNo(theRegionLevel);
00051 bool barrel_muon=(barrel == 1);
00052 int maxLevel;
00053 if (barrel_muon) {
00054 maxLevel=theBChamberLevel;
00055 } else {
00056 maxLevel=theERollLevel;
00057 }
00058
00059 if (num.getLevels()!=maxLevel) {
00060 std::cout << "MuonRpcNS::BNToUN "
00061 << "BaseNumber has " << num.getLevels() << " levels,"
00062 << "need "<<maxLevel<<std::endl;
00063 return 0;
00064 }
00065
00066 int plane_id=0;
00067 int sector_id=0;
00068 int copy_id=0;
00069 int roll_id=0;
00070 int eta_id=0;
00071 int rr12_id=0;
00072 bool forward=0;
00073
00074 int sector_copy=0;
00075
00076
00077
00078 for (int level=1;level<=maxLevel;level++) {
00079
00080
00081 if (level==theRegionLevel) {
00082 if (barrel_muon) {
00083 roll_id=0;
00084 } else {
00085 copy_id=1;
00086 }
00087 }
00088 if (barrel_muon) {
00089 if (level==theBWheelLevel) {
00090 const int copyno = num.getBaseNo(level);
00091 eta_id = 4 + copyno;
00092 } else if (level==theBStationLevel) {
00093
00094 const int copyno = num.getBaseNo(level);
00095
00096 sector_id=copyno+1;
00097 if( sector_id == 13 ) {
00098 sector_id = 4;
00099 sector_copy = 1;
00100 }else if( sector_id == 14 ) {
00101 sector_id = 10;
00102 sector_copy = 1;
00103 }
00104
00105 sector_id*=3;
00106
00107 } else if (level==theBPlaneLevel) {
00108 const int plane_tag = num.getSuperNo(level);
00109
00110 if (plane_tag == 1) {
00111 plane_id=1;
00112 } else if (plane_tag == 2) {
00113 plane_id=5;
00114 } else if (plane_tag == 3) {
00115
00116
00117
00118
00119 plane_id=2;
00120
00121
00122
00123 } else if (plane_tag == 4) {
00124
00125
00126
00127
00128 plane_id=6;
00129
00130
00131 } else if (plane_tag == 5) {
00132 plane_id=3;
00133 } else {
00134 plane_id=4;
00135 }
00136
00137 } else if (level==theBChamberLevel) {
00138 const int copyno = num.getBaseNo(level);
00139 if ((plane_id == 4) && (sector_id == 4*3)) {
00140 copy_id=sector_copy*2+copyno+1;
00141 } else if ((plane_id == 4) && (sector_id == 10*3)) {
00142 copy_id=sector_copy+1;
00143 } else {
00144 copy_id=copyno+1;
00145 }
00146 const int rollno = num.getSuperNo(level);
00147 roll_id = rollno;
00148 }
00149
00150 } else {
00151
00152 if (level==theRegionLevel) {
00153 const int copyno = num.getBaseNo(level);
00154 forward=(copyno == 0);
00155 } else if (level==theEPlaneLevel) {
00156 const int plane_tag = num.getSuperNo(level);
00157 const int rr12_tag = num.getBaseNo(level);
00158 plane_id = plane_tag;
00159 rr12_id = rr12_tag;
00160 } else if (level==theESectorLevel) {
00161 const int copyno = num.getBaseNo(level);
00162 sector_id = copyno+1;
00163 if (rr12_id==1) {
00164 sector_id = sector_id*2-1;
00165 }else if(rr12_id==2){
00166 sector_id = sector_id*2;
00167 }
00168 } else if (level==theERollLevel) {
00169 const int copyno = num.getBaseNo(level);
00170 const int eta_tag = num.getSuperNo(level);
00171
00172 if ((eta_tag == 1) || (eta_tag == 4) ||
00173 (eta_tag == 7) || (eta_tag == 8)) {
00174 eta_id=1;
00175 } else if ((eta_tag == 2) || (eta_tag == 5)) {
00176 eta_id=2;
00177 } else if ((eta_tag == 3) || (eta_tag == 6)) {
00178 eta_id=3;
00179 }
00180
00181 if (forward) eta_id=12-eta_id;
00182
00183
00184
00185 if ((eta_tag == 4) || (eta_tag == 7) ||
00186 (eta_tag == 8)) {
00187 sector_id*=2;
00188 }
00189
00190 roll_id = copyno+1;
00191
00192 }
00193
00194 }
00195 }
00196
00197
00198
00199 int trIndex=(eta_id*10000+plane_id*1000+sector_id*10+copy_id)*10+
00200 roll_id;
00201
00202 #ifdef LOCAL_DEBUG
00203 if (barrel_muon) {
00204 std::cout << "RPCNumberingScheme (barrel): ";
00205 } else {
00206 if (forward) {
00207 std::cout << "RPCNumberingScheme (forward): ";
00208 } else {
00209 std::cout << "RPCNumberingScheme (backward): ";
00210 }
00211 }
00212 std::cout << " roll " << roll_id;
00213 std::cout << " copy " << copy_id;
00214 std::cout << " sector " << sector_id;
00215 std::cout << " plane " << plane_id;
00216 std::cout << " eta " << eta_id;
00217 std::cout << " rr12 " << rr12_id;
00218 #endif
00219
00220
00221 RPCDetId id;
00222 id.buildfromTrIndex(trIndex);
00223
00224
00225 #ifdef LOCAL_DEBUG
00226 std::cout << " DetId " << id;
00227 std::cout << std::endl;
00228 #endif
00229
00230 return id.rawId();
00231 }
00232
00233
00234
00235