Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerDiskBuilder.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/CmsTrackerPanelBuilder.h"
0007 #include "Geometry/TrackerNumberingBuilder/interface/trackerStablePhiSort.h"
0008 #include "DataFormats/DetId/interface/DetId.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 #include <vector>
0012 #include <algorithm>
0013 
0014 using namespace std;
0015 
0016 template <class FilteredView>
0017 void CmsTrackerDiskBuilder<FilteredView>::buildComponent(FilteredView& fv, GeometricDet* g, const std::string& s) {
0018   CmsTrackerPanelBuilder<FilteredView> theCmsTrackerPanelBuilder;
0019   GeometricDet* subdet = new GeometricDet(&fv,
0020                                           CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0021                                               ExtractStringFromDDD<FilteredView>::getString(s, &fv)));
0022 
0023   switch (CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0024       ExtractStringFromDDD<FilteredView>::getString(s, &fv))) {
0025     case GeometricDet::panel:
0026       theCmsTrackerPanelBuilder.build(fv, subdet, s);
0027       break;
0028     default:
0029       edm::LogError("CmsTrackerDiskBuilder")
0030           << " ERROR - I was expecting a Panel, I got a " << ExtractStringFromDDD<FilteredView>::getString(s, &fv);
0031   }
0032   g->addComponent(subdet);
0033 }
0034 
0035 template <class FilteredView>
0036 void CmsTrackerDiskBuilder<FilteredView>::sortNS(FilteredView& fv, GeometricDet* det) {
0037   GeometricDet::ConstGeometricDetContainer& comp = det->components();
0038 
0039   switch (det->components().front()->type()) {
0040     case GeometricDet::panel:
0041       trackerStablePhiSort(comp.begin(), comp.end(), CmsTrackerLevelBuilderHelper::getPhi);
0042       break;
0043     default:
0044       edm::LogError("CmsTrackerDiskBuilder")
0045           << "ERROR - wrong SubDet to sort..... " << det->components().front()->type();
0046   }
0047 
0048   GeometricDet::GeometricDetContainer zminpanels;  // Here z refers abs(z);
0049   GeometricDet::GeometricDetContainer zmaxpanels;  // So, zmin panel is always closer to ip.
0050 
0051   uint32_t totalblade = comp.size() / 2;
0052   //  std::cout << "pixel_disk " << pixel_disk << endl;
0053 
0054   zminpanels.reserve(totalblade);
0055   zmaxpanels.reserve(totalblade);
0056   for (uint32_t j = 0; j < totalblade; j++) {
0057     if (std::abs(comp[2 * j]->translation().z()) > std::abs(comp[2 * j + 1]->translation().z())) {
0058       zmaxpanels.emplace_back(det->component(2 * j));
0059       zminpanels.emplace_back(det->component(2 * j + 1));
0060 
0061     } else if (std::abs(comp[2 * j]->translation().z()) < std::abs(comp[2 * j + 1]->translation().z())) {
0062       zmaxpanels.emplace_back(det->component(2 * j + 1));
0063       zminpanels.emplace_back(det->component(2 * j));
0064     } else {
0065       edm::LogWarning("CmsTrackerDiskBuilder") << "WARNING - The Z of  both panels are equal! ";
0066     }
0067   }
0068 
0069   for (uint32_t fn = 0; fn < zminpanels.size(); fn++) {
0070     uint32_t blade = fn + 1;
0071     uint32_t panel = 1;
0072     uint32_t temp = (blade << 2) | panel;
0073     zminpanels[fn]->setGeographicalID(temp);
0074   }
0075 
0076   for (uint32_t bn = 0; bn < zmaxpanels.size(); bn++) {
0077     uint32_t blade = bn + 1;
0078     uint32_t panel = 2;
0079     uint32_t temp = (blade << 2) | panel;
0080     zmaxpanels[bn]->setGeographicalID(temp);
0081   }
0082 
0083   det->clearComponents();
0084   det->addComponents(zminpanels);
0085   det->addComponents(zmaxpanels);
0086 }
0087 
0088 template class CmsTrackerDiskBuilder<DDFilteredView>;
0089 template class CmsTrackerDiskBuilder<cms::DDFilteredView>;