Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerWheelBuilder.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/CmsTrackerRingBuilder.h"
0008 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerPetalBuilder.h"
0009 #include "Geometry/TrackerNumberingBuilder/interface/trackerStablePhiSort.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 
0012 #include <vector>
0013 #include <bitset>
0014 
0015 template <class FilteredView>
0016 void CmsTrackerWheelBuilder<FilteredView>::buildComponent(FilteredView& fv, GeometricDet* g, const std::string& s) {
0017   CmsTrackerRingBuilder<FilteredView> theCmsTrackerRingBuilder;
0018   CmsTrackerPetalBuilder<FilteredView> theCmsTrackerPetalBuilder;
0019 
0020   GeometricDet* subdet = new GeometricDet(&fv,
0021                                           CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0022                                               ExtractStringFromDDD<FilteredView>::getString(s, &fv)));
0023   switch (CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0024       ExtractStringFromDDD<FilteredView>::getString(s, &fv))) {
0025     case GeometricDet::ring:
0026       theCmsTrackerRingBuilder.build(fv, subdet, s);
0027       break;
0028     case GeometricDet::petal:
0029       theCmsTrackerPetalBuilder.build(fv, subdet, s);
0030       break;
0031     default:
0032       edm::LogError("CmsTrackerWheelBuilder") << " ERROR - I was expecting a Ring or Petal, I got a "
0033                                               << ExtractStringFromDDD<FilteredView>::getString(s, &fv);
0034   }
0035   g->addComponent(subdet);
0036 }
0037 
0038 template <class FilteredView>
0039 void CmsTrackerWheelBuilder<FilteredView>::sortNS(FilteredView& fv, GeometricDet* det) {
0040   GeometricDet::ConstGeometricDetContainer& comp = det->components();
0041 
0042   if (!comp.empty()) {
0043     if (comp.front()->type() == GeometricDet::petal) {
0044       GeometricDet::GeometricDetContainer compfw;
0045       GeometricDet::GeometricDetContainer compbw;
0046       compfw.clear();
0047       compbw.clear();
0048       for (uint32_t i = 0; i < comp.size(); i++) {
0049         if (std::abs(comp[i]->translation().z()) < std::abs(det->translation().z())) {
0050           compfw.emplace_back(det->component(i));
0051         } else {
0052           compbw.emplace_back(det->component(i));
0053         }
0054       }
0055 
0056       trackerStablePhiSort(compfw.begin(), compfw.end(), CmsTrackerLevelBuilderHelper::getPhiModule);
0057       trackerStablePhiSort(compbw.begin(), compbw.end(), CmsTrackerLevelBuilderHelper::getPhiModule);
0058 
0059       //
0060       // TEC
0061       // Wheel Part:   3 bits [back:1 front:2]
0062       // Petal Number: 4 bits [1,...,8]
0063       //
0064       for (uint32_t i = 0; i < compbw.size(); i++) {
0065         uint32_t temp = i + 1;
0066         temp |= (1 << 4);
0067         compbw[i]->setGeographicalID(DetId(temp));
0068       }
0069       for (uint32_t i = 0; i < compfw.size(); i++) {
0070         uint32_t temp = i + 1;
0071         temp |= (2 << 4);
0072         compfw[i]->setGeographicalID(DetId(temp));
0073       }
0074 
0075       det->clearComponents();
0076       det->addComponents(compfw);
0077       det->addComponents(compbw);
0078 
0079     } else {
0080       std::stable_sort(comp.begin(), comp.end(), CmsTrackerLevelBuilderHelper::isLessRModule);
0081 
0082       // TID
0083       // Disk Number: 2 bits [1,2,3]
0084       for (uint32_t i = 0; i < comp.size(); i++) {
0085         det->component(i)->setGeographicalID(DetId(i + 1));
0086       }
0087     }
0088   } else {
0089     edm::LogError("CmsTrackerWheelBuilder") << "Where are the Petals or Rings?";
0090   }
0091 }
0092 
0093 template class CmsTrackerWheelBuilder<DDFilteredView>;
0094 template class CmsTrackerWheelBuilder<cms::DDFilteredView>;