Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:11

0001 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerRingBuilder.h"
0002 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0003 #include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
0004 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
0005 #include "Geometry/TrackerNumberingBuilder/plugins/ExtractStringFromDDD.h"
0006 #include "DataFormats/DetId/interface/DetId.h"
0007 #include "Geometry/TrackerNumberingBuilder/plugins/CmsDetConstruction.h"
0008 #include "Geometry/TrackerNumberingBuilder/interface/trackerStablePhiSort.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 #include <vector>
0012 #include <bitset>
0013 
0014 template <class FilteredView>
0015 void CmsTrackerRingBuilder<FilteredView>::buildComponent(FilteredView& fv, GeometricDet* g, const std::string& s) {
0016   moduleName_ = ExtractStringFromDDD<FilteredView>::getString("TkDDDStructure", &fv);
0017 
0018   CmsDetConstruction<FilteredView> theCmsDetConstruction;
0019   theCmsDetConstruction.buildComponent(fv, g, s);
0020 }
0021 
0022 template <class FilteredView>
0023 void CmsTrackerRingBuilder<FilteredView>::sortNS(FilteredView& fv, GeometricDet* det) {
0024   GeometricDet::ConstGeometricDetContainer& comp = det->components();
0025   GeometricDet::GeometricDetContainer compfw;
0026   GeometricDet::GeometricDetContainer compbw;
0027 
0028   switch (comp.front()->type()) {
0029     case GeometricDet::mergedDet:
0030       trackerStablePhiSort(comp.begin(), comp.end(), CmsTrackerLevelBuilderHelper::getPhiGluedModule);
0031       break;
0032     case GeometricDet::DetUnit:
0033       trackerStablePhiSort(comp.begin(), comp.end(), CmsTrackerLevelBuilderHelper::getPhi);
0034       break;
0035     default:
0036       edm::LogError("CmsTrackerRingBuilder")
0037           << "ERROR - wrong SubDet to sort..... " << det->components().front()->type();
0038   }
0039 
0040   static std::string const TECGluedDet("TECGluedDet");
0041   static std::string const TECDet("TECDet");
0042 
0043   // TEC
0044   // Module Number: 3 bits [1,...,5 at most]
0045   if (moduleName_ == TECGluedDet || moduleName_ == TECDet) {
0046     // TEC-
0047     if (det->translation().z() < 0 && moduleName_ == TECDet) {
0048       trackerStablePhiSort(comp.begin(), comp.end(), CmsTrackerLevelBuilderHelper::getPhiMirror);
0049     }
0050 
0051     if (det->translation().z() < 0 && moduleName_ == TECGluedDet) {
0052       trackerStablePhiSort(comp.begin(), comp.end(), CmsTrackerLevelBuilderHelper::getPhiGluedModuleMirror);
0053     }
0054 
0055     for (uint32_t i = 0; i < comp.size(); i++)
0056       det->component(i)->setGeographicalID(i + 1);
0057 
0058   } else {
0059     // TID
0060     // Ring Side: 2 bits [back:1 front:2]
0061     // Module Number: 5 bits [1,...,20 at most]
0062     //
0063     for (uint32_t i = 0; i < comp.size(); i++) {
0064       if (std::abs(comp[i]->translation().z()) < std::abs(det->translation().z())) {
0065         compfw.emplace_back(det->component(i));
0066       } else {
0067         compbw.emplace_back(det->component(i));
0068       }
0069     }
0070 
0071     for (uint32_t i = 0; i < compbw.size(); i++) {
0072       uint32_t temp = i + 1;
0073       temp |= (1 << 5);
0074       compbw[i]->setGeographicalID(temp);
0075     }
0076 
0077     for (uint32_t i = 0; i < compfw.size(); i++) {
0078       uint32_t temp = i + 1;
0079       temp |= (2 << 5);
0080       compfw[i]->setGeographicalID(temp);
0081     }
0082 
0083     det->clearComponents();
0084     det->addComponents(compfw);
0085     det->addComponents(compbw);
0086   }
0087 }
0088 
0089 template class CmsTrackerRingBuilder<DDFilteredView>;
0090 template class CmsTrackerRingBuilder<cms::DDFilteredView>;