Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerOTLayerBuilder.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 "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerOTRingBuilder.h"
0007 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerLadderBuilder.h"
0008 #include "Geometry/TrackerNumberingBuilder/interface/trackerStablePhiSort.h"
0009 #include "DataFormats/DetId/interface/DetId.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 
0012 #include <vector>
0013 #include <bitset>
0014 
0015 template <class FilteredView>
0016 void CmsTrackerOTLayerBuilder<FilteredView>::buildComponent(FilteredView& fv, GeometricDet* g, const std::string& s) {
0017   LogTrace("DetConstruction") << " CmsTrackerOTLayerBuilder::buildComponent ";
0018   CmsTrackerLadderBuilder<FilteredView> theCmsTrackerLadderBuilder;
0019   CmsTrackerOTRingBuilder<FilteredView> theCmsTrackerOTRingBuilder;
0020 
0021   GeometricDet* subdet = new GeometricDet(&fv,
0022                                           CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0023                                               ExtractStringFromDDD<FilteredView>::getString(s, &fv)));
0024   switch (CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0025       ExtractStringFromDDD<FilteredView>::getString(s, &fv))) {
0026     case GeometricDet::ladder:
0027       theCmsTrackerLadderBuilder.build(fv, subdet, s);
0028       break;
0029     case GeometricDet::panel:
0030       theCmsTrackerOTRingBuilder.build(fv, subdet, s);
0031       break;
0032     default:
0033       edm::LogError("CmsTrackerOTLayerBuilder") << " ERROR - I was expecting a ladder or a panel, I got a "
0034                                                 << ExtractStringFromDDD<FilteredView>::getString(s, &fv);
0035   }
0036   g->addComponent(subdet);
0037 }
0038 
0039 template <class FilteredView>
0040 void CmsTrackerOTLayerBuilder<FilteredView>::sortNS(FilteredView& fv, GeometricDet* det) {
0041   GeometricDet::ConstGeometricDetContainer comp = det->components();
0042 
0043   //order ladder and rings together
0044   GeometricDet::GeometricDetContainer rods;
0045   GeometricDet::GeometricDetContainer ringsNeg;
0046   GeometricDet::GeometricDetContainer ringsPos;
0047   rods.clear();
0048   ringsNeg.clear();
0049   ringsPos.clear();
0050 
0051   for (uint32_t i = 0; i < comp.size(); i++) {
0052     auto component = det->component(i);
0053     if (component->type() == GeometricDet::ladder) {
0054       rods.emplace_back(component);
0055     } else if (component->type() == GeometricDet::panel) {
0056       if (component->translation().z() < 0.) {
0057         ringsNeg.emplace_back(component);
0058       } else if (component->translation().z() > 0.) {
0059         ringsPos.emplace_back(component);
0060       }
0061     } else {
0062       edm::LogError("CmsTrackerOTLayerBuilder")
0063           << "ERROR - wrong SubDet to sort..... " << det->components().front()->type();
0064     }
0065   }
0066 
0067   // negative rings
0068   if (!ringsNeg.empty()) {
0069     std::sort(ringsNeg.begin(), ringsNeg.end(), CmsTrackerLevelBuilderHelper::isLessZ);
0070     uint32_t totalringsNeg = ringsNeg.size();
0071 
0072     LogTrace("DetConstruction") << " Neg rings ordered by z: ";
0073     for (uint32_t ring = 0; ring < totalringsNeg; ring++) {
0074       uint32_t temp = ring + 1;
0075       temp |= (1 << 8);
0076       ringsNeg[ring]->setGeographicalID(temp);
0077       LogTrace("BuildingTrackerDetId") << "\t\t\t DetId >> " << temp
0078                                        << "(r: " << sqrt(ringsNeg[ring]->translation().Perp2())
0079                                        << ", phi: " << ringsNeg[ring]->phi()
0080                                        << ", z: " << ringsNeg[ring]->translation().z() << ")";
0081     }
0082   }
0083 
0084   // rods
0085   if (!rods.empty()) {
0086     trackerStablePhiSort(rods.begin(), rods.end(), CmsTrackerLevelBuilderHelper::getPhi);
0087     uint32_t totalrods = rods.size();
0088 
0089     LogTrace("DetConstruction") << " Rods ordered by phi: ";
0090     for (uint32_t rod = 0; rod < totalrods; rod++) {
0091       uint32_t temp = rod + 1;
0092       temp |= (3 << 8);
0093       rods[rod]->setGeographicalID(DetId(temp));
0094       LogTrace("BuildingTrackerDetId") << "\t\t\t DetId >> " << temp << "(r: " << sqrt(rods[rod]->translation().Perp2())
0095                                        << ", phi: " << rods[rod]->phi() << ", z: " << rods[rod]->translation().z()
0096                                        << ")";
0097     }
0098   }
0099 
0100   // positive rings
0101   if (!ringsPos.empty()) {
0102     std::sort(ringsPos.begin(), ringsPos.end(), CmsTrackerLevelBuilderHelper::isLessZ);
0103     uint32_t totalringsPos = ringsPos.size();
0104 
0105     LogTrace("DetConstruction") << " Pos rings ordered by z: ";
0106     for (uint32_t ring = 0; ring < totalringsPos; ring++) {
0107       uint32_t temp = ring + 1;
0108       temp |= (2 << 8);
0109       ringsPos[ring]->setGeographicalID(temp);
0110       LogTrace("BuildingTrackerDetId") << "\t\t\t DetId >> " << temp
0111                                        << "(r: " << sqrt(ringsPos[ring]->translation().Perp2())
0112                                        << ", phi: " << ringsPos[ring]->phi()
0113                                        << ", z: " << ringsPos[ring]->translation().z() << ")";
0114     }
0115   }
0116 
0117   det->clearComponents();
0118   det->addComponents(ringsNeg);
0119   det->addComponents(rods);
0120   det->addComponents(ringsPos);
0121 }
0122 
0123 template class CmsTrackerOTLayerBuilder<DDFilteredView>;
0124 template class CmsTrackerOTLayerBuilder<cms::DDFilteredView>;