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 << "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
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
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
00089 decode(num,
00090 wire_id,
00091 layer_id,
00092 superlayer_id,
00093 sector_id,
00094 station_id,
00095 wheel_id);
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
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
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 }