Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-12 02:58:34

0001 //#define EDM_ML_DEBUG
0002 
0003 #include "RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h"
0004 
0005 #include <DataFormats/ForwardDetId/interface/BTLDetId.h>
0006 #include <Geometry/CommonDetUnit/interface/GeomDet.h>
0007 #include <RecoMTD/DetLayers/interface/MTDTrayBarrelLayer.h>
0008 #include <RecoMTD/DetLayers/interface/MTDDetTray.h>
0009 
0010 #include <Utilities/General/interface/precomputed_value_sort.h>
0011 #include <Geometry/CommonDetUnit/interface/DetSorting.h>
0012 
0013 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0014 
0015 #include <iostream>
0016 
0017 using namespace std;
0018 
0019 BTLDetLayerGeometryBuilder::BTLDetLayerGeometryBuilder() {}
0020 
0021 BTLDetLayerGeometryBuilder::~BTLDetLayerGeometryBuilder() {}
0022 
0023 vector<DetLayer*> BTLDetLayerGeometryBuilder::buildLayers(const MTDGeometry& geo) {
0024   vector<DetLayer*> detlayers;
0025   vector<MTDTrayBarrelLayer*> result;
0026 
0027   vector<const DetRod*> btlDetTrays;
0028 
0029   for (unsigned tray = 1; tray <= BTLDetId::HALF_ROD; ++tray) {
0030     vector<const GeomDet*> geomDets;
0031     for (unsigned module = 1; module <= BTLDetId::kModulesPerRODBarPhiFlat; ++module) {
0032       for (unsigned side = 0; side <= 1; ++side) {
0033         const GeomDet* geomDet = geo.idToDet(BTLDetId(side, tray, module, 0, 1));
0034         if (geomDet != nullptr) {
0035           geomDets.push_back(geomDet);
0036           LogTrace("MTDDetLayers") << "get BTL module " << std::hex << BTLDetId(side, tray, module, 0, 1).rawId()
0037                                    << std::dec << " at R=" << geomDet->position().perp()
0038                                    << ", phi=" << geomDet->position().phi();
0039         }
0040       }
0041     }
0042 
0043     if (!geomDets.empty()) {
0044       precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetZ());
0045       btlDetTrays.push_back(new MTDDetTray(geomDets));
0046       LogTrace("MTDDetLayers") << "  New BTLDetTray with " << geomDets.size()
0047                                << " modules at R=" << btlDetTrays.back()->position().perp()
0048                                << ", phi=" << btlDetTrays.back()->position().phi();
0049     }
0050   }
0051 
0052   precomputed_value_sort(btlDetTrays.begin(), btlDetTrays.end(), geomsort::ExtractPhi<GeometricSearchDet, float>());
0053   result.push_back(new MTDTrayBarrelLayer(btlDetTrays));
0054   LogTrace("MTDDetLayers") << "BTLDetLayerGeometryBuilder: new MTDTrayBarrelLayer with " << btlDetTrays.size()
0055                            << " rods, at R " << result.back()->specificSurface().radius();
0056 
0057   for (vector<MTDTrayBarrelLayer*>::const_iterator it = result.begin(); it != result.end(); it++)
0058     detlayers.push_back((DetLayer*)(*it));
0059 
0060   return detlayers;
0061 }