diff --git a/RecoMTD/DetLayers/BuildFile.xml b/RecoMTD/DetLayers/BuildFile.xml index a3b2724a92901..5ed71cd29ee88 100644 --- a/RecoMTD/DetLayers/BuildFile.xml +++ b/RecoMTD/DetLayers/BuildFile.xml @@ -4,6 +4,9 @@ + + + diff --git a/RecoMTD/DetLayers/plugins/BTLDetLayerGeometryBuilder.h b/RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h similarity index 100% rename from RecoMTD/DetLayers/plugins/BTLDetLayerGeometryBuilder.h rename to RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h diff --git a/RecoMTD/DetLayers/plugins/ETLDetLayerGeometryBuilder.h b/RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h similarity index 100% rename from RecoMTD/DetLayers/plugins/ETLDetLayerGeometryBuilder.h rename to RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h diff --git a/RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h b/RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h index 0fc82b62fae1a..57a4cd620c6b7 100644 --- a/RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h +++ b/RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h @@ -11,6 +11,9 @@ #include "DataFormats/DetId/interface/DetId.h" #include "TrackingTools/DetLayers/interface/DetLayerGeometry.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" +#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" + #include #include @@ -50,6 +53,11 @@ class MTDDetLayerGeometry : public DetLayerGeometry { /// return the DetLayer which correspond to a certain DetId const DetLayer* idToLayer(const DetId& detId) const override; + // Added to allow building the MTDDetLayer from external plugins + void buildLayers(const MTDGeometry* geo, const MTDTopology* mtopo); + + void sortLayers(); + private: /// Add ETL layers /// etllayers.first=forward (+Z), etllayers.second=backward (-Z) @@ -61,8 +69,6 @@ class MTDDetLayerGeometry : public DetLayerGeometry { DetId makeDetLayerId(const DetLayer* detLayer) const; - void sortLayers(); - std::vector etlLayers_fw; std::vector etlLayers_bk; std::vector etlLayers_all; diff --git a/RecoMTD/DetLayers/plugins/MTDDetLayerGeometryESProducer.cc b/RecoMTD/DetLayers/plugins/MTDDetLayerGeometryESProducer.cc index 93a83d0d95bee..6fd869bc030cc 100644 --- a/RecoMTD/DetLayers/plugins/MTDDetLayerGeometryESProducer.cc +++ b/RecoMTD/DetLayers/plugins/MTDDetLayerGeometryESProducer.cc @@ -18,8 +18,8 @@ #include "Geometry/Records/interface/MTDTopologyRcd.h" #include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" -#include "ETLDetLayerGeometryBuilder.h" -#include "BTLDetLayerGeometryBuilder.h" +#include "RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h" +#include "RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h" #include "RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -52,19 +52,12 @@ MTDDetLayerGeometryESProducer::MTDDetLayerGeometryESProducer(const edm::Paramete std::unique_ptr MTDDetLayerGeometryESProducer::produce(const MTDRecoGeometryRecord& record) { auto mtdDetLayerGeometry = std::make_unique(); + auto mtd = record.getHandle(geomToken_); + auto mtdtopo = record.getHandle(mtdtopoToken_); - if (auto mtd = record.getHandle(geomToken_)) { - // Build BTL layers - mtdDetLayerGeometry->addBTLLayers(BTLDetLayerGeometryBuilder::buildLayers(*mtd)); - // Build ETL layers, depends on the scenario - if (auto mtdtopo = record.getHandle(mtdtopoToken_)) { - mtdDetLayerGeometry->addETLLayers(ETLDetLayerGeometryBuilder::buildLayers(*mtd, mtdtopo->getMTDTopologyMode())); - } else { - LogWarning("MTDDetLayers") << "No MTD topology is available."; - } - } else { - LogWarning("MTDDetLayers") << "No MTD geometry is available."; - } + //The BTL and ETL builders are now called internally by the MTDDetLayerGeometry. + //This allows external plugings to use and build the object. + mtdDetLayerGeometry->buildLayers(&(*mtd), &(*mtdtopo)); // Sort layers properly mtdDetLayerGeometry->sortLayers(); diff --git a/RecoMTD/DetLayers/plugins/BTLDetLayerGeometryBuilder.cc b/RecoMTD/DetLayers/src/BTLDetLayerGeometryBuilder.cc similarity index 97% rename from RecoMTD/DetLayers/plugins/BTLDetLayerGeometryBuilder.cc rename to RecoMTD/DetLayers/src/BTLDetLayerGeometryBuilder.cc index 3d53848e01274..5abd51a8cdce0 100644 --- a/RecoMTD/DetLayers/plugins/BTLDetLayerGeometryBuilder.cc +++ b/RecoMTD/DetLayers/src/BTLDetLayerGeometryBuilder.cc @@ -1,6 +1,6 @@ //#define EDM_ML_DEBUG -#include "BTLDetLayerGeometryBuilder.h" +#include "RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h" #include #include diff --git a/RecoMTD/DetLayers/plugins/ETLDetLayerGeometryBuilder.cc b/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc similarity index 98% rename from RecoMTD/DetLayers/plugins/ETLDetLayerGeometryBuilder.cc rename to RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc index 81f0597d9835b..83af5cda4e386 100644 --- a/RecoMTD/DetLayers/plugins/ETLDetLayerGeometryBuilder.cc +++ b/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc @@ -1,6 +1,6 @@ //#define EDM_ML_DEBUG -#include "ETLDetLayerGeometryBuilder.h" +#include "RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h" #include #include @@ -66,9 +66,6 @@ pair, vector > ETLDetLayerGeometryBuilder::buildLay } } } - // - // the first entry is Z+ ( MTD side 1), the second is Z- (MTD side 0) - // pair, vector > res_pair(result[1], result[0]); return res_pair; } diff --git a/RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc b/RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc index be76d374b1ea0..61e92406557e8 100644 --- a/RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc +++ b/RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc @@ -5,6 +5,8 @@ */ #include +#include +#include #include #include @@ -14,15 +16,32 @@ #include #include +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include using namespace std; using namespace geomsort; +using namespace edm; MTDDetLayerGeometry::MTDDetLayerGeometry() {} MTDDetLayerGeometry::~MTDDetLayerGeometry() {} +void MTDDetLayerGeometry::buildLayers(const MTDGeometry* geo, const MTDTopology* mtopo) { + if (geo) { + // Build BTL layers + this->addBTLLayers(BTLDetLayerGeometryBuilder::buildLayers(*geo)); + // Build ETL layers, depends on the scenario + if (mtopo) { + this->addETLLayers(ETLDetLayerGeometryBuilder::buildLayers(*geo, mtopo->getMTDTopologyMode())); + } else { + LogWarning("MTDDetLayers") << "No MTD topology is available."; + } + } else { + LogWarning("MTDDetLayers") << "No MTD geometry is available."; + } +} + void MTDDetLayerGeometry::addETLLayers(const pair, vector >& etllayers) { for (auto const it : etllayers.first) { etlLayers_fw.push_back(it); diff --git a/RecoTracker/GeometryESProducer/plugins/TrackerMTDRecoGeometryESProducer.cc b/RecoTracker/GeometryESProducer/plugins/TrackerMTDRecoGeometryESProducer.cc new file mode 100644 index 0000000000000..12ceadaa7270a --- /dev/null +++ b/RecoTracker/GeometryESProducer/plugins/TrackerMTDRecoGeometryESProducer.cc @@ -0,0 +1,70 @@ +#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" +#include "RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h" +#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "Geometry/Records/interface/TrackerTopologyRcd.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" +#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" +#include "Geometry/Records/interface/MTDTopologyRcd.h" +#include "Geometry/Records/interface/MTDDigiGeometryRecord.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include +#include + +class TrackerMTDRecoGeometryESProducer : public edm::ESProducer { +public: + TrackerMTDRecoGeometryESProducer(const edm::ParameterSet &p); + + std::unique_ptr produce(const TrackerRecoGeometryRecord &); + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + +private: + edm::ESGetToken geomToken_; + edm::ESGetToken tTopToken_; + edm::ESGetToken mtdgeomToken_; + edm::ESGetToken mtdTopToken_; + bool usePhase2Stacks_; +}; + +using namespace edm; + +TrackerMTDRecoGeometryESProducer::TrackerMTDRecoGeometryESProducer(const edm::ParameterSet &p) + : usePhase2Stacks_(p.getParameter("usePhase2Stacks")) { + auto c = setWhatProduced(this); + + tTopToken_ = c.consumes(); + geomToken_ = c.consumes(edm::ESInputTag("", p.getUntrackedParameter("trackerGeometryLabel"))); + mtdgeomToken_ = c.consumes(); + mtdTopToken_ = c.consumes(); +} + +std::unique_ptr TrackerMTDRecoGeometryESProducer::produce( + const TrackerRecoGeometryRecord &iRecord) { + TrackerGeometry const &tG = iRecord.get(geomToken_); + MTDGeometry const &mG = iRecord.get(mtdgeomToken_); + + GeometricSearchTrackerBuilder builder; + return std::unique_ptr( + builder.build(tG.trackerDet(), &tG, &iRecord.get(tTopToken_), &mG, &iRecord.get(mtdTopToken_), usePhase2Stacks_)); +} + +void TrackerMTDRecoGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { + edm::ParameterSetDescription desc; + + desc.add("usePhase2Stacks", false); + desc.addUntracked("trackerGeometryLabel", ""); + descriptions.addDefault(desc); +} + +DEFINE_FWK_EVENTSETUP_MODULE(TrackerMTDRecoGeometryESProducer); diff --git a/RecoTracker/GeometryESProducer/python/TrackerMTDRecoGeometryESProducer_cfi.py b/RecoTracker/GeometryESProducer/python/TrackerMTDRecoGeometryESProducer_cfi.py new file mode 100644 index 0000000000000..2d8709b2618ae --- /dev/null +++ b/RecoTracker/GeometryESProducer/python/TrackerMTDRecoGeometryESProducer_cfi.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +TrackerRecoGeometryESProducer = cms.ESProducer("TrackerMTDRecoGeometryESProducer", + usePhase2Stacks = cms.bool(False) +) + +from Configuration.ProcessModifiers.vectorHits_cff import vectorHits +vectorHits.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True) diff --git a/RecoTracker/MkFit/plugins/MkFitOutputConverter.cc b/RecoTracker/MkFit/plugins/MkFitOutputConverter.cc index 87ac3e4023677..b21bc7c35b8b0 100644 --- a/RecoTracker/MkFit/plugins/MkFitOutputConverter.cc +++ b/RecoTracker/MkFit/plugins/MkFitOutputConverter.cc @@ -190,7 +190,8 @@ std::vector MkFitOutputConverter::createDetLayers(const mkfit:: const int subdet, const int layer, const int isStereo, const DetId& detId, const DetLayer* lay) { const int index = lnc.convertLayerNumber(subdet, layer, false, isStereo, isPlusSide(detId)); if (index < 0 or static_cast(index) >= dets.size()) { - throw cms::Exception("LogicError") << "Invalid mkFit layer index " << index << " for DetId " << detId + throw cms::Exception("LogicError") << "Invalid mkFit layer index " << index << " for det rawId " << detId.rawId() + << " " << " subdet " << subdet << " layer " << layer << " isStereo " << isStereo; } dets[index] = lay; diff --git a/RecoTracker/Record/interface/TrackerRecoGeometryRecord.h b/RecoTracker/Record/interface/TrackerRecoGeometryRecord.h index 89d99257f6683..7c7f764c34e41 100644 --- a/RecoTracker/Record/interface/TrackerRecoGeometryRecord.h +++ b/RecoTracker/Record/interface/TrackerRecoGeometryRecord.h @@ -5,11 +5,18 @@ #include "FWCore/Framework/interface/DependentRecordImplementation.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/Records/interface/TrackerTopologyRcd.h" +#include "Geometry/Records/interface/MTDGeometryRecord.h" +#include "Geometry/Records/interface/MTDDigiGeometryRecord.h" +#include "Geometry/Records/interface/MTDTopologyRcd.h" #include "FWCore/Utilities/interface/mplVector.h" -class TrackerRecoGeometryRecord : public edm::eventsetup::DependentRecordImplementation< - TrackerRecoGeometryRecord, - edm::mpl::Vector > {}; +class TrackerRecoGeometryRecord + : public edm::eventsetup::DependentRecordImplementation > {}; #endif diff --git a/RecoTracker/TkDetLayers/BuildFile.xml b/RecoTracker/TkDetLayers/BuildFile.xml index ac0c879187f94..daee53060a497 100644 --- a/RecoTracker/TkDetLayers/BuildFile.xml +++ b/RecoTracker/TkDetLayers/BuildFile.xml @@ -8,4 +8,5 @@ + diff --git a/RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h b/RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h index 1f50c1c9dd766..53d41ae3b18f2 100644 --- a/RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h +++ b/RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h @@ -4,6 +4,7 @@ #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h" #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h" #include "TrackingTools/DetLayers/interface/DetLayerGeometry.h" +#include "RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h" class TrackerTopology; @@ -26,6 +27,12 @@ class GeometricSearchTracker : public DetLayerGeometry { ~GeometricSearchTracker() override __attribute__((cold)); + void addDetLayerGeometry(); + + void addMTDLayers(const std::vector& btl, + const std::vector& negEtl, + const std::vector& posEtl); + std::vector const& allLayers() const { return theAllLayers; } std::vector const& barrelLayers() const { return theBarrelLayers; } @@ -52,6 +59,9 @@ class GeometricSearchTracker : public DetLayerGeometry { /// obsolete method. Use idToLayer() instead. const DetLayer* detLayer(const DetId& id) const { return idToLayer(id); }; + //Need to make this pointer public so the tracker builder can build the MTD + MTDDetLayerGeometry* mtdDetLayerGeometry; + private: std::vector theAllLayers; std::vector theBarrelLayers; @@ -70,6 +80,12 @@ class GeometricSearchTracker : public DetLayerGeometry { std::vector thePosTidLayers; std::vector thePosTecLayers; + //MTD stuff + std::vector theBTLLayers; + std::vector theETLLayers; + std::vector theNegETLLayers; + std::vector thePosETLLayers; + const TrackerTopology* theTrkTopo; }; diff --git a/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h b/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h index 893f7fdf1b2b9..19c5077180d77 100644 --- a/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h +++ b/RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h @@ -6,6 +6,7 @@ #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" class TrackerTopology; +class MTDTopology; /** GeometricSearchTrackerBuilder implementation * @@ -20,6 +21,14 @@ class GeometricSearchTrackerBuilder { const TrackerGeometry* theGeomDetGeometry, const TrackerTopology* tTopo, const bool usePhase2Stacks = false) __attribute__((cold)); + + //This constructor builds also the MTD geometry + GeometricSearchTracker* build(const GeometricDet* theGeometricTracker, + const TrackerGeometry* theGeomDetGeometry, + const TrackerTopology* tTopo, + const MTDGeometry* mtd, + const MTDTopology* mTopo, + const bool usePhase2Stacks = false) __attribute__((cold)); }; #endif diff --git a/RecoTracker/TkDetLayers/src/GeometricSearchTracker.cc b/RecoTracker/TkDetLayers/src/GeometricSearchTracker.cc index ff4a370995734..49af2946cc83d 100644 --- a/RecoTracker/TkDetLayers/src/GeometricSearchTracker.cc +++ b/RecoTracker/TkDetLayers/src/GeometricSearchTracker.cc @@ -78,46 +78,101 @@ GeometricSearchTracker::~GeometricSearchTracker() { #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" const DetLayer* GeometricSearchTracker::idToLayer(const DetId& id) const { - switch (id.subdetId()) { - case StripSubdetector::TIB: - return theTibLayers[theTrkTopo->tibLayer(id) - 1]; - break; - - case StripSubdetector::TOB: - return theTobLayers[theTrkTopo->tobLayer(id) - 1]; - break; - - case StripSubdetector::TID: - if (theTrkTopo->tidSide(id) == 1) { - return theNegTidLayers[theTrkTopo->tidWheel(id) - 1]; - } else if (theTrkTopo->tidSide(id) == 2) { - return thePosTidLayers[theTrkTopo->tidWheel(id) - 1]; - } - break; - - case StripSubdetector::TEC: - if (theTrkTopo->tecSide(id) == 1) { - return theNegTecLayers[theTrkTopo->tecWheel(id) - 1]; - } else if (theTrkTopo->tecSide(id) == 2) { - return thePosTecLayers[theTrkTopo->tecWheel(id) - 1]; - } - break; - - case PixelSubdetector::PixelBarrel: - return thePixelBarrelLayers[theTrkTopo->pxbLayer(id) - 1]; - break; - - case PixelSubdetector::PixelEndcap: - if (theTrkTopo->pxfSide(id) == 1) { - return theNegPixelForwardLayers[theTrkTopo->pxfDisk(id) - 1]; - } else if (theTrkTopo->pxfSide(id) == 2) { - return thePosPixelForwardLayers[theTrkTopo->pxfDisk(id) - 1]; - } - break; - - default: - edm::LogError("TkDetLayers") << "ERROR:layer not found!"; - // throw(something); + //If it's a tracker Det + if (id.det() == DetId::Detector::Tracker) { + switch (id.subdetId()) { + case StripSubdetector::TIB: + return theTibLayers[theTrkTopo->tibLayer(id) - 1]; + break; + + case StripSubdetector::TOB: + return theTobLayers[theTrkTopo->tobLayer(id) - 1]; + break; + + case StripSubdetector::TID: + if (theTrkTopo->tidSide(id) == 1) { + return theNegTidLayers[theTrkTopo->tidWheel(id) - 1]; + } else if (theTrkTopo->tidSide(id) == 2) { + return thePosTidLayers[theTrkTopo->tidWheel(id) - 1]; + } + break; + + case StripSubdetector::TEC: + if (theTrkTopo->tecSide(id) == 1) { + return theNegTecLayers[theTrkTopo->tecWheel(id) - 1]; + } else if (theTrkTopo->tecSide(id) == 2) { + return thePosTecLayers[theTrkTopo->tecWheel(id) - 1]; + } + break; + + case PixelSubdetector::PixelBarrel: + return thePixelBarrelLayers[theTrkTopo->pxbLayer(id) - 1]; + break; + + case PixelSubdetector::PixelEndcap: + if (theTrkTopo->pxfSide(id) == 1) { + return theNegPixelForwardLayers[theTrkTopo->pxfDisk(id) - 1]; + } else if (theTrkTopo->pxfSide(id) == 2) { + return thePosPixelForwardLayers[theTrkTopo->pxfDisk(id) - 1]; + } + break; + + default: + edm::LogError("TkDetLayers") << "ERROR:layer not found!"; + // throw(something); + } + return nullptr; //just to avoid compile warnings + } else if (id.det() == DetId::Forward && id.subdetId() == FastTime) { + //If it's MTD + return mtdDetLayerGeometry->idToLayer(id); } return nullptr; //just to avoid compile warnings } + +void GeometricSearchTracker::addDetLayerGeometry() { mtdDetLayerGeometry = new MTDDetLayerGeometry(); } + +void GeometricSearchTracker::addMTDLayers(const std::vector& btl, + const std::vector& negEtl, + const std::vector& posEtl) { + //Barrel + theBTLLayers.assign(btl.begin(), btl.end()); + theBarrelLayers.insert(theBarrelLayers.end(), theBTLLayers.begin(), theBTLLayers.end()); + //Endcap + theNegETLLayers.assign(negEtl.begin(), negEtl.end()); + thePosETLLayers.assign(posEtl.begin(), posEtl.end()); + theETLLayers.assign(negEtl.begin(), negEtl.end()); + theETLLayers.insert(theETLLayers.end(), posEtl.begin(), posEtl.end()); + theNegForwardLayers.insert(theNegForwardLayers.end(), theNegETLLayers.begin(), theNegETLLayers.end()); + thePosForwardLayers.insert(thePosForwardLayers.end(), thePosETLLayers.begin(), thePosETLLayers.end()); + //Reordering of tracker + MTD layers + theForwardLayers.clear(); + theAllLayers.clear(); + theForwardLayers.assign(theNegForwardLayers.begin(), theNegForwardLayers.end()); + theForwardLayers.insert(theForwardLayers.end(), thePosForwardLayers.begin(), thePosForwardLayers.end()); + theAllLayers.assign(theBarrelLayers.begin(), theBarrelLayers.end()); + theAllLayers.insert(theAllLayers.end(), theForwardLayers.begin(), theForwardLayers.end()); + + // number the layers + int sq = 0; + for (auto l : theAllLayers) + const_cast(*l).setSeqNum(sq++); + + edm::LogInfo("MTDDetLayers") << "------ GeometricSearchTracker+MTD constructed with: ------" + << "\n" + << "n pxlBarLayers: " << this->pixelBarrelLayers().size() << "\n" + << "n tibLayers: " << this->tibLayers().size() << "\n" + << "n tobLayers: " << this->tobLayers().size() << "\n" + << "n negPxlFwdLayers: " << this->negPixelForwardLayers().size() << "\n" + << "n posPxlFwdLayers: " << this->posPixelForwardLayers().size() << "\n" + << "n negTidLayers: " << this->negTidLayers().size() << "\n" + << "n posTidLayers: " << this->posTidLayers().size() << "\n" + << "n negTecLayers: " << this->negTecLayers().size() << "\n" + << "n posTecLayers: " << this->posTecLayers().size() << "\n" + << "n barreLayers: " << this->barrelLayers().size() << "\n" + << "n negforwardLayers: " << this->negForwardLayers().size() << "\n" + << "n posForwardLayers: " << this->posForwardLayers().size() << "\n" + << "n MTDbarrelLayers: " << this->theBTLLayers.size() << "\n" + << "n MTDnegLayers: " << this->theNegETLLayers.size() << "\n" + << "n MTDposLayers: " << this->thePosETLLayers.size() << "\n" + << "\nn Total : " << theAllLayers.size() << std::endl; +} diff --git a/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc b/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc index 51cd455a23717..e37decf07465e 100644 --- a/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc +++ b/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc @@ -14,14 +14,15 @@ #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" #include "DataFormats/Common/interface/Trie.h" using namespace std; -GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* theGeometricTracker, - const TrackerGeometry* theGeomDetGeometry, - const TrackerTopology* tTopo, +GeometricSearchTracker *GeometricSearchTrackerBuilder::build(const GeometricDet *theGeometricTracker, + const TrackerGeometry *theGeomDetGeometry, + const TrackerTopology *tTopo, const bool usePhase2Stacks) { PixelBarrelLayerBuilder aPixelBarrelLayerBuilder; Phase2OTBarrelLayerBuilder aPhase2OTBarrelLayerBuilder; @@ -33,24 +34,24 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* TIDLayerBuilder aTIDLayerBuilder; TECLayerBuilder aTECLayerBuilder; - vector thePxlBarLayers; - vector theTIBLayers; - vector theTOBLayers; - vector theNegPxlFwdLayers; - vector thePosPxlFwdLayers; - vector theNegTIDLayers; - vector thePosTIDLayers; - vector theNegTECLayers; - vector thePosTECLayers; + vector thePxlBarLayers; + vector theTIBLayers; + vector theTOBLayers; + vector theNegPxlFwdLayers; + vector thePosPxlFwdLayers; + vector theNegTIDLayers; + vector thePosTIDLayers; + vector theNegTECLayers; + vector thePosTECLayers; bool useBrothers = !usePhase2Stacks; - vector theGeometricDetLayers = theGeometricTracker->components(); - for (vector::const_iterator it = theGeometricDetLayers.begin(); + vector theGeometricDetLayers = theGeometricTracker->components(); + for (vector::const_iterator it = theGeometricDetLayers.begin(); it != theGeometricDetLayers.end(); it++) { if ((*it)->type() == GeometricDet::PixelBarrel) { - vector thePxlBarGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = thePxlBarGeometricDetLayers.begin(); + vector thePxlBarGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = thePxlBarGeometricDetLayers.begin(); it2 != thePxlBarGeometricDetLayers.end(); it2++) { thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(*it2, theGeomDetGeometry)); @@ -58,8 +59,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::PixelPhase1Barrel) { - vector thePxlBarGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = thePxlBarGeometricDetLayers.begin(); + vector thePxlBarGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = thePxlBarGeometricDetLayers.begin(); it2 != thePxlBarGeometricDetLayers.end(); it2++) { thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(*it2, theGeomDetGeometry)); @@ -67,8 +68,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::PixelPhase2Barrel) { - vector thePxlBarGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = thePxlBarGeometricDetLayers.begin(); + vector thePxlBarGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = thePxlBarGeometricDetLayers.begin(); it2 != thePxlBarGeometricDetLayers.end(); it2++) { thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(*it2, theGeomDetGeometry)); @@ -76,8 +77,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::TIB) { - vector theTIBGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = theTIBGeometricDetLayers.begin(); + vector theTIBGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = theTIBGeometricDetLayers.begin(); it2 != theTIBGeometricDetLayers.end(); it2++) { theTIBLayers.push_back(aTIBLayerBuilder.build(*it2, theGeomDetGeometry)); @@ -85,8 +86,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::TOB) { - vector theTOBGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = theTOBGeometricDetLayers.begin(); + vector theTOBGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = theTOBGeometricDetLayers.begin(); it2 != theTOBGeometricDetLayers.end(); it2++) { theTOBLayers.push_back(aTOBLayerBuilder.build(*it2, theGeomDetGeometry)); @@ -94,9 +95,9 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::OTPhase2Barrel) { - vector theTOBGeometricDetLayers = (*it)->components(); + vector theTOBGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = theTOBGeometricDetLayers.begin(); + for (vector::const_iterator it2 = theTOBGeometricDetLayers.begin(); it2 != theTOBGeometricDetLayers.end(); it2++) { theTOBLayers.push_back(aPhase2OTBarrelLayerBuilder.build(*it2, theGeomDetGeometry, useBrothers)); @@ -104,8 +105,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::PixelEndCap) { - vector thePxlFwdGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = thePxlFwdGeometricDetLayers.begin(); + vector thePxlFwdGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = thePxlFwdGeometricDetLayers.begin(); it2 != thePxlFwdGeometricDetLayers.end(); it2++) { if ((*it2)->positionBounds().z() < 0) @@ -116,8 +117,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::PixelPhase1EndCap) { - vector thePxlFwdGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = thePxlFwdGeometricDetLayers.begin(); + vector thePxlFwdGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = thePxlFwdGeometricDetLayers.begin(); it2 != thePxlFwdGeometricDetLayers.end(); it2++) { if ((*it2)->positionBounds().z() < 0) @@ -128,8 +129,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::PixelPhase2EndCap) { - vector thePxlFwdGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = thePxlFwdGeometricDetLayers.begin(); + vector thePxlFwdGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = thePxlFwdGeometricDetLayers.begin(); it2 != thePxlFwdGeometricDetLayers.end(); it2++) { //FIXME: this is just to keep the compatibility with the PixelPhase1 extension layout @@ -154,8 +155,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::TID) { - vector theTIDGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = theTIDGeometricDetLayers.begin(); + vector theTIDGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = theTIDGeometricDetLayers.begin(); it2 != theTIDGeometricDetLayers.end(); it2++) { if ((*it2)->positionBounds().z() < 0) @@ -166,10 +167,10 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::OTPhase2EndCap) { - vector theTIDGeometricDetLayers = (*it)->components(); + vector theTIDGeometricDetLayers = (*it)->components(); bool useBrothers = !usePhase2Stacks; - for (vector::const_iterator it2 = theTIDGeometricDetLayers.begin(); + for (vector::const_iterator it2 = theTIDGeometricDetLayers.begin(); it2 != theTIDGeometricDetLayers.end(); it2++) { if ((*it2)->positionBounds().z() < 0) @@ -180,8 +181,8 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* } if ((*it)->type() == GeometricDet::TEC) { - vector theTECGeometricDetLayers = (*it)->components(); - for (vector::const_iterator it2 = theTECGeometricDetLayers.begin(); + vector theTECGeometricDetLayers = (*it)->components(); + for (vector::const_iterator it2 = theTECGeometricDetLayers.begin(); it2 != theTECGeometricDetLayers.end(); it2++) { if ((*it2)->positionBounds().z() < 0) @@ -203,3 +204,42 @@ GeometricSearchTracker* GeometricSearchTrackerBuilder::build(const GeometricDet* thePosTECLayers, tTopo); } + +GeometricSearchTracker *GeometricSearchTrackerBuilder::build(const GeometricDet *theGeometricTracker, + const TrackerGeometry *theGeomDetGeometry, + const TrackerTopology *tTopo, + const MTDGeometry *mtd, + const MTDTopology *mTopo, + const bool usePhase2Stacks) { + //Tracker part + GeometricSearchTracker *theSearchTrack = this->build(theGeometricTracker, theGeomDetGeometry, tTopo, usePhase2Stacks); + + theSearchTrack->addDetLayerGeometry(); + theSearchTrack->mtdDetLayerGeometry->buildLayers(mtd, mTopo); + theSearchTrack->mtdDetLayerGeometry->sortLayers(); + + std::vector barrel; + for (auto &&e : theSearchTrack->mtdDetLayerGeometry->allBarrelLayers()) { + auto p = dynamic_cast(e); + if (p) { + barrel.push_back(p); + } + } + std::vector backward; + for (auto &&e : theSearchTrack->mtdDetLayerGeometry->allBackwardLayers()) { + auto p = dynamic_cast(e); + if (p) { + backward.push_back(p); + } + } + std::vector forward; + for (auto &&e : theSearchTrack->mtdDetLayerGeometry->allForwardLayers()) { + auto p = dynamic_cast(e); + if (p) { + forward.push_back(p); + } + } + //Include the MTD layers in the TrackerSearchGeometry + theSearchTrack->addMTDLayers(barrel, backward, forward); + return theSearchTrack; +} diff --git a/RecoTracker/TkNavigation/plugins/SimpleBarrelNavigableLayer.cc b/RecoTracker/TkNavigation/plugins/SimpleBarrelNavigableLayer.cc index 6824dab41fd31..c4f2dea02c8e6 100644 --- a/RecoTracker/TkNavigation/plugins/SimpleBarrelNavigableLayer.cc +++ b/RecoTracker/TkNavigation/plugins/SimpleBarrelNavigableLayer.cc @@ -114,15 +114,13 @@ vector SimpleBarrelNavigableLayer::nextLayers(const FreeTraject bool signZmomentumXORdir = (((momentum.z() > 0) && !(dir == alongMomentum)) || (!(momentum.z() > 0) && (dir == alongMomentum))); - if - LIKELY(dirOppositeXORisInOutTrackBarrel && dirOppositeXORisInOutTrackFWD) { - if (signZmomentumXORdir) { - wellInside(ftsWithoutErrors, dir, theNegOuterLayers, result); - } else { - wellInside(ftsWithoutErrors, dir, thePosOuterLayers, result); - } + if LIKELY (dirOppositeXORisInOutTrackBarrel && dirOppositeXORisInOutTrackFWD) { + if (signZmomentumXORdir) { + wellInside(ftsWithoutErrors, dir, theNegOuterLayers, result); + } else { + wellInside(ftsWithoutErrors, dir, thePosOuterLayers, result); } - else if (!dirOppositeXORisInOutTrackBarrel && !dirOppositeXORisInOutTrackFWD) { + } else if (!dirOppositeXORisInOutTrackBarrel && !dirOppositeXORisInOutTrackFWD) { if (signZmomentumXORdir) { wellInside(ftsWithoutErrors, dir, thePosInnerLayers, result); } else { @@ -152,21 +150,20 @@ vector SimpleBarrelNavigableLayer::nextLayers(const FreeTraject LogDebug("SimpleBarrelNavigableLayer") << "goingIntoTheBarrel: " << goingIntoTheBarrel; - if - UNLIKELY(theSelfSearch && result.empty()) { - if (!goingIntoTheBarrel) { - LogDebug("SimpleBarrelNavigableLayer") - << " state is not going toward the center of the barrel. not adding self search."; - } else { - const BarrelDetLayer* bl = reinterpret_cast(detLayer()); - unsigned int before = result.size(); - LogDebug("SimpleBarrelNavigableLayer") << " I am trying to added myself as a next layer."; - wellInside(ftsWithoutErrors, dir, bl, result); - unsigned int after = result.size(); - if (before != after) - LogDebug("SimpleBarrelNavigableLayer") << " I have added myself as a next layer."; - } + if UNLIKELY (theSelfSearch && result.empty()) { + if (!goingIntoTheBarrel) { + LogDebug("SimpleBarrelNavigableLayer") + << " state is not going toward the center of the barrel. not adding self search."; + } else { + const BarrelDetLayer* bl = reinterpret_cast(detLayer()); + unsigned int before = result.size(); + LogDebug("SimpleBarrelNavigableLayer") << " I am trying to added myself as a next layer."; + wellInside(ftsWithoutErrors, dir, bl, result); + unsigned int after = result.size(); + if (before != after) + LogDebug("SimpleBarrelNavigableLayer") << " I have added myself as a next layer."; } + } return result; } diff --git a/RecoTracker/TkNavigation/plugins/SimpleNavigationSchool.cc b/RecoTracker/TkNavigation/plugins/SimpleNavigationSchool.cc index 1ff9051dfcd7b..6d80ce4572902 100644 --- a/RecoTracker/TkNavigation/plugins/SimpleNavigationSchool.cc +++ b/RecoTracker/TkNavigation/plugins/SimpleNavigationSchool.cc @@ -82,9 +82,10 @@ void SimpleNavigationSchool::linkBarrelLayers(SymmetricLayerFinder& symFinder) { FDLC leftFL; FDLC rightFL; - // always add next barrel layer first - if (i + 1 != theBarrelLayers.end()) + //always add next barrel layer first + if (i + 1 != theBarrelLayers.end()) { reachableBL.push_back(*(i + 1)); + } // Add closest reachable forward layer (except for last BarrelLayer) if (i != theBarrelLayers.end() - 1) { diff --git a/RecoTracker/TkNavigation/test/NavigationSchoolAnalyzer.cc b/RecoTracker/TkNavigation/test/NavigationSchoolAnalyzer.cc index af3f1ecde9258..fc7f1e8536475 100644 --- a/RecoTracker/TkNavigation/test/NavigationSchoolAnalyzer.cc +++ b/RecoTracker/TkNavigation/test/NavigationSchoolAnalyzer.cc @@ -37,6 +37,9 @@ #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/MuonDetId/interface/DTChamberId.h" +#include +#include + #include "TrackingTools/DetLayers/interface/NavigationSchool.h" #include "RecoTracker/Record/interface/NavigationSchoolRecord.h" @@ -75,6 +78,12 @@ void NavigationSchoolAnalyzer::print(std::ostream& os, const DetLayer* dl) { if (GeomDetEnumerators::isTracker(dl->subDetector())) { LorW = tTopo->layer(tag->geographicalId()); side = tTopo->side(tag->geographicalId()); + } else if (dl->subDetector() == GeomDetEnumerators::TimingEndcap) { + ETLDetId id(dl->basicComponents().front()->geographicalId().rawId()); + LorW = id.nDisc(); + //The MTD side returns 0 for the negative side and 1 for the positive side + //In order to be comp + side = id.mtdSide() + 1; } else { switch (dl->subDetector()) { case GeomDetEnumerators::DT: diff --git a/RecoTracker/TkNavigation/test/NavigationSchoolAnalyzer_cfg.py b/RecoTracker/TkNavigation/test/NavigationSchoolAnalyzer_cfg.py index dd7c78377a1ed..89b73e37f9efc 100644 --- a/RecoTracker/TkNavigation/test/NavigationSchoolAnalyzer_cfg.py +++ b/RecoTracker/TkNavigation/test/NavigationSchoolAnalyzer_cfg.py @@ -6,8 +6,7 @@ # process.load("Configuration.StandardSequences.Geometry_cff") #process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -#process.load('Configuration.Geometry.GeometryExtended2023D1Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2023D4Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D76Reco_cff') process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag @@ -23,6 +22,13 @@ # indentation = cms.untracked.string('$$') #) + +#This has to be modified in order to read the tracker + MTD structure +process.TrackerRecoGeometryESProducer = cms.ESProducer("TrackerMTDRecoGeometryESProducer", + usePhase2Stacks = cms.bool(False) +) + + process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) ) diff --git a/TrackingTools/RecoGeometry/src/GlobalDetLayerGeometry.cc b/TrackingTools/RecoGeometry/src/GlobalDetLayerGeometry.cc index 320c57543a8f9..d12c61b200af9 100644 --- a/TrackingTools/RecoGeometry/src/GlobalDetLayerGeometry.cc +++ b/TrackingTools/RecoGeometry/src/GlobalDetLayerGeometry.cc @@ -12,7 +12,8 @@ const DetLayer* GlobalDetLayerGeometry::idToLayer(const DetId& detId) const { else { throw cms::Exception("DetLayers") << "Error: called GlobalDetLayerGeometry::idToLayer() for a detId which is neither Tracker nor Muon " - << (mtd_ == nullptr ? "" : "nor MTD ") << detId; + << (mtd_ == nullptr ? "" : "nor MTD ") << " det rawId " << detId.rawId() << " det " << detId.det() + << " subdetId " << detId.subdetId(); } }