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
Making Quark-Gluon likelihood conditions DB object #2924
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b46e0fc
Adding QGLikelihood first attempt
rappoccio e2b7bf2
Fixing ESProducer label
rappoccio fac0170
Fixing root-to-EDM histogram index off-by-one error
rappoccio 42fd8aa
Removing cout in favor of LogInfo and LogError
rappoccio e70c2c6
Adding edmFileInPath
rappoccio 7af0d4c
Fixing wrong initialization for fileinpath
rappoccio File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef QGLikelihoodRcd_QGLikelihoodRcd_h | ||
#define QGLikelihoodRcd_QGLikelihoodRcd_h | ||
// -*- C++ -*- | ||
// | ||
// Package: CondFormats/JetMETObjects | ||
// Class : QGLikelihoodRcd | ||
// | ||
/**\class QGLikelihoodRcd QGLikelihoodRcd.h CondFormats/JetMETObjects/interface/QGLikelihoodRcd.h | ||
|
||
Description: [one line class summary] | ||
|
||
Usage: | ||
<usage> | ||
|
||
*/ | ||
// | ||
// Author: Salvatore Rappoccio | ||
// Created: Thu, 13 Mar 2014 15:14:40 GMT | ||
// | ||
|
||
#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" | ||
|
||
class QGLikelihoodRcd : public edm::eventsetup::EventSetupRecordImplementation<QGLikelihoodRcd> {}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// -*- C++ -*- | ||
// | ||
// Package: CondFormats/JetMETObjects | ||
// Class : QGLikelihoodRcd | ||
// | ||
// Implementation: | ||
// [Notes on implementation] | ||
// | ||
// Author: Salvatore Rappoccio | ||
// Created: Thu, 13 Mar 2014 15:14:40 GMT | ||
|
||
#include "CondFormats/DataRecord/interface/QGLikelihoodRcd.h" | ||
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" | ||
|
||
EVENTSETUP_RECORD_REG(QGLikelihoodRcd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef QGLikelihoodObject_h | ||
#define QGLikelihoodObject_h | ||
|
||
#include "CondFormats/BTauObjects/interface/CombinedSVCategoryData.h" | ||
#include "CondFormats/PhysicsToolsObjects/interface/Histogram.h" | ||
|
||
|
||
|
||
#include <vector> | ||
|
||
|
||
struct QGLikelihoodCategory { | ||
float RhoVal, PtMin, PtMax; | ||
int EtaBin; | ||
int QGIndex; | ||
int VarIndex; | ||
}; | ||
|
||
|
||
|
||
struct QGLikelihoodObject | ||
{ | ||
typedef PhysicsTools::Calibration::HistogramF Histogram; | ||
|
||
struct Entry | ||
{ | ||
QGLikelihoodCategory category; | ||
Histogram histogram; | ||
}; | ||
|
||
std::vector<Entry> data; | ||
|
||
}; | ||
|
||
#endif //QGLikelihoodObject_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "CondFormats/JetMETObjects/interface/QGLikelihoodObject.h" | ||
#include "FWCore/Utilities/interface/typelookup.h" | ||
|
||
TYPELOOKUP_DATA_REG(QGLikelihoodObject); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
JetMETCorrections/Modules/interface/QGLikelihoodESProducer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef JetMETCorrections_Modules_QGLikelihoodESProducer_h | ||
#define JetMETCorrections_Modules_QGLikelihoodESProducer_h | ||
|
||
// -*- C++ -*- | ||
// | ||
// Package: JetMETCorrections/QGLikelihoodESProducer | ||
// Class: QGLikelihoodESProducer | ||
// | ||
/**\class QGLikelihoodESProducer QGLikelihoodESProducer.h JetMETCorrections/QGLikelihoodESProducer/plugins/QGLikelihoodESProducer.cc | ||
|
||
Description: ESProducer to get the quark-gluon likelihood object "QGLikelihoodObject" | ||
from record "QGLikelihoodRcd". | ||
|
||
Implementation: | ||
Completely trivial, simply returns the QGLikelihoodObject to the user. There is only | ||
one QGLikelihoodObject object in each record. | ||
*/ | ||
// | ||
// Original Author: Salvatore Rappoccio | ||
// Created: Thu, 13 Mar 2014 15:02:39 GMT | ||
// | ||
// | ||
|
||
|
||
// system include files | ||
#include <memory> | ||
#include <iostream> | ||
#include "boost/shared_ptr.hpp" | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/ModuleFactory.h" | ||
#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" | ||
#include "FWCore/Framework/interface/ESProducer.h" | ||
|
||
#include "FWCore/Framework/interface/ESHandle.h" | ||
|
||
#include "FWCore/Framework/interface/ESProducts.h" | ||
#include "CondFormats/JetMETObjects/interface/QGLikelihoodObject.h" | ||
#include "CondFormats/DataRecord/interface/QGLikelihoodRcd.h" | ||
|
||
|
||
// | ||
// class declaration | ||
// | ||
|
||
class QGLikelihoodESProducer : public edm::ESProducer { //, public edm::EventSetupRecordIntervalFinder { | ||
public: | ||
QGLikelihoodESProducer(const edm::ParameterSet&); | ||
~QGLikelihoodESProducer(); | ||
|
||
typedef boost::shared_ptr<QGLikelihoodObject> ReturnType; | ||
|
||
ReturnType produce(const QGLikelihoodRcd&); | ||
|
||
/// set validity interval | ||
void setIntervalFor( const edm::eventsetup::EventSetupRecordKey &, | ||
const edm::IOVSyncValue &, | ||
edm::ValidityInterval & ); | ||
private: | ||
// ----------member data --------------------------- | ||
std::string mAlgo; | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
JetMETCorrections/Modules/plugins/QGLikelihoodDBReader.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// -*- C++ -*- | ||
// | ||
// Package: QGLikelihoodDBReader | ||
// Class: | ||
// | ||
/**\class QGLikelihoodDBReader | ||
|
||
Description: <one line class summary> | ||
|
||
Implementation: | ||
<Notes on implementation> | ||
*/ | ||
// | ||
// Original Author: Salvatore Rappoccio | ||
// | ||
// | ||
|
||
|
||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
#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 declaration | ||
// | ||
|
||
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"); | ||
} | ||
|
||
|
||
QGLikelihoodDBReader::~QGLikelihoodDBReader() | ||
{ | ||
|
||
} | ||
|
||
void QGLikelihoodDBReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) | ||
{ | ||
std::cout << "Getting QGL objects from DB" << std::endl; | ||
edm::ESHandle<QGLikelihoodObject> QGLParamsColl; | ||
std::cout <<"Inspecting QGLikelihood payload with label: "<< mPayloadName <<std::endl; | ||
QGLikelihoodRcd const & rcdhandle = iSetup.get<QGLikelihoodRcd>(); | ||
rcdhandle.get(mPayloadName,QGLParamsColl); | ||
std::vector<QGLikelihoodObject::Entry> const & data = QGLParamsColl->data; | ||
std::cout << "There are " << data.size() << " objects in this payload" << std::endl; | ||
for ( auto ibegin = data.begin(), | ||
iend = data.end(), idata = ibegin; idata != iend; ++idata ) { | ||
int varIndex = idata->category.VarIndex; | ||
int qgBin = idata->category.QGIndex; | ||
int etaBin = idata->category.EtaBin; | ||
double rhoVal = idata->category.RhoVal; | ||
double ptMin = idata->category.PtMin; | ||
double ptMax = idata->category.PtMax; | ||
// Print out for debugging | ||
char buff[1000]; | ||
sprintf( buff, "var=%1d, eta=%1d, qg=%1d, ptMin=%8.2f, ptMax=%8.2f, rhoVal=%6.2f", varIndex, etaBin, qgBin, ptMin, ptMax, rhoVal ); | ||
std::cout << buff << std::endl; | ||
|
||
} | ||
} | ||
|
||
void | ||
QGLikelihoodDBReader::beginJob() | ||
{ | ||
} | ||
|
||
void | ||
QGLikelihoodDBReader::endJob() | ||
{ | ||
} | ||
|
||
//define this as a plug-in | ||
DEFINE_FWK_MODULE(QGLikelihoodDBReader); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please switch to MessageLogger here and elsewhere? This should be max. an edm::LogInfo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, Volker,
I can for completeness, but this is a "user-level" plugin that is designed to be run by the QGL contact once in a while, but interactively with lots of debugging output. They'll always have it on, so I'm not sure that LogInfo is the way to go (since the user will always turn it on).
Cheers,
Sal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sal, couts will get garbled in the threaded framework while MessageLogger will be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, All,
OK, I can change this then. But can I make it a warning so people will always see it? Or do I really have to make this a LogInfo (and the user will have to do the somewhat painful step of enabling it)?
Cheers,
Sal