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
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 << "Initialize DTNumberingScheme" << std::endl;
00028 std::cout << "theRegionLevel " << theRegionLevel <<std::endl;
00029 std::cout << "theWheelLevel " << theWheelLevel <<std::endl;
00030 std::cout << "theStationLevel " << theStationLevel <<std::endl;
00031 std::cout << "theSuperLayerLevel " << theSuperLayerLevel <<std::endl;
00032 std::cout << "theLayerLevel " << theLayerLevel <<std::endl;
00033 std::cout << "theWireLevel " << theWireLevel <<std::endl;
00034 #endif
00035
00036 }
00037
00038 int DTNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber num){
00039
00040 #ifdef LOCAL_DEBUG
00041 std::cout << "DTNumbering "<<num.getLevels()<<std::endl;
00042 for (int level=1;level<=num.getLevels();level++) {
00043 std::cout << level << " " << num.getSuperNo(level)
00044 << " " << num.getBaseNo(level) << std::endl;
00045 }
00046 #endif
00047 if (num.getLevels()!=theWireLevel) {
00048 std::cout << "DTNS::BNToUN "
00049 << "BaseNumber has " << num.getLevels() << " levels,"
00050 << "need "<<theWireLevel<<std::endl;
00051 return 0;
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 return getDetId(num);
00078 }
00079
00080 int DTNumberingScheme::getDetId(const MuonBaseNumber num) const {
00081
00082 int wire_id=0;
00083 int layer_id=0;
00084 int superlayer_id=0;
00085 int sector_id=0;
00086 int station_id=0;
00087 int wheel_id=0;
00088
00089
00090 decode(num,
00091 wire_id,
00092 layer_id,
00093 superlayer_id,
00094 sector_id,
00095 station_id,
00096 wheel_id);
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 DTWireId id(wheel_id,station_id,sector_id,superlayer_id,layer_id,wire_id);
00118
00119 #ifdef LOCAL_DEBUG
00120 std::cout << "DTNumberingScheme: " << id << std::endl;
00121 #endif
00122
00123 return id.rawId();
00124 }
00125
00126 void DTNumberingScheme::decode(const MuonBaseNumber& num,
00127 int& wire_id,
00128 int& layer_id,
00129 int& superlayer_id,
00130 int& sector_id,
00131 int& station_id,
00132 int& wheel_id) const {
00133 for (int level=1;level<=num.getLevels();level++) {
00134
00135
00136 if (level==theWheelLevel) {
00137 const int copyno=num.getBaseNo(level);
00138 wheel_id=copyno-2;
00139
00140 } else if (level==theStationLevel) {
00141 const int station_tag = num.getSuperNo(level);
00142 const int copyno = num.getBaseNo(level);
00143 station_id=station_tag;
00144 sector_id=copyno+1;
00145
00146 } else if (level==theSuperLayerLevel) {
00147 const int copyno = num.getBaseNo(level);
00148 superlayer_id = copyno + 1;
00149
00150 } else if (level==theLayerLevel) {
00151 const int copyno = num.getBaseNo(level);
00152 layer_id=copyno+1;
00153
00154 } else if (level==theWireLevel) {
00155 const int copyno = num.getBaseNo(level);
00156 wire_id = copyno+1;
00157 }
00158 }
00159 }