Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-07 05:53:40

0001 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0002 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0003 #include "DataFormats/TrackerCommon/interface/TrackerDetSide.h"
0004 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0005 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
0006 #include "RecoTracker/MkFit/interface/MkFitGeometry.h"
0007 
0008 #include "RecoTracker/MkFitCMS/interface/LayerNumberConverter.h"
0009 #include "RecoTracker/MkFitCore/interface/TrackerInfo.h"
0010 
0011 namespace {
0012   bool isPlusSide(const TrackerTopology& ttopo, DetId detid) {
0013     return ttopo.side(detid) == static_cast<unsigned>(TrackerDetSide::PosEndcap);
0014   }
0015 }  // namespace
0016 
0017 MkFitGeometry::MkFitGeometry(const TrackerGeometry& geom,
0018                              const GeometricSearchTracker& tracker,
0019                              const TrackerTopology& ttopo,
0020                              std::unique_ptr<mkfit::TrackerInfo> trackerInfo)
0021     : ttopo_(&ttopo),
0022       lnc_{std::make_unique<mkfit::LayerNumberConverter>(mkfit::TkLayout::phase1)},
0023       trackerInfo_(std::move(trackerInfo)) {
0024   if (geom.numberOfLayers(PixelSubdetector::PixelBarrel) != 4 ||
0025       geom.numberOfLayers(PixelSubdetector::PixelEndcap) != 3) {
0026     throw cms::Exception("Assert") << "For now this code works only with phase1 tracker, you have something else";
0027   }
0028 
0029   // Create DetLayer structure
0030   dets_.resize(lnc_->nLayers(), nullptr);
0031   auto setDet = [this](const int subdet, const int layer, const int isStereo, const DetId& detId, const DetLayer* lay) {
0032     const int index = lnc_->convertLayerNumber(subdet, layer, false, isStereo, isPlusSide(*ttopo_, detId));
0033     if (index < 0 or static_cast<unsigned>(index) >= dets_.size()) {
0034       throw cms::Exception("LogicError") << "Invalid mkFit layer index " << index << " for DetId " << detId.rawId()
0035                                          << " subdet " << subdet << " layer " << layer << " isStereo " << isStereo;
0036     }
0037     dets_[index] = lay;
0038   };
0039   constexpr int monoLayer = 0;
0040   constexpr int stereoLayer = 1;
0041   for (const DetLayer* lay : tracker.allLayers()) {
0042     const auto& comp = lay->basicComponents();
0043     if (UNLIKELY(comp.empty())) {
0044       throw cms::Exception("LogicError") << "Got a tracker layer (subdet " << lay->subDetector()
0045                                          << ") with empty basicComponents.";
0046     }
0047     // First component is enough for layer and side information
0048     const auto& detId = comp.front()->geographicalId();
0049     const auto subdet = detId.subdetId();
0050     const auto layer = ttopo.layer(detId);
0051 
0052     // TODO: mono/stereo structure is still hardcoded for phase0/1 strip tracker
0053     setDet(subdet, layer, monoLayer, detId, lay);
0054     if (((subdet == StripSubdetector::TIB or subdet == StripSubdetector::TOB) and (layer == 1 or layer == 2)) or
0055         subdet == StripSubdetector::TID or subdet == StripSubdetector::TEC) {
0056       setDet(subdet, layer, stereoLayer, detId, lay);
0057     }
0058   }
0059 }
0060 
0061 // Explicit out-of-line because of the mkfit::LayerNumberConverter is
0062 // only forward declared in the header
0063 MkFitGeometry::~MkFitGeometry() {}
0064 
0065 int MkFitGeometry::mkFitLayerNumber(DetId detId) const {
0066   return lnc_->convertLayerNumber(
0067       detId.subdetId(), ttopo_->layer(detId), false, ttopo_->isStereo(detId), isPlusSide(*ttopo_, detId));
0068 }