Skip to content

Commit

Permalink
Merge pull request cms-sw#3582 from UAEDF-tomc/QGTagger
Browse files Browse the repository at this point in the history
Qg tagger
  • Loading branch information
nclopezo committed May 9, 2014
2 parents 5d5fee3 + 9181ee7 commit 1953572
Show file tree
Hide file tree
Showing 24 changed files with 955 additions and 363 deletions.
2 changes: 2 additions & 0 deletions CondCore/JetMETPlugins/src/plugins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

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

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



REGISTER_PLUGIN(QGLikelihoodRcd, QGLikelihoodObject);
REGISTER_PLUGIN(QGLikelihoodSystematicsRcd, QGLikelihoodSystematicsObject);

REGISTER_PLUGIN(FFTBasicJetCorrectorParametersRcd, FFTJetCorrectorParameters);
REGISTER_PLUGIN(FFTGenJetCorrectorParametersRcd, FFTJetCorrectorParameters);
Expand Down
25 changes: 25 additions & 0 deletions CondFormats/DataRecord/interface/QGLikelihoodSystematicsRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef QGLikelihoodSystematicsRcd_QGLikelihoodSystematicsRcd_h
#define QGLikelihoodSystematicsRcd_QGLikelihoodSystematicsRcd_h
// -*- C++ -*-
//
// Package: CondFormats/JetMETObjects
// Class : QGLikelihoodSystematicsRcd
//
/**\class QGLikelihoodSystematicsRcd QGLikelihoodSystematicsRcd.h CondFormats/JetMETObjects/interface/QGLikelihoodSystematicsRcd.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 QGLikelihoodSystematicsRcd : public edm::eventsetup::EventSetupRecordImplementation<QGLikelihoodSystematicsRcd> {};

#endif
15 changes: 15 additions & 0 deletions CondFormats/DataRecord/src/QGLikelihoodSystematicsRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// -*- C++ -*-
//
// Package: CondFormats/JetMETObjects
// Class : QGLikelihoodSystematicsRcd
//
// Implementation:
// [Notes on implementation]
//
// Author: Salvatore Rappoccio
// Created: Thu, 13 Mar 2014 15:14:40 GMT

#include "CondFormats/DataRecord/interface/QGLikelihoodSystematicsRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(QGLikelihoodSystematicsRcd);
56 changes: 38 additions & 18 deletions CondFormats/JetMETObjects/interface/QGLikelihoodObject.h
Original file line number Diff line number Diff line change
@@ -1,35 +1,55 @@
#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;
/// Category structure: ranges associated with QGLikelihood histograms
struct QGLikelihoodCategory{
float RhoMin, RhoMax, PtMin, PtMax, EtaMin, EtaMax;
int QGIndex, VarIndex;
};

/// Parameters structure
struct QGLikelihoodParameters{
float Rho, Pt, Eta;
int QGIndex, VarIndex;
};


struct QGLikelihoodObject
{
/// QGLikelihoodObject containing valid range and entries with category, histogram and mean
struct QGLikelihoodObject{
typedef PhysicsTools::Calibration::HistogramF Histogram;

struct Entry
{
struct Entry{
QGLikelihoodCategory category;
Histogram histogram;
float mean;
};

std::vector<Entry> data;

QGLikelihoodCategory qgValidRange;
std::vector<Entry> data;
};

/// QGLikelihoodSystematicsObject containing the parameters for the systematic smearing
struct QGLikelihoodSystematicsObject{
struct Entry{
QGLikelihoodCategory systCategory;
float a, b, lmin, lmax;
};
std::vector<Entry> data;
};

#endif //QGLikelihoodObject_h
/// Test if parameters are compatible with category
inline bool operator==(const QGLikelihoodParameters& lhs, const QGLikelihoodCategory& rhs){
if(lhs.QGIndex != rhs.QGIndex) return false;
if(lhs.VarIndex != rhs.VarIndex) return false;
if(lhs.Eta < rhs.EtaMin) return false;
if(lhs.Eta > rhs.EtaMax) return false;
if(lhs.Rho < rhs.RhoMin) return false;
if(lhs.Rho > rhs.RhoMax) return false;
if(lhs.Pt < rhs.PtMin) return false;
if(lhs.Pt > rhs.PtMax) return false;
return true;
}

#endif
1 change: 1 addition & 0 deletions CondFormats/JetMETObjects/src/QGLikelihoodObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(QGLikelihoodObject);
TYPELOOKUP_DATA_REG(QGLikelihoodSystematicsObject);
3 changes: 3 additions & 0 deletions CondFormats/JetMETObjects/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace CondFormats_JetMETObjects {
QGLikelihoodObject qgobj;
QGLikelihoodObject::Entry qgentry;
std::vector< QGLikelihoodObject::Entry > qgentryv;
QGLikelihoodSystematicsObject qgsystobj;
QGLikelihoodSystematicsObject::Entry qgsystentry;
std::vector< QGLikelihoodSystematicsObject::Entry > qgsystentryv;

};
}
7 changes: 7 additions & 0 deletions CondFormats/JetMETObjects/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
</class>

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

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

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

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


</selection>
Expand Down
40 changes: 4 additions & 36 deletions JetMETCorrections/Modules/interface/QGLikelihoodESProducer.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
#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
Expand All @@ -39,25 +17,15 @@
#include "CondFormats/DataRecord/interface/QGLikelihoodRcd.h"


//
// class declaration
//

class QGLikelihoodESProducer : public edm::ESProducer { //, public edm::EventSetupRecordIntervalFinder {
class QGLikelihoodESProducer : public edm::ESProducer{
public:
QGLikelihoodESProducer(const edm::ParameterSet&);
~QGLikelihoodESProducer();

typedef boost::shared_ptr<QGLikelihoodObject> ReturnType;
~QGLikelihoodESProducer(){};

ReturnType produce(const QGLikelihoodRcd&);
boost::shared_ptr<QGLikelihoodObject> produce(const QGLikelihoodRcd&);
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &);

/// set validity interval
void setIntervalFor( const edm::eventsetup::EventSetupRecordKey &,
const edm::IOVSyncValue &,
edm::ValidityInterval & );
private:
// ----------member data ---------------------------
std::string mAlgo;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef JetMETCorrections_Modules_QGLikelihoodSystematicsESProducer_h
#define JetMETCorrections_Modules_QGLikelihoodSystematicsESProducer_h

// system include files
#include <memory>
#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/QGLikelihoodSystematicsRcd.h"


class QGLikelihoodSystematicsESProducer : public edm::ESProducer{
public:
QGLikelihoodSystematicsESProducer(const edm::ParameterSet&);
~QGLikelihoodSystematicsESProducer(){};

boost::shared_ptr<QGLikelihoodSystematicsObject> produce(const QGLikelihoodSystematicsRcd&);
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &);
private:
std::string mAlgo;
};

#endif

89 changes: 25 additions & 64 deletions JetMETCorrections/Modules/plugins/QGLikelihoodDBReader.cc
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
// -*- 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"
Expand All @@ -31,73 +9,56 @@
#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 {
class QGLikelihoodDBReader : public edm::EDAnalyzer{
public:
explicit QGLikelihoodDBReader(const edm::ParameterSet&);
~QGLikelihoodDBReader();

~QGLikelihoodDBReader(){};

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

std::string mPayloadName;
bool mCreateTextFile,mPrintScreen;
};


QGLikelihoodDBReader::QGLikelihoodDBReader(const edm::ParameterSet& iConfig)
{
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)
{
edm::LogInfo ("UserOutput") << "Getting QGL objects from DB" << std::endl;
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;
edm::LogInfo ("UserOutput") << "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;
edm::LogInfo ("UserOutput") << "There are " << data.size() << " objects in this payload" << std::endl;
for ( auto ibegin = data.begin(),
iend = data.end(), idata = ibegin; idata != iend; ++idata ) {
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;
int etaBin = idata->category.EtaBin;
double rhoVal = idata->category.RhoVal;
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;
// 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 );
edm::LogVerbatim ("UserOutput") << buff << std::endl;

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

void
QGLikelihoodDBReader::beginJob()
{
}

void
QGLikelihoodDBReader::endJob()
{
}

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

0 comments on commit 1953572

Please sign in to comment.