From bf59855fa13c2ef80399039e77ea64bee15be1bb Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Fri, 9 Jul 2021 04:24:12 +0200 Subject: [PATCH 1/2] Migrate MultiTrackSelector to EventSetup consumes --- .../plugins/MultiTrackSelector.cc | 13 ++++++++----- .../plugins/MultiTrackSelector.h | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc b/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc index 8cdece741e801..298438550a569 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc @@ -2,9 +2,8 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Common/interface/ValueMap.h" -#include "CondFormats/DataRecord/interface/GBRWrapperRcd.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/transform.h" #include #include @@ -195,6 +194,12 @@ MultiTrackSelector::MultiTrackSelector(const edm::ParameterSet& cfg) forestLabel_.push_back("MVASelectorIter0"); } } + + if (useForestFromDB_) { + forestToken_ = edm::vector_transform(forestLabel_, [this](auto const& label) { + return esConsumes(edm::ESInputTag("", label)); + }); + } } MultiTrackSelector::~MultiTrackSelector() { @@ -606,9 +611,7 @@ void MultiTrackSelector::processMVA(edm::Event& evt, GBRForest const* forest = forest_[selIndex]; if (useForestFromDB_) { - edm::ESHandle forestHandle; - es.get().get(forestLabel_[selIndex], forestHandle); - forest = forestHandle.product(); + forest = &es.getData(forestToken_[selIndex]); } float gbrVals_[16]; diff --git a/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h b/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h index a4884a3a1b51c..feb80e87a968d 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h +++ b/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h @@ -31,6 +31,7 @@ #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" #include "CondFormats/GBRForest/interface/GBRForest.h" +#include "CondFormats/DataRecord/interface/GBRWrapperRcd.h" class dso_hidden MultiTrackSelector : public edm::stream::EDProducer<> { private: @@ -151,6 +152,7 @@ class dso_hidden MultiTrackSelector : public edm::stream::EDProducer<> { std::vector mvaType_; std::vector forestLabel_; + std::vector> forestToken_; std::vector forest_; bool useForestFromDB_; std::string dbFileName_; From f7400782d2697be236c1db1d599e3e4d882a443e Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Fri, 9 Jul 2021 04:25:46 +0200 Subject: [PATCH 2/2] Code format --- .../FinalTrackSelectors/plugins/MultiTrackSelector.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h b/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h index feb80e87a968d..ff45507aa0927 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h +++ b/RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h @@ -99,16 +99,16 @@ class dso_hidden MultiTrackSelector : public edm::stream::EDProducer<> { /// vertex cuts std::vector vtxNumber_; //StringCutObjectSelector is not const thread safe - std::vector > vertexCut_; + std::vector> vertexCut_; // parameters for adapted optimal cuts on chi2 and primary vertex compatibility - std::vector > res_par_; + std::vector> res_par_; std::vector chi2n_par_; std::vector chi2n_no1Dmod_par_; - std::vector > d0_par1_; - std::vector > dz_par1_; - std::vector > d0_par2_; - std::vector > dz_par2_; + std::vector> d0_par1_; + std::vector> dz_par1_; + std::vector> d0_par2_; + std::vector> dz_par2_; // Boolean indicating if adapted primary vertex compatibility cuts are to be applied. std::vector applyAdaptedPVCuts_;