diff --git a/DataFormats/NanoAOD/BuildFile.xml b/DataFormats/NanoAOD/BuildFile.xml
index 178475a1a9d39..02ec339df90e2 100644
--- a/DataFormats/NanoAOD/BuildFile.xml
+++ b/DataFormats/NanoAOD/BuildFile.xml
@@ -3,8 +3,6 @@
-
-
diff --git a/DataFormats/NanoAOD/interface/FlatTable.h b/DataFormats/NanoAOD/interface/FlatTable.h
index 8fda70f7992d7..8a1a5909dc13b 100644
--- a/DataFormats/NanoAOD/interface/FlatTable.h
+++ b/DataFormats/NanoAOD/interface/FlatTable.h
@@ -5,8 +5,10 @@
#include
#include
#include
-#include
-#include
+#include "FWCore/Utilities/interface/Exception.h"
+#include "DataFormats/PatCandidates/interface/libminifloat.h"
+
+namespace nanoaod {
namespace flatTableHelper {
template struct MaybeMantissaReduce {
@@ -21,6 +23,7 @@ namespace flatTableHelper {
inline void bulk(boost::sub_range> data) const { if (bits_ > 0) MiniFloatConverter::reduceMantissaToNbitsRounding(bits_, data.begin(), data.end(), data.begin()); }
};
}
+
class FlatTable {
public:
enum ColumnType { FloatColumn, IntColumn, UInt8Column, BoolColumn }; // We could have other Float types with reduced mantissa, and similar
@@ -155,5 +158,6 @@ template<> inline std::vector & FlatTable::bigVector() { retur
template<> inline std::vector & FlatTable::bigVector() { return ints_; }
template<> inline std::vector & FlatTable::bigVector() { return uint8s_; }
+} // nanoaod
#endif
diff --git a/DataFormats/NanoAOD/interface/MergeableCounterTable.h b/DataFormats/NanoAOD/interface/MergeableCounterTable.h
index 3b7606813c071..cfd99d399b0b9 100644
--- a/DataFormats/NanoAOD/interface/MergeableCounterTable.h
+++ b/DataFormats/NanoAOD/interface/MergeableCounterTable.h
@@ -1,10 +1,12 @@
#ifndef DataFormats_NanoAOD_MergeableCounterTable_h
#define DataFormats_NanoAOD_MergeableCounterTable_h
-#include
+#include "FWCore/Utilities/interface/Exception.h"
#include
#include
+namespace nanoaod {
+
class MergeableCounterTable {
public:
MergeableCounterTable() {}
@@ -19,6 +21,8 @@ class MergeableCounterTable {
std::string name, doc;
T value;
void operator+=(const SingleColumn & other) {
+ //// if one arrives here from tryMerge the checks are already done in the compatible() function before.
+ //// you may however want to enable these and remove the 'return false' in tryMerge in order to see what's incompatible between the tables.
//if (name != other.name) throw cms::Exception("LogicError", "Trying to merge "+name+" with "+other.name+"\n");
value += other.value;
}
@@ -38,6 +42,8 @@ class MergeableCounterTable {
std::string name, doc;
std::vector values;
void operator+=(const VectorColumn & other) {
+ //// if one arrives here from tryMerge the checks are already done in the compatible() function before.
+ //// you may however want to enable these and remove the 'return false' in tryMerge in order to see what's incompatible between the tables.
//if (name != other.name) throw cms::Exception("LogicError", "Trying to merge "+name+" with "+other.name+"\n");
//if (values.size() != other.values.size()) throw cms::Exception("LogicError", "Trying to merge "+name+" with different number of values!\n");
for (unsigned int i = 0, n = values.size(); i < n; ++i) {
@@ -100,4 +106,6 @@ class MergeableCounterTable {
}
};
+} // namespace nanoaod
+
#endif
diff --git a/DataFormats/NanoAOD/interface/UniqueString.h b/DataFormats/NanoAOD/interface/UniqueString.h
index be0090da5b20e..8f2ad35c1c56f 100644
--- a/DataFormats/NanoAOD/interface/UniqueString.h
+++ b/DataFormats/NanoAOD/interface/UniqueString.h
@@ -3,6 +3,8 @@
#include
+namespace nanoaod {
+
class UniqueString {
public:
UniqueString() {}
@@ -15,4 +17,6 @@ class UniqueString {
std::string str_;
};
+} // namespace nanoaod
+
#endif
diff --git a/DataFormats/NanoAOD/src/FlatTable.cc b/DataFormats/NanoAOD/src/FlatTable.cc
index e3015ed6df007..bffa199ed8f95 100644
--- a/DataFormats/NanoAOD/src/FlatTable.cc
+++ b/DataFormats/NanoAOD/src/FlatTable.cc
@@ -1,6 +1,6 @@
-#include
+#include "DataFormats/NanoAOD/interface/FlatTable.h"
-int FlatTable::columnIndex(const std::string & name) const {
+int nanoaod::FlatTable::columnIndex(const std::string & name) const {
for (unsigned int i = 0, n = columns_.size(); i < n; ++i) {
if (columns_[i].name == name) return i;
}
diff --git a/DataFormats/NanoAOD/src/classes.h b/DataFormats/NanoAOD/src/classes.h
index e98cbc8ab12ab..cd21de1d1e072 100644
--- a/DataFormats/NanoAOD/src/classes.h
+++ b/DataFormats/NanoAOD/src/classes.h
@@ -1,14 +1,15 @@
#include "Rtypes.h"
-#include
-#include
-#include
+#include "DataFormats/NanoAOD/interface/FlatTable.h"
+#include "DataFormats/NanoAOD/interface/MergeableCounterTable.h"
+#include "DataFormats/NanoAOD/interface/UniqueString.h"
#include "DataFormats/Common/interface/Wrapper.h"
namespace DataFormats_NanoAOD {
struct dictionary {
- edm::Wrapper w_table;
- edm::Wrapper w_mtable;
- edm::Wrapper w_ustr;
+ nanoaod::FlatTable table;
+ edm::Wrapper w_table;
+ edm::Wrapper w_mtable;
+ edm::Wrapper w_ustr;
};
}
diff --git a/DataFormats/NanoAOD/src/classes_def.xml b/DataFormats/NanoAOD/src/classes_def.xml
index c53c27cac0d61..7c85fe046b919 100644
--- a/DataFormats/NanoAOD/src/classes_def.xml
+++ b/DataFormats/NanoAOD/src/classes_def.xml
@@ -1,36 +1,36 @@
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
+
diff --git a/PhysicsTools/NanoAOD/plugins/GenVisTauProducer.cc b/PhysicsTools/HepMCCandAlgos/plugins/GenVisTauProducer.cc
similarity index 100%
rename from PhysicsTools/NanoAOD/plugins/GenVisTauProducer.cc
rename to PhysicsTools/HepMCCandAlgos/plugins/GenVisTauProducer.cc
diff --git a/PhysicsTools/NanoAOD/BuildFile.xml b/PhysicsTools/NanoAOD/BuildFile.xml
index d01dc83a278a4..c36ed4184624a 100644
--- a/PhysicsTools/NanoAOD/BuildFile.xml
+++ b/PhysicsTools/NanoAOD/BuildFile.xml
@@ -5,8 +5,6 @@
-
-
diff --git a/PhysicsTools/NanoAOD/plugins/BJetEnergyRegressionMVA.cc b/PhysicsTools/NanoAOD/plugins/BJetEnergyRegressionMVA.cc
index fd8ca8cb9228c..d32d0458953af 100644
--- a/PhysicsTools/NanoAOD/plugins/BJetEnergyRegressionMVA.cc
+++ b/PhysicsTools/NanoAOD/plugins/BJetEnergyRegressionMVA.cc
@@ -25,7 +25,7 @@
#include "RecoVertex/VertexPrimitives/interface/ConvertToFromReco.h"
#include "RecoVertex/VertexPrimitives/interface/VertexState.h"
-#include "PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.h"
+#include "PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.h"
#include
class BJetEnergyRegressionMVA : public BaseMVAValueMapProducer {
diff --git a/PhysicsTools/NanoAOD/plugins/CandMCMatchTableProducer.cc b/PhysicsTools/NanoAOD/plugins/CandMCMatchTableProducer.cc
index cfb0c2205ef37..e0de5e212ae47 100644
--- a/PhysicsTools/NanoAOD/plugins/CandMCMatchTableProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/CandMCMatchTableProducer.cc
@@ -21,7 +21,7 @@ class CandMCMatchTableProducer : public edm::global::EDProducer<> {
src_(consumes(params.getParameter("src"))),
candMap_(consumes>(params.getParameter("mcMap")))
{
- produces();
+ produces();
const std::string & type = params.getParameter("objType");
if (type == "Muon") type_ = MMuon;
else if (type == "Electron") type_ = MElectron;
@@ -53,7 +53,7 @@ class CandMCMatchTableProducer : public edm::global::EDProducer<> {
iEvent.getByToken(src_, cands);
unsigned int ncand = cands->size();
- auto tab = std::make_unique(ncand, objName_, false, true);
+ auto tab = std::make_unique(ncand, objName_, false, true);
edm::Handle> map;
iEvent.getByToken(candMap_, map);
@@ -101,8 +101,8 @@ class CandMCMatchTableProducer : public edm::global::EDProducer<> {
};
}
- tab->addColumn(branchName_+"Idx", key, "Index into genParticle list for "+doc_, FlatTable::IntColumn);
- tab->addColumn(branchName_+"Flav", flav, "Flavour of genParticle for "+doc_+": "+flavDoc_, FlatTable::UInt8Column);
+ tab->addColumn(branchName_+"Idx", key, "Index into genParticle list for "+doc_, nanoaod::FlatTable::IntColumn);
+ tab->addColumn(branchName_+"Flav", flav, "Flavour of genParticle for "+doc_+": "+flavDoc_, nanoaod::FlatTable::UInt8Column);
iEvent.put(std::move(tab));
}
@@ -127,7 +127,7 @@ class CandMCMatchTableProducer : public edm::global::EDProducer<> {
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions) {
edm::ParameterSetDescription desc;
- desc.add("objName")->setComment("name of the FlatTable to extend with this table");
+ desc.add("objName")->setComment("name of the nanoaod::FlatTable to extend with this table");
desc.add("branchName")->setComment("name of the column to write (the final branch in the nanoaod will be _Idx and _Flav");
desc.add("docString")->setComment("documentation to forward to the output");
desc.add("src")->setComment("physics object collection for the reconstructed objects (e.g. leptons)");
diff --git a/PhysicsTools/NanoAOD/plugins/EGMEnergyVarProducer.cc b/PhysicsTools/NanoAOD/plugins/EGMEnergyVarProducer.cc
index 6e111542be19d..44c9114f69f45 100644
--- a/PhysicsTools/NanoAOD/plugins/EGMEnergyVarProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/EGMEnergyVarProducer.cc
@@ -90,9 +90,9 @@ EGMEnergyVarProducer::produce(edm::StreamID streamID, edm::Event& iEvent, con
std::vector eCorr(nSrcCorr,-1);
- for (uint ir = 0; irptrAt(ir);
- for (uint ic = 0; icptrAt(ic);
if(matchByCommonParentSuperClusterRef(*egm_raw,*egm_corr)){
eCorr[ir] = egm_corr->energy()/egm_raw->energy();
diff --git a/PhysicsTools/NanoAOD/plugins/GenWeightsTableProducer.cc b/PhysicsTools/NanoAOD/plugins/GenWeightsTableProducer.cc
index 1a7794b82c701..7e25fe71db49a 100644
--- a/PhysicsTools/NanoAOD/plugins/GenWeightsTableProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/GenWeightsTableProducer.cc
@@ -116,11 +116,11 @@ class GenWeightsTableProducer : public edm::global::EDProducer("debug",false)), debugRun_(debug_.load()),
hasIssuedWarning_(false)
{
- produces();
- produces("LHEScale");
- produces("LHEPdf");
- produces("LHENamed");
- produces();
+ produces();
+ produces("LHEScale");
+ produces("LHEPdf");
+ produces("LHENamed");
+ produces();
if (namedWeightIDs_.size() != namedWeightLabels_.size()) {
throw cms::Exception("Configuration", "Size mismatch between namedWeightIDs & namedWeightLabels");
}
@@ -138,13 +138,13 @@ class GenWeightsTableProducer : public edm::global::EDProducerweight();
// table for gen info, always available
- auto out = std::make_unique(1, "genWeight", true);
+ auto out = std::make_unique(1, "genWeight", true);
out->setDoc("generator weight");
- out->addColumnValue("", weight, "generator weight", FlatTable::FloatColumn);
+ out->addColumnValue("", weight, "generator weight", nanoaod::FlatTable::FloatColumn);
iEvent.put(std::move(out));
// tables for LHE weights, may not be filled
- std::unique_ptr lheScaleTab, lhePdfTab, lheNamedTab;
+ std::unique_ptr lheScaleTab, lhePdfTab, lheNamedTab;
edm::Handle lheInfo;
if (iEvent.getByToken(lheTag_, lheInfo)) {
@@ -156,9 +156,9 @@ class GenWeightsTableProducer : public edm::global::EDProducerincGenOnly(weight);
// make dummy values
- lheScaleTab.reset(new FlatTable(1, "LHEScaleWeights", true));
- lhePdfTab.reset(new FlatTable(1, "LHEPdfWeights", true));
- lheNamedTab.reset(new FlatTable(1, "LHENamedWeights", true));
+ lheScaleTab.reset(new nanoaod::FlatTable(1, "LHEScaleWeights", true));
+ lhePdfTab.reset(new nanoaod::FlatTable(1, "LHEPdfWeights", true));
+ lheNamedTab.reset(new nanoaod::FlatTable(1, "LHENamedWeights", true));
if (!hasIssuedWarning_.exchange(true)) {
edm::LogWarning("LHETablesProducer") << "No LHEEventProduct, so there will be no LHE Tables\n";
}
@@ -174,9 +174,9 @@ class GenWeightsTableProducer : public edm::global::EDProducer & outScale,
- std::unique_ptr & outPdf,
- std::unique_ptr & outNamed ) const
+ std::unique_ptr & outScale,
+ std::unique_ptr & outPdf,
+ std::unique_ptr & outNamed ) const
{
bool lheDebug = debug_.exchange(false); // make sure only the first thread dumps out this (even if may still be mixed up with other output, but nevermind)
@@ -199,16 +199,16 @@ class GenWeightsTableProducer : public edm::global::EDProduceraddColumn("", wScale, weightChoice->scaleWeightsDoc, FlatTable::FloatColumn, lheWeightPrecision_);
+ outScale.reset(new nanoaod::FlatTable(wScale.size(), "LHEScaleWeight", false));
+ outScale->addColumn("", wScale, weightChoice->scaleWeightsDoc, nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
- outPdf.reset(new FlatTable(wPDF.size(), "LHEPdfWeight", false));
- outPdf->addColumn("", wPDF, weightChoice->pdfWeightsDoc, FlatTable::FloatColumn, lheWeightPrecision_);
+ outPdf.reset(new nanoaod::FlatTable(wPDF.size(), "LHEPdfWeight", false));
+ outPdf->addColumn("", wPDF, weightChoice->pdfWeightsDoc, nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
- outNamed.reset(new FlatTable(1, "LHEWeight", true));
- outNamed->addColumnValue("originalXWGTUP", lheProd.originalXWGTUP(), "Nominal event weight in the LHE file", FlatTable::FloatColumn);
+ outNamed.reset(new nanoaod::FlatTable(1, "LHEWeight", true));
+ outNamed->addColumnValue("originalXWGTUP", lheProd.originalXWGTUP(), "Nominal event weight in the LHE file", nanoaod::FlatTable::FloatColumn);
for (unsigned int i = 0, n = wNamed.size(); i < n; ++i) {
- outNamed->addColumnValue(namedWeightLabels_[i], wNamed[i], "LHE weight for id "+namedWeightIDs_[i]+", relative to nominal", FlatTable::FloatColumn, lheWeightPrecision_);
+ outNamed->addColumnValue(namedWeightLabels_[i], wNamed[i], "LHE weight for id "+namedWeightIDs_[i]+", relative to nominal", nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
}
counter->incLHE(genWeight, wScale, wPDF, wNamed);
@@ -355,7 +355,7 @@ class GenWeightsTableProducer : public edm::global::EDProducer();
+ auto out = std::make_unique();
out->addInt("genEventCount", "event count", runCounter->num);
out->addFloat("genEventSumw", "sum of gen weights", runCounter->sumw);
out->addFloat("genEventSumw2", "sum of gen (weight^2)", runCounter->sumw2);
diff --git a/PhysicsTools/NanoAOD/plugins/GlobalVariablesTableProducer.cc b/PhysicsTools/NanoAOD/plugins/GlobalVariablesTableProducer.cc
index 59c26d2a9282f..83418b2e05c49 100644
--- a/PhysicsTools/NanoAOD/plugins/GlobalVariablesTableProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/GlobalVariablesTableProducer.cc
@@ -17,22 +17,22 @@ class GlobalVariablesTableProducer : public edm::stream::EDProducer<> {
for (const std::string & vname : varsPSet.getParameterNamesForType()) {
const auto & varPSet = varsPSet.getParameter(vname);
const std::string & type = varPSet.getParameter("type");
- if (type == "int") vars_.push_back(new IntVar(vname, FlatTable::IntColumn, varPSet, consumesCollector()));
- else if (type == "float") vars_.push_back(new FloatVar(vname, FlatTable::FloatColumn, varPSet, consumesCollector()));
- else if (type == "double") vars_.push_back(new DoubleVar(vname, FlatTable::FloatColumn, varPSet, consumesCollector()));
- else if (type == "bool") vars_.push_back(new BoolVar(vname, FlatTable::UInt8Column, varPSet, consumesCollector()));
- else if (type == "candidatescalarsum") vars_.push_back(new CandidateScalarSumVar(vname, FlatTable::FloatColumn, varPSet, consumesCollector()));
- else if (type == "candidatesize") vars_.push_back(new CandidateSizeVar(vname, FlatTable::IntColumn, varPSet, consumesCollector()));
+ if (type == "int") vars_.push_back(new IntVar(vname, nanoaod::FlatTable::IntColumn, varPSet, consumesCollector()));
+ else if (type == "float") vars_.push_back(new FloatVar(vname, nanoaod::FlatTable::FloatColumn, varPSet, consumesCollector()));
+ else if (type == "double") vars_.push_back(new DoubleVar(vname, nanoaod::FlatTable::FloatColumn, varPSet, consumesCollector()));
+ else if (type == "bool") vars_.push_back(new BoolVar(vname, nanoaod::FlatTable::UInt8Column, varPSet, consumesCollector()));
+ else if (type == "candidatescalarsum") vars_.push_back(new CandidateScalarSumVar(vname, nanoaod::FlatTable::FloatColumn, varPSet, consumesCollector()));
+ else if (type == "candidatesize") vars_.push_back(new CandidateSizeVar(vname, nanoaod::FlatTable::IntColumn, varPSet, consumesCollector()));
else throw cms::Exception("Configuration", "unsupported type "+type+" for variable "+vname);
}
- produces();
+ produces();
}
~GlobalVariablesTableProducer() override {}
void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override {
- auto out = std::make_unique(1, "", true);
+ auto out = std::make_unique(1, "", true);
for (const auto & var : vars_) var.fill(iEvent, *out);
@@ -42,15 +42,15 @@ class GlobalVariablesTableProducer : public edm::stream::EDProducer<> {
protected:
class Variable {
public:
- Variable(const std::string & aname, FlatTable::ColumnType atype, const edm::ParameterSet & cfg) :
+ Variable(const std::string & aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet & cfg) :
name_(aname), doc_(cfg.getParameter("doc")), type_(atype) {}
- virtual void fill(const edm::Event &iEvent, FlatTable & out) const = 0;
+ virtual void fill(const edm::Event &iEvent, nanoaod::FlatTable & out) const = 0;
virtual ~Variable() {}
const std::string & name() const { return name_; }
- const FlatTable::ColumnType & type() const { return type_; }
+ const nanoaod::FlatTable::ColumnType & type() const { return type_; }
protected:
std::string name_, doc_;
- FlatTable::ColumnType type_;
+ nanoaod::FlatTable::ColumnType type_;
};
template
class Identity {
@@ -109,10 +109,10 @@ class GlobalVariablesTableProducer : public edm::stream::EDProducer<> {
template >
class VariableT : public Variable {
public:
- VariableT(const std::string & aname, FlatTable::ColumnType atype, const edm::ParameterSet & cfg, edm::ConsumesCollector && cc) :
+ VariableT(const std::string & aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet & cfg, edm::ConsumesCollector && cc) :
Variable(aname, atype, cfg), src_(cc.consumes(cfg.getParameter("src"))) {}
~VariableT() override {}
- void fill(const edm::Event &iEvent, FlatTable & out) const override {
+ void fill(const edm::Event &iEvent, nanoaod::FlatTable & out) const override {
edm::Handle handle;
iEvent.getByToken(src_, handle);
out.template addColumnValue(this->name_, Converter::convert(*handle), this->doc_, this->type_);
diff --git a/PhysicsTools/NanoAOD/plugins/IsoValueMapProducer.cc b/PhysicsTools/NanoAOD/plugins/IsoValueMapProducer.cc
index c6a27d76457bf..bc2300f133dfe 100644
--- a/PhysicsTools/NanoAOD/plugins/IsoValueMapProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/IsoValueMapProducer.cc
@@ -45,7 +45,8 @@ template
class IsoValueMapProducer : public edm::global::EDProducer<> {
public:
explicit IsoValueMapProducer(const edm::ParameterSet &iConfig):
- src_(consumes>(iConfig.getParameter("src")))
+ src_(consumes>(iConfig.getParameter("src"))),
+ relative_(iConfig.getParameter("relative"))
{
if ((typeid(T) == typeid(pat::Muon)) || (typeid(T) == typeid(pat::Electron)) || typeid(T) == typeid(pat::IsolatedTrack)) {
produces>("miniIsoChg");
@@ -59,7 +60,7 @@ class IsoValueMapProducer : public edm::global::EDProducer<> {
ea_pfiso_.reset(new EffectiveAreas((iConfig.getParameter("EAFile_PFIso")).fullPath()));
rho_pfiso_ = consumes(iConfig.getParameter("rho_PFIso"));
}
- if ((typeid(T) == typeid(pat::Photon))) {
+ else if ((typeid(T) == typeid(pat::Photon))) {
produces>("PFIsoChg");
produces>("PFIsoAll");
mapIsoChg_ = consumes >(iConfig.getParameter("mapIsoChg"));
@@ -82,6 +83,7 @@ class IsoValueMapProducer : public edm::global::EDProducer<> {
// ----------member data ---------------------------
edm::EDGetTokenT> src_;
+ bool relative_;
edm::EDGetTokenT rho_miniiso_;
edm::EDGetTokenT rho_pfiso_;
edm::EDGetTokenT> mapIsoChg_;
@@ -138,23 +140,23 @@ IsoValueMapProducer::doMiniIso(edm::Event& iEvent) const{
edm::Handle rho;
iEvent.getByToken(rho_miniiso_,rho);
- unsigned nInput = src->size();
+ unsigned int nInput = src->size();
std::vector miniIsoChg, miniIsoAll;
miniIsoChg.reserve(nInput);
miniIsoAll.reserve(nInput);
-
- for (uint i=0; i(src->ptrAt(i).get()); // temporarily needed
- auto iso = obj->miniPFIsolation();
+
+ for (const auto & obj : *src) {
+ auto iso = obj.miniPFIsolation();
auto chg = iso.chargedHadronIso();
auto neu = iso.neutralHadronIso();
auto pho = iso.photonIso();
- auto ea = ea_miniiso_->getEffectiveArea(fabs(getEtaForEA(obj)));
- float R = 10.0/std::min(std::max(obj->pt(), 50.0),200.0);
+ auto ea = ea_miniiso_->getEffectiveArea(fabs(getEtaForEA(&obj)));
+ float R = 10.0/std::min(std::max(obj.pt(), 50.0),200.0);
ea *= std::pow(R/0.3,2);
- miniIsoChg.push_back(chg);
- miniIsoAll.push_back(chg+std::max(0.0,neu+pho-(*rho)*ea));
+ float scale = relative_ ? 1.0/obj.pt() : 1;
+ miniIsoChg.push_back(scale*chg);
+ miniIsoAll.push_back(scale*(chg+std::max(0.0,neu+pho-(*rho)*ea)));
}
std::unique_ptr> miniIsoChgV(new edm::ValueMap());
@@ -188,21 +190,21 @@ IsoValueMapProducer::doPFIsoEle(edm::Event& iEvent) const{
edm::Handle rho;
iEvent.getByToken(rho_pfiso_,rho);
- unsigned nInput = src->size();
+ unsigned int nInput = src->size();
std::vector PFIsoChg, PFIsoAll;
PFIsoChg.reserve(nInput);
PFIsoAll.reserve(nInput);
- for (uint i=0; iptrAt(i).get();
- auto iso = obj->pfIsolationVariables();
+ for (const auto & obj : *src) {
+ auto iso = obj.pfIsolationVariables();
auto chg = iso.sumChargedHadronPt;
auto neu = iso.sumNeutralHadronEt;
auto pho = iso.sumPhotonEt;
- auto ea = ea_pfiso_->getEffectiveArea(fabs(getEtaForEA(obj)));
- PFIsoChg.push_back(chg);
- PFIsoAll.push_back(chg+std::max(0.0,neu+pho-(*rho)*ea));
+ auto ea = ea_pfiso_->getEffectiveArea(fabs(getEtaForEA(&obj)));
+ float scale = relative_ ? 1.0/obj.pt() : 1;
+ PFIsoChg.push_back(scale*chg);
+ PFIsoAll.push_back(scale*(chg+std::max(0.0,neu+pho-(*rho)*ea)));
}
std::unique_ptr> PFIsoChgV(new edm::ValueMap());
@@ -238,13 +240,13 @@ IsoValueMapProducer::doPFIsoPho(edm::Event& iEvent) const {
edm::Handle > mapIsoPho;
iEvent.getByToken(mapIsoPho_, mapIsoPho);
- unsigned nInput = src->size();
+ unsigned int nInput = src->size();
std::vector PFIsoChg, PFIsoAll;
PFIsoChg.reserve(nInput);
PFIsoAll.reserve(nInput);
- for (uint i=0; iptrAt(i);
auto chg = (*mapIsoChg)[obj];
auto neu = (*mapIsoNeu)[obj];
@@ -252,8 +254,9 @@ IsoValueMapProducer::doPFIsoPho(edm::Event& iEvent) const {
auto ea_chg = ea_pfiso_chg_->getEffectiveArea(fabs(getEtaForEA(obj.get())));
auto ea_neu = ea_pfiso_neu_->getEffectiveArea(fabs(getEtaForEA(obj.get())));
auto ea_pho = ea_pfiso_pho_->getEffectiveArea(fabs(getEtaForEA(obj.get())));
- PFIsoChg.push_back(std::max(0.0,chg-(*rho)*ea_chg));
- PFIsoAll.push_back(PFIsoChg.back()+std::max(0.0,neu-(*rho)*ea_neu)+std::max(0.0,pho-(*rho)*ea_pho));
+ float scale = relative_ ? 1.0/obj->pt() : 1;
+ PFIsoChg.push_back(scale*std::max(0.0,chg-(*rho)*ea_chg));
+ PFIsoAll.push_back(PFIsoChg.back()+scale*(std::max(0.0,neu-(*rho)*ea_neu)+std::max(0.0,pho-(*rho)*ea_pho)));
}
std::unique_ptr> PFIsoChgV(new edm::ValueMap());
@@ -278,6 +281,7 @@ void
IsoValueMapProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add("src")->setComment("input physics object collection");
+ desc.add("relative")->setComment("compute relative isolation instead of absolute one");
if ((typeid(T) == typeid(pat::Muon)) || (typeid(T) == typeid(pat::Electron)) || typeid(T) == typeid(pat::IsolatedTrack)) {
desc.add("EAFile_MiniIso")->setComment("txt file containing effective areas to be used for mini-isolation pileup subtraction");
desc.add("rho_MiniIso")->setComment("rho to be used for effective-area based mini-isolation pileup subtraction");
diff --git a/PhysicsTools/NanoAOD/plugins/LHETablesProducer.cc b/PhysicsTools/NanoAOD/plugins/LHETablesProducer.cc
index d3f89e1ad3ac8..4ffaeb2eb5b7b 100644
--- a/PhysicsTools/NanoAOD/plugins/LHETablesProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/LHETablesProducer.cc
@@ -15,13 +15,13 @@ class LHETablesProducer : public edm::global::EDProducer<> {
LHETablesProducer( edm::ParameterSet const & params ) :
lheTag_(consumes(params.getParameter("lheInfo")))
{
- produces();
+ produces();
}
~LHETablesProducer() override {}
void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override {
- auto lheTab = std::make_unique(1, "LHE", true);
+ auto lheTab = std::make_unique(1, "LHE", true);
edm::Handle lheInfo;
if (iEvent.getByToken(lheTag_, lheInfo)) {
@@ -31,7 +31,7 @@ class LHETablesProducer : public edm::global::EDProducer<> {
iEvent.put(std::move(lheTab));
}
- void fillLHEObjectTable(const LHEEventProduct & lheProd, FlatTable & out) const {
+ void fillLHEObjectTable(const LHEEventProduct & lheProd, nanoaod::FlatTable & out) const {
double lheHT = 0, lheHTIncoming = 0;
unsigned int lheNj = 0, lheNb = 0, lheNc = 0, lheNuds = 0, lheNglu = 0;
double lheVpt = 0;
@@ -73,14 +73,14 @@ class LHETablesProducer : public edm::global::EDProducer<> {
lheVpt = std::hypot( pup[v.first][0] + pup[v.second][0], pup[v.first][1] + pup[v.second][1] );
}
- out.addColumnValue("Njets", lheNj, "Number of jets (partons) at LHE step", FlatTable::UInt8Column);
- out.addColumnValue("Nb", lheNb, "Number of b partons at LHE step", FlatTable::UInt8Column);
- out.addColumnValue("Nc", lheNc, "Number of c partons at LHE step", FlatTable::UInt8Column);
- out.addColumnValue("Nuds", lheNuds, "Number of u,d,s partons at LHE step", FlatTable::UInt8Column);
- out.addColumnValue("Nglu", lheNglu, "Number of gluon partons at LHE step", FlatTable::UInt8Column);
- out.addColumnValue("HT", lheHT, "HT, scalar sum of parton pTs at LHE step", FlatTable::FloatColumn);
- out.addColumnValue("HTIncoming", lheHTIncoming, "HT, scalar sum of parton pTs at LHE step, restricted to partons", FlatTable::FloatColumn);
- out.addColumnValue("Vpt", lheVpt, "pT of the W or Z boson at LHE step", FlatTable::FloatColumn);
+ out.addColumnValue("Njets", lheNj, "Number of jets (partons) at LHE step", nanoaod::FlatTable::UInt8Column);
+ out.addColumnValue("Nb", lheNb, "Number of b partons at LHE step", nanoaod::FlatTable::UInt8Column);
+ out.addColumnValue("Nc", lheNc, "Number of c partons at LHE step", nanoaod::FlatTable::UInt8Column);
+ out.addColumnValue("Nuds", lheNuds, "Number of u,d,s partons at LHE step", nanoaod::FlatTable::UInt8Column);
+ out.addColumnValue("Nglu", lheNglu, "Number of gluon partons at LHE step", nanoaod::FlatTable::UInt8Column);
+ out.addColumnValue("HT", lheHT, "HT, scalar sum of parton pTs at LHE step", nanoaod::FlatTable::FloatColumn);
+ out.addColumnValue("HTIncoming", lheHTIncoming, "HT, scalar sum of parton pTs at LHE step, restricted to partons", nanoaod::FlatTable::FloatColumn);
+ out.addColumnValue("Vpt", lheVpt, "pT of the W or Z boson at LHE step", nanoaod::FlatTable::FloatColumn);
}
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions) {
diff --git a/PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc b/PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc
index f05abb454cf1e..a671e8650a98f 100644
--- a/PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc
@@ -35,7 +35,6 @@
#include "DataFormats/PatCandidates/interface/Electron.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
-#include "TLorentzVector.h"
#include "DataFormats/Common/interface/View.h"
#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"
@@ -100,8 +99,8 @@ LeptonJetVarProducer::produce(edm::StreamID streamID, edm::Event& iEvent, con
edm::Handle> srcVtx;
iEvent.getByToken(srcVtx_, srcVtx);
- unsigned nJet = srcJet->size();
- unsigned nLep = srcLep->size();
+ unsigned int nJet = srcJet->size();
+ unsigned int nLep = srcLep->size();
std::vector ptRatio(nLep,-1);
std::vector ptRel(nLep,-1);
@@ -110,8 +109,8 @@ LeptonJetVarProducer::produce(edm::StreamID streamID, edm::Event& iEvent, con
const auto & pv = (*srcVtx)[0];
- for (uint il = 0; ilptrAt(il);
auto jet = srcJet->ptrAt(ij);
if(matchByCommonSourceCandidatePtr(*lep,*jet)){
@@ -156,17 +155,16 @@ template
std::tuple
LeptonJetVarProducer::calculatePtRatioRel(edm::Ptr lep, edm::Ptr jet, const reco::Vertex &vtx) const {
- auto rawp4_ = jet->correctedP4("Uncorrected");
- auto rawp4 = TLorentzVector(rawp4_.pt(),rawp4_.eta(),rawp4_.phi(),rawp4_.energy());
- auto lepp4 = TLorentzVector(lep->pt(),lep->eta(),lep->phi(),lep->energy());
+ auto rawp4 = jet->correctedP4("Uncorrected");
+ auto lepp4 = lep->p4();
- if ((rawp4-lepp4).Rho()<1e-4) return std::tuple(1.0,0.0,0.0);
+ if ((rawp4-lepp4).R()<1e-4) return std::tuple(1.0,0.0,0.0);
- auto jetp4 = (rawp4 - lepp4*(1.0/jet->jecFactor("L1FastJet")))*(jet->pt()/rawp4.Pt())+lepp4;
- auto ptratio = lepp4.Pt()/jetp4.Pt();
- auto ptrel = lepp4.Perp((jetp4-lepp4).Vect());
+ auto jetp4 = (rawp4 - lepp4*(1.0/jet->jecFactor("L1FastJet")))*(jet->pt()/rawp4.pt())+lepp4;
+ auto ptratio = lepp4.pt()/jetp4.pt();
+ auto ptrel = lepp4.Vect().Cross((jetp4-lepp4).Vect().Unit()).R();
- unsigned jndau = 0;
+ unsigned int jndau = 0;
for(const auto _d : jet->daughterPtrVector()) {
const auto d = dynamic_cast(_d.get());
if (d->charge()==0) continue;
diff --git a/PhysicsTools/NanoAOD/plugins/MuonIDTableProducer.cc b/PhysicsTools/NanoAOD/plugins/MuonIDTableProducer.cc
index b6ae1c19d4445..3970ca344db86 100644
--- a/PhysicsTools/NanoAOD/plugins/MuonIDTableProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/MuonIDTableProducer.cc
@@ -24,7 +24,7 @@ class MuonIDTableProducer : public edm::global::EDProducer<> {
src_(consumes>(iConfig.getParameter("muons"))),
srcVtx_(consumes>(iConfig.getParameter("vertices")))
{
- produces();
+ produces();
}
~MuonIDTableProducer() override {};
@@ -33,7 +33,7 @@ class MuonIDTableProducer : public edm::global::EDProducer<> {
edm::ParameterSetDescription desc;
desc.add("muons")->setComment("input muon collection");
desc.add("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"))->setComment("input vertex collection, for dxy/dz");
- desc.add("name")->setComment("name of the muon FlatTable we are extending with IDs");
+ desc.add("name")->setComment("name of the muon nanoaod::FlatTable we are extending with IDs");
descriptions.add("muonIDTable", desc);
}
@@ -73,11 +73,11 @@ MuonIDTableProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::Event
medium[i] = isRun2016BCDEF ? isMediumMuonHIP(mu) : muon::isMediumMuon(mu);
}
- auto tab = std::make_unique(ncand, name_, false, true);
- tab->addColumn("tightId", tight, "POG Tight muon ID", FlatTable::BoolColumn);
- tab->addColumn("highPtId", highPt, "POG highPt muon ID (1 = tracker high pT, 2 = global high pT, which includes tracker high pT)", FlatTable::UInt8Column);
- tab->addColumn("softId", soft, "POG Soft muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)", FlatTable::BoolColumn);
- tab->addColumn("mediumId", medium, "POG Medium muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)", FlatTable::BoolColumn);
+ auto tab = std::make_unique(ncand, name_, false, true);
+ tab->addColumn("tightId", tight, "POG Tight muon ID", nanoaod::FlatTable::BoolColumn);
+ tab->addColumn("highPtId", highPt, "POG highPt muon ID (1 = tracker high pT, 2 = global high pT, which includes tracker high pT)", nanoaod::FlatTable::UInt8Column);
+ tab->addColumn("softId", soft, "POG Soft muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)", nanoaod::FlatTable::BoolColumn);
+ tab->addColumn("mediumId", medium, "POG Medium muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)", nanoaod::FlatTable::BoolColumn);
iEvent.put(std::move(tab));
}
diff --git a/PhysicsTools/NanoAOD/plugins/NanoAODBaseCrossCleaner.cc b/PhysicsTools/NanoAOD/plugins/NanoAODBaseCrossCleaner.cc
index 0c4e7df51ff51..cc41a35563882 100644
--- a/PhysicsTools/NanoAOD/plugins/NanoAODBaseCrossCleaner.cc
+++ b/PhysicsTools/NanoAOD/plugins/NanoAODBaseCrossCleaner.cc
@@ -42,11 +42,11 @@ NanoAODBaseCrossCleaner::NanoAODBaseCrossCleaner(const edm::ParameterSet& params
photonName_(params.getParameter("photonName") )
{
- produces("jets");
- produces("muons");
- produces("electrons");
- produces("taus");
- produces("photons");
+ produces("jets");
+ produces("muons");
+ produces("electrons");
+ produces("taus");
+ produces("photons");
}
@@ -75,41 +75,41 @@ NanoAODBaseCrossCleaner::produce(edm::Event& iEvent, const edm::EventSetup& iSet
iEvent.getByToken(jets_, jetsIn);
std::vector jets;
for (const auto & j: *jetsIn) {jets.push_back(jetSel_(j));}
- auto jetsTable = std::make_unique(jetsIn->size(),jetName_,false,true);
+ auto jetsTable = std::make_unique(jetsIn->size(),jetName_,false,true);
edm::Handle> muonsIn;
iEvent.getByToken(muons_, muonsIn);
std::vector muons;
for (const auto & m: *muonsIn) {muons.push_back(muonSel_(m));}
- auto muonsTable = std::make_unique(muonsIn->size(),muonName_,false,true);
+ auto muonsTable = std::make_unique(muonsIn->size(),muonName_,false,true);
edm::Handle> electronsIn;
iEvent.getByToken(electrons_, electronsIn);
std::vector eles;
for (const auto & e: *electronsIn) {eles.push_back(electronSel_(e));}
- auto electronsTable = std::make_unique(electronsIn->size(),electronName_,false,true);
+ auto electronsTable = std::make_unique(electronsIn->size(),electronName_,false,true);
edm::Handle> tausIn;
iEvent.getByToken(taus_, tausIn);
std::vector taus;
for (const auto & t: *tausIn) {taus.push_back(tauSel_(t));}
- auto tausTable = std::make_unique(tausIn->size(),tauName_,false,true);
+ auto tausTable = std::make_unique(tausIn->size(),tauName_,false,true);
edm::Handle> photonsIn;
iEvent.getByToken(photons_, photonsIn);
std::vector photons;
for (const auto & p: *photonsIn) {photons.push_back(photonSel_(p));}
- auto photonsTable = std::make_unique(photonsIn->size(),photonName_,false,true);
+ auto photonsTable = std::make_unique(photonsIn->size(),photonName_,false,true);
objectSelection(*jetsIn,*muonsIn,*electronsIn,*tausIn,*photonsIn,jets,muons,eles,taus,photons);
- muonsTable->addColumn(name_,muons,doc_,FlatTable::UInt8Column);
- jetsTable->addColumn(name_,jets,doc_,FlatTable::UInt8Column);
- electronsTable->addColumn(name_,eles,doc_,FlatTable::UInt8Column);
- tausTable->addColumn(name_,taus,doc_,FlatTable::UInt8Column);
- photonsTable->addColumn(name_,photons,doc_,FlatTable::UInt8Column);
+ muonsTable->addColumn(name_,muons,doc_,nanoaod::FlatTable::UInt8Column);
+ jetsTable->addColumn(name_,jets,doc_,nanoaod::FlatTable::UInt8Column);
+ electronsTable->addColumn(name_,eles,doc_,nanoaod::FlatTable::UInt8Column);
+ tausTable->addColumn(name_,taus,doc_,nanoaod::FlatTable::UInt8Column);
+ photonsTable->addColumn(name_,photons,doc_,nanoaod::FlatTable::UInt8Column);
iEvent.put(std::move(jetsTable),"jets");
iEvent.put(std::move(muonsTable),"muons");
diff --git a/PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc b/PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc
index f605147323cc2..9db6aa7d21033 100644
--- a/PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc
+++ b/PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc
@@ -185,7 +185,7 @@ NanoAODOutputModule::writeRun(edm::RunForOutput const& iRun) {
for (auto & t : m_runTables) t.fill(iRun,*m_runTree);
- edm::Handle hstring;
+ edm::Handle hstring;
for (const auto & p : m_nanoMetadata) {
iRun.getByToken(p.second, hstring);
TObjString *tos = dynamic_cast(m_file->Get(p.first.c_str()));
@@ -237,7 +237,7 @@ NanoAODOutputModule::openFile(edm::FileBlock const&) {
m_runTables.clear();
const auto & keeps = keptProducts();
for (const auto & keep : keeps[edm::InEvent]) {
- if(keep.first->className() == "FlatTable" )
+ if(keep.first->className() == "nanoaod::FlatTable" )
m_tables.emplace_back(keep.first, keep.second);
else if(keep.first->className() == "edm::TriggerResults" )
{
@@ -247,9 +247,9 @@ NanoAODOutputModule::openFile(edm::FileBlock const&) {
}
for (const auto & keep : keeps[edm::InRun]) {
- if(keep.first->className() == "MergeableCounterTable" )
+ if(keep.first->className() == "nanoaod::MergeableCounterTable" )
m_runTables.push_back(SummaryTableOutputBranches(keep.first, keep.second));
- else if(keep.first->className() == "UniqueString" && keep.first->moduleLabel() == "nanoMetadata")
+ else if(keep.first->className() == "nanoaod::UniqueString" && keep.first->moduleLabel() == "nanoMetadata")
m_nanoMetadata.emplace_back(keep.first->productInstanceName(), keep.second);
else throw cms::Exception("Configuration", "NanoAODOutputModule cannot handle class " + keep.first->className() + " in Run branch");
}
diff --git a/PhysicsTools/NanoAOD/plugins/NativeArrayTableProducer.cc b/PhysicsTools/NanoAOD/plugins/NativeArrayTableProducer.cc
index 96bda47e3c1e9..6ce265f7e2638 100644
--- a/PhysicsTools/NanoAOD/plugins/NativeArrayTableProducer.cc
+++ b/PhysicsTools/NanoAOD/plugins/NativeArrayTableProducer.cc
@@ -4,7 +4,7 @@
#include
-template
+template