diff --git a/JetMETCorrections/Modules/plugins/QGLikelihoodDBReader.cc b/JetMETCorrections/Modules/plugins/QGLikelihoodDBReader.cc new file mode 100644 index 0000000000000..038d1453136d4 --- /dev/null +++ b/JetMETCorrections/Modules/plugins/QGLikelihoodDBReader.cc @@ -0,0 +1,64 @@ +#include +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "CondFormats/JetMETObjects/interface/QGLikelihoodObject.h" +#include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h" +#include "CondFormats/DataRecord/interface/QGLikelihoodRcd.h" + +class QGLikelihoodDBReader : public edm::EDAnalyzer{ +public: + explicit QGLikelihoodDBReader(const edm::ParameterSet&); + ~QGLikelihoodDBReader(){}; + +private: + virtual void beginJob() override{}; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override{}; + + std::string mPayloadName; + bool mCreateTextFile,mPrintScreen; +}; + + +QGLikelihoodDBReader::QGLikelihoodDBReader(const edm::ParameterSet& iConfig){ + mPayloadName = iConfig.getUntrackedParameter("payloadName"); + mPrintScreen = iConfig.getUntrackedParameter("printScreen"); + mCreateTextFile = iConfig.getUntrackedParameter("createTextFile"); +} + + +void QGLikelihoodDBReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){ + edm::LogInfo("UserOutput") << "Inspecting QGLikelihood payload with label:" << mPayloadName << std::endl; + edm::ESHandle QGLParamsColl; + QGLikelihoodRcd const& rcdhandle = iSetup.get(); + rcdhandle.get(mPayloadName, QGLParamsColl); + + edm::LogInfo("UserOutput") << "Ranges in which the QGTagger could be applied:" + << " pt: " << QGLParamsColl->qgValidRange.PtMin << " --> " << QGLParamsColl->qgValidRange.PtMax + << ", eta: " << QGLParamsColl->qgValidRange.EtaMin << " --> " << QGLParamsColl->qgValidRange.EtaMax + << ", rho: " << QGLParamsColl->qgValidRange.RhoMin << " --> " << QGLParamsColl->qgValidRange.RhoMax << std::endl; + + std::vector const& data = QGLParamsColl->data; + edm::LogInfo("UserOutput") << "There are " << data.size() << " entries (categories with associated PDF):" << std::endl; + for(auto idata = data.begin(); idata != data.end(); ++idata){ + int varIndex = idata->category.VarIndex; + int qgBin = idata->category.QGIndex; + double etaMin = idata->category.EtaMin; + double etaMax = idata->category.EtaMax; + double rhoMin = idata->category.RhoMin; + double rhoMax = idata->category.RhoMax; + double ptMin = idata->category.PtMin; + double ptMax = idata->category.PtMax; + + char buff[1000]; + sprintf(buff, "var=%1d, qg=%1d, ptMin=%8.2f, ptMax=%8.2f, etaMin=%3.1f, etaMax=%3.1f, rhoMin=%6.2f, rhoMax=%6.2f", varIndex, qgBin, ptMin, ptMax, etaMin, etaMax, rhoMin, rhoMax); + edm::LogVerbatim("UserOutput") << buff << std::endl; + } +} + +DEFINE_FWK_MODULE(QGLikelihoodDBReader); diff --git a/JetMETCorrections/Modules/plugins/QGLikelihoodSystematicsDBReader.cc b/JetMETCorrections/Modules/plugins/QGLikelihoodSystematicsDBReader.cc new file mode 100644 index 0000000000000..969c36d52bfab --- /dev/null +++ b/JetMETCorrections/Modules/plugins/QGLikelihoodSystematicsDBReader.cc @@ -0,0 +1,62 @@ +#include +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "CondFormats/JetMETObjects/interface/QGLikelihoodObject.h" +#include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h" +#include "CondFormats/DataRecord/interface/QGLikelihoodSystematicsRcd.h" + +class QGLikelihoodSystematicsDBReader : public edm::EDAnalyzer{ +public: + explicit QGLikelihoodSystematicsDBReader(const edm::ParameterSet&); + ~QGLikelihoodSystematicsDBReader(){}; + +private: + virtual void beginJob() override{}; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override{}; + + std::string mPayloadName; + bool mCreateTextFile,mPrintScreen; +}; + + +QGLikelihoodSystematicsDBReader::QGLikelihoodSystematicsDBReader(const edm::ParameterSet& iConfig){ + mPayloadName = iConfig.getUntrackedParameter("payloadName"); + mPrintScreen = iConfig.getUntrackedParameter("printScreen"); + mCreateTextFile = iConfig.getUntrackedParameter("createTextFile"); +} + + +void QGLikelihoodSystematicsDBReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){ + edm::LogInfo("UserOutput") << "Inspecting QGLikelihood payload with label:" << mPayloadName << std::endl; + edm::ESHandle QGLSysPar; + QGLikelihoodSystematicsRcd const& rcdhandle = iSetup.get(); + rcdhandle.get(mPayloadName, QGLSysPar); + + std::vector const& data = QGLSysPar->data; + edm::LogInfo("UserOutput") << "There are " << data.size() << " entries (categories with parameters for smearing):" << std::endl; + for(auto idata = data.begin(); idata != data.end(); ++idata){ + int qgBin = idata->systCategory.QGIndex; + double etaMin = idata->systCategory.EtaMin; + double etaMax = idata->systCategory.EtaMax; + double rhoMin = idata->systCategory.RhoMin; + double rhoMax = idata->systCategory.RhoMax; + double ptMin = idata->systCategory.PtMin; + double ptMax = idata->systCategory.PtMax; + double a = idata->a; + double b = idata->b; + double lmin = idata->lmin; + double lmax = idata->lmax; + + char buff[1000]; + sprintf(buff, "qg=%1d, ptMin=%8.2f, ptMax=%8.2f, etaMin=%3.1f, etaMax=%3.1f, rhoMin=%6.2f, rhoMax=%6.2f, a=%7.3f, b=%7.3f, lmin=%6.2f, lmax=%6.2f", qgBin, ptMin, ptMax, etaMin, etaMax, rhoMin, rhoMax, a, b, lmin, lmax); + edm::LogVerbatim("UserOutput") << buff << std::endl; + } +} + +DEFINE_FWK_MODULE(QGLikelihoodSystematicsDBReader); diff --git a/JetMETCorrections/Modules/test/QGLikelihoodLocalDBReader_cfg.py b/JetMETCorrections/Modules/test/QGLikelihoodLocalDBReader_cfg.py new file mode 100644 index 0000000000000..fc1200598afd8 --- /dev/null +++ b/JetMETCorrections/Modules/test/QGLikelihoodLocalDBReader_cfg.py @@ -0,0 +1,72 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("LikelihoodDBLocalReader") + +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet(threshold = cms.untracked.string( 'INFO' )), +) + +process.load('Configuration.StandardSequences.Services_cff') +process.load("JetMETCorrections.Modules.qglESProducer_cfi") + +from CondCore.DBCommon.CondDBSetup_cfi import * + +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1)) + +process.source = cms.Source("EmptySource") + +qgDatabaseVersion = 'v0-test' +process.PoolDBESSource = cms.ESSource("PoolDBESSource", + CondDBSetup, + toGet = cms.VPSet( + cms.PSet( + record = cms.string('QGLikelihoodRcd'), + tag = cms.string('QGLikelihoodObject_'+qgDatabaseVersion+'_AK5PF'), + label = cms.untracked.string('QGL_AK5PF') + ), + cms.PSet( + record = cms.string('QGLikelihoodRcd'), + tag = cms.string('QGLikelihoodObject_'+qgDatabaseVersion+'_AK5PFchs'), + label = cms.untracked.string('QGL_AK5PFchs') + ), + cms.PSet( + record = cms.string('QGLikelihoodSystematicsRcd'), + tag = cms.string('QGLikelihoodSystematicsObject_'+qgDatabaseVersion+'_Pythia'), + label = cms.untracked.string('QGL_Syst_Pythia') + ), + cms.PSet( + record = cms.string('QGLikelihoodSystematicsRcd'), + tag = cms.string('QGLikelihoodSystematicsObject_'+qgDatabaseVersion+'_Herwig++'), + label = cms.untracked.string('QGL_Syst_Herwig++') + ), + ), + connect = cms.string('sqlite:QGL_'+qgDatabaseVersion+'.db') +) + + +process.demo1 = cms.EDAnalyzer('QGLikelihoodDBReader', + payloadName = cms.untracked.string('QGL_AK5PF'), + printScreen = cms.untracked.bool(False), + createTextFile = cms.untracked.bool(True) +) + +process.demo2 = cms.EDAnalyzer('QGLikelihoodDBReader', + payloadName = cms.untracked.string('QGL_AK5PFchs'), + printScreen = cms.untracked.bool(False), + createTextFile = cms.untracked.bool(True) +) + +process.demo3 = cms.EDAnalyzer('QGLikelihoodSystematicsDBReader', + payloadName = cms.untracked.string('QGL_Syst_Pythia'), + printScreen = cms.untracked.bool(False), + createTextFile = cms.untracked.bool(True) +) + +process.demo4 = cms.EDAnalyzer('QGLikelihoodSystematicsDBReader', + payloadName = cms.untracked.string('QGL_Syst_Herwig++'), + printScreen = cms.untracked.bool(False), + createTextFile = cms.untracked.bool(True) +) + +process.p = cms.Path(process.demo1 * process.demo2 * process.demo3 * process.demo4)