Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-08-23 12:58:59

0001 #include "FWCore/Framework/interface/ESProducer.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 
0006 #include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
0007 
0008 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0009 class TrackerTopology;
0010 
0011 #include "Geometry/TrackerNumberingBuilder/interface/utils.h"
0012 
0013 class TkDetMapESProducer : public edm::ESProducer {
0014 public:
0015   TkDetMapESProducer(const edm::ParameterSet&);
0016   ~TkDetMapESProducer() override {}
0017 
0018   std::unique_ptr<TkDetMap> produce(const TrackerTopologyRcd&);
0019 
0020 private:
0021   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0022   edm::ESGetToken<GeometricDet, IdealGeometryRecord> geomDetToken_;
0023 };
0024 
0025 TkDetMapESProducer::TkDetMapESProducer(const edm::ParameterSet&) {
0026   auto cc = setWhatProduced(this);
0027   tTopoToken_ = cc.consumes();
0028   geomDetToken_ = cc.consumes();
0029 }
0030 
0031 namespace {
0032   TkLayerMap makeTkLayerMap(int layer, const TrackerTopology* tTopo, const std::vector<uint32_t> tkDetIdList) {
0033     LogTrace("TkLayerMap") << " TkLayerMap::constructor for layer " << layer;
0034     uint32_t nStringExt, nRod;
0035     std::vector<uint32_t> SingleExtString;
0036     switch (layer) {
0037       case TkLayerMap::TIB_L1:  //TIBL1
0038         nStringExt = 30;
0039         SingleExtString.insert(SingleExtString.begin(), 8, 0);
0040         SingleExtString.insert(SingleExtString.begin() + 8, 7, 1);
0041         SingleExtString.insert(SingleExtString.begin() + 15, 8, 2);
0042         SingleExtString.insert(SingleExtString.begin() + 23, 7, 3);
0043         return TkLayerMap(layer,
0044                           12,
0045                           -6.,
0046                           6.,
0047                           2 * (nStringExt + 1),
0048                           -1. * (nStringExt + 1.),
0049                           (nStringExt + 1),
0050                           tTopo,
0051                           tkDetIdList,
0052                           SingleExtString,
0053                           {},
0054                           {},
0055                           {},
0056                           nStringExt);
0057         break;
0058       case TkLayerMap::TIB_L2:
0059         nStringExt = 38;
0060         SingleExtString.insert(SingleExtString.begin(), 10, 0);
0061         SingleExtString.insert(SingleExtString.begin() + 10, 9, 1);
0062         SingleExtString.insert(SingleExtString.begin() + 19, 10, 2);
0063         SingleExtString.insert(SingleExtString.begin() + 29, 9, 3);
0064         return TkLayerMap(layer,
0065                           12,
0066                           -6.,
0067                           6.,
0068                           2 * (nStringExt + 1),
0069                           -1. * (nStringExt + 1.),
0070                           (nStringExt + 1),
0071                           tTopo,
0072                           tkDetIdList,
0073                           SingleExtString,
0074                           {},
0075                           {},
0076                           {},
0077                           nStringExt);
0078         break;
0079       case TkLayerMap::TIB_L3:
0080         nStringExt = 46;
0081         SingleExtString.insert(SingleExtString.begin(), 23, 0);
0082         SingleExtString.insert(SingleExtString.begin() + 23, 23, 1);
0083         return TkLayerMap(
0084             layer, 12, -6., 6., nStringExt, 0, nStringExt, tTopo, tkDetIdList, SingleExtString, {}, {}, {}, nStringExt);
0085         break;
0086       case TkLayerMap::TIB_L4:
0087         nStringExt = 56;
0088         SingleExtString.insert(SingleExtString.begin(), 14, 0);
0089         SingleExtString.insert(SingleExtString.begin() + 14, 14, 1);
0090         SingleExtString.insert(SingleExtString.begin() + 28, 14, 2);
0091         SingleExtString.insert(SingleExtString.begin() + 42, 14, 3);
0092         return TkLayerMap(
0093             layer, 12, -6., 6., nStringExt, 0, nStringExt, tTopo, tkDetIdList, SingleExtString, {}, {}, {}, nStringExt);
0094         break;
0095       case TkLayerMap::TIDM_D1:  //TID
0096       case TkLayerMap::TIDM_D2:  //TID
0097       case TkLayerMap::TIDM_D3:  //TID
0098         return TkLayerMap(layer, 7, -7., 0., 40, 0., 40., tTopo, tkDetIdList, {});
0099         break;
0100       case TkLayerMap::TIDP_D1:  //TID
0101       case TkLayerMap::TIDP_D2:  //TID
0102       case TkLayerMap::TIDP_D3:  //TID
0103         return TkLayerMap(layer, 7, 0., 7., 40, 0., 40., tTopo, tkDetIdList, {});
0104         break;
0105       case TkLayerMap::TOB_L1:  //TOBL1
0106         nRod = 42;
0107         return TkLayerMap(layer,
0108                           12,
0109                           -6.,
0110                           6.,
0111                           2 * (nRod + 1),
0112                           -1. * (nRod + 1.),
0113                           (nRod + 1.),
0114                           tTopo,
0115                           tkDetIdList,
0116                           {},
0117                           {},
0118                           {},
0119                           {},
0120                           0,
0121                           nRod);
0122         break;
0123       case TkLayerMap::TOB_L2:
0124         nRod = 48;
0125         return TkLayerMap(layer,
0126                           12,
0127                           -6.,
0128                           6.,
0129                           2 * (nRod + 1),
0130                           -1. * (nRod + 1.),
0131                           (nRod + 1.),
0132                           tTopo,
0133                           tkDetIdList,
0134                           {},
0135                           {},
0136                           {},
0137                           {},
0138                           0,
0139                           nRod);
0140         break;
0141       case TkLayerMap::TOB_L3:  //TOBL3
0142         nRod = 54;
0143         return TkLayerMap(layer, 12, -6., 6., nRod, 0., 1. * nRod, tTopo, tkDetIdList, {}, {}, {}, {}, 0, nRod);
0144         break;
0145       case TkLayerMap::TOB_L4:
0146         nRod = 60;
0147         return TkLayerMap(layer, 12, -6., 6., nRod, 0., 1. * nRod, tTopo, tkDetIdList, {}, {}, {}, {}, 0, nRod);
0148         break;
0149       case TkLayerMap::TOB_L5:
0150         nRod = 66;
0151         return TkLayerMap(layer, 12, -6., 6., nRod, 0., 1. * nRod, tTopo, tkDetIdList, {}, {}, {}, {}, 0, nRod);
0152         break;
0153       case TkLayerMap::TOB_L6:
0154         nRod = 74;
0155         return TkLayerMap(layer, 12, -6., 6., nRod, 0., 1. * nRod, tTopo, tkDetIdList, {}, {}, {}, {}, 0, nRod);
0156         break;
0157       default:  //TEC
0158         std::vector<uint32_t> modulesInRingFront = {0, 2, 2, 3, 4, 2, 4, 5};
0159         std::vector<uint32_t> modulesInRingBack = {0, 1, 1, 2, 3, 3, 3, 5};
0160         switch (layer) {
0161           case TkLayerMap::TECM_W1:
0162           case TkLayerMap::TECM_W2:
0163           case TkLayerMap::TECM_W3:
0164             return TkLayerMap(layer,
0165                               16,
0166                               -16.,
0167                               0.,
0168                               80,
0169                               0.,
0170                               80.,
0171                               tTopo,
0172                               tkDetIdList,
0173                               {},
0174                               modulesInRingFront,
0175                               modulesInRingBack,
0176                               {0, 1, 4, 7, 9, 11, 14, 16});
0177             break;
0178           case TkLayerMap::TECM_W4:
0179           case TkLayerMap::TECM_W5:
0180           case TkLayerMap::TECM_W6:
0181             return TkLayerMap(layer,
0182                               13,
0183                               -16.,
0184                               -3.,
0185                               80,
0186                               0.,
0187                               80.,
0188                               tTopo,
0189                               tkDetIdList,
0190                               {},
0191                               modulesInRingFront,
0192                               modulesInRingBack,
0193                               {0, 0, 1, 4, 6, 8, 11, 13});
0194             break;
0195           case TkLayerMap::TECM_W7:
0196           case TkLayerMap::TECM_W8:
0197             return TkLayerMap(layer,
0198                               10,
0199                               -16.,
0200                               -6.,
0201                               80,
0202                               0.,
0203                               80.,
0204                               tTopo,
0205                               tkDetIdList,
0206                               {},
0207                               modulesInRingFront,
0208                               modulesInRingBack,
0209                               {0, 0, 0, 1, 3, 5, 8, 10});
0210             break;
0211           case TkLayerMap::TECM_W9:
0212             return TkLayerMap(layer,
0213                               8,
0214                               -16.,
0215                               -8.,
0216                               80,
0217                               0.,
0218                               80.,
0219                               tTopo,
0220                               tkDetIdList,
0221                               {},
0222                               modulesInRingFront,
0223                               modulesInRingBack,
0224                               {0, 0, 0, 0, 1, 3, 6, 8});
0225             break;
0226           case TkLayerMap::TECP_W1:
0227           case TkLayerMap::TECP_W2:
0228           case TkLayerMap::TECP_W3:
0229             return TkLayerMap(layer,
0230                               16,
0231                               0.,
0232                               16.,
0233                               80,
0234                               0.,
0235                               80.,
0236                               tTopo,
0237                               tkDetIdList,
0238                               {},
0239                               modulesInRingFront,
0240                               modulesInRingBack,
0241                               {0, 1, 4, 7, 9, 11, 14, 16});
0242             break;
0243           case TkLayerMap::TECP_W4:
0244           case TkLayerMap::TECP_W5:
0245           case TkLayerMap::TECP_W6:
0246             return TkLayerMap(layer,
0247                               13,
0248                               3.,
0249                               16.,
0250                               80,
0251                               0.,
0252                               80.,
0253                               tTopo,
0254                               tkDetIdList,
0255                               {},
0256                               modulesInRingFront,
0257                               modulesInRingBack,
0258                               {0, 0, 1, 4, 6, 8, 11, 13});
0259             break;
0260           case TkLayerMap::TECP_W7:
0261           case TkLayerMap::TECP_W8:
0262             return TkLayerMap(layer,
0263                               10,
0264                               6.,
0265                               16.,
0266                               80,
0267                               0.,
0268                               80.,
0269                               tTopo,
0270                               tkDetIdList,
0271                               {},
0272                               modulesInRingFront,
0273                               modulesInRingBack,
0274                               {0, 0, 0, 1, 3, 5, 8, 10});
0275             break;
0276           case TkLayerMap::TECP_W9:
0277             return TkLayerMap(layer,
0278                               8,
0279                               8.,
0280                               16.,
0281                               80,
0282                               0.,
0283                               80.,
0284                               tTopo,
0285                               tkDetIdList,
0286                               {},
0287                               modulesInRingFront,
0288                               modulesInRingBack,
0289                               {0, 0, 0, 0, 1, 3, 6, 8});
0290         }
0291     }
0292     return TkLayerMap{};
0293   }
0294 }  // namespace
0295 
0296 std::unique_ptr<TkDetMap> TkDetMapESProducer::produce(const TrackerTopologyRcd& tTopoRcd) {
0297   const auto& geomDet = tTopoRcd.get(geomDetToken_);
0298   const auto TkDetIdList = TrackerGeometryUtils::getSiStripDetIds(geomDet);
0299 
0300   const auto& tTopo = tTopoRcd.get(tTopoToken_);
0301   auto tkDetMap = std::make_unique<TkDetMap>(&tTopo);
0302 
0303   LogTrace("TkDetMap") << "TkDetMap::constructor ";
0304   //Create TkLayerMap for each layer declared in the TkLayerEnum
0305   for (int layer = 1; layer < TkLayerMap::NUMLAYERS; ++layer) {
0306     tkDetMap->setLayerMap(layer, makeTkLayerMap(layer, &tTopo, TkDetIdList));
0307   }
0308 
0309   return tkDetMap;
0310 }
0311 
0312 #include "FWCore/Framework/interface/ModuleFactory.h"
0313 DEFINE_FWK_EVENTSETUP_MODULE(TkDetMapESProducer);