Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate MultiTrackSelector to EventSetup consumes #34416

Merged
merged 2 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Math/DistFunc.h>
#include <TMath.h>
Expand Down Expand Up @@ -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<GBRForest, GBRWrapperRcd>(edm::ESInputTag("", label));
});
}
}

MultiTrackSelector::~MultiTrackSelector() {
Expand Down Expand Up @@ -606,9 +611,7 @@ void MultiTrackSelector::processMVA(edm::Event& evt,

GBRForest const* forest = forest_[selIndex];
if (useForestFromDB_) {
edm::ESHandle<GBRForest> forestHandle;
es.get<GBRWrapperRcd>().get(forestLabel_[selIndex], forestHandle);
forest = forestHandle.product();
forest = &es.getData(forestToken_[selIndex]);
}

float gbrVals_[16];
Expand Down
14 changes: 8 additions & 6 deletions RecoTracker/FinalTrackSelectors/plugins/MultiTrackSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -98,16 +99,16 @@ class dso_hidden MultiTrackSelector : public edm::stream::EDProducer<> {
/// vertex cuts
std::vector<int32_t> vtxNumber_;
//StringCutObjectSelector is not const thread safe
std::vector<StringCutObjectSelector<reco::Vertex> > vertexCut_;
std::vector<StringCutObjectSelector<reco::Vertex>> vertexCut_;

// parameters for adapted optimal cuts on chi2 and primary vertex compatibility
std::vector<std::vector<double> > res_par_;
std::vector<std::vector<double>> res_par_;
std::vector<double> chi2n_par_;
std::vector<double> chi2n_no1Dmod_par_;
std::vector<std::vector<double> > d0_par1_;
std::vector<std::vector<double> > dz_par1_;
std::vector<std::vector<double> > d0_par2_;
std::vector<std::vector<double> > dz_par2_;
std::vector<std::vector<double>> d0_par1_;
std::vector<std::vector<double>> dz_par1_;
std::vector<std::vector<double>> d0_par2_;
std::vector<std::vector<double>> dz_par2_;
// Boolean indicating if adapted primary vertex compatibility cuts are to be applied.
std::vector<bool> applyAdaptedPVCuts_;

Expand Down Expand Up @@ -151,6 +152,7 @@ class dso_hidden MultiTrackSelector : public edm::stream::EDProducer<> {

std::vector<std::string> mvaType_;
std::vector<std::string> forestLabel_;
std::vector<edm::ESGetToken<GBRForest, GBRWrapperRcd>> forestToken_;
std::vector<GBRForest *> forest_;
bool useForestFromDB_;
std::string dbFileName_;
Expand Down