Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-22 23:03:23

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "DataFormats/TrackerCommon/interface/SiStripSubStructure.h"
0003 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0004 
0005 #include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
0006 
0007 // TkLayerMap
0008 
0009 void TkLayerMap::initMap(const std::vector<uint32_t>& TkDetIdList) {
0010   switch (layer_) {
0011     case TkLayerMap::TIB_L1:
0012     case TkLayerMap::TIB_L2:
0013     case TkLayerMap::TIB_L3:
0014     case TkLayerMap::TIB_L4:
0015       initMap_TIB(TkDetIdList);
0016       break;
0017     case TkLayerMap::TIDP_D1:
0018     case TkLayerMap::TIDP_D2:
0019     case TkLayerMap::TIDP_D3:
0020     case TkLayerMap::TIDM_D1:
0021     case TkLayerMap::TIDM_D2:
0022     case TkLayerMap::TIDM_D3:
0023       initMap_TID(TkDetIdList);
0024       break;
0025     case TkLayerMap::TOB_L1:
0026     case TkLayerMap::TOB_L2:
0027     case TkLayerMap::TOB_L3:
0028     case TkLayerMap::TOB_L4:
0029     case TkLayerMap::TOB_L5:
0030     case TkLayerMap::TOB_L6:
0031       initMap_TOB(TkDetIdList);
0032       break;
0033     case TkLayerMap::TECP_W1:
0034     case TkLayerMap::TECP_W2:
0035     case TkLayerMap::TECP_W3:
0036     case TkLayerMap::TECP_W4:
0037     case TkLayerMap::TECP_W5:
0038     case TkLayerMap::TECP_W6:
0039     case TkLayerMap::TECP_W7:
0040     case TkLayerMap::TECP_W8:
0041     case TkLayerMap::TECP_W9:
0042     case TkLayerMap::TECM_W1:
0043     case TkLayerMap::TECM_W2:
0044     case TkLayerMap::TECM_W3:
0045     case TkLayerMap::TECM_W4:
0046     case TkLayerMap::TECM_W5:
0047     case TkLayerMap::TECM_W6:
0048     case TkLayerMap::TECM_W7:
0049     case TkLayerMap::TECM_W8:
0050     case TkLayerMap::TECM_W9:
0051       initMap_TEC(TkDetIdList);
0052       break;
0053     default:
0054       edm::LogError("TkLayerMap") << " TkLayerMap::requested creation of a wrong layer Nb " << layer_;
0055   }
0056 }
0057 
0058 void TkLayerMap::initMap_TIB(const std::vector<uint32_t>& TkDetIdList) {
0059   //extract  vector of module in the layer
0060   std::vector<uint32_t> LayerDetIdList;
0061   SiStripSubStructure::getTIBDetectors(TkDetIdList, LayerDetIdList, tTopo_, layer_, 0, 0, 0);
0062 
0063   LogTrace("TkLayerMap") << "[TkLayerMap::createTIB12] layer " << layer_ << " number of dets " << LayerDetIdList.size()
0064                          << " lowY " << lowY_ << " high " << highY_ << " Nstring " << nStringExt_;
0065 
0066   for (uint32_t det : LayerDetIdList) {
0067     const auto xyb = getXY_TIB(det);
0068     binToDet_[bin(xyb.ix, xyb.iy)] = det;
0069 
0070     LogTrace("TkLayerMap") << "[TkLayerMap::createTIB] " << det << " " << xyb.ix << " " << xyb.iy << " " << xyb.x << " "
0071                            << xyb.y;
0072   }
0073 }
0074 
0075 void TkLayerMap::initMap_TOB(const std::vector<uint32_t>& TkDetIdList) {
0076   //extract  vector of module in the layer
0077   std::vector<uint32_t> LayerDetIdList;
0078   SiStripSubStructure::getTOBDetectors(TkDetIdList, LayerDetIdList, tTopo_, layer_ - 10, 0, 0);
0079 
0080   LogTrace("TkLayerMap") << "[TkLayerMap::createTOB] layer " << layer_ - 10 << " number of dets "
0081                          << LayerDetIdList.size() << " lowY " << lowY_ << " high " << highY_ << " Nstring "
0082                          << nStringExt_;
0083 
0084   for (uint32_t det : LayerDetIdList) {
0085     const auto xyb = getXY_TOB(det);
0086     binToDet_[bin(xyb.ix, xyb.iy)] = det;
0087 
0088     LogTrace("TkLayerMap") << "[TkLayerMap::createTOB] " << det << " " << xyb.ix << " " << xyb.iy << " " << xyb.x << " "
0089                            << xyb.y;
0090   }
0091 }
0092 
0093 void TkLayerMap::initMap_TID(const std::vector<uint32_t>& TkDetIdList) {
0094   //extract  vector of module in the layer
0095   std::vector<uint32_t> LayerDetIdList;
0096   SiStripSubStructure::getTIDDetectors(TkDetIdList,
0097                                        LayerDetIdList,
0098                                        tTopo_,
0099                                        (layer_ - TkLayerMap::TIDM_D1) / 3 + 1,
0100                                        (layer_ - TkLayerMap::TIDM_D1) % 3 + 1,
0101                                        0,
0102                                        0);
0103 
0104   LogTrace("TkLayerMap") << "[TkLayerMap::createTID] layer side " << (layer_ - TkLayerMap::TIDM_D1) / 3 + 1 << " nb "
0105                          << (layer_ - TkLayerMap::TIDM_D1) % 3 + 1 << " number of dets " << LayerDetIdList.size()
0106                          << " lowY " << lowY_ << " high " << highY_ << " Nstring " << nStringExt_;
0107 
0108   for (uint32_t det : LayerDetIdList) {
0109     const auto xyb = getXY_TID(det);
0110     binToDet_[bin(xyb.ix, xyb.iy)] = det;
0111 
0112     LogTrace("TkLayerMap") << "[TkLayerMap::createTID] " << det << " " << xyb.ix << " " << xyb.iy << " " << xyb.x << " "
0113                            << xyb.y;
0114   }
0115 }
0116 
0117 void TkLayerMap::initMap_TEC(const std::vector<uint32_t>& TkDetIdList) {
0118   //extract  vector of module in the layer
0119   std::vector<uint32_t> LayerDetIdList;
0120   SiStripSubStructure::getTECDetectors(TkDetIdList,
0121                                        LayerDetIdList,
0122                                        tTopo_,
0123                                        (layer_ - TkLayerMap::TECM_W1) / 9 + 1,
0124                                        (layer_ - TkLayerMap::TECM_W1) % 9 + 1,
0125                                        0,
0126                                        0);
0127 
0128   LogTrace("TkLayerMap") << "[TkLayerMap::createTEC] layer side " << (layer_ - TkLayerMap::TECM_W1) / 9 + 1 << " "
0129                          << (layer_ - TkLayerMap::TECM_W1) % 9 + 1 << " number of dets " << LayerDetIdList.size()
0130                          << " lowY " << lowY_ << " high " << highY_ << " Nstring " << nStringExt_;
0131 
0132   for (uint32_t det : LayerDetIdList) {
0133     const auto xyb = getXY_TEC(det);
0134     binToDet_[bin(xyb.ix, xyb.iy)] = det;
0135 
0136     LogTrace("TkLayerMap") << "[TkLayerMap::createTEC] " << det << " " << xyb.ix << " " << xyb.iy << " " << xyb.x << " "
0137                            << xyb.y;
0138   }
0139 }
0140 
0141 const int16_t TkLayerMap::layerSearch(DetId detid, const TrackerTopology* tTopo) {
0142   switch (detid.subdetId()) {
0143     case SiStripDetId::TIB:
0144       return TkLayerMap::TIB_L1 - 1 + tTopo->tibLayer(detid);
0145     case SiStripDetId::TID:
0146       return TkLayerMap::TIDM_D1 - 1 + (tTopo->tidSide(detid) - 1) * 3 + tTopo->tidWheel(detid);
0147     case SiStripDetId::TOB:
0148       return TkLayerMap::TOB_L1 - 1 + tTopo->tobLayer(detid);
0149     case SiStripDetId::TEC:
0150       return TkLayerMap::TECM_W1 - 1 + (tTopo->tecSide(detid) - 1) * 9 + tTopo->tecWheel(detid);
0151     default:
0152       return TkLayerMap::INVALID;
0153   }
0154 }
0155 
0156 const TkLayerMap::XYbin TkLayerMap::getXY(DetId detid, int layerEnumNb) const {
0157   LogTrace("TkLayerMap") << "[TkLayerMap::getXY] " << detid.rawId() << " layer " << layerEnumNb;
0158 
0159   if (!layerEnumNb)
0160     layerEnumNb = layerSearch(detid, tTopo_);
0161 
0162   if (layerEnumNb != layer_)
0163     throw cms::Exception("CorruptedData")
0164         << "[TkLayerMap::getXY] Fill of DetId " << detid.rawId() << " layerEnumNb " << layerEnumNb
0165         << " are requested to wrong TkLayerMap " << layer_ << " \nPlease check the TkDetMap code";
0166 
0167   if (layerEnumNb >= TkLayerMap::TIB_L1 && layerEnumNb <= TkLayerMap::TIB_L4)
0168     return getXY_TIB(detid);
0169   else if (layerEnumNb >= TkLayerMap::TIDM_D1 && layerEnumNb <= TkLayerMap::TIDP_D3)
0170     return getXY_TID(detid);
0171   else if (layerEnumNb >= TkLayerMap::TOB_L1 && layerEnumNb <= TkLayerMap::TOB_L6)
0172     return getXY_TOB(detid);
0173   else
0174     return getXY_TEC(detid);
0175 }
0176 
0177 TkLayerMap::XYbin TkLayerMap::getXY_TIB(DetId detid) const {
0178   XYbin xyb;
0179   xyb.ix = (2 * (tTopo_->tibIsZMinusSide(detid) ? -1 * tTopo_->tibModule(detid) + 3 : tTopo_->tibModule(detid) + 2) +
0180             (tTopo_->tibLayer(detid) % 2 ? (tTopo_->tibIsInternalString(detid) ? 2 : 1)
0181                                          : (tTopo_->tibIsInternalString(detid) ? 1 : 2)));
0182   xyb.iy = ((tTopo_->tibIsInternalString(detid) ? tTopo_->tibString(detid) + singleExtStr_[tTopo_->tibString(detid)]
0183                                                 : tTopo_->tibString(detid)) +
0184             ((tTopo_->tibLayer(detid) < 3) && (!tTopo_->tibIsStereo(detid)) ? nStringExt_ + 2 : 0));
0185 
0186   xyb.x = lowX_ + xyb.ix - 0.5;
0187   xyb.y = lowY_ + xyb.iy - 0.5;
0188 
0189   return xyb;
0190 }
0191 
0192 TkLayerMap::XYbin TkLayerMap::getXY_TOB(DetId detid) const {
0193   XYbin xyb;
0194   xyb.ix = (tTopo_->tobIsZMinusSide(detid) ? -1 * tTopo_->tobModule(detid) + 7 : tTopo_->tobModule(detid) + 6);
0195   xyb.iy = (tTopo_->tobRod(detid) + (tTopo_->tobLayer(detid) < 3 && !tTopo_->tobIsStereo(detid) ? nRod_ + 2 : 0));
0196 
0197   xyb.x = lowX_ + xyb.ix - 0.5;
0198   xyb.y = lowY_ + xyb.iy - 0.5;
0199 
0200   return xyb;
0201 }
0202 
0203 TkLayerMap::XYbin TkLayerMap::getXY_TID(DetId detid) const {
0204   XYbin xyb;
0205   xyb.ix = ((tTopo_->tidIsZMinusSide(detid) ? -3 * tTopo_->tidRing(detid) + 10 : 3 * tTopo_->tidRing(detid) - 2) +
0206             (tTopo_->tidIsStereo(detid) ? (tTopo_->tidIsZMinusSide(detid) ? -1 : 1) : 0));
0207   xyb.iy = 2 * tTopo_->tidModule(detid) - (tTopo_->tidIsBackRing(detid) ? 0 : 1);
0208 
0209   xyb.x = lowX_ + xyb.ix - 0.5;
0210   xyb.y = lowY_ + xyb.iy - 0.5;
0211 
0212   return xyb;
0213 }
0214 
0215 TkLayerMap::XYbin TkLayerMap::getXY_TEC(DetId detid) const {
0216   XYbin xyb;
0217   xyb.ix = ((tTopo_->tecIsZMinusSide(detid) ? binForRing_[7] - binForRing_[tTopo_->tecRing(detid)] + 1
0218                                             : binForRing_[tTopo_->tecRing(detid)]) +
0219             (tTopo_->tecIsStereo(detid) ? (tTopo_->tecIsZMinusSide(detid) ? -1 : 1) : 0));
0220 
0221   xyb.iy = ((tTopo_->tecPetalNumber(detid) - 1) *
0222                 (modulesInRingFront_[tTopo_->tecRing(detid)] + modulesInRingBack_[tTopo_->tecRing(detid)]) +
0223             (tTopo_->tecIsZMinusSide(detid)
0224                  ? modulesInRingFront_[tTopo_->tecRing(detid)] - tTopo_->tecModule(detid) + 1 +
0225                        (tTopo_->tecIsBackPetal(detid) ? modulesInRingBack_[tTopo_->tecRing(detid)] : 0)
0226                  : tTopo_->tecModule(detid) +
0227                        (tTopo_->tecIsBackPetal(detid) ? modulesInRingFront_[tTopo_->tecRing(detid)] : 0)));
0228 
0229   xyb.x = lowX_ + xyb.ix - 0.5;
0230   xyb.y = lowY_ + xyb.iy - 0.5;
0231 
0232   return xyb;
0233 }
0234 
0235 // TkDetMap
0236 
0237 std::string TkDetMap::getLayerName(int in) {
0238   switch (in) {
0239     case TkLayerMap::TIB_L1:
0240       return "TIB_L1";
0241     case TkLayerMap::TIB_L2:
0242       return "TIB_L2";
0243     case TkLayerMap::TIB_L3:
0244       return "TIB_L3";
0245     case TkLayerMap::TIB_L4:
0246       return "TIB_L4";
0247     case TkLayerMap::TIDP_D1:
0248       return "TIDP_D1";
0249     case TkLayerMap::TIDP_D2:
0250       return "TIDP_D2";
0251     case TkLayerMap::TIDP_D3:
0252       return "TIDP_D3";
0253     case TkLayerMap::TIDM_D1:
0254       return "TIDM_D1";
0255     case TkLayerMap::TIDM_D2:
0256       return "TIDM_D2";
0257     case TkLayerMap::TIDM_D3:
0258       return "TIDM_D3";
0259     case TkLayerMap::TOB_L1:
0260       return "TOB_L1";
0261     case TkLayerMap::TOB_L2:
0262       return "TOB_L2";
0263     case TkLayerMap::TOB_L3:
0264       return "TOB_L3";
0265     case TkLayerMap::TOB_L4:
0266       return "TOB_L4";
0267     case TkLayerMap::TOB_L5:
0268       return "TOB_L5";
0269     case TkLayerMap::TOB_L6:
0270       return "TOB_L6";
0271     case TkLayerMap::TECP_W1:
0272       return "TECP_W1";
0273     case TkLayerMap::TECP_W2:
0274       return "TECP_W2";
0275     case TkLayerMap::TECP_W3:
0276       return "TECP_W3";
0277     case TkLayerMap::TECP_W4:
0278       return "TECP_W4";
0279     case TkLayerMap::TECP_W5:
0280       return "TECP_W5";
0281     case TkLayerMap::TECP_W6:
0282       return "TECP_W6";
0283     case TkLayerMap::TECP_W7:
0284       return "TECP_W7";
0285     case TkLayerMap::TECP_W8:
0286       return "TECP_W8";
0287     case TkLayerMap::TECP_W9:
0288       return "TECP_W9";
0289     case TkLayerMap::TECM_W1:
0290       return "TECM_W1";
0291     case TkLayerMap::TECM_W2:
0292       return "TECM_W2";
0293     case TkLayerMap::TECM_W3:
0294       return "TECM_W3";
0295     case TkLayerMap::TECM_W4:
0296       return "TECM_W4";
0297     case TkLayerMap::TECM_W5:
0298       return "TECM_W5";
0299     case TkLayerMap::TECM_W6:
0300       return "TECM_W6";
0301     case TkLayerMap::TECM_W7:
0302       return "TECM_W7";
0303     case TkLayerMap::TECM_W8:
0304       return "TECM_W8";
0305     case TkLayerMap::TECM_W9:
0306       return "TECM_W9";
0307   }
0308   return "Invalid";
0309 }
0310 
0311 int TkDetMap::getLayerNum(const std::string& in) {
0312   if (in == "TIB_L1")
0313     return TkLayerMap::TIB_L1;
0314   if (in == "TIB_L2")
0315     return TkLayerMap::TIB_L2;
0316   if (in == "TIB_L3")
0317     return TkLayerMap::TIB_L3;
0318   if (in == "TIB_L4")
0319     return TkLayerMap::TIB_L4;
0320   if (in == "TIDP_D1")
0321     return TkLayerMap::TIDP_D1;
0322   if (in == "TIDP_D2")
0323     return TkLayerMap::TIDP_D2;
0324   if (in == "TIDP_D3")
0325     return TkLayerMap::TIDP_D3;
0326   if (in == "TIDM_D1")
0327     return TkLayerMap::TIDM_D1;
0328   if (in == "TIDM_D2")
0329     return TkLayerMap::TIDM_D2;
0330   if (in == "TIDM_D3")
0331     return TkLayerMap::TIDM_D3;
0332   if (in == "TOB_L1")
0333     return TkLayerMap::TOB_L1;
0334   if (in == "TOB_L2")
0335     return TkLayerMap::TOB_L2;
0336   if (in == "TOB_L3")
0337     return TkLayerMap::TOB_L3;
0338   if (in == "TOB_L4")
0339     return TkLayerMap::TOB_L4;
0340   if (in == "TOB_L5")
0341     return TkLayerMap::TOB_L5;
0342   if (in == "TOB_L6")
0343     return TkLayerMap::TOB_L6;
0344   if (in == "TECP_W1")
0345     return TkLayerMap::TECP_W1;
0346   if (in == "TECP_W2")
0347     return TkLayerMap::TECP_W2;
0348   if (in == "TECP_W3")
0349     return TkLayerMap::TECP_W3;
0350   if (in == "TECP_W4")
0351     return TkLayerMap::TECP_W4;
0352   if (in == "TECP_W5")
0353     return TkLayerMap::TECP_W5;
0354   if (in == "TECP_W6")
0355     return TkLayerMap::TECP_W6;
0356   if (in == "TECP_W7")
0357     return TkLayerMap::TECP_W7;
0358   if (in == "TECP_W8")
0359     return TkLayerMap::TECP_W8;
0360   if (in == "TECP_W9")
0361     return TkLayerMap::TECP_W9;
0362   if (in == "TECM_W1")
0363     return TkLayerMap::TECM_W1;
0364   if (in == "TECM_W2")
0365     return TkLayerMap::TECM_W2;
0366   if (in == "TECM_W3")
0367     return TkLayerMap::TECM_W3;
0368   if (in == "TECM_W4")
0369     return TkLayerMap::TECM_W4;
0370   if (in == "TECM_W5")
0371     return TkLayerMap::TECM_W5;
0372   if (in == "TECM_W6")
0373     return TkLayerMap::TECM_W6;
0374   if (in == "TECM_W7")
0375     return TkLayerMap::TECM_W7;
0376   if (in == "TECM_W8")
0377     return TkLayerMap::TECM_W8;
0378   if (in == "TECM_W9")
0379     return TkLayerMap::TECM_W9;
0380   return 0;
0381 }
0382 
0383 void TkDetMap::getSubDetLayerSide(int in, SiStripDetId::SubDetector& subDet, uint32_t& layer, uint32_t& side) {
0384   switch (in) {
0385     case TkLayerMap::TIB_L1:
0386       subDet = SiStripDetId::TIB;
0387       layer = 1;
0388       break;
0389     case TkLayerMap::TIB_L2:
0390       subDet = SiStripDetId::TIB;
0391       layer = 2;
0392       break;
0393     case TkLayerMap::TIB_L3:
0394       subDet = SiStripDetId::TIB;
0395       layer = 3;
0396       break;
0397     case TkLayerMap::TIB_L4:
0398       subDet = SiStripDetId::TIB;
0399       layer = 4;
0400       break;
0401     case TkLayerMap::TIDP_D1:
0402       subDet = SiStripDetId::TID;
0403       layer = 1;
0404       side = 2;
0405       break;
0406     case TkLayerMap::TIDP_D2:
0407       subDet = SiStripDetId::TID;
0408       layer = 2;
0409       side = 2;
0410       break;
0411     case TkLayerMap::TIDP_D3:
0412       subDet = SiStripDetId::TID;
0413       layer = 3;
0414       side = 2;
0415       break;
0416     case TkLayerMap::TIDM_D1:
0417       subDet = SiStripDetId::TID;
0418       layer = 1;
0419       side = 1;
0420       break;
0421     case TkLayerMap::TIDM_D2:
0422       subDet = SiStripDetId::TID;
0423       layer = 2;
0424       side = 1;
0425       break;
0426     case TkLayerMap::TIDM_D3:
0427       subDet = SiStripDetId::TID;
0428       layer = 3;
0429       side = 1;
0430       break;
0431     case TkLayerMap::TOB_L1:
0432       subDet = SiStripDetId::TOB;
0433       layer = 1;
0434       break;
0435     case TkLayerMap::TOB_L2:
0436       subDet = SiStripDetId::TOB;
0437       layer = 2;
0438       break;
0439     case TkLayerMap::TOB_L3:
0440       subDet = SiStripDetId::TOB;
0441       layer = 3;
0442       break;
0443     case TkLayerMap::TOB_L4:
0444       subDet = SiStripDetId::TOB;
0445       layer = 4;
0446       break;
0447     case TkLayerMap::TOB_L5:
0448       subDet = SiStripDetId::TOB;
0449       layer = 5;
0450       break;
0451     case TkLayerMap::TOB_L6:
0452       subDet = SiStripDetId::TOB;
0453       layer = 6;
0454       break;
0455     case TkLayerMap::TECP_W1:
0456       subDet = SiStripDetId::TEC;
0457       layer = 1;
0458       side = 2;
0459       break;
0460     case TkLayerMap::TECP_W2:
0461       subDet = SiStripDetId::TEC;
0462       layer = 2;
0463       side = 2;
0464       break;
0465     case TkLayerMap::TECP_W3:
0466       subDet = SiStripDetId::TEC;
0467       layer = 3;
0468       side = 2;
0469       break;
0470     case TkLayerMap::TECP_W4:
0471       subDet = SiStripDetId::TEC;
0472       layer = 4;
0473       side = 2;
0474       break;
0475     case TkLayerMap::TECP_W5:
0476       subDet = SiStripDetId::TEC;
0477       layer = 5;
0478       side = 2;
0479       break;
0480     case TkLayerMap::TECP_W6:
0481       subDet = SiStripDetId::TEC;
0482       layer = 6;
0483       side = 2;
0484       break;
0485     case TkLayerMap::TECP_W7:
0486       subDet = SiStripDetId::TEC;
0487       layer = 7;
0488       side = 2;
0489       break;
0490     case TkLayerMap::TECP_W8:
0491       subDet = SiStripDetId::TEC;
0492       layer = 8;
0493       side = 2;
0494       break;
0495     case TkLayerMap::TECP_W9:
0496       subDet = SiStripDetId::TEC;
0497       layer = 9;
0498       side = 2;
0499       break;
0500     case TkLayerMap::TECM_W1:
0501       subDet = SiStripDetId::TEC;
0502       layer = 1;
0503       side = 1;
0504       break;
0505     case TkLayerMap::TECM_W2:
0506       subDet = SiStripDetId::TEC;
0507       layer = 2;
0508       side = 1;
0509       break;
0510     case TkLayerMap::TECM_W3:
0511       subDet = SiStripDetId::TEC;
0512       layer = 3;
0513       side = 1;
0514       break;
0515     case TkLayerMap::TECM_W4:
0516       subDet = SiStripDetId::TEC;
0517       layer = 4;
0518       side = 1;
0519       break;
0520     case TkLayerMap::TECM_W5:
0521       subDet = SiStripDetId::TEC;
0522       layer = 5;
0523       side = 1;
0524       break;
0525     case TkLayerMap::TECM_W6:
0526       subDet = SiStripDetId::TEC;
0527       layer = 6;
0528       side = 1;
0529       break;
0530     case TkLayerMap::TECM_W7:
0531       subDet = SiStripDetId::TEC;
0532       layer = 7;
0533       side = 1;
0534       break;
0535     case TkLayerMap::TECM_W8:
0536       subDet = SiStripDetId::TEC;
0537       layer = 8;
0538       side = 1;
0539       break;
0540     case TkLayerMap::TECM_W9:
0541       subDet = SiStripDetId::TEC;
0542       layer = 9;
0543       side = 1;
0544       break;
0545   }
0546 }
0547 
0548 const TkLayerMap::XYbin& TkDetMap::getXY(DetId detid,
0549                                          DetId& cached_detid,
0550                                          int16_t& cached_layer,
0551                                          TkLayerMap::XYbin& cached_XYbin) const {
0552   LogTrace("TkDetMap") << "[getXY] detid " << detid.rawId() << " cache " << cached_detid.rawId() << " layer "
0553                        << cached_layer << " XY " << cached_XYbin.ix << " " << cached_XYbin.iy << " " << cached_XYbin.x
0554                        << " " << cached_XYbin.y;
0555   if (detid == cached_detid)
0556     return cached_XYbin;
0557 
0558   /*FIXME*/
0559   //if (layer!=INVALID)
0560   findLayer(detid, cached_detid, cached_layer, cached_XYbin);
0561   LogTrace("TkDetMap") << "[getXY] detid " << detid.rawId() << " cache " << cached_detid.rawId() << " layer "
0562                        << cached_layer << " XY " << cached_XYbin.ix << " " << cached_XYbin.iy << " " << cached_XYbin.x
0563                        << " " << cached_XYbin.y;
0564 
0565   return cached_XYbin;
0566 }
0567 
0568 int16_t TkDetMap::findLayer(DetId detid,
0569                             DetId& cached_detid,
0570                             int16_t& cached_layer,
0571                             TkLayerMap::XYbin& cached_XYbin) const {
0572   if (detid == cached_detid)
0573     return cached_layer;
0574 
0575   cached_detid = detid;
0576 
0577   int16_t layer = TkLayerMap::layerSearch(detid, tTopo_);
0578   if (layer == TkLayerMap::INVALID) {
0579     // there is something wrong if the layer is 0, early return
0580     return TkLayerMap::INVALID;
0581   }
0582 
0583   LogTrace("TkDetMap") << "[findLayer] detid " << detid.rawId() << " layer " << layer;
0584   if (layer != cached_layer) {
0585     cached_layer = layer;
0586   }
0587   cached_XYbin = TkMap[cached_layer].getXY(detid, layer);
0588   LogTrace("TkDetMap") << "[findLayer] detid " << detid.rawId() << " cached_XYbin " << cached_XYbin.ix << " "
0589                        << cached_XYbin.iy;
0590 
0591   return cached_layer;
0592 }
0593 
0594 void TkDetMap::getComponents(
0595     int layer, int& nchX, double& lowX, double& highX, int& nchY, double& lowY, double& highY) const {
0596   nchX = TkMap[layer].get_nchX();
0597   lowX = TkMap[layer].get_lowX();
0598   highX = TkMap[layer].get_highX();
0599   nchY = TkMap[layer].get_nchY();
0600   lowY = TkMap[layer].get_lowY();
0601   highY = TkMap[layer].get_highY();
0602 }