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

Making Quark-Gluon likelihood conditions DB object #2924

Merged
merged 6 commits into from Apr 3, 2014
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
7 changes: 7 additions & 0 deletions CondCore/JetMETPlugins/src/plugins.cc
@@ -1,8 +1,15 @@
#include "CondCore/PluginSystem/interface/registration_macros.h"

#include "CondFormats/JetMETObjects/interface/QGLikelihoodObject.h"
#include "CondFormats/DataRecord/interface/QGLikelihoodRcd.h"

#include "CondFormats/JetMETObjects/interface/FFTJetCorrectorParameters.h"
#include "CondFormats/DataRecord/interface/FFTJetCorrectorParametersRcdTypes.h"



REGISTER_PLUGIN(QGLikelihoodRcd, QGLikelihoodObject);

REGISTER_PLUGIN(FFTBasicJetCorrectorParametersRcd, FFTJetCorrectorParameters);
REGISTER_PLUGIN(FFTGenJetCorrectorParametersRcd, FFTJetCorrectorParameters);
REGISTER_PLUGIN(FFTCaloJetCorrectorParametersRcd, FFTJetCorrectorParameters);
Expand Down
25 changes: 25 additions & 0 deletions CondFormats/DataRecord/interface/QGLikelihoodRcd.h
@@ -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
15 changes: 15 additions & 0 deletions CondFormats/DataRecord/src/QGLikelihoodRcd.cc
@@ -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);
1 change: 1 addition & 0 deletions CondFormats/JetMETObjects/BuildFile.xml
Expand Up @@ -5,6 +5,7 @@
<use name="rootmath"/>
<use name="rootrflx"/>
<use name="clhep"/>
<use name="CondFormats/PhysicsToolsObjects"/>
<export>
<lib name="1"/>
</export>
35 changes: 35 additions & 0 deletions CondFormats/JetMETObjects/interface/QGLikelihoodObject.h
@@ -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
4 changes: 4 additions & 0 deletions CondFormats/JetMETObjects/src/QGLikelihoodObject.cc
@@ -0,0 +1,4 @@
#include "CondFormats/JetMETObjects/interface/QGLikelihoodObject.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(QGLikelihoodObject);
6 changes: 6 additions & 0 deletions CondFormats/JetMETObjects/src/classes.h
Expand Up @@ -5,6 +5,7 @@
#include "CondFormats/JetMETObjects/interface/SimpleJetCorrector.h"
#include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
#include "CondFormats/JetMETObjects/interface/FFTJetCorrectorParameters.h"
#include "CondFormats/JetMETObjects/interface/QGLikelihoodObject.h"

#include <vector>

Expand All @@ -20,5 +21,10 @@ namespace CondFormats_JetMETObjects {
JetCorrectorParametersCollection::collection_type colltype;
std::vector<JetCorrectorParametersCollection> collv;
FFTJetCorrectorParameters fftcorr;
QGLikelihoodCategory qgcat;
QGLikelihoodObject qgobj;
QGLikelihoodObject::Entry qgentry;
std::vector< QGLikelihoodObject::Entry > qgentryv;

};
}
11 changes: 11 additions & 0 deletions CondFormats/JetMETObjects/src/classes_def.xml
Expand Up @@ -16,5 +16,16 @@
<class name="FFTJetCorrectorParameters" class_version="0">
<field name="m_buffer" mapping="blob"/>
</class>

<class name="QGLikelihoodCategory"/>
<class name="QGLikelihoodObject" class_version="0">
<field name="data" mapping="blob"/>
</class>

<class name="QGLikelihoodObject::Entry"/>
<class name="std::vector<QGLikelihoodObject::Entry>"/>



</selection>
</lcgdict>
1 change: 1 addition & 0 deletions JetMETCorrections/Modules/BuildFile.xml
@@ -1,5 +1,6 @@
<use name="CondCore/PluginSystem"/>
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/JetMETObjects"/>
<use name="CondCore/DBCommon"/>
<use name="CondCore/DBOutputService"/>
<use name="CommonTools/Utils"/>
Expand Down
65 changes: 65 additions & 0 deletions JetMETCorrections/Modules/interface/QGLikelihoodESProducer.h
@@ -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

2 changes: 2 additions & 0 deletions JetMETCorrections/Modules/plugins/BuildFile.xml
@@ -1,11 +1,13 @@
<library file="*.cc" name="JetMETCorrectionsModulesPlugins">
<use name="CondCore/PluginSystem"/>
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/JetMETObjects"/>
<use name="CondCore/DBCommon"/>
<use name="CondCore/DBOutputService"/>
<use name="DataFormats/JetReco"/>
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ServiceRegistry"/>
<use name="JetMETCorrections/Algorithms"/>
<use name="JetMETCorrections/Objects"/>
<use name="JetMETCorrections/Modules"/>
Expand Down
103 changes: 103 additions & 0 deletions JetMETCorrections/Modules/plugins/QGLikelihoodDBReader.cc
@@ -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;
Copy link

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

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);