Skip to content

Commit

Permalink
Add again (updated) local DBReader for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
UAEDF-tomc committed May 8, 2014
1 parent 5f78c61 commit 9181ee7
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 0 deletions.
64 changes: 64 additions & 0 deletions JetMETCorrections/Modules/plugins/QGLikelihoodDBReader.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <memory>
#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<std::string>("payloadName");
mPrintScreen = iConfig.getUntrackedParameter<bool>("printScreen");
mCreateTextFile = iConfig.getUntrackedParameter<bool>("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<QGLikelihoodObject> QGLParamsColl;
QGLikelihoodRcd const& rcdhandle = iSetup.get<QGLikelihoodRcd>();
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<QGLikelihoodObject::Entry> 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);
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <memory>
#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<std::string>("payloadName");
mPrintScreen = iConfig.getUntrackedParameter<bool>("printScreen");
mCreateTextFile = iConfig.getUntrackedParameter<bool>("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<QGLikelihoodSystematicsObject> QGLSysPar;
QGLikelihoodSystematicsRcd const& rcdhandle = iSetup.get<QGLikelihoodSystematicsRcd>();
rcdhandle.get(mPayloadName, QGLSysPar);

std::vector<QGLikelihoodSystematicsObject::Entry> 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);
72 changes: 72 additions & 0 deletions JetMETCorrections/Modules/test/QGLikelihoodLocalDBReader_cfg.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9181ee7

Please sign in to comment.