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

Remove CMS deprecation warnings from RecoBTag/PerformanceDB #36576

Merged
merged 2 commits into from Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,7 +22,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"

Expand All @@ -47,18 +47,16 @@
// class declaration
//

class BTagPerformaceRootProducerFromSQLITE : public edm::EDAnalyzer {
class BTagPerformaceRootProducerFromSQLITE : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit BTagPerformaceRootProducerFromSQLITE(const edm::ParameterSet&);
~BTagPerformaceRootProducerFromSQLITE() override;

private:
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override;
void endJob() override;

// ----------member data ---------------------------
std::vector<std::string> names_;
std::vector<edm::ESGetToken<BtagPerformance, BTagPerformanceRecord>> tokens_;
edm::ESWatcher<BTagPerformanceRecord> recWatcher_;
std::unique_ptr<fwlite::RecordWriter> writer_;
edm::IOVSyncValue lastValue_;
Expand All @@ -76,9 +74,13 @@ class BTagPerformaceRootProducerFromSQLITE : public edm::EDAnalyzer {
// constructors and destructor
//
BTagPerformaceRootProducerFromSQLITE::BTagPerformaceRootProducerFromSQLITE(const edm::ParameterSet& iConfig)
: names_(iConfig.getParameter<std::vector<std::string> >("names")) {}

BTagPerformaceRootProducerFromSQLITE::~BTagPerformaceRootProducerFromSQLITE() {}
: names_(iConfig.getParameter<std::vector<std::string>>("names")) {
usesResource(TFileService::kSharedResource);
tokens_.reserve(names_.size());
for (auto const& n : names_) {
tokens_.push_back(esConsumes<BtagPerformance, BTagPerformanceRecord>(edm::ESInputTag("", n)));
}
}

//
// member functions
Expand All @@ -98,29 +100,15 @@ void BTagPerformaceRootProducerFromSQLITE::analyze(const edm::Event& iEvent, con
lastValue_ = r.validityInterval().last();

for (size_t i = 0; i < names_.size(); i++) {
edm::ESHandle<BtagPerformance> perfH;
edm::LogInfo("BTagPerformaceRootProducerFromSQLITE") << " Studying performance with label " << names_.at(i);
r.get(names_.at(i), perfH);
const BtagPerformance& perf = *(perfH.product());
edm::LogInfo("BTagPerformaceRootProducerFromSQLITE") << " Studying performance with label " << names_[i];
const BtagPerformance& perf = r.get(tokens_[i]);

writer_->update(&(perf.payload()), typeid(PerformancePayload), names_.at(i).c_str());
writer_->update(&(perf.workingPoint()), typeid(PerformanceWorkingPoint), names_.at(i).c_str());
writer_->update(&(perf.payload()), typeid(PerformancePayload), names_[i].c_str());
writer_->update(&(perf.workingPoint()), typeid(PerformanceWorkingPoint), names_[i].c_str());
}
writer_->fill(edm::ESRecordAuxiliary(r.validityInterval().first().eventID(), r.validityInterval().first().time()));
}
}

// ------------ method called once each job just before starting event loop ------------
void BTagPerformaceRootProducerFromSQLITE::beginJob() {}

// ------------ method called once each job just after ending the event loop ------------
void BTagPerformaceRootProducerFromSQLITE::endJob() {
/*if(writer_.get()) {
writer_->fill(edm::ESRecordAuxiliary(lastValue_.eventID(),
lastValue_.time()));
writer_->write();
} */
}

//define this as a plug-in
DEFINE_FWK_MODULE(BTagPerformaceRootProducerFromSQLITE);
42 changes: 26 additions & 16 deletions RecoBTag/PerformanceDB/plugins/BtagPerformanceESProducer.cc
@@ -1,5 +1,4 @@
#include "RecoBTag/PerformanceDB/plugins/BtagPerformanceESProducer.h"

#include "RecoBTag/PerformanceDB/interface/BtagPerformance.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
Expand All @@ -9,30 +8,41 @@
#include <memory>
#include <string>

#include "RecoBTag/Records/interface/BTagPerformanceRecord.h"

#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include <memory>

using namespace edm;

class BtagPerformanceESProducer : public edm::ESProducer {
public:
BtagPerformanceESProducer(const edm::ParameterSet& p);
~BtagPerformanceESProducer() override;
std::unique_ptr<BtagPerformance> produce(const BTagPerformanceRecord&);

private:
edm::ESGetToken<PerformancePayload, PerformancePayloadRecord> payloadToken_;
edm::ESGetToken<PerformanceWorkingPoint, PerformanceWPRecord> workingPointToken_;
};

BtagPerformanceESProducer::BtagPerformanceESProducer(const edm::ParameterSet& p) {
std::string myname = p.getParameter<std::string>("ComponentName");
mypl = p.getParameter<std::string>("PayloadName");
mywp = p.getParameter<std::string>("WorkingPointName");
auto mypl = p.getParameter<std::string>("PayloadName");
auto mywp = p.getParameter<std::string>("WorkingPointName");

pset_ = p;
setWhatProduced(this, myname);
auto c = setWhatProduced(this, myname);
payloadToken_ = c.consumes(edm::ESInputTag("", mypl));
workingPointToken_ = c.consumes(edm::ESInputTag("", mywp));
}

BtagPerformanceESProducer::~BtagPerformanceESProducer() {}

std::unique_ptr<BtagPerformance> BtagPerformanceESProducer::produce(const BTagPerformanceRecord& iRecord) {
ESHandle<PerformancePayload> pl;
//ESHandle<PhysicsPerformancePayload> pl;
ESHandle<PerformanceWorkingPoint> wp;
iRecord.getRecord<PerformancePayloadRecord>().get(mypl, pl);

iRecord.getRecord<PerformanceWPRecord>().get(mywp, wp);

// BtagWorkingPoint wp;

return std::make_unique<BtagPerformance>(*((pl.product())), *((wp.product())));
auto const& pl = iRecord.get(payloadToken_);
auto const& wp = iRecord.get(workingPointToken_);
return std::make_unique<BtagPerformance>(pl, wp);
}

DEFINE_FWK_EVENTSETUP_MODULE(BtagPerformanceESProducer);
23 changes: 0 additions & 23 deletions RecoBTag/PerformanceDB/plugins/BtagPerformanceESProducer.h

This file was deleted.

1 change: 1 addition & 0 deletions RecoBTag/PerformanceDB/plugins/BuildFile.xml
Expand Up @@ -2,6 +2,7 @@
</export>
<library name="RecoBTagPerformanceDBplugins" file="*.cc">
<use name="CondFormats/PhysicsToolsObjects"/>
<use name="CommonTools/UtilAlgos"/>
<use name="RecoBTag/Records"/>
<use name="RecoBTag/PerformanceDB"/>
<use name="FWCore/Framework"/>
Expand Down
Expand Up @@ -3,7 +3,7 @@
#include <fstream>
#include <iostream>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -13,11 +13,11 @@

#include "CondFormats/PhysicsToolsObjects/interface/PerformanceWorkingPoint.h"

class PhysicsPerformanceDBWriterFromFile_WPandPayload : public edm::EDAnalyzer {
class PhysicsPerformanceDBWriterFromFile_WPandPayload : public edm::global::EDAnalyzer<> {
public:
PhysicsPerformanceDBWriterFromFile_WPandPayload(const edm::ParameterSet&);
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override {}
void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const override {}
void endJob() override {}
~PhysicsPerformanceDBWriterFromFile_WPandPayload() override {}

Expand Down
Expand Up @@ -3,7 +3,7 @@
#include <fstream>
#include <iostream>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -13,11 +13,11 @@

#include "CondFormats/PhysicsToolsObjects/interface/PerformanceWorkingPoint.h"

class PhysicsPerformanceDBWriterFromFile_WPandPayload_IOV : public edm::EDAnalyzer {
class PhysicsPerformanceDBWriterFromFile_WPandPayload_IOV : public edm::global::EDAnalyzer<> {
public:
PhysicsPerformanceDBWriterFromFile_WPandPayload_IOV(const edm::ParameterSet&);
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override {}
void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const override {}
void endJob() override {}
~PhysicsPerformanceDBWriterFromFile_WPandPayload_IOV() override {}

Expand Down
Expand Up @@ -3,7 +3,7 @@
#include <fstream>
#include <iostream>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -12,11 +12,11 @@
#include "CondFormats/PhysicsToolsObjects/interface/PerformancePayloadFromBinnedTFormula.h"
#include "CondFormats/PhysicsToolsObjects/interface/PerformanceWorkingPoint.h"

class PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL : public edm::EDAnalyzer {
class PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL : public edm::global::EDAnalyzer<> {
public:
PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL(const edm::ParameterSet&);
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override {}
void analyze(edm::StreamID, const edm::Event&, const edm::EventSetup&) const override {}
void endJob() override {}
~PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL() override {}

Expand Down
33 changes: 12 additions & 21 deletions RecoBTag/PerformanceDB/test/DumpBtagTable.cc
Expand Up @@ -25,7 +25,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand All @@ -42,32 +42,31 @@

using namespace std;

class DumpBtagTable : public edm::EDAnalyzer {
class DumpBtagTable : public edm::one::EDAnalyzer<> {
public:
explicit DumpBtagTable(const edm::ParameterSet&);
~DumpBtagTable();

private:
string name;
vector<string> measureName;
vector<string> measureType;
virtual void beginJob();
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void endJob();
vector<edm::ESGetToken<BtagPerformance, BTagPerformanceRecord>> measureToken;
void analyze(const edm::Event&, const edm::EventSetup&) final;

// ----------member data ---------------------------
};

DumpBtagTable::DumpBtagTable(const edm::ParameterSet& iConfig)

{
measureName = iConfig.getParameter<vector<string> >("measureName");
measureType = iConfig.getParameter<vector<string> >("measureType");
}
measureName = iConfig.getParameter<vector<string>>("measureName");
measureType = iConfig.getParameter<vector<string>>("measureType");

measureToken.reserve(measureName.size());

DumpBtagTable::~DumpBtagTable() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
for (auto const& n : measureName) {
measureToken.push_back(esConsumes<BtagPerformance, BTagPerformanceRecord>(edm::ESInputTag("", n)));
}
}

//
Expand Down Expand Up @@ -99,7 +98,6 @@ void DumpBtagTable::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe
measureMap["MUFAKE"] = PerformanceResult::MUFAKE;
measureMap["MUEFAKE"] = PerformanceResult::MUEFAKE;

edm::ESHandle<BtagPerformance> perfH;
if (measureName.size() != measureType.size()) {
std::cout << "measureName, measureType size mismatch!" << std::endl;
exit(-1);
Expand All @@ -109,8 +107,7 @@ void DumpBtagTable::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe
std::cout << "# Dump table: " << measureName[iMeasure] << " of type " << measureType[iMeasure] << std::endl;

//Setup our measurement
iSetup.get<BTagPerformanceRecord>().get(measureName[iMeasure], perfH);
const BtagPerformance& perf = *(perfH.product());
const BtagPerformance& perf = iSetup.getData(measureToken[iMeasure]);

//Working point
std::cout << "# Working point: " << perf.workingPoint().cut() << std::endl;
Expand Down Expand Up @@ -173,11 +170,5 @@ void DumpBtagTable::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe
}
}

// ------------ method called once each job just before starting event loop ------------
void DumpBtagTable::beginJob() {}

// ------------ method called once each job just after ending the event loop ------------
void DumpBtagTable::endJob() {}

//define this as a plug-in
DEFINE_FWK_MODULE(DumpBtagTable);