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 class NativeArrayTableProducer : public edm::stream::EDProducer<> { public: @@ -13,7 +13,7 @@ class NativeArrayTableProducer : public edm::stream::EDProducer<> { doc_(params.existsAs("doc") ? params.getParameter("doc") : ""), src_(consumes( params.getParameter("src") )) { - produces(); + produces(); } ~NativeArrayTableProducer() override {} @@ -23,7 +23,7 @@ class NativeArrayTableProducer : public edm::stream::EDProducer<> { iEvent.getByToken(src_, src); const auto & in = *src; - auto out = std::make_unique(in.size(), name_, false, false); + auto out = std::make_unique(in.size(), name_, false, false); out->setDoc(doc_); (*out).template addColumn(this->name_, in, this->doc_, CT); iEvent.put(std::move(out)); @@ -35,10 +35,10 @@ class NativeArrayTableProducer : public edm::stream::EDProducer<> { const edm::EDGetTokenT src_; }; -typedef NativeArrayTableProducer,float,FlatTable::FloatColumn> FloatArrayTableProducer; -typedef NativeArrayTableProducer,float,FlatTable::FloatColumn> DoubleArrayTableProducer; -typedef NativeArrayTableProducer,int,FlatTable::IntColumn> IntArrayTableProducer; -typedef NativeArrayTableProducer,uint8_t,FlatTable::UInt8Column> BoolArrayTableProducer; +typedef NativeArrayTableProducer,float,nanoaod::FlatTable::FloatColumn> FloatArrayTableProducer; +typedef NativeArrayTableProducer,float,nanoaod::FlatTable::FloatColumn> DoubleArrayTableProducer; +typedef NativeArrayTableProducer,int,nanoaod::FlatTable::IntColumn> IntArrayTableProducer; +typedef NativeArrayTableProducer,uint8_t,nanoaod::FlatTable::UInt8Column> BoolArrayTableProducer; #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(FloatArrayTableProducer); diff --git a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducer.cc b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducer.cc index 05ce64638e86a..68a96105d6b3f 100644 --- a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducer.cc @@ -25,27 +25,27 @@ class SimpleFlatTableProducerBase : 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)); - else if (type == "float") vars_.push_back(new FloatVar(vname, FlatTable::FloatColumn, varPSet)); - else if (type == "uint8") vars_.push_back(new BoolVar(vname, FlatTable::UInt8Column, varPSet)); - else if (type == "bool") vars_.push_back(new BoolVar(vname, FlatTable::BoolColumn, varPSet)); + if (type == "int") vars_.push_back(new IntVar(vname, nanoaod::FlatTable::IntColumn, varPSet)); + else if (type == "float") vars_.push_back(new FloatVar(vname, nanoaod::FlatTable::FloatColumn, varPSet)); + else if (type == "uint8") vars_.push_back(new BoolVar(vname, nanoaod::FlatTable::UInt8Column, varPSet)); + else if (type == "bool") vars_.push_back(new BoolVar(vname, nanoaod::FlatTable::BoolColumn, varPSet)); else throw cms::Exception("Configuration", "unsupported type "+type+" for variable "+vname); } - produces(); + produces(); } ~SimpleFlatTableProducerBase() override {} // this is to be overriden by the child class - virtual std::unique_ptr fillTable(const edm::Event &iEvent, const edm::Handle & prod) const = 0; + virtual std::unique_ptr fillTable(const edm::Event &iEvent, const edm::Handle & prod) const = 0; void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override { edm::Handle src; iEvent.getByToken(src_, src); - std::unique_ptr out = fillTable(iEvent, src); + std::unique_ptr out = fillTable(iEvent, src); out->setDoc(doc_); iEvent.put(std::move(out)); @@ -59,32 +59,32 @@ class SimpleFlatTableProducerBase : public edm::stream::EDProducer<> { class VariableBase { public: - VariableBase(const std::string & aname, FlatTable::ColumnType atype, const edm::ParameterSet & cfg) : + VariableBase(const std::string & aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet & cfg) : name_(aname), doc_(cfg.getParameter("doc")), type_(atype), precision_(cfg.existsAs("precision") ? cfg.getParameter("precision") : -1) { } virtual ~VariableBase() {} 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_; int precision_; }; class Variable : public VariableBase { 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) : VariableBase(aname, atype, cfg) {} - virtual void fill(std::vector selobjs, FlatTable & out) const = 0; + virtual void fill(std::vector selobjs, nanoaod::FlatTable & out) const = 0; }; template class FuncVariable : public Variable { public: - FuncVariable(const std::string & aname, FlatTable::ColumnType atype, const edm::ParameterSet & cfg) : + FuncVariable(const std::string & aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet & cfg) : Variable(aname, atype, cfg), func_(cfg.getParameter("expr"), true) {} ~FuncVariable() override {} - void fill(std::vector selobjs, FlatTable & out) const override { + void fill(std::vector selobjs, nanoaod::FlatTable & out) const override { std::vector vals(selobjs.size()); for (unsigned int i = 0, n = vals.size(); i < n; ++i) { vals[i] = func_(*selobjs[i]); @@ -117,11 +117,11 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase()) { const auto & varPSet = extvarsPSet.getParameter(vname); const std::string & type = varPSet.getParameter("type"); - if (type == "int") extvars_.push_back(new IntExtVar(vname, FlatTable::IntColumn, varPSet, this->consumesCollector())); - else if (type == "float") extvars_.push_back(new FloatExtVar(vname, FlatTable::FloatColumn, varPSet, this->consumesCollector())); - else if (type == "double") extvars_.push_back(new DoubleExtVar(vname, FlatTable::FloatColumn, varPSet, this->consumesCollector())); - else if (type == "uint8") extvars_.push_back(new UInt8ExtVar(vname, FlatTable::UInt8Column, varPSet, this->consumesCollector())); - else if (type == "bool") extvars_.push_back(new BoolExtVar(vname, FlatTable::BoolColumn, varPSet, this->consumesCollector())); + if (type == "int") extvars_.push_back(new IntExtVar(vname, nanoaod::FlatTable::IntColumn, varPSet, this->consumesCollector())); + else if (type == "float") extvars_.push_back(new FloatExtVar(vname, nanoaod::FlatTable::FloatColumn, varPSet, this->consumesCollector())); + else if (type == "double") extvars_.push_back(new DoubleExtVar(vname, nanoaod::FlatTable::FloatColumn, varPSet, this->consumesCollector())); + else if (type == "uint8") extvars_.push_back(new UInt8ExtVar(vname, nanoaod::FlatTable::UInt8Column, varPSet, this->consumesCollector())); + else if (type == "bool") extvars_.push_back(new BoolExtVar(vname, nanoaod::FlatTable::BoolColumn, varPSet, this->consumesCollector())); else throw cms::Exception("Configuration", "unsupported type "+type+" for variable "+vname); } } @@ -129,7 +129,7 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase fillTable(const edm::Event &iEvent, const edm::Handle> & prod) const override { + std::unique_ptr fillTable(const edm::Event &iEvent, const edm::Handle> & prod) const override { std::vector selobjs; std::vector> selptrs; // for external variables if (singleton_) { @@ -146,7 +146,7 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase=maxLen_) break; } } - auto out = std::make_unique(selobjs.size(), this->name_, singleton_, this->extension_); + auto out = std::make_unique(selobjs.size(), this->name_, singleton_, this->extension_); for (const auto & var : this->vars_) var.fill(selobjs, *out); for (const auto & var : this->extvars_) var.fill(iEvent, selptrs, *out); return out; @@ -159,16 +159,16 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase> selptrs, FlatTable & out) const = 0; + virtual void fill(const edm::Event & iEvent, std::vector> selptrs, nanoaod::FlatTable & out) const = 0; }; template class ValueMapVariable : public ExtVariable { public: - ValueMapVariable(const std::string & aname, FlatTable::ColumnType atype, const edm::ParameterSet & cfg, edm::ConsumesCollector && cc) : + ValueMapVariable(const std::string & aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet & cfg, edm::ConsumesCollector && cc) : ExtVariable(aname, atype, cfg), token_(cc.consumes>(cfg.getParameter("src"))) {} - void fill(const edm::Event & iEvent, std::vector> selptrs, FlatTable & out) const override { + void fill(const edm::Event & iEvent, std::vector> selptrs, nanoaod::FlatTable & out) const override { edm::Handle> vmap; iEvent.getByToken(token_, vmap); std::vector vals(selptrs.size()); @@ -197,8 +197,8 @@ class EventSingletonSimpleFlatTableProducer : public SimpleFlatTableProducerBase virtual ~EventSingletonSimpleFlatTableProducer() {} - std::unique_ptr fillTable(const edm::Event &, const edm::Handle & prod) const override { - auto out = std::make_unique(1, this->name_, true, this->extension_); + std::unique_ptr fillTable(const edm::Event &, const edm::Handle & prod) const override { + auto out = std::make_unique(1, this->name_, true, this->extension_); std::vector selobjs(1, prod->product()); for (const auto & var : this->vars_) var.fill(selobjs, *out); return out; @@ -213,8 +213,8 @@ class FirstObjectSimpleFlatTableProducer : public SimpleFlatTableProducerBase fillTable(const edm::Event &iEvent, const edm::Handle> & prod) const override { - auto out = std::make_unique(1, this->name_, true, this->extension_); + std::unique_ptr fillTable(const edm::Event &iEvent, const edm::Handle> & prod) const override { + auto out = std::make_unique(1, this->name_, true, this->extension_); std::vector selobjs(1, & (*prod)[0]); for (const auto & var : this->vars_) var.fill(selobjs, *out); return out; diff --git a/PhysicsTools/NanoAOD/plugins/SummaryTableOutputBranches.cc b/PhysicsTools/NanoAOD/plugins/SummaryTableOutputBranches.cc index 811c485610411..4fa92cc6a6679 100644 --- a/PhysicsTools/NanoAOD/plugins/SummaryTableOutputBranches.cc +++ b/PhysicsTools/NanoAOD/plugins/SummaryTableOutputBranches.cc @@ -46,7 +46,7 @@ SummaryTableOutputBranches::fillVectorBranches(const std::vector & tabcols, void -SummaryTableOutputBranches::defineBranchesFromFirstEvent(const MergeableCounterTable & tab, TTree & tree) +SummaryTableOutputBranches::defineBranchesFromFirstEvent(const nanoaod::MergeableCounterTable & tab, TTree & tree) { makeScalarBranches(tab.intCols(), tree, "L", m_intBranches); makeScalarBranches(tab.floatCols(), tree, "D", m_floatBranches); @@ -61,9 +61,9 @@ SummaryTableOutputBranches::defineBranchesFromFirstEvent(const MergeableCounterT void SummaryTableOutputBranches::fill(const edm::OccurrenceForOutput &iWhatever, TTree & tree) { - edm::Handle handle; + edm::Handle handle; iWhatever.getByToken(m_token, handle); - const MergeableCounterTable & tab = *handle; + const nanoaod::MergeableCounterTable & tab = *handle; if(!m_branchesBooked) { defineBranchesFromFirstEvent(tab, tree); diff --git a/PhysicsTools/NanoAOD/plugins/SummaryTableOutputBranches.h b/PhysicsTools/NanoAOD/plugins/SummaryTableOutputBranches.h index 99dda07f4bb2a..1bbd5ecaef2dc 100644 --- a/PhysicsTools/NanoAOD/plugins/SummaryTableOutputBranches.h +++ b/PhysicsTools/NanoAOD/plugins/SummaryTableOutputBranches.h @@ -14,7 +14,7 @@ class SummaryTableOutputBranches { SummaryTableOutputBranches(const edm::BranchDescription *desc, const edm::EDGetToken & token ) : m_token(token), m_branchesBooked(false) { - if (desc->className() != "MergeableCounterTable") throw cms::Exception("Configuration", "NanoAODOutputModule can only write out MergableCounterTable objects"); + if (desc->className() != "nanoaod::MergeableCounterTable") throw cms::Exception("Configuration", "NanoAODOutputModule can only write out MergableCounterTable objects"); } void fill(const edm::OccurrenceForOutput &iWhatever, TTree & tree) ; @@ -40,7 +40,7 @@ class SummaryTableOutputBranches { bool m_branchesBooked; - void defineBranchesFromFirstEvent(const MergeableCounterTable & tab, TTree & tree) ; + void defineBranchesFromFirstEvent(const nanoaod::MergeableCounterTable & tab, TTree & tree) ; template void makeScalarBranches(const std::vector & tabcols, TTree & tree, const std::string & rootType, std::vector & branches); template void makeVectorBranches(const std::vector & tabcols, TTree & tree, const std::string & rootType, std::vector & branches ); diff --git a/PhysicsTools/NanoAOD/plugins/TableOutputBranches.cc b/PhysicsTools/NanoAOD/plugins/TableOutputBranches.cc index 690e101373839..6687c23980778 100644 --- a/PhysicsTools/NanoAOD/plugins/TableOutputBranches.cc +++ b/PhysicsTools/NanoAOD/plugins/TableOutputBranches.cc @@ -11,22 +11,22 @@ namespace { } void -TableOutputBranches::defineBranchesFromFirstEvent(const FlatTable & tab) +TableOutputBranches::defineBranchesFromFirstEvent(const nanoaod::FlatTable & tab) { m_baseName=tab.name(); for(size_t i=0;i handle; + edm::Handle handle; iEvent.getByToken(m_token, handle); - const FlatTable & tab = *handle; + const nanoaod::FlatTable & tab = *handle; m_counter = tab.size(); m_singleton = tab.singleton(); if(!m_branchesBooked) { diff --git a/PhysicsTools/NanoAOD/plugins/TableOutputBranches.h b/PhysicsTools/NanoAOD/plugins/TableOutputBranches.h index e461760366f78..684cf8cfeddc8 100644 --- a/PhysicsTools/NanoAOD/plugins/TableOutputBranches.h +++ b/PhysicsTools/NanoAOD/plugins/TableOutputBranches.h @@ -14,10 +14,10 @@ class TableOutputBranches { TableOutputBranches(const edm::BranchDescription *desc, const edm::EDGetToken & token ) : m_token(token), m_extension(DontKnowYetIfMainOrExtension), m_branchesBooked(false) { - if (desc->className() != "FlatTable") throw cms::Exception("Configuration", "NanoAODOutputModule can only write out FlatTable objects"); + if (desc->className() != "nanoaod::FlatTable") throw cms::Exception("Configuration", "NanoAODOutputModule can only write out nanoaod::FlatTable objects"); } - void defineBranchesFromFirstEvent(const FlatTable & tab) ; + void defineBranchesFromFirstEvent(const nanoaod::FlatTable & tab) ; void branch(TTree &tree) ; /// Fill the current table, if extensions == table.extension(). @@ -44,7 +44,7 @@ class TableOutputBranches { bool m_branchesBooked; template - void fillColumn(NamedBranchPtr & pair, const FlatTable & tab) { + void fillColumn(NamedBranchPtr & pair, const nanoaod::FlatTable & tab) { int idx = tab.columnIndex(pair.name); if (idx == -1) throw cms::Exception("LogicError", "Missing column in input for "+m_baseName+"_"+pair.name); pair.branch->SetAddress( const_cast(& tab.columnData(idx).front() ) ); // SetAddress should take a const * ! diff --git a/PhysicsTools/NanoAOD/plugins/TriggerObjectTableProducer.cc b/PhysicsTools/NanoAOD/plugins/TriggerObjectTableProducer.cc index 5dc83dbff801b..4dc5def91ada0 100644 --- a/PhysicsTools/NanoAOD/plugins/TriggerObjectTableProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/TriggerObjectTableProducer.cc @@ -39,7 +39,7 @@ class TriggerObjectTableProducer : public edm::global::EDProducer<> { idDoc_ = idstr.str(); bitsDoc_ = qualitystr.str(); - produces(); + produces(); } ~TriggerObjectTableProducer() override {} @@ -136,14 +136,14 @@ TriggerObjectTableProducer::produce(edm::StreamID, edm::Event& iEvent, const edm } } - auto tab = std::make_unique(nobj, name_, false, false); - tab->addColumn("id", id, idDoc_, FlatTable::IntColumn); - tab->addColumn("pt", pt, "pt", FlatTable::FloatColumn, 12); - tab->addColumn("eta", eta, "eta", FlatTable::FloatColumn, 12); - tab->addColumn("phi", phi, "phi", FlatTable::FloatColumn, 12); - tab->addColumn("l1pt", l1pt, "pt of associated L1 seed", FlatTable::FloatColumn, 10); - tab->addColumn("l2pt", l2pt, "pt of associated 'L2' seed (i.e. HLT before tracking/PF)", FlatTable::FloatColumn, 10); - tab->addColumn("filterBits", bits, "extra bits of associated information: "+bitsDoc_, FlatTable::FloatColumn, 10); + auto tab = std::make_unique(nobj, name_, false, false); + tab->addColumn("id", id, idDoc_, nanoaod::FlatTable::IntColumn); + tab->addColumn("pt", pt, "pt", nanoaod::FlatTable::FloatColumn, 12); + tab->addColumn("eta", eta, "eta", nanoaod::FlatTable::FloatColumn, 12); + tab->addColumn("phi", phi, "phi", nanoaod::FlatTable::FloatColumn, 12); + tab->addColumn("l1pt", l1pt, "pt of associated L1 seed", nanoaod::FlatTable::FloatColumn, 10); + tab->addColumn("l2pt", l2pt, "pt of associated 'L2' seed (i.e. HLT before tracking/PF)", nanoaod::FlatTable::FloatColumn, 10); + tab->addColumn("filterBits", bits, "extra bits of associated information: "+bitsDoc_, nanoaod::FlatTable::FloatColumn, 10); iEvent.put(std::move(tab)); } diff --git a/PhysicsTools/NanoAOD/plugins/TriggerOutputBranches.cc b/PhysicsTools/NanoAOD/plugins/TriggerOutputBranches.cc index 54aa22a1213cf..efa9adf312335 100644 --- a/PhysicsTools/NanoAOD/plugins/TriggerOutputBranches.cc +++ b/PhysicsTools/NanoAOD/plugins/TriggerOutputBranches.cc @@ -10,7 +10,7 @@ TriggerOutputBranches::updateTriggerNames(TTree & tree, const edm::TriggerNames std::vector newNames(triggers.getTriggerNames()); if(newNames.empty()) { for(unsigned int j=0;jSetTitle(nb.title.c_str()); - nb.idx=j; + nb.idx=j; m_triggerBranches.push_back(nb); - for(size_t i=0;iFill(); // Back fill + for(size_t i=0;iFill(); // Back fill } - } + } } } @@ -75,8 +75,8 @@ void TriggerOutputBranches::fill(const edm::EventForOutput &iEvent,TTree & tree) const edm::TriggerNames &names = triggerNames(triggers); if(m_lastRun!=iEvent.id().run()) { - m_lastRun=iEvent.id().run(); - updateTriggerNames(tree,names,triggers); + m_lastRun=iEvent.id().run(); + updateTriggerNames(tree,names,triggers); } for (auto & pair : m_triggerBranches) fillColumn(pair, triggers); m_fills++; diff --git a/PhysicsTools/NanoAOD/plugins/UniqueStringProducer.cc b/PhysicsTools/NanoAOD/plugins/UniqueStringProducer.cc index 266bb1239dcb3..ba4615e79a3bd 100644 --- a/PhysicsTools/NanoAOD/plugins/UniqueStringProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/UniqueStringProducer.cc @@ -11,7 +11,7 @@ class UniqueStringProducer : public edm::global::EDProducer("strings"); for (const std::string & vname : strings.getParameterNamesForType()) { strings_.emplace_back(vname, strings.getParameter(vname)); - produces(vname); + produces(vname); } } @@ -21,7 +21,7 @@ class UniqueStringProducer : public edm::global::EDProducer(pair.second), pair.first); + iRun.put(std::make_unique(pair.second), pair.first); } } diff --git a/PhysicsTools/NanoAOD/plugins/VIDNestedWPBitmapProducer.cc b/PhysicsTools/NanoAOD/plugins/VIDNestedWPBitmapProducer.cc index 4774d9298dd34..51f41b400b82d 100644 --- a/PhysicsTools/NanoAOD/plugins/VIDNestedWPBitmapProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/VIDNestedWPBitmapProducer.cc @@ -48,7 +48,7 @@ class VIDNestedWPBitmapProducer : public edm::stream::EDProducer<> { { auto vwp = iConfig.getParameter>("WorkingPoints"); for (auto wp : vwp) { - src_bitmaps_.push_back(consumes >(edm::InputTag(wp+std::string("Bitmap")))); + src_bitmaps_.push_back(consumes >(edm::InputTag(wp+std::string("Bitmap")))); src_cutflows_.push_back(consumes >(edm::InputTag(wp))); } nWP = src_bitmaps_.size(); @@ -71,16 +71,16 @@ class VIDNestedWPBitmapProducer : public edm::stream::EDProducer<> { // ----------member data --------------------------- edm::EDGetTokenT> src_; - std::vector > > src_bitmaps_; + std::vector > > src_bitmaps_; std::vector > > src_cutflows_; - unsigned nWP; - unsigned nBits; - unsigned nCuts; - std::vector res_; + unsigned int nWP; + unsigned int nBits; + unsigned int nCuts; + std::vector res_; bool isInit_; - void initNCuts(unsigned); + void initNCuts(unsigned int); }; @@ -100,22 +100,22 @@ VIDNestedWPBitmapProducer::produce(edm::Event& iEvent, const edm::EventSetup& edm::Handle> src; iEvent.getByToken(src_, src); - std::vector>> src_bitmaps(nWP); - for (uint i=0; i>> src_bitmaps(nWP); + for (unsigned int i=0; i>> src_cutflows(nWP); - for (uint i=0; i res; + std::vector res; auto npho = src->size(); - for (uint i=0; iptrAt(i); - for (uint j=0; j>k & 1) { if (res_[k]!=j) throw cms::Exception("Configuration","Trying to compress VID bitmaps which are not nested in the correct order for all cuts"); @@ -125,7 +125,7 @@ VIDNestedWPBitmapProducer::produce(edm::Event& iEvent, const edm::EventSetup& } int out = 0; - for (uint k=0; k::produce(edm::Event& iEvent, const edm::EventSetup& template void -VIDNestedWPBitmapProducer::initNCuts(uint n){ +VIDNestedWPBitmapProducer::initNCuts(unsigned int n){ nCuts = n; nBits = ceil(log2(nWP+1)); if (nBits*nCuts>sizeof(int)*8) throw cms::Exception("Configuration","Integer cannot contain the compressed VID bitmap information"); diff --git a/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc b/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc index de1835b314e13..6cde1a339f5c4 100644 --- a/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc @@ -92,9 +92,9 @@ VertexTableProducer::VertexTableProducer(const edm::ParameterSet& params): dlenSigMin_(params.getParameter("dlenSigMin") ) { - produces("pv"); - produces("otherPVs"); - produces("svs"); + produces("pv"); + produces("otherPVs"); + produces("svs"); produces >(); } @@ -124,19 +124,19 @@ VertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) edm::Handle> pvsIn; iEvent.getByToken(pvs_, pvsIn); iEvent.getByToken(pvsScore_, pvsScoreIn); - auto pvTable = std::make_unique(1,pvName_,true); - pvTable->addColumnValue("ndof",(*pvsIn)[0].ndof(),"main primary vertex number of degree of freedom",FlatTable::FloatColumn,8); - pvTable->addColumnValue("x",(*pvsIn)[0].position().x(),"main primary vertex position x coordinate",FlatTable::FloatColumn,10); - pvTable->addColumnValue("y",(*pvsIn)[0].position().y(),"main primary vertex position y coordinate",FlatTable::FloatColumn,10); - pvTable->addColumnValue("z",(*pvsIn)[0].position().z(),"main primary vertex position z coordinate",FlatTable::FloatColumn,16); - pvTable->addColumnValue("chi2",(*pvsIn)[0].normalizedChi2(),"main primary vertex reduced chi2",FlatTable::FloatColumn,8); - pvTable->addColumnValue("npvs",(*pvsIn).size(),"total number of reconstructed primary vertices",FlatTable::IntColumn); - pvTable->addColumnValue("score",(*pvsScoreIn).get(pvsIn.id(),0),"main primary vertex score, i.e. sum pt2 of clustered objects",FlatTable::FloatColumn,8); - - auto otherPVsTable = std::make_unique((*pvsIn).size() >4?3:(*pvsIn).size()-1,"Other"+pvName_,false); + auto pvTable = std::make_unique(1,pvName_,true); + pvTable->addColumnValue("ndof",(*pvsIn)[0].ndof(),"main primary vertex number of degree of freedom",nanoaod::FlatTable::FloatColumn,8); + pvTable->addColumnValue("x",(*pvsIn)[0].position().x(),"main primary vertex position x coordinate",nanoaod::FlatTable::FloatColumn,10); + pvTable->addColumnValue("y",(*pvsIn)[0].position().y(),"main primary vertex position y coordinate",nanoaod::FlatTable::FloatColumn,10); + pvTable->addColumnValue("z",(*pvsIn)[0].position().z(),"main primary vertex position z coordinate",nanoaod::FlatTable::FloatColumn,16); + pvTable->addColumnValue("chi2",(*pvsIn)[0].normalizedChi2(),"main primary vertex reduced chi2",nanoaod::FlatTable::FloatColumn,8); + pvTable->addColumnValue("npvs",(*pvsIn).size(),"total number of reconstructed primary vertices",nanoaod::FlatTable::IntColumn); + pvTable->addColumnValue("score",(*pvsScoreIn).get(pvsIn.id(),0),"main primary vertex score, i.e. sum pt2 of clustered objects",nanoaod::FlatTable::FloatColumn,8); + + auto otherPVsTable = std::make_unique((*pvsIn).size() >4?3:(*pvsIn).size()-1,"Other"+pvName_,false); std::vector pvsz; for(size_t i=1;i < (*pvsIn).size() && i < 4; i++) pvsz.push_back((*pvsIn)[i-1].position().z()); - otherPVsTable->addColumn("z",pvsz,"Z position of other primary vertices, excluding the main PV",FlatTable::FloatColumn,8); + otherPVsTable->addColumn("z",pvsz,"Z position of other primary vertices, excluding the main PV",nanoaod::FlatTable::FloatColumn,8); edm::Handle > svsIn; @@ -149,21 +149,21 @@ VertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (const auto & sv : *svsIn) { if (svCut_(sv)) { Measurement1D dl= vdist.distance((*pvsIn)[0],VertexState(RecoVertex::convertPos(sv.position()),RecoVertex::convertError(sv.error()))); - if(dl.value() > dlenMin_ and dl.significance() > dlenSigMin_){ - dlen.push_back(dl.value()); - dlenSig.push_back(dl.significance()); - edm::Ptr c = svsIn->ptrAt(i); - selCandSv->push_back(c); - } + if(dl.value() > dlenMin_ and dl.significance() > dlenSigMin_){ + dlen.push_back(dl.value()); + dlenSig.push_back(dl.significance()); + edm::Ptr c = svsIn->ptrAt(i); + selCandSv->push_back(c); + } } i++; } - auto svsTable = std::make_unique(selCandSv->size(),svName_,false); + auto svsTable = std::make_unique(selCandSv->size(),svName_,false); // For SV we fill from here only stuff that cannot be created with the SimpleFlatTableProducer - svsTable->addColumn("dlen",dlen,"decay length in cm",FlatTable::FloatColumn,10); - svsTable->addColumn("dlenSig",dlenSig,"decay length significance",FlatTable::FloatColumn, 10); + svsTable->addColumn("dlen",dlen,"decay length in cm",nanoaod::FlatTable::FloatColumn,10); + svsTable->addColumn("dlenSig",dlenSig,"decay length significance",nanoaod::FlatTable::FloatColumn, 10); iEvent.put(std::move(pvTable),"pv"); diff --git a/PhysicsTools/NanoAOD/python/electrons_cff.py b/PhysicsTools/NanoAOD/python/electrons_cff.py index 1faa862480c85..ab19dcfdbd640 100644 --- a/PhysicsTools/NanoAOD/python/electrons_cff.py +++ b/PhysicsTools/NanoAOD/python/electrons_cff.py @@ -37,6 +37,7 @@ isoForEle = cms.EDProducer("EleIsoValueMapProducer", src = cms.InputTag("slimmedElectrons"), + relative = cms.bool(False), rho_MiniIso = cms.InputTag("fixedGridRhoFastjetCentralNeutral"), rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"), EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt"), @@ -144,12 +145,12 @@ mvaSpring16HZZ = Var("userFloat('mvaSpring16HZZ')",float,doc="MVA HZZ ID score"), mvaSpring16HZZ_WPL = Var("userInt('mvaSpring16HZZ_WPL')",bool,doc="MVA HZZ ID loose WP"), cutBased = Var("userInt('cutbasedID_veto')+userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",int,doc="cut-based ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"), - VIDNestedWPBitmap = Var("userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForEle_docstring), + vidNestedWPBitmap = Var("userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForEle_docstring), cutBased_HLTPreSel = Var("userInt('cutbasedID_HLT')",int,doc="cut-based HLT pre-selection ID"), - miniPFIso_chg = Var("userFloat('miniIsoChg')",float,doc="mini PF isolation, charged component"), - miniPFIso_all = Var("userFloat('miniIsoAll')",float,doc="mini PF isolation, total (with scaled rho*EA PU corrections)"), - PFIso03_chg = Var("userFloat('PFIsoChg')",float,doc="PF isolation dR=0.3, charged component"), - PFIso03_all = Var("userFloat('PFIsoAll')",float,doc="PF isolation dR=0.3, total (with rho*EA PU corrections)"), + miniPFRelIso_chg = Var("userFloat('miniIsoChg')/pt",float,doc="mini PF relative isolation, charged component"), + miniPFRelIso_all = Var("userFloat('miniIsoAll')/pt",float,doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"), + pfRelIso03_chg = Var("userFloat('PFIsoChg')/pt",float,doc="PF relative isolation dR=0.3, charged component"), + pfRelIso03_all = Var("userFloat('PFIsoAll')/pt",float,doc="PF relative isolation dR=0.3, total (with rho*EA PU corrections)"), hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8), tightCharge = Var("isGsfCtfScPixChargeConsistent() + isGsfScPixChargeConsistent()",int,doc="Tight charge criteria (0:none, 1:isGsfScPixChargeConsistent, 2:isGsfCtfScPixChargeConsistent)"), convVeto = Var("passConversionVeto()",bool,doc="pass conversion veto"), @@ -178,7 +179,7 @@ mcMap = cms.InputTag("electronsMCMatchForTable"), objName = electronTable.name, objType = electronTable.name, #cms.string("Electron"), - branchName = cms.string("mcMatch"), + branchName = cms.string("genPart"), docString = cms.string("MC matching to status==1 electrons or photons"), ) diff --git a/PhysicsTools/NanoAOD/python/isotracks_cff.py b/PhysicsTools/NanoAOD/python/isotracks_cff.py index 4a252509a4620..98194503e9b7a 100644 --- a/PhysicsTools/NanoAOD/python/isotracks_cff.py +++ b/PhysicsTools/NanoAOD/python/isotracks_cff.py @@ -13,6 +13,7 @@ isoForIsoTk = cms.EDProducer("IsoTrackIsoValueMapProducer", src = cms.InputTag("finalIsolatedTracks"), + relative = cms.bool(True), rho_MiniIso = cms.InputTag("fixedGridRhoFastjetCentralNeutral"), EAFile_MiniIso = cms.FileInPath("PhysicsTools/NanoAOD/data/effAreaMuons_cone03_pfNeuHadronsAndPhotons_80X.txt"), ) @@ -27,12 +28,12 @@ variables = cms.PSet(P3Vars, dz = Var("dz",float,doc="dz (with sign) wrt first PV, in cm",precision=10), dxy = Var("dxy",float,doc="dxy (with sign) wrt first PV, in cm",precision=10), - PFIso03_chg = Var("pfIsolationDR03().chargedHadronIso",float,doc="PF isolation dR=0.3, charged component",precision=10), - PFIso03_all = Var("(pfIsolationDR03().chargedHadronIso + max(pfIsolationDR03().neutralHadronIso + pfIsolationDR03().photonIso - pfIsolationDR03().puChargedHadronIso/2,0.0))",float,doc="PF isolation dR=0.3, total (deltaBeta corrections)",precision=10), + pfRelIso03_chg = Var("pfIsolationDR03().chargedHadronIso/pt",float,doc="PF relative isolation dR=0.3, charged component",precision=10), + pfRelIso03_all = Var("(pfIsolationDR03().chargedHadronIso + max(pfIsolationDR03().neutralHadronIso + pfIsolationDR03().photonIso - pfIsolationDR03().puChargedHadronIso/2,0.0))/pt",float,doc="PF relative isolation dR=0.3, total (deltaBeta corrections)",precision=10), ), externalVariables = cms.PSet( - miniPFIso_chg = ExtVar("isoForIsoTk:miniIsoChg",float,doc="mini PF isolation, charged component",precision=10), - miniPFIso_all = ExtVar("isoForIsoTk:miniIsoAll",float,doc="mini PF isolation, total (with scaled rho*EA PU corrections)",precision=10), + miniPFRelIso_chg = ExtVar("isoForIsoTk:miniIsoChg",float,doc="mini PF relative isolation, charged component",precision=10), + miniPFRelIso_all = ExtVar("isoForIsoTk:miniIsoAll",float,doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)",precision=10), ), ) diff --git a/PhysicsTools/NanoAOD/python/muons_cff.py b/PhysicsTools/NanoAOD/python/muons_cff.py index db7cdbadc5e76..ef9db95ed0351 100644 --- a/PhysicsTools/NanoAOD/python/muons_cff.py +++ b/PhysicsTools/NanoAOD/python/muons_cff.py @@ -3,6 +3,7 @@ isoForMu = cms.EDProducer("MuonIsoValueMapProducer", src = cms.InputTag("slimmedMuons"), + relative = cms.bool(False), rho_MiniIso = cms.InputTag("fixedGridRhoFastjetCentralNeutral"), EAFile_MiniIso = cms.FileInPath("PhysicsTools/NanoAOD/data/effAreaMuons_cone03_pfNeuHadronsAndPhotons_80X.txt"), ) @@ -72,10 +73,11 @@ segmentComp = Var("segmentCompatibility()", float, doc = "muon segment compatibility", precision=14), # keep higher precision since people have cuts with 3 digits on this nStations = Var("numberOfMatchedStations", int, doc = "number of matched stations with default arbitration (segment & track)"), jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"), - miniPFIso_chg = Var("userFloat('miniIsoChg')",float,doc="mini PF isolation, charged component"), - miniPFIso_all = Var("userFloat('miniIsoAll')",float,doc="mini PF isolation, total (with scaled rho*EA PU corrections)"), - PFIso03_chg = Var("pfIsolationR03().sumChargedHadronPt",float,doc="PF isolation dR=0.3, charged component"), - PFIso03_all = Var("(pfIsolationR03().sumChargedHadronPt + max(pfIsolationR03().sumNeutralHadronEt + pfIsolationR03().sumPhotonEt - pfIsolationR03().sumPUPt/2,0.0))",float,doc="PF isolation dR=0.3, total (deltaBeta corrections)"), + miniPFRelIso_chg = Var("userFloat('miniIsoChg')/pt",float,doc="mini PF relative isolation, charged component"), + miniPFRelIso_all = Var("userFloat('miniIsoAll')/pt",float,doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"), + pfRelIso03_chg = Var("pfIsolationR03().sumChargedHadronPt/pt",float,doc="PF relative isolation dR=0.3, charged component"), + pfRelIso03_all = Var("(pfIsolationR03().sumChargedHadronPt + max(pfIsolationR03().sumNeutralHadronEt + pfIsolationR03().sumPhotonEt - pfIsolationR03().sumPUPt/2,0.0))/pt",float,doc="PF relative isolation dR=0.3, total (deltaBeta corrections)"), + pfRelIso04_all = Var("(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt",float,doc="PF relative isolation dR=0.4, total (deltaBeta corrections)"), tightCharge = Var("?(muonBestTrack().ptError()/muonBestTrack().pt() < 0.2)?2:0",int,doc="Tight charge criterion using pterr/pt of muonBestTrack (0:fail, 2:pass)"), ), externalVariables = cms.PSet( @@ -107,7 +109,7 @@ mcMap = cms.InputTag("muonsMCMatchForTable"), objName = muonTable.name, objType = muonTable.name, #cms.string("Muon"), - branchName = cms.string("mcMatch"), + branchName = cms.string("genPart"), docString = cms.string("MC matching to status==1 muons"), ) diff --git a/PhysicsTools/NanoAOD/python/photons_cff.py b/PhysicsTools/NanoAOD/python/photons_cff.py index 53ed6a6b4303c..b367b65b87e32 100644 --- a/PhysicsTools/NanoAOD/python/photons_cff.py +++ b/PhysicsTools/NanoAOD/python/photons_cff.py @@ -37,6 +37,7 @@ isoForPho = cms.EDProducer("PhoIsoValueMapProducer", src = cms.InputTag("slimmedPhotons"), + relative = cms.bool(False), rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"), mapIsoChg = cms.InputTag("photonIDValueMapProducer:phoChargedIsolation"), mapIsoNeu = cms.InputTag("photonIDValueMapProducer:phoNeutralHadronIsolation"), @@ -94,14 +95,14 @@ r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=10), sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10), cutBased = Var("userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",int,doc="cut-based ID (0:fail, 1::loose, 2:medium, 3:tight)"), - VIDNestedWPBitmap = Var("userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForPho_docstring), + vidNestedWPBitmap = Var("userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForPho_docstring), electronVeto = Var("passElectronVeto()",bool,doc="pass electron veto"), pixelSeed = Var("hasPixelSeed()",bool,doc="has pixel seed"), mvaID = Var("userFloat('mvaID')",float,doc="MVA ID score",precision=10), mvaID_WP90 = Var("userInt('mvaID_WP90')",bool,doc="MVA ID WP90"), mvaID_WP80 = Var("userInt('mvaID_WP90')",bool,doc="MVA ID WP80"), - PFIso03_chg = Var("userFloat('PFIsoChg')",float,doc="PF isolation dR=0.3, charged component (with rho*EA PU corrections)"), - PFIso03_all = Var("userFloat('PFIsoAll')",float,doc="PF isolation dR=0.3, total (with rho*EA PU corrections)"), + pfRelIso03_chg = Var("userFloat('PFIsoChg')/pt",float,doc="PF relative isolation dR=0.3, charged component (with rho*EA PU corrections)"), + pfRelIso03_all = Var("userFloat('PFIsoAll')/pt",float,doc="PF relative isolation dR=0.3, total (with rho*EA PU corrections)"), hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8), ) ) @@ -124,7 +125,7 @@ mcMap = cms.InputTag("photonsMCMatchForTable"), objName = photonTable.name, objType = photonTable.name, #cms.string("Photon"), - branchName = cms.string("mcMatch"), + branchName = cms.string("genPart"), docString = cms.string("MC matching to status==1 photons or electrons"), ) diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index 31f98270fc8f9..9e6de49a2c0b3 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -128,7 +128,7 @@ def _tauId6WPMask(pattern,doc): mcMapVisTau = cms.InputTag("tausMCMatchHadTauForTable"), objName = tauTable.name, objType = tauTable.name, #cms.string("Tau"), - branchName = cms.string("mcMatch"), + branchName = cms.string("genPart"), docString = cms.string("MC matching to status==2 taus"), ) diff --git a/PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.cc b/PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.cc similarity index 84% rename from PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.cc rename to PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.cc index 94de717fb2b42..9f13f2f5f62cc 100644 --- a/PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.cc @@ -1,9 +1,9 @@ // -*- C++ -*- // -// Package: PhysicsTools/NanoAOD +// Package: PhysicsTools/PatAlgos // Class: BaseMVAValueMapProducer // -/**\class BaseMVAValueMapProducer BaseMVAValueMapProducer.cc PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.cc +/**\class BaseMVAValueMapProducer BaseMVAValueMapProducer.cc PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.cc Description: [one line class summary] @@ -23,7 +23,7 @@ #include "DataFormats/PatCandidates/interface/Jet.h" -#include "PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.h" +#include "PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.h" typedef BaseMVAValueMapProducer JetBaseMVAValueMapProducer; typedef BaseMVAValueMapProducer MuonBaseMVAValueMapProducer; diff --git a/PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.h b/PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.h similarity index 96% rename from PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.h rename to PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.h index 3582dd58f5d60..2944b638dafef 100644 --- a/PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.h +++ b/PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.h @@ -1,12 +1,12 @@ -#ifndef PhysicsTools_NanoAOD_BaseMVAValueMapProducer -#define PhysicsTools_NanoAOD_BaseMVAValueMapProducer +#ifndef PhysicsTools_PatAlgos_BaseMVAValueMapProducer +#define PhysicsTools_PatAlgos_BaseMVAValueMapProducer // -*- C++ -*- // -// Package: PhysicsTools/NanoAOD +// Package: PhysicsTools/PatAlgos // Class: BaseMVAValueMapProducer // -/**\class BaseMVAValueMapProducer BaseMVAValueMapProducer.cc PhysicsTools/NanoAOD/plugins/BaseMVAValueMapProducer.cc +/**\class BaseMVAValueMapProducer BaseMVAValueMapProducer.cc PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.cc Description: [one line class summary] diff --git a/PhysicsTools/NanoAOD/plugins/IsolatedTrackCleaner.cc b/PhysicsTools/PatAlgos/plugins/IsolatedTrackCleaner.cc similarity index 100% rename from PhysicsTools/NanoAOD/plugins/IsolatedTrackCleaner.cc rename to PhysicsTools/PatAlgos/plugins/IsolatedTrackCleaner.cc diff --git a/PhysicsTools/NanoAOD/plugins/LeptonUpdater.cc b/PhysicsTools/PatAlgos/plugins/LeptonUpdater.cc similarity index 100% rename from PhysicsTools/NanoAOD/plugins/LeptonUpdater.cc rename to PhysicsTools/PatAlgos/plugins/LeptonUpdater.cc diff --git a/PhysicsTools/NanoAOD/plugins/PATObjectCrossLinker.cc b/PhysicsTools/PatAlgos/plugins/PATObjectCrossLinker.cc similarity index 100% rename from PhysicsTools/NanoAOD/plugins/PATObjectCrossLinker.cc rename to PhysicsTools/PatAlgos/plugins/PATObjectCrossLinker.cc diff --git a/PhysicsTools/NanoAOD/plugins/PATObjectUserDataEmbedder.cc b/PhysicsTools/PatAlgos/plugins/PATObjectUserDataEmbedder.cc similarity index 100% rename from PhysicsTools/NanoAOD/plugins/PATObjectUserDataEmbedder.cc rename to PhysicsTools/PatAlgos/plugins/PATObjectUserDataEmbedder.cc