From 7b46498a9742af0875d093eefa655c37a8636ca1 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 14 Dec 2020 12:59:29 -0600 Subject: [PATCH] Use esConsumes with SiPixelStatusProducer - regenerate SiPixelTopoFinder on each Run boundary rather than try to allow reuse to simplify code and decouple from use of SerialTaskQueue. --- .../plugins/SiPixelStatusProducer.cc | 21 ++++- .../plugins/SiPixelStatusProducer.h | 79 +++---------------- 2 files changed, 31 insertions(+), 69 deletions(-) diff --git a/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.cc b/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.cc index aafbe44ee1750..812ced2a3b4a2 100644 --- a/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.cc +++ b/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.cc @@ -27,7 +27,13 @@ // Header file #include "CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h" -SiPixelStatusProducer::SiPixelStatusProducer(const edm::ParameterSet& iConfig, SiPixelTopoCache const*) { +SiPixelStatusProducer::SiPixelStatusProducer(const edm::ParameterSet& iConfig, SiPixelStatusCache const* iCache) { + //NOTE: Token for all stream replicas are identical and constructors for the replicas are called + // sequentially so there is no race condition. + iCache->trackerGeometryToken_ = esConsumes(); + iCache->trackerTopologyToken_ = esConsumes(); + iCache->siPixelFedCablingMapToken_ = esConsumes(); + /* badPixelFEDChannelCollections */ std::vector badPixelFEDChannelCollectionLabels = iConfig.getParameter("SiPixelStatusProducerParameters") @@ -50,6 +56,19 @@ SiPixelStatusProducer::~SiPixelStatusProducer() {} //-------------------------------------------------------------------------------------------------- +std::shared_ptr SiPixelStatusProducer::globalBeginRun(edm::Run const& iRun, + edm::EventSetup const& iSetup, + GlobalCache const* iCache) { + const TrackerGeometry* trackerGeometry = &iSetup.getData(iCache->trackerGeometryToken_); + const TrackerTopology* trackerTopology = &iSetup.getData(iCache->trackerTopologyToken_); + const SiPixelFedCablingMap* cablingMap = &iSetup.getData(iCache->siPixelFedCablingMapToken_); + + auto returnValue = std::make_shared(); + + returnValue->init(trackerGeometry, trackerTopology, cablingMap); + return returnValue; +} + void SiPixelStatusProducer::beginRun(edm::Run const&, edm::EventSetup const&) { /*Is it good to pass the objects stored in runCache to set class private members values * or just call runCahche every time in the calss function?*/ diff --git a/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h b/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h index cb8b3b492e478..54d0eae8c2127 100644 --- a/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h +++ b/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h @@ -50,73 +50,25 @@ #include "CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h" /* Cache to pertain SiPixelTopoFinder */ -class SiPixelTopoCache { +class SiPixelStatusCache { public: - SiPixelTopoCache(edm::ParameterSet const& iPSet){}; - - std::shared_ptr getSiPixelTopoFinder(edm::EventSetup const& iSetup) const { - std::shared_ptr returnValue; - - m_queue.pushAndWait([&]() { - if (!this->siPixelFedCablingMapWatcher_.check(iSetup) && !this->trackerDIGIGeoWatcher_.check(iSetup) && - !this->trackerTopoWatcher_.check(iSetup)) { - /*the condition hasn't changed so we can just use our old value*/ - returnValue = m_mostRecentSiPixelTopoFinder_; - } else { - edm::ESHandle tkGeoHandle; - iSetup.get().get(tkGeoHandle); - const TrackerGeometry* trackerGeometry = tkGeoHandle.product(); - - edm::ESHandle tkTopoHandle; - iSetup.get().get(tkTopoHandle); - const TrackerTopology* trackerTopology = tkTopoHandle.product(); - - edm::ESHandle cMapHandle; - iSetup.get().get(cMapHandle); - const SiPixelFedCablingMap* cablingMap = cMapHandle.product(); - - /*the condition has changed so we need to update*/ - //const TrackerGeometry* trackerGeometry = &iSetup.getData(trackerGeometryToken); - //const TrackerTopology* trackerTopology = &iSetup.getData(trackerTopologyToken); - //const SiPixelFedCablingMap* cablingMap = &iSetup.getData(siPixelFedCablingMapToken); - - returnValue = m_holder.makeOrGet([]() { return new SiPixelTopoFinder(); }); - returnValue->init(trackerGeometry, trackerTopology, cablingMap); - - m_mostRecentSiPixelTopoFinder_ = returnValue; - } - }); //m_queue - - return returnValue; - } - -private: - mutable edm::ReusableObjectHolder m_holder; - mutable edm::SerialTaskQueue m_queue; - - /* Condition watchers */ - /* CablingMaps */ - mutable edm::ESWatcher siPixelFedCablingMapWatcher_; - /* TrackerDIGIGeo */ - mutable edm::ESWatcher trackerDIGIGeoWatcher_; - /* TrackerTopology */ - mutable edm::ESWatcher trackerTopoWatcher_; - - /* SiPixelTopoFinder */ - mutable std::shared_ptr m_mostRecentSiPixelTopoFinder_; + //NOTE: these are only changes in the constructor call + mutable edm::ESGetToken trackerGeometryToken_; + mutable edm::ESGetToken trackerTopologyToken_; + mutable edm::ESGetToken siPixelFedCablingMapToken_; }; /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/ class SiPixelStatusProducer : - public edm::stream::EDProducer, + public edm::stream::EDProducer, edm::RunCache, edm::LuminosityBlockSummaryCache>, edm::EndLuminosityBlockProducer, edm::Accumulator> { public: - SiPixelStatusProducer(edm::ParameterSet const& iPSet, SiPixelTopoCache const*); + SiPixelStatusProducer(edm::ParameterSet const& iPSet, SiPixelStatusCache const*); ~SiPixelStatusProducer() override; /* module description */ @@ -150,23 +102,20 @@ class SiPixelStatusProducer : /* For global or runCache */ - static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& iPSet) { + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& iPSet) { edm::LogInfo("SiPixelStatusProducer") << "Init global Cache " << std::endl; - return std::make_unique(iPSet); + return std::make_unique(); } static std::shared_ptr globalBeginRun(edm::Run const& iRun, edm::EventSetup const& iSetup, - GlobalCache const* iCache) { - edm::LogInfo("SiPixelStatusProducer") << "Global beginRun " << std::endl; - return iCache->getSiPixelTopoFinder(iSetup); - } + GlobalCache const* iCache); static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext) { /* Do nothing */ } - static void globalEndJob(SiPixelTopoCache const*) { /* Do nothing */ + static void globalEndJob(SiPixelStatusCache const*) { /* Do nothing */ } static std::shared_ptr> globalBeginLuminosityBlockSummary( @@ -228,12 +177,6 @@ class SiPixelStatusProducer : edm::EDGetTokenT> fSiPixelClusterToken_; std::vector> theBadPixelFEDChannelsTokens_; - /* - edm::ESGetToken trackerGeometryToken_; - edm::ESGetToken trackerTopologyToken_; - edm::ESGetToken siPixelFedCablingMapToken_; - */ - /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/ /* private data member, one instance per stream */