From 0b87cd043e270bdcc1e0ac3d79fb62d806074baa Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 21 Sep 2020 13:36:14 -0500 Subject: [PATCH 01/29] necessary additions to BuildFile for pps info --- PhysicsTools/NanoAOD/plugins/BuildFile.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PhysicsTools/NanoAOD/plugins/BuildFile.xml b/PhysicsTools/NanoAOD/plugins/BuildFile.xml index 8d4e3269834b9..b90cf33c63a40 100644 --- a/PhysicsTools/NanoAOD/plugins/BuildFile.xml +++ b/PhysicsTools/NanoAOD/plugins/BuildFile.xml @@ -17,6 +17,11 @@ + + + + + From 49d67330610c9946d1d26ad97df88ad0b76c4aa6 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 21 Sep 2020 13:57:26 -0500 Subject: [PATCH 02/29] added ProtonProducer version compatible with CMSSW_11_2_X --- .../NanoAOD/plugins/ProtonProducer.cc | 230 ++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 PhysicsTools/NanoAOD/plugins/ProtonProducer.cc diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc new file mode 100644 index 0000000000000..70b04d53f2b1f --- /dev/null +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -0,0 +1,230 @@ +// -*- C++ -*- +// +// Package: PhysicsTools/NanoAOD +// Class: ProtonProducer +// +/**\class ProtonProducer ProtonProducer.cc PhysicsTools/NanoAOD/plugins/ProtonProducer.cc + Description: Realavent proton variables for analysis usage + Implementation: +*/ +// +// Original Author: Justin Williams +// Created: 04 Jul 2019 15:27:53 GMT +// +// + +// system include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include "RecoEgamma/EgammaTools/interface/EffectiveAreas.h" + +#include "DataFormats/NanoAOD/interface/FlatTable.h" +#include "DataFormats/Common/interface/ValueMap.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" +#include "DataFormats/CTPPSReco/interface/CTPPSPixelLocalTrack.h" + +class ProtonProducer : public edm::global::EDProducer<> { +public: + ProtonProducer( edm::ParameterSet const & ps) : + tokenRecoProtonsSingleRP_(mayConsume(ps.getParameter("tagRecoProtonsSingle"))), + tokenRecoProtonsMultiRP_(mayConsume(ps.getParameter("tagRecoProtonsMulti"))), + tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))), + { + produces>("protonRPId"); + produces>("singleRPsector45"); + produces>("multiRPsector45"); + produces>("singleRPsector56"); + produces>("multiRPsector56"); + produces("ppsTrackTable"); + } + ~ProtonProducer() override {} + + // ------------ method called to produce the data ------------ + void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override { + + // Get Forward Proton handles + edm::Handle hRecoProtonsSingleRP; + iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); + + edm::Handle hRecoProtonsMultiRP; + iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); + + // Get PPS Local Track handle + edm::Handle > ppsTracksLite; + iEvent.getByToken( tokenTracksLite_, ppsTracksLite ); + + // book output variables for protons + std::vector singleRP_RPId; + std::vector singleRP_sector45, singleRP_sector56, multiRP_sector45, multiRP_sector56; + + // book output variables for tracks + std::vector trackX, trackXUnc, trackY, trackYUnc, trackTime, trackTimeUnc, localSlopeX, localSlopeY, normalizedChi2; + std::vector singleRPProtonIdx, multiRPProtonIdx, decRPId, numFitPoints, pixelRecoInfo, rpType; + + // process single-RP protons + { + const auto &num_proton = hRecoProtonsSingleRP->size(); + singleRP_RPId.reserve( num_proton ); + singleRP_sector45.reserve( num_proton ); + singleRP_sector56.reserve( num_proton ); + + for (const auto &proton : *hRecoProtonsSingleRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId()); + unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); + singleRP_RPId.push_back(rpDecId); + singleRP_sector45.push_back( (proton.pz() > 0.) ? true : false ); + singleRP_sector56.push_back( (proton.pz() < 0.) ? true : false ); + } + } + + // process multi-RP protons + { + const auto &num_proton = hRecoProtonsMultiRP->size(); + multiRP_sector45.reserve( num_proton ); + multiRP_sector56.reserve( num_proton ); + + for (const auto &proton : *hRecoProtonsMultiRP) + { + multiRP_sector45.push_back( (proton.pz() > 0.) ? true : false ); + multiRP_sector56.push_back( (proton.pz() < 0.) ? true : false ); + } + } + + // process local tracks + for (unsigned int tr_idx = 0; tr_idx < ppsTracksLite->size(); ++tr_idx) + { + const auto& tr = ppsTracksLite->at(tr_idx); + + CTPPSDetId rpId(tr.rpId()); + unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); + + decRPId.push_back(rpDecId); + rpType.push_back(rpId.subdetId()); + + trackX.push_back( tr.x() ); + trackXUnc.push_back( tr.xUnc() ); + trackY.push_back( tr.y() ); + trackYUnc.push_back( tr.yUnc() ); + trackTime.push_back( tr.time() ); + trackTimeUnc.push_back( tr.timeUnc() ); + numFitPoints.push_back( tr.numberOfPointsUsedForFit() ); + pixelRecoInfo.push_back( static_cast(tr.pixelTrackRecoInfo()) ); + normalizedChi2.push_back( tr.chiSquaredOverNDF() ); + localSlopeX.push_back( tr.tx() ); + localSlopeY.push_back( tr.ty() ); + + signed int singleRP_idx = -1; + for (unsigned int p_idx = 0; p_idx < hRecoProtonsSingleRP->size(); ++p_idx) + { + const auto &proton = hRecoProtonsSingleRP->at(p_idx); + + for (const auto &ref : proton.contributingLocalTracks()) + { + if (ref.key() == tr_idx) + singleRP_idx = p_idx; + } + } + singleRPProtonIdx.push_back(singleRP_idx); + + signed int multiRP_idx = -1; + for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) + { + const auto &proton = hRecoProtonsMultiRP->at(p_idx); + + for (const auto &ref : proton.contributingLocalTracks()) + { + if (ref.key() == tr_idx) + multiRP_idx = p_idx; + } + } + multiRPProtonIdx.push_back(multiRP_idx); + } + + // update proton tables + std::unique_ptr> protonRPIdV(new edm::ValueMap()); + edm::ValueMap::Filler fillerID(*protonRPIdV); + fillerID.insert(hRecoProtonsSingleRP, singleRP_RPId.begin(), singleRP_RPId.end()); + fillerID.fill(); + + std::unique_ptr> singleRP_sector45V(new edm::ValueMap()); + edm::ValueMap::Filler fillersingle45(*singleRP_sector45V); + fillersingle45.insert(hRecoProtonsSingleRP, singleRP_sector45.begin(), singleRP_sector45.end()); + fillersingle45.fill(); + + std::unique_ptr> singleRP_sector56V(new edm::ValueMap()); + edm::ValueMap::Filler fillersingle56(*singleRP_sector56V); + fillersingle56.insert(hRecoProtonsSingleRP, singleRP_sector56.begin(), singleRP_sector56.end()); + fillersingle56.fill(); + + std::unique_ptr> multiRP_sector45V(new edm::ValueMap()); + edm::ValueMap::Filler fillermulti45(*multiRP_sector45V); + fillermulti45.insert(hRecoProtonsMultiRP, multiRP_sector45.begin(), multiRP_sector45.end()); + fillermulti45.fill(); + + std::unique_ptr> multiRP_sector56V(new edm::ValueMap()); + edm::ValueMap::Filler fillermulti56(*multiRP_sector56V); + fillermulti56.insert(hRecoProtonsMultiRP, multiRP_sector56.begin(), multiRP_sector56.end()); + fillermulti56.fill(); + + // build track table + auto ppsTab = std::make_unique(trackX.size(), "PPSLocalTrack", false); + ppsTab->addColumn("singleRPProtonIdx",singleRPProtonIdx,"local track - proton correspondence",nanoaod::FlatTable::IntColumn); + ppsTab->addColumn("multiRPProtonIdx",multiRPProtonIdx,"local track - proton correspondence",nanoaod::FlatTable::IntColumn); + ppsTab->addColumn("x",trackX,"local track x",nanoaod::FlatTable::FloatColumn,16); + ppsTab->addColumn("xUnc",trackXUnc,"local track x uncertainty",nanoaod::FlatTable::FloatColumn,8); + ppsTab->addColumn("y",trackY,"local track y",nanoaod::FlatTable::FloatColumn,13); + ppsTab->addColumn("yUnc",trackYUnc,"local track y uncertainty",nanoaod::FlatTable::FloatColumn,8); + ppsTab->addColumn("time",trackTime,"local track time",nanoaod::FlatTable::FloatColumn,16); + ppsTab->addColumn("timeUnc",trackTimeUnc,"local track time uncertainty",nanoaod::FlatTable::FloatColumn,13); + ppsTab->addColumn("decRPId",decRPId,"local track detector dec id",nanoaod::FlatTable::IntColumn); + ppsTab->addColumn("numFitPoints",numFitPoints,"number of points used for fit",nanoaod::FlatTable::IntColumn); + ppsTab->addColumn("pixelRecoInfo",pixelRecoInfo,"flag if a ROC was shifted by a bunchx",nanoaod::FlatTable::IntColumn); + ppsTab->addColumn("normalizedChi2",normalizedChi2,"chi2 over NDF",nanoaod::FlatTable::FloatColumn,8); + ppsTab->addColumn("rpType",rpType,"strip=3, pixel=4, diamond=5, timing=6",nanoaod::FlatTable::IntColumn); + ppsTab->addColumn("localSlopeX",localSlopeX,"track horizontal angle",nanoaod::FlatTable::FloatColumn,11); + ppsTab->addColumn("localSlopeY",localSlopeY,"track vertical angle",nanoaod::FlatTable::FloatColumn,11); + ppsTab->setDoc("ppsLocalTrack variables"); + + // save output + iEvent.put(std::move(protonRPIdV), "protonRPId"); + iEvent.put(std::move(singleRP_sector45V), "singleRPsector45"); + iEvent.put(std::move(singleRP_sector56V), "singleRPsector56"); + iEvent.put(std::move(multiRP_sector45V), "multiRPsector45"); + iEvent.put(std::move(multiRP_sector56V), "multiRPsector56"); + iEvent.put(std::move(ppsTab), "ppsTrackTable"); + } + + // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions) { + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); + } + +protected: + const edm::EDGetTokenT tokenRecoProtonsSingleRP_; + const edm::EDGetTokenT tokenRecoProtonsMultiRP_; + const edm::EDGetTokenT > tokenTracksLite_; +}; + + +DEFINE_FWK_MODULE(ProtonProducer); From 47f2a92c3336e9824fa614063ffa5bf710e19e18 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 21 Sep 2020 14:16:12 -0500 Subject: [PATCH 03/29] added LHCInfoProducer to get conditions from LHC db --- .../NanoAOD/plugins/LHCInfoProducer.cc | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc diff --git a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc new file mode 100644 index 0000000000000..f8497a02bfd46 --- /dev/null +++ b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc @@ -0,0 +1,103 @@ +// -*- C++ -*- +// +// Package: PhysicsTools/NanoAOD +// Class: LHCInfoProducer +// +/**\class LHCInfoProducer LHCInfoProducer.cc PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc + Description: [one line class summary] + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Justin Williams +// Created: 05 Jul 2019 14:06:12 GMT +// +// + +// System include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" +#include "FWCore/Framework/interface/SourceFactory.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include "RecoEgamma/EgammaTools/interface/EffectiveAreas.h" + +#include "DataFormats/NanoAOD/interface/FlatTable.h" +#include "DataFormats/Common/interface/ValueMap.h" + +#include "FWCore/Utilities/interface/transform.h" + +// LHC Info +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" +#include "CondTools/RunInfo/interface/LHCInfoPopConSourceHandler.h" + +class LHCInfoProducer : public edm::global::EDProducer<> { +public: + LHCInfoProducer( edm::ParameterSet const & ps) : + precision_( ps.getParameter("precision") ) + { + produces("lhcInfoTab"); + } + ~LHCInfoProducer() override {} + + + // ------------ method called to produce the data ------------ + void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override { + + // Get LHCInfo handle + edm::ESHandle lhcInfo; + iSetup.get().get(lhcInfo); + + std::unique_ptr out = fillTable(iEvent, lhcInfo); + out->setDoc("LHC Info"); + + iEvent.put(std::move(out),"lhcInfoTab"); + + } + + std::unique_ptr fillTable(const edm::Event &iEvent, const edm::ESHandle & prod) const { + + const LHCInfo* info = prod.product(); + float crossingAngle = info->crossingAngle(); + float betaStar = info->betaStar(); + float energy = info->energy(); + + auto out = std::make_unique(1,"LHCInfo",true); + out->addColumnValue("crossingAngle", crossingAngle, "LHC crossing angle", nanoaod::FlatTable::FloatColumn,precision_); + out->addColumnValue("betaStar",betaStar,"LHC beta star", nanoaod::FlatTable::FloatColumn,precision_); + out->addColumnValue("energy",energy,"LHC beam energy", nanoaod::FlatTable::FloatColumn,precision_); + return out; + } + + // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ + + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions) { + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); + } + +protected: + const unsigned int precision_; +}; + + +DEFINE_FWK_MODULE(LHCInfoProducer); From bc14a01d2eb668b895ed19ef61a162ec41a43319 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 21 Sep 2020 14:18:53 -0500 Subject: [PATCH 04/29] updates SimpleFlatTableProducerPlugins to work with newly added proton tables --- .../NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc index 63ed401278769..5df583d99c311 100644 --- a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc +++ b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc @@ -9,7 +9,15 @@ typedef EventSingletonSimpleFlatTableProducer SimpleGenEven #include "SimDataFormats/HTXS/interface/HiggsTemplateCrossSections.h" typedef EventSingletonSimpleFlatTableProducer SimpleHTXSFlatTableProducer; +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +typedef SimpleFlatTableProducer SimpleProtonTrackFlatTableProducer; + +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +typedef SimpleFlatTableProducer SimpleLocalTrackFlatTableProducer; + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SimpleCandidateFlatTableProducer); DEFINE_FWK_MODULE(SimpleGenEventFlatTableProducer); DEFINE_FWK_MODULE(SimpleHTXSFlatTableProducer); +DEFINE_FWK_MODULE(SimpleProtonTrackFlatTableProducer); +DEFINE_FWK_MODULE(SimpleLocalTrackFlatTableProducer); From 6ac43cd3c358e8f57b1e2e9b75c3c5f15240fc82 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 21 Sep 2020 14:28:10 -0500 Subject: [PATCH 05/29] Added nanoSequenceOnlyData to introduce proton and lhcInfo variables. This was Mario's Peruzzi's idea to have this separate sequence. --- PhysicsTools/NanoAOD/python/nano_cff.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PhysicsTools/NanoAOD/python/nano_cff.py b/PhysicsTools/NanoAOD/python/nano_cff.py index 94a3eb282791e..c1b086fa34e55 100644 --- a/PhysicsTools/NanoAOD/python/nano_cff.py +++ b/PhysicsTools/NanoAOD/python/nano_cff.py @@ -16,6 +16,7 @@ from PhysicsTools.NanoAOD.met_cff import * from PhysicsTools.NanoAOD.triggerObjects_cff import * from PhysicsTools.NanoAOD.isotracks_cff import * +from PhysicsTools.NanoAOD.protons_cff import * from PhysicsTools.NanoAOD.NanoAODEDMEventContent_cff import * from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy @@ -93,6 +94,9 @@ ) ) +lhcInfoTable = cms.EDProducer("LHCInfoProducer", + precision = cms.int32(10), +) lheInfoTable = cms.EDProducer("LHETablesProducer", lheInfo = cms.VInputTag(cms.InputTag("externalLHEProducer"), cms.InputTag("source")), @@ -111,8 +115,9 @@ jetTables + muonTables + tauTables + electronTables + photonTables + globalTables +vertexTables+ metTables+simpleCleanerTable + isoTrackTables ) nanoSequenceOnlyFullSim = cms.Sequence(triggerObjectTables + l1bits) +nanoSequenceOnlyData = cms.Sequence(protonTables + lhcInfoTable) -nanoSequence = cms.Sequence(nanoSequenceCommon + nanoSequenceOnlyFullSim) +nanoSequence = cms.Sequence(nanoSequenceCommon + nanoSequenceOnlyData + nanoSequenceOnlyFullSim) nanoSequenceFS = cms.Sequence(genParticleSequence + particleLevelSequence + nanoSequenceCommon + jetMC + muonMC + electronMC + photonMC + tauMC + metMC + ttbarCatMCProducers + globalTablesMC + btagWeightTable + genWeightsTable + genParticleTables + particleLevelTables + lheInfoTable + ttbarCategoryTable ) From 6d2d78ba6c6ca947050a5244544686711147e4a4 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 21 Sep 2020 14:30:08 -0500 Subject: [PATCH 06/29] added proton table for singleRP and multiRP instances --- PhysicsTools/NanoAOD/python/protons_cff.py | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 PhysicsTools/NanoAOD/python/protons_cff.py diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py new file mode 100644 index 0000000000000..9a7c488b7f649 --- /dev/null +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -0,0 +1,64 @@ +import FWCore.ParameterSet.Config as cms +from PhysicsTools.NanoAOD.common_cff import * + +protonTable = cms.EDProducer("ProtonProducer", + tagRecoProtonsSingle = cms.InputTag("ctppsProtons", "singleRP"), + tagRecoProtonsMulti = cms.InputTag("ctppsProtons", "multiRP"), + tagTrackLite = cms.InputTag("ctppsLocalTrackLiteProducer") +) + +singleRPTable = cms.EDProducer("SimpleProtonTrackFlatTableProducer", + src = cms.InputTag("ctppsProtons","singleRP"), + cut = cms.string(""), + name = cms.string("Proton_singleRP"), + doc = cms.string("bon"), + singleton = cms.bool(False), + extension = cms.bool(False), + variables = cms.PSet( + xi = Var("xi",float,doc="xi or dp/p",precision=12), + xiUnc = Var("xiError",float,doc="uncertainty on xi or dp/p",precision=8), + thetaY = Var("thetaY",float,doc="th y",precision=13), + thetaYUnc = Var("thetaYError",float,doc="theta Y uncertainty",precision=8), + ), + externalVariables = cms.PSet( + decRPId = ExtVar("protonTable:protonRPId",int,doc="Detector ID",precision=8), + sector45 = ExtVar("protonTable:singleRPsector45",bool,doc="LHC sector 45"), + sector56 = ExtVar("protonTable:singleRPsector56",bool,doc="LHC sector 56"), + ), +) + +multiRPTable = cms.EDProducer("SimpleProtonTrackFlatTableProducer", + src = cms.InputTag("ctppsProtons","multiRP"), + cut = cms.string(""), + name = cms.string("Proton_multiRP"), + doc = cms.string("bon"), + singleton = cms.bool(False), + extension = cms.bool(False), + variables = cms.PSet( + xi = Var("xi",float,doc="xi or dp/p",precision=12), + xiUnc = Var("xiError",float,doc="uncertainty on xi or dp/p",precision=8), + vtxY = Var("vy()",float,doc="vertex y",precision=11), + vtxYUnc = Var("vyError",float,doc="vy Error",precision=8), + pt = Var("pt",float,doc="pt",precision=15), + thetaX = Var("thetaX",float,doc="theta x",precision=13), + thetaXUnc = Var("thetaXError",float,doc="theta X uncertainty",precision=8), + thetaY = Var("thetaY",float,doc="theta y",precision=13), + thetaYUnc = Var("thetaYError",float,doc="theta Y uncertainty",precision=8), + chi2 = Var("chi2",float,doc="chi 2",precision=15), + ndof = Var("ndof()",int, doc="n dof", precision=8), + t = Var("t",float,doc="t",precision=13), + validFit = Var("validFit",bool,doc="valid Fit"), + time = Var("time()",float,doc="time",precision=16), + timeUnc = Var("timeError",float,doc="time uncertainty",precision=13), + ), + externalVariables = cms.PSet( + sector45 = ExtVar("protonTable:multiRPsector45",bool,doc="LHC sector 45"), + sector56 = ExtVar("protonTable:multiRPsector56",bool,doc="LHC sector 56"), + ), +) + +protonTables = cms.Sequence( + protonTable + +singleRPTable + +multiRPTable +) From 08af7a7a0de724a226aebaf43dd22cdef0a9b21d Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 21 Sep 2020 14:52:01 -0500 Subject: [PATCH 07/29] removed FloatColumn, IntColumn, etc. to be compatible with 11_2_X --- .../NanoAOD/plugins/LHCInfoProducer.cc | 8 ++--- .../NanoAOD/plugins/ProtonProducer.cc | 34 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc index f8497a02bfd46..97ad33a50610f 100644 --- a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc @@ -37,7 +37,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/StreamID.h" -#include "RecoEgamma/EgammaTools/interface/EffectiveAreas.h" +#include "CommonTools/Egamma/interface/EffectiveAreas.h" #include "DataFormats/NanoAOD/interface/FlatTable.h" #include "DataFormats/Common/interface/ValueMap.h" @@ -81,9 +81,9 @@ class LHCInfoProducer : public edm::global::EDProducer<> { float energy = info->energy(); auto out = std::make_unique(1,"LHCInfo",true); - out->addColumnValue("crossingAngle", crossingAngle, "LHC crossing angle", nanoaod::FlatTable::FloatColumn,precision_); - out->addColumnValue("betaStar",betaStar,"LHC beta star", nanoaod::FlatTable::FloatColumn,precision_); - out->addColumnValue("energy",energy,"LHC beam energy", nanoaod::FlatTable::FloatColumn,precision_); + out->addColumnValue("crossingAngle", crossingAngle, "LHC crossing angle",precision_); + out->addColumnValue("betaStar",betaStar,"LHC beta star",precision_); + out->addColumnValue("energy",energy,"LHC beam energy",precision_); return out; } diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index 70b04d53f2b1f..b2a809d88dd9c 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -30,7 +30,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/StreamID.h" -#include "RecoEgamma/EgammaTools/interface/EffectiveAreas.h" +#include "CommonTools/Egamma/interface/EffectiveAreas.h" #include "DataFormats/NanoAOD/interface/FlatTable.h" #include "DataFormats/Common/interface/ValueMap.h" @@ -46,7 +46,7 @@ class ProtonProducer : public edm::global::EDProducer<> { ProtonProducer( edm::ParameterSet const & ps) : tokenRecoProtonsSingleRP_(mayConsume(ps.getParameter("tagRecoProtonsSingle"))), tokenRecoProtonsMultiRP_(mayConsume(ps.getParameter("tagRecoProtonsMulti"))), - tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))), + tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))) { produces>("protonRPId"); produces>("singleRPsector45"); @@ -187,21 +187,21 @@ class ProtonProducer : public edm::global::EDProducer<> { // build track table auto ppsTab = std::make_unique(trackX.size(), "PPSLocalTrack", false); - ppsTab->addColumn("singleRPProtonIdx",singleRPProtonIdx,"local track - proton correspondence",nanoaod::FlatTable::IntColumn); - ppsTab->addColumn("multiRPProtonIdx",multiRPProtonIdx,"local track - proton correspondence",nanoaod::FlatTable::IntColumn); - ppsTab->addColumn("x",trackX,"local track x",nanoaod::FlatTable::FloatColumn,16); - ppsTab->addColumn("xUnc",trackXUnc,"local track x uncertainty",nanoaod::FlatTable::FloatColumn,8); - ppsTab->addColumn("y",trackY,"local track y",nanoaod::FlatTable::FloatColumn,13); - ppsTab->addColumn("yUnc",trackYUnc,"local track y uncertainty",nanoaod::FlatTable::FloatColumn,8); - ppsTab->addColumn("time",trackTime,"local track time",nanoaod::FlatTable::FloatColumn,16); - ppsTab->addColumn("timeUnc",trackTimeUnc,"local track time uncertainty",nanoaod::FlatTable::FloatColumn,13); - ppsTab->addColumn("decRPId",decRPId,"local track detector dec id",nanoaod::FlatTable::IntColumn); - ppsTab->addColumn("numFitPoints",numFitPoints,"number of points used for fit",nanoaod::FlatTable::IntColumn); - ppsTab->addColumn("pixelRecoInfo",pixelRecoInfo,"flag if a ROC was shifted by a bunchx",nanoaod::FlatTable::IntColumn); - ppsTab->addColumn("normalizedChi2",normalizedChi2,"chi2 over NDF",nanoaod::FlatTable::FloatColumn,8); - ppsTab->addColumn("rpType",rpType,"strip=3, pixel=4, diamond=5, timing=6",nanoaod::FlatTable::IntColumn); - ppsTab->addColumn("localSlopeX",localSlopeX,"track horizontal angle",nanoaod::FlatTable::FloatColumn,11); - ppsTab->addColumn("localSlopeY",localSlopeY,"track vertical angle",nanoaod::FlatTable::FloatColumn,11); + ppsTab->addColumn("singleRPProtonIdx",singleRPProtonIdx,"local track - proton correspondence"); + ppsTab->addColumn("multiRPProtonIdx",multiRPProtonIdx,"local track - proton correspondence"); + ppsTab->addColumn("x",trackX,"local track x",16); + ppsTab->addColumn("xUnc",trackXUnc,"local track x uncertainty",8); + ppsTab->addColumn("y",trackY,"local track y",13); + ppsTab->addColumn("yUnc",trackYUnc,"local track y uncertainty",8); + ppsTab->addColumn("time",trackTime,"local track time",16); + ppsTab->addColumn("timeUnc",trackTimeUnc,"local track time uncertainty",13); + ppsTab->addColumn("decRPId",decRPId,"local track detector dec id"); + ppsTab->addColumn("numFitPoints",numFitPoints,"number of points used for fit"); + ppsTab->addColumn("pixelRecoInfo",pixelRecoInfo,"flag if a ROC was shifted by a bunchx"); + ppsTab->addColumn("normalizedChi2",normalizedChi2,"chi2 over NDF",8); + ppsTab->addColumn("rpType",rpType,"strip=3, pixel=4, diamond=5, timing=6"); + ppsTab->addColumn("localSlopeX",localSlopeX,"track horizontal angle",11); + ppsTab->addColumn("localSlopeY",localSlopeY,"track vertical angle",11); ppsTab->setDoc("ppsLocalTrack variables"); // save output From 458d1a50cb0b018c5eafd310473555591dd3f3d3 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Tue, 22 Sep 2020 07:33:09 -0500 Subject: [PATCH 08/29] patched code recommended by code-checks --- .../NanoAOD/plugins/LHCInfoProducer.cc | 23 +-- .../NanoAOD/plugins/ProtonProducer.cc | 195 +++++++++--------- 2 files changed, 102 insertions(+), 116 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc index 97ad33a50610f..72617ba9e8094 100644 --- a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc @@ -51,17 +51,13 @@ class LHCInfoProducer : public edm::global::EDProducer<> { public: - LHCInfoProducer( edm::ParameterSet const & ps) : - precision_( ps.getParameter("precision") ) - { + LHCInfoProducer(edm::ParameterSet const& ps) : precision_(ps.getParameter("precision")) { produces("lhcInfoTab"); } ~LHCInfoProducer() override {} - // ------------ method called to produce the data ------------ void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override { - // Get LHCInfo handle edm::ESHandle lhcInfo; iSetup.get().get(lhcInfo); @@ -69,27 +65,25 @@ class LHCInfoProducer : public edm::global::EDProducer<> { std::unique_ptr out = fillTable(iEvent, lhcInfo); out->setDoc("LHC Info"); - iEvent.put(std::move(out),"lhcInfoTab"); - + iEvent.put(std::move(out), "lhcInfoTab"); } - std::unique_ptr fillTable(const edm::Event &iEvent, const edm::ESHandle & prod) const { - + std::unique_ptr fillTable(const edm::Event& iEvent, const edm::ESHandle& prod) const { const LHCInfo* info = prod.product(); float crossingAngle = info->crossingAngle(); float betaStar = info->betaStar(); float energy = info->energy(); - auto out = std::make_unique(1,"LHCInfo",true); - out->addColumnValue("crossingAngle", crossingAngle, "LHC crossing angle",precision_); - out->addColumnValue("betaStar",betaStar,"LHC beta star",precision_); - out->addColumnValue("energy",energy,"LHC beam energy",precision_); + auto out = std::make_unique(1, "LHCInfo", true); + out->addColumnValue("crossingAngle", crossingAngle, "LHC crossing angle", precision_); + out->addColumnValue("betaStar", betaStar, "LHC beta star", precision_); + out->addColumnValue("energy", energy, "LHC beam energy", precision_); return out; } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ - static void fillDescriptions(edm::ConfigurationDescriptions & descriptions) { + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.setUnknown(); descriptions.addDefault(desc); @@ -99,5 +93,4 @@ class LHCInfoProducer : public edm::global::EDProducer<> { const unsigned int precision_; }; - DEFINE_FWK_MODULE(LHCInfoProducer); diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index b2a809d88dd9c..625a93d5b69a2 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -43,11 +43,12 @@ class ProtonProducer : public edm::global::EDProducer<> { public: - ProtonProducer( edm::ParameterSet const & ps) : - tokenRecoProtonsSingleRP_(mayConsume(ps.getParameter("tagRecoProtonsSingle"))), - tokenRecoProtonsMultiRP_(mayConsume(ps.getParameter("tagRecoProtonsMulti"))), - tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))) - { + ProtonProducer(edm::ParameterSet const &ps) + : tokenRecoProtonsSingleRP_( + mayConsume(ps.getParameter("tagRecoProtonsSingle"))), + tokenRecoProtonsMultiRP_( + mayConsume(ps.getParameter("tagRecoProtonsMulti"))), + tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))) { produces>("protonRPId"); produces>("singleRPsector45"); produces>("multiRPsector45"); @@ -56,10 +57,9 @@ class ProtonProducer : public edm::global::EDProducer<> { produces("ppsTrackTable"); } ~ProtonProducer() override {} - - // ------------ method called to produce the data ------------ - void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override { + // ------------ method called to produce the data ------------ + void produce(edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override { // Get Forward Proton handles edm::Handle hRecoProtonsSingleRP; iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); @@ -68,96 +68,90 @@ class ProtonProducer : public edm::global::EDProducer<> { iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); // Get PPS Local Track handle - edm::Handle > ppsTracksLite; - iEvent.getByToken( tokenTracksLite_, ppsTracksLite ); + edm::Handle> ppsTracksLite; + iEvent.getByToken(tokenTracksLite_, ppsTracksLite); // book output variables for protons std::vector singleRP_RPId; std::vector singleRP_sector45, singleRP_sector56, multiRP_sector45, multiRP_sector56; // book output variables for tracks - std::vector trackX, trackXUnc, trackY, trackYUnc, trackTime, trackTimeUnc, localSlopeX, localSlopeY, normalizedChi2; + std::vector trackX, trackXUnc, trackY, trackYUnc, trackTime, trackTimeUnc, localSlopeX, localSlopeY, + normalizedChi2; std::vector singleRPProtonIdx, multiRPProtonIdx, decRPId, numFitPoints, pixelRecoInfo, rpType; // process single-RP protons { const auto &num_proton = hRecoProtonsSingleRP->size(); - singleRP_RPId.reserve( num_proton ); - singleRP_sector45.reserve( num_proton ); - singleRP_sector56.reserve( num_proton ); - - for (const auto &proton : *hRecoProtonsSingleRP) - { - CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId()); - unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); - singleRP_RPId.push_back(rpDecId); - singleRP_sector45.push_back( (proton.pz() > 0.) ? true : false ); - singleRP_sector56.push_back( (proton.pz() < 0.) ? true : false ); - } + singleRP_RPId.reserve(num_proton); + singleRP_sector45.reserve(num_proton); + singleRP_sector56.reserve(num_proton); + + for (const auto &proton : *hRecoProtonsSingleRP) { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId()); + unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); + singleRP_RPId.push_back(rpDecId); + singleRP_sector45.push_back((proton.pz() > 0.) ? true : false); + singleRP_sector56.push_back((proton.pz() < 0.) ? true : false); + } } // process multi-RP protons { const auto &num_proton = hRecoProtonsMultiRP->size(); - multiRP_sector45.reserve( num_proton ); - multiRP_sector56.reserve( num_proton ); - - for (const auto &proton : *hRecoProtonsMultiRP) - { - multiRP_sector45.push_back( (proton.pz() > 0.) ? true : false ); - multiRP_sector56.push_back( (proton.pz() < 0.) ? true : false ); - } + multiRP_sector45.reserve(num_proton); + multiRP_sector56.reserve(num_proton); + + for (const auto &proton : *hRecoProtonsMultiRP) { + multiRP_sector45.push_back((proton.pz() > 0.) ? true : false); + multiRP_sector56.push_back((proton.pz() < 0.) ? true : false); + } } // process local tracks - for (unsigned int tr_idx = 0; tr_idx < ppsTracksLite->size(); ++tr_idx) - { - const auto& tr = ppsTracksLite->at(tr_idx); - - CTPPSDetId rpId(tr.rpId()); - unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); - - decRPId.push_back(rpDecId); - rpType.push_back(rpId.subdetId()); - - trackX.push_back( tr.x() ); - trackXUnc.push_back( tr.xUnc() ); - trackY.push_back( tr.y() ); - trackYUnc.push_back( tr.yUnc() ); - trackTime.push_back( tr.time() ); - trackTimeUnc.push_back( tr.timeUnc() ); - numFitPoints.push_back( tr.numberOfPointsUsedForFit() ); - pixelRecoInfo.push_back( static_cast(tr.pixelTrackRecoInfo()) ); - normalizedChi2.push_back( tr.chiSquaredOverNDF() ); - localSlopeX.push_back( tr.tx() ); - localSlopeY.push_back( tr.ty() ); - - signed int singleRP_idx = -1; - for (unsigned int p_idx = 0; p_idx < hRecoProtonsSingleRP->size(); ++p_idx) - { - const auto &proton = hRecoProtonsSingleRP->at(p_idx); - - for (const auto &ref : proton.contributingLocalTracks()) - { - if (ref.key() == tr_idx) - singleRP_idx = p_idx; - } - } - singleRPProtonIdx.push_back(singleRP_idx); - - signed int multiRP_idx = -1; - for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) - { - const auto &proton = hRecoProtonsMultiRP->at(p_idx); - - for (const auto &ref : proton.contributingLocalTracks()) - { - if (ref.key() == tr_idx) - multiRP_idx = p_idx; - } - } - multiRPProtonIdx.push_back(multiRP_idx); + for (unsigned int tr_idx = 0; tr_idx < ppsTracksLite->size(); ++tr_idx) { + const auto &tr = ppsTracksLite->at(tr_idx); + + CTPPSDetId rpId(tr.rpId()); + unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); + + decRPId.push_back(rpDecId); + rpType.push_back(rpId.subdetId()); + + trackX.push_back(tr.x()); + trackXUnc.push_back(tr.xUnc()); + trackY.push_back(tr.y()); + trackYUnc.push_back(tr.yUnc()); + trackTime.push_back(tr.time()); + trackTimeUnc.push_back(tr.timeUnc()); + numFitPoints.push_back(tr.numberOfPointsUsedForFit()); + pixelRecoInfo.push_back(static_cast(tr.pixelTrackRecoInfo())); + normalizedChi2.push_back(tr.chiSquaredOverNDF()); + localSlopeX.push_back(tr.tx()); + localSlopeY.push_back(tr.ty()); + + signed int singleRP_idx = -1; + for (unsigned int p_idx = 0; p_idx < hRecoProtonsSingleRP->size(); ++p_idx) { + const auto &proton = hRecoProtonsSingleRP->at(p_idx); + + for (const auto &ref : proton.contributingLocalTracks()) { + if (ref.key() == tr_idx) + singleRP_idx = p_idx; + } } + singleRPProtonIdx.push_back(singleRP_idx); + + signed int multiRP_idx = -1; + for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) { + const auto &proton = hRecoProtonsMultiRP->at(p_idx); + + for (const auto &ref : proton.contributingLocalTracks()) { + if (ref.key() == tr_idx) + multiRP_idx = p_idx; + } + } + multiRPProtonIdx.push_back(multiRP_idx); + } // update proton tables std::unique_ptr> protonRPIdV(new edm::ValueMap()); @@ -169,7 +163,7 @@ class ProtonProducer : public edm::global::EDProducer<> { edm::ValueMap::Filler fillersingle45(*singleRP_sector45V); fillersingle45.insert(hRecoProtonsSingleRP, singleRP_sector45.begin(), singleRP_sector45.end()); fillersingle45.fill(); - + std::unique_ptr> singleRP_sector56V(new edm::ValueMap()); edm::ValueMap::Filler fillersingle56(*singleRP_sector56V); fillersingle56.insert(hRecoProtonsSingleRP, singleRP_sector56.begin(), singleRP_sector56.end()); @@ -179,31 +173,31 @@ class ProtonProducer : public edm::global::EDProducer<> { edm::ValueMap::Filler fillermulti45(*multiRP_sector45V); fillermulti45.insert(hRecoProtonsMultiRP, multiRP_sector45.begin(), multiRP_sector45.end()); fillermulti45.fill(); - + std::unique_ptr> multiRP_sector56V(new edm::ValueMap()); edm::ValueMap::Filler fillermulti56(*multiRP_sector56V); fillermulti56.insert(hRecoProtonsMultiRP, multiRP_sector56.begin(), multiRP_sector56.end()); fillermulti56.fill(); - + // build track table auto ppsTab = std::make_unique(trackX.size(), "PPSLocalTrack", false); - ppsTab->addColumn("singleRPProtonIdx",singleRPProtonIdx,"local track - proton correspondence"); - ppsTab->addColumn("multiRPProtonIdx",multiRPProtonIdx,"local track - proton correspondence"); - ppsTab->addColumn("x",trackX,"local track x",16); - ppsTab->addColumn("xUnc",trackXUnc,"local track x uncertainty",8); - ppsTab->addColumn("y",trackY,"local track y",13); - ppsTab->addColumn("yUnc",trackYUnc,"local track y uncertainty",8); - ppsTab->addColumn("time",trackTime,"local track time",16); - ppsTab->addColumn("timeUnc",trackTimeUnc,"local track time uncertainty",13); - ppsTab->addColumn("decRPId",decRPId,"local track detector dec id"); - ppsTab->addColumn("numFitPoints",numFitPoints,"number of points used for fit"); - ppsTab->addColumn("pixelRecoInfo",pixelRecoInfo,"flag if a ROC was shifted by a bunchx"); - ppsTab->addColumn("normalizedChi2",normalizedChi2,"chi2 over NDF",8); - ppsTab->addColumn("rpType",rpType,"strip=3, pixel=4, diamond=5, timing=6"); - ppsTab->addColumn("localSlopeX",localSlopeX,"track horizontal angle",11); - ppsTab->addColumn("localSlopeY",localSlopeY,"track vertical angle",11); + ppsTab->addColumn("singleRPProtonIdx", singleRPProtonIdx, "local track - proton correspondence"); + ppsTab->addColumn("multiRPProtonIdx", multiRPProtonIdx, "local track - proton correspondence"); + ppsTab->addColumn("x", trackX, "local track x", 16); + ppsTab->addColumn("xUnc", trackXUnc, "local track x uncertainty", 8); + ppsTab->addColumn("y", trackY, "local track y", 13); + ppsTab->addColumn("yUnc", trackYUnc, "local track y uncertainty", 8); + ppsTab->addColumn("time", trackTime, "local track time", 16); + ppsTab->addColumn("timeUnc", trackTimeUnc, "local track time uncertainty", 13); + ppsTab->addColumn("decRPId", decRPId, "local track detector dec id"); + ppsTab->addColumn("numFitPoints", numFitPoints, "number of points used for fit"); + ppsTab->addColumn("pixelRecoInfo", pixelRecoInfo, "flag if a ROC was shifted by a bunchx"); + ppsTab->addColumn("normalizedChi2", normalizedChi2, "chi2 over NDF", 8); + ppsTab->addColumn("rpType", rpType, "strip=3, pixel=4, diamond=5, timing=6"); + ppsTab->addColumn("localSlopeX", localSlopeX, "track horizontal angle", 11); + ppsTab->addColumn("localSlopeY", localSlopeY, "track vertical angle", 11); ppsTab->setDoc("ppsLocalTrack variables"); - + // save output iEvent.put(std::move(protonRPIdV), "protonRPId"); iEvent.put(std::move(singleRP_sector45V), "singleRPsector45"); @@ -214,17 +208,16 @@ class ProtonProducer : public edm::global::EDProducer<> { } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ - static void fillDescriptions(edm::ConfigurationDescriptions & descriptions) { + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; desc.setUnknown(); descriptions.addDefault(desc); } - + protected: const edm::EDGetTokenT tokenRecoProtonsSingleRP_; const edm::EDGetTokenT tokenRecoProtonsMultiRP_; - const edm::EDGetTokenT > tokenTracksLite_; + const edm::EDGetTokenT> tokenTracksLite_; }; - DEFINE_FWK_MODULE(ProtonProducer); From 872f58b2759c5cf5fe0f153982c2b8a8746ff2f9 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Tue, 22 Sep 2020 14:11:11 -0500 Subject: [PATCH 09/29] added Marco Peruzzi's suggested edits for compatibility with datasets without pps info --- .../interface/SimpleFlatTableProducer.h | 63 +++++++++++-------- .../NanoAOD/plugins/ProtonProducer.cc | 5 +- PhysicsTools/NanoAOD/python/protons_cff.py | 9 +++ 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h b/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h index 92b704a89bef4..596e65a9ac389 100644 --- a/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h +++ b/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h @@ -18,7 +18,10 @@ class SimpleFlatTableProducerBase : public edm::stream::EDProducer<> { : name_(params.getParameter("name")), doc_(params.existsAs("doc") ? params.getParameter("doc") : ""), extension_(params.existsAs("extension") ? params.getParameter("extension") : false), - src_(consumes(params.getParameter("src"))) { + skipNonExistingSrc_( + params.existsAs("skipNonExistingSrc") ? params.getParameter("skipNonExistingSrc") : false), + src_(skipNonExistingSrc_ ? mayConsume(params.getParameter("src")) + : consumes(params.getParameter("src"))) { edm::ParameterSet const &varsPSet = params.getParameter("variables"); for (const std::string &vname : varsPSet.getParameterNamesForType()) { const auto &varPSet = varsPSet.getParameter(vname); @@ -58,6 +61,7 @@ class SimpleFlatTableProducerBase : public edm::stream::EDProducer<> { const std::string name_; const std::string doc_; const bool extension_; + const bool skipNonExistingSrc_; const edm::EDGetTokenT src_; class VariableBase { @@ -135,15 +139,15 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase(vname); const std::string &type = varPSet.getParameter("type"); if (type == "int") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector())); + extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else if (type == "float") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector())); + extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else if (type == "double") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector())); + extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else if (type == "uint8") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector())); + extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else if (type == "bool") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector())); + extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname); } @@ -156,21 +160,23 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase> &prod) const override { std::vector selobjs; std::vector> selptrs; // for external variables - if (singleton_) { - assert(prod->size() == 1); - selobjs.push_back(&(*prod)[0]); - if (!extvars_.empty()) - selptrs.emplace_back(prod->ptrAt(0)); - } else { - for (unsigned int i = 0, n = prod->size(); i < n; ++i) { - const auto &obj = (*prod)[i]; - if (cut_(obj)) { - selobjs.push_back(&obj); - if (!extvars_.empty()) - selptrs.emplace_back(prod->ptrAt(i)); + if (prod.isValid() || !(this->skipNonExistingSrc_)) { + if (singleton_) { + assert(prod->size() == 1); + selobjs.push_back(&(*prod)[0]); + if (!extvars_.empty()) + selptrs.emplace_back(prod->ptrAt(0)); + } else { + for (unsigned int i = 0, n = prod->size(); i < n; ++i) { + const auto &obj = (*prod)[i]; + if (cut_(obj)) { + selobjs.push_back(&obj); + if (!extvars_.empty()) + selptrs.emplace_back(prod->ptrAt(i)); + } + if (selobjs.size() >= maxLen_) + break; } - if (selobjs.size() >= maxLen_) - break; } } auto out = std::make_unique(selobjs.size(), this->name_, singleton_, this->extension_); @@ -194,19 +200,26 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase class ValueMapVariable : public ExtVariable { public: - ValueMapVariable(const std::string &aname, const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc) - : ExtVariable(aname, cfg), token_(cc.consumes>(cfg.getParameter("src"))) {} + ValueMapVariable(const std::string &aname, const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc, bool skipNonExistingSrc = false) + : ExtVariable(aname, cfg), + skipNonExistingSrc_(skipNonExistingSrc), + token_(skipNonExistingSrc_ ? cc.mayConsume>(cfg.getParameter("src")) + : cc.consumes>(cfg.getParameter("src"))) {} 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()); - for (unsigned int i = 0, n = vals.size(); i < n; ++i) { - vals[i] = (*vmap)[selptrs[i]]; + std::vector vals; + if (vmap.isValid() || !skipNonExistingSrc_) { + vals.resize(selptrs.size()); + for (unsigned int i = 0, n = vals.size(); i < n; ++i) { + vals[i] = (*vmap)[selptrs[i]]; + } } out.template addColumn(this->name_, vals, this->doc_, this->precision_); } protected: + const bool skipNonExistingSrc_; edm::EDGetTokenT> token_; }; typedef ValueMapVariable IntExtVar; diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index 625a93d5b69a2..4f29d7d8525c1 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -210,8 +210,9 @@ class ProtonProducer : public edm::global::EDProducer<> { // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.setUnknown(); - descriptions.addDefault(desc); + desc.add("tagRecoProtonsSingleRP")->setComment("singleRP proton collection"); + desc.add("tagRecoProtonsMultiRP")->setComment("multiRP proton collection"); + descriptions.add("ProtonProducer", desc); } protected: diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index 9a7c488b7f649..d52bd9f2a627c 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -1,5 +1,9 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * +from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy +from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff import run2_nanoAOD_94XMiniAODv1 +from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff import run2_nanoAOD_94XMiniAODv2 +from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff import run2_nanoAOD_94X2016 protonTable = cms.EDProducer("ProtonProducer", tagRecoProtonsSingle = cms.InputTag("ctppsProtons", "singleRP"), @@ -14,6 +18,7 @@ doc = cms.string("bon"), singleton = cms.bool(False), extension = cms.bool(False), + skipNonExistingSrc = cms.bool(True), variables = cms.PSet( xi = Var("xi",float,doc="xi or dp/p",precision=12), xiUnc = Var("xiError",float,doc="uncertainty on xi or dp/p",precision=8), @@ -34,6 +39,7 @@ doc = cms.string("bon"), singleton = cms.bool(False), extension = cms.bool(False), + skipNonExistingSrc = cms.bool(True), variables = cms.PSet( xi = Var("xi",float,doc="xi or dp/p",precision=12), xiUnc = Var("xiError",float,doc="uncertainty on xi or dp/p",precision=8), @@ -62,3 +68,6 @@ +singleRPTable +multiRPTable ) + +for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016: + modifier.toReplaceWith(protonTables, cms.Sequence()) From 262c9754109cafc8d7b06b5484400be2934d2818 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Wed, 23 Sep 2020 16:27:21 -0500 Subject: [PATCH 10/29] code-format updates --- .../interface/SimpleFlatTableProducer.h | 50 +++++++++++-------- .../NanoAOD/plugins/ProtonProducer.cc | 5 +- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h b/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h index 596e65a9ac389..087fa85bdb3b9 100644 --- a/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h +++ b/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h @@ -19,9 +19,9 @@ class SimpleFlatTableProducerBase : public edm::stream::EDProducer<> { doc_(params.existsAs("doc") ? params.getParameter("doc") : ""), extension_(params.existsAs("extension") ? params.getParameter("extension") : false), skipNonExistingSrc_( - params.existsAs("skipNonExistingSrc") ? params.getParameter("skipNonExistingSrc") : false), + params.existsAs("skipNonExistingSrc") ? params.getParameter("skipNonExistingSrc") : false), src_(skipNonExistingSrc_ ? mayConsume(params.getParameter("src")) - : consumes(params.getParameter("src"))) { + : consumes(params.getParameter("src"))) { edm::ParameterSet const &varsPSet = params.getParameter("variables"); for (const std::string &vname : varsPSet.getParameterNamesForType()) { const auto &varPSet = varsPSet.getParameter(vname); @@ -139,15 +139,20 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase(vname); const std::string &type = varPSet.getParameter("type"); if (type == "int") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); + extvars_.push_back( + std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else if (type == "float") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); + extvars_.push_back( + std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else if (type == "double") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); + extvars_.push_back( + std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else if (type == "uint8") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); + extvars_.push_back( + std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else if (type == "bool") - extvars_.push_back(std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); + extvars_.push_back( + std::make_unique(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_)); else throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname); } @@ -162,20 +167,20 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase> selptrs; // for external variables if (prod.isValid() || !(this->skipNonExistingSrc_)) { if (singleton_) { - assert(prod->size() == 1); - selobjs.push_back(&(*prod)[0]); - if (!extvars_.empty()) - selptrs.emplace_back(prod->ptrAt(0)); + assert(prod->size() == 1); + selobjs.push_back(&(*prod)[0]); + if (!extvars_.empty()) + selptrs.emplace_back(prod->ptrAt(0)); } else { for (unsigned int i = 0, n = prod->size(); i < n; ++i) { - const auto &obj = (*prod)[i]; - if (cut_(obj)) { - selobjs.push_back(&obj); - if (!extvars_.empty()) - selptrs.emplace_back(prod->ptrAt(i)); - } - if (selobjs.size() >= maxLen_) - break; + const auto &obj = (*prod)[i]; + if (cut_(obj)) { + selobjs.push_back(&obj); + if (!extvars_.empty()) + selptrs.emplace_back(prod->ptrAt(i)); + } + if (selobjs.size() >= maxLen_) + break; } } } @@ -200,11 +205,14 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase class ValueMapVariable : public ExtVariable { public: - ValueMapVariable(const std::string &aname, const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc, bool skipNonExistingSrc = false) + ValueMapVariable(const std::string &aname, + const edm::ParameterSet &cfg, + edm::ConsumesCollector &&cc, + bool skipNonExistingSrc = false) : ExtVariable(aname, cfg), skipNonExistingSrc_(skipNonExistingSrc), token_(skipNonExistingSrc_ ? cc.mayConsume>(cfg.getParameter("src")) - : cc.consumes>(cfg.getParameter("src"))) {} + : cc.consumes>(cfg.getParameter("src"))) {} void fill(const edm::Event &iEvent, std::vector> selptrs, nanoaod::FlatTable &out) const override { edm::Handle> vmap; iEvent.getByToken(token_, vmap); diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index 4f29d7d8525c1..55d718b81358b 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -210,8 +210,9 @@ class ProtonProducer : public edm::global::EDProducer<> { // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.add("tagRecoProtonsSingleRP")->setComment("singleRP proton collection"); - desc.add("tagRecoProtonsMultiRP")->setComment("multiRP proton collection"); + desc.add("tagRecoProtonsSingle")->setComment("singleRP proton collection"); + desc.add("tagRecoProtonsMulti")->setComment("multiRP proton collection"); + desc.add("tagTrackLite")->setComment("pps local tracks lite collection"); descriptions.add("ProtonProducer", desc); } From 1f7f1db1dd9cc7f20768ebb745c9d7cd29ea12be Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 28 Sep 2020 19:42:07 -0500 Subject: [PATCH 11/29] Added proton plots --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 50d873969b5e3..a898eb3d16789 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -517,6 +517,36 @@ NoPlot('vidNestedWPBitmap'), ) ), + Proton = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 3, -0.5, 2.5, 'bon'), + Plot1D('multiRP_chi2', 'multiRP_chi2', 20, 0, 6e-07, 'chi 2'), + Plot1D('multiRP_ndof', 'multiRP_ndof', 1, -0.5, 0.5, 'n dof'), + Plot1D('multiRP_pt', 'multiRP_pt', 20, 0.06, 2, 'pt'), + Plot1D('multiRP_sector45', 'multiRP_sector45', 2, -0.5, 1.5, 'LHC sector 45'), + Plot1D('multiRP_sector56', 'multiRP_sector56', 2, -0.5, 1.5, 'LHC sector 56'), + Plot1D('multiRP_t', 'multiRP_t', 20, -2, -0.02, 't'), + Plot1D('multiRP_thetaX', 'multiRP_thetaX', 20, -0.0004, 0.0004, 'scattering angle in the y direction'), + Plot1D('multiRP_thetaXUnc', 'multiRP_thetaXUnc', 20, 9e-06, 9e-06, 'theta X uncertainty'), + Plot1D('multiRP_thetaY', 'multiRP_thetaY', 20, -0.001, 0.001, 'scattering angle in the x direction'), + Plot1D('multiRP_thetaYUnc', 'multiRP_thetaYUnc', 20, 2e-05, 2e-05, 'theta Y uncertainty'), + Plot1D('multiRP_time', 'multiRP_time', 20, -1000, -1000, 'time'), + Plot1D('multiRP_timeUnc', 'multiRP_timeUnc', 20, 0, 0, 'time uncertainty'), + Plot1D('multiRP_validFit', 'multiRP_validFit', 2, -0.5, 1.5, 'valid Fit'), + Plot1D('multiRP_vtxY', 'multiRP_vtxY', 20, -0.07, 0.07, 'vertex y'), + Plot1D('multiRP_vtxYUnc', 'multiRP_vtxYUnc', 20, 0.02, 0.02, 'vy Error'), + Plot1D('multiRP_xi', 'multiRP_xi', 20, 0, 0.3, 'fractional momentum loss'), + Plot1D('multiRP_xiUnc', 'multiRP_xiUnc', 20, 0.003, 0.003, 'uncertainty on xi or dp/p'), + Plot1D('singleRP_decRPId', 'singleRP_decRPId', 20, 0, 200, 'Detector ID'), + Plot1D('singleRP_sector45', 'singleRP_sector45', 2, -0.5, 1.5, 'LHC sector 45'), + Plot1D('singleRP_sector56', 'singleRP_sector56', 2, -0.5, 1.5, 'LHC sector 56'), + Plot1D('singleRP_thetaY', 'singleRP_thetaY', 20, -0.003, 0.003, 'th y'), + Plot1D('singleRP_thetaYUnc', 'singleRP_thetaYUnc', 20, 0, 0.0002, 'theta Y uncertainty'), + Plot1D('singleRP_xi', 'singleRP_xi', 20, 0.03, 0.2, 'xi or dp/p'), + Plot1D('singleRP_xiUnc', 'singleRP_xiUnc', 20, 6e-05, 0.0005, 'uncertainty on xi or dp/p'), + ) + ), Pileup = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( From b0c0009e28b163aa678395192f3e5323c7984fd6 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 5 Oct 2020 07:16:10 -0500 Subject: [PATCH 12/29] storing LHCInfo in nanoAOD per luminosity block instead of per event --- .../NanoAOD/plugins/LHCInfoProducer.cc | 41 ++++++------------- .../NanoAOD/plugins/NanoAODOutputModule.cc | 16 ++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc index 72617ba9e8094..f6c3aa83dd734 100644 --- a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc @@ -41,56 +41,41 @@ #include "DataFormats/NanoAOD/interface/FlatTable.h" #include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/NanoAOD/interface/MergeableCounterTable.h" #include "FWCore/Utilities/interface/transform.h" -// LHC Info #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/DataRecord/interface/LHCInfoRcd.h" -#include "CondTools/RunInfo/interface/LHCInfoPopConSourceHandler.h" -class LHCInfoProducer : public edm::global::EDProducer<> { +class LHCInfoProducer : public edm::global::EDProducer { public: - LHCInfoProducer(edm::ParameterSet const& ps) : precision_(ps.getParameter("precision")) { - produces("lhcInfoTab"); + LHCInfoProducer(edm::ParameterSet const&) { + produces(); } ~LHCInfoProducer() override {} // ------------ method called to produce the data ------------ - void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override { - // Get LHCInfo handle + void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override {} + + void globalBeginLuminosityBlockProduce(edm::LuminosityBlock& iLumi, edm::EventSetup const& iSetup) const override { edm::ESHandle lhcInfo; iSetup.get().get(lhcInfo); - - std::unique_ptr out = fillTable(iEvent, lhcInfo); - out->setDoc("LHC Info"); - - iEvent.put(std::move(out), "lhcInfoTab"); - } - - std::unique_ptr fillTable(const edm::Event& iEvent, const edm::ESHandle& prod) const { - const LHCInfo* info = prod.product(); - float crossingAngle = info->crossingAngle(); - float betaStar = info->betaStar(); - float energy = info->energy(); - - auto out = std::make_unique(1, "LHCInfo", true); - out->addColumnValue("crossingAngle", crossingAngle, "LHC crossing angle", precision_); - out->addColumnValue("betaStar", betaStar, "LHC beta star", precision_); - out->addColumnValue("energy", energy, "LHC beam energy", precision_); - return out; + const LHCInfo* info = lhcInfo.product(); + auto out = std::make_unique(); + out->addFloat("crossingAngle", "LHC crossing angle", info->crossingAngle()); + out->addFloat("betaStar", "LHC beta star", info->betaStar()); + out->addFloat("energy", "LHC beam energy", info->energy()); + iLumi.put(std::move(out)); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.setUnknown(); descriptions.addDefault(desc); } -protected: - const unsigned int precision_; }; DEFINE_FWK_MODULE(LHCInfoProducer); diff --git a/PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc b/PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc index 02198c149c17c..715b0b090143d 100644 --- a/PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc +++ b/PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc @@ -125,6 +125,7 @@ class NanoAODOutputModule : public edm::one::OutputModule<> { std::vector m_evstrings; std::vector m_runTables; + std::vector m_lumiTables; std::vector> m_nanoMetadata; }; @@ -224,6 +225,10 @@ void NanoAODOutputModule::writeLuminosityBlock(edm::LuminosityBlockForOutput con jr->reportLumiSection(m_jrToken, iLumi.id().run(), iLumi.id().value()); m_commonLumiBranches.fill(iLumi.id()); + + for (auto& t : m_lumiTables) + t.fill(iLumi, *m_lumiTree); + m_lumiTree->Fill(); m_processHistoryRegistry.registerProcessHistory(iLumi.processHistory()); @@ -287,6 +292,7 @@ void NanoAODOutputModule::openFile(edm::FileBlock const&) { m_triggers_areSorted = false; m_evstrings.clear(); m_runTables.clear(); + m_lumiTables.clear(); const auto& keeps = keptProducts(); for (const auto& keep : keeps[edm::InEvent]) { if (keep.first->className() == "nanoaod::FlatTable") @@ -300,6 +306,16 @@ void NanoAODOutputModule::openFile(edm::FileBlock const&) { throw cms::Exception("Configuration", "NanoAODOutputModule cannot handle class " + keep.first->className()); } + for (const auto& keep : keeps[edm::InLumi]) { + if (keep.first->className() == "nanoaod::MergeableCounterTable") + m_lumiTables.push_back(SummaryTableOutputBranches(keep.first, keep.second)); + 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 LuminosityBlock branch"); + } + for (const auto& keep : keeps[edm::InRun]) { if (keep.first->className() == "nanoaod::MergeableCounterTable") m_runTables.push_back(SummaryTableOutputBranches(keep.first, keep.second)); From 64a59346670493871e963597656b310bbf316c10 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 5 Oct 2020 13:12:37 -0500 Subject: [PATCH 13/29] fixed code checks --- PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc | 1 - PhysicsTools/NanoAOD/plugins/NanoAODOutputModule.cc | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc index f6c3aa83dd734..ffc6ffa734dad 100644 --- a/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/LHCInfoProducer.cc @@ -75,7 +75,6 @@ class LHCInfoProducer : public edm::global::EDProducerclassName() == "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 LuminosityBlock branch"); + throw cms::Exception( + "Configuration", + "NanoAODOutputModule cannot handle class " + keep.first->className() + " in LuminosityBlock branch"); } for (const auto& keep : keeps[edm::InRun]) { From 4376344f29233e5231c1fe8767f66a640be08af5 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Tue, 6 Oct 2020 09:28:48 -0500 Subject: [PATCH 14/29] excluding EOY datasets for PPS tables --- PhysicsTools/NanoAOD/python/protons_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index d52bd9f2a627c..e47db604fcec9 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -69,5 +69,5 @@ +multiRPTable ) -for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016: +for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1: modifier.toReplaceWith(protonTables, cms.Sequence()) From f5822f92a1ec6944d2c8c76fb1b43d2f72687b29 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Tue, 6 Oct 2020 10:19:40 -0500 Subject: [PATCH 15/29] imported run2_nanoAOD_102Xv1 --- PhysicsTools/NanoAOD/python/protons_cff.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index e47db604fcec9..88d7ba7268b1c 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -4,6 +4,7 @@ from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff import run2_nanoAOD_94XMiniAODv1 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff import run2_nanoAOD_94XMiniAODv2 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff import run2_nanoAOD_94X2016 +from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 protonTable = cms.EDProducer("ProtonProducer", tagRecoProtonsSingle = cms.InputTag("ctppsProtons", "singleRP"), From 93b952e29ef3e3ec4ccd2de61f6f178636bdc9e0 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Wed, 14 Oct 2020 19:59:31 -0500 Subject: [PATCH 16/29] revisions to stored variables decided by proton POG --- .../NanoAOD/plugins/ProtonProducer.cc | 51 ++++--------------- PhysicsTools/NanoAOD/python/protons_cff.py | 19 ++----- 2 files changed, 13 insertions(+), 57 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index 55d718b81358b..d35d83fc4a93f 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -50,10 +50,7 @@ class ProtonProducer : public edm::global::EDProducer<> { mayConsume(ps.getParameter("tagRecoProtonsMulti"))), tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))) { produces>("protonRPId"); - produces>("singleRPsector45"); - produces>("multiRPsector45"); - produces>("singleRPsector56"); - produces>("multiRPsector56"); + produces>("arm"); produces("ppsTrackTable"); } ~ProtonProducer() override {} @@ -73,10 +70,10 @@ class ProtonProducer : public edm::global::EDProducer<> { // book output variables for protons std::vector singleRP_RPId; - std::vector singleRP_sector45, singleRP_sector56, multiRP_sector45, multiRP_sector56; + std::vector multiRP_arm; // book output variables for tracks - std::vector trackX, trackXUnc, trackY, trackYUnc, trackTime, trackTimeUnc, localSlopeX, localSlopeY, + std::vector trackX, trackY, trackTime, trackTimeUnc, localSlopeX, localSlopeY, normalizedChi2; std::vector singleRPProtonIdx, multiRPProtonIdx, decRPId, numFitPoints, pixelRecoInfo, rpType; @@ -84,27 +81,21 @@ class ProtonProducer : public edm::global::EDProducer<> { { const auto &num_proton = hRecoProtonsSingleRP->size(); singleRP_RPId.reserve(num_proton); - singleRP_sector45.reserve(num_proton); - singleRP_sector56.reserve(num_proton); for (const auto &proton : *hRecoProtonsSingleRP) { CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId()); unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); singleRP_RPId.push_back(rpDecId); - singleRP_sector45.push_back((proton.pz() > 0.) ? true : false); - singleRP_sector56.push_back((proton.pz() < 0.) ? true : false); } } // process multi-RP protons { const auto &num_proton = hRecoProtonsMultiRP->size(); - multiRP_sector45.reserve(num_proton); - multiRP_sector56.reserve(num_proton); + multiRP_arm.reserve(num_proton); for (const auto &proton : *hRecoProtonsMultiRP) { - multiRP_sector45.push_back((proton.pz() > 0.) ? true : false); - multiRP_sector56.push_back((proton.pz() < 0.) ? true : false); + multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); } } @@ -119,9 +110,7 @@ class ProtonProducer : public edm::global::EDProducer<> { rpType.push_back(rpId.subdetId()); trackX.push_back(tr.x()); - trackXUnc.push_back(tr.xUnc()); trackY.push_back(tr.y()); - trackYUnc.push_back(tr.yUnc()); trackTime.push_back(tr.time()); trackTimeUnc.push_back(tr.timeUnc()); numFitPoints.push_back(tr.numberOfPointsUsedForFit()); @@ -159,34 +148,17 @@ class ProtonProducer : public edm::global::EDProducer<> { fillerID.insert(hRecoProtonsSingleRP, singleRP_RPId.begin(), singleRP_RPId.end()); fillerID.fill(); - std::unique_ptr> singleRP_sector45V(new edm::ValueMap()); - edm::ValueMap::Filler fillersingle45(*singleRP_sector45V); - fillersingle45.insert(hRecoProtonsSingleRP, singleRP_sector45.begin(), singleRP_sector45.end()); - fillersingle45.fill(); - - std::unique_ptr> singleRP_sector56V(new edm::ValueMap()); - edm::ValueMap::Filler fillersingle56(*singleRP_sector56V); - fillersingle56.insert(hRecoProtonsSingleRP, singleRP_sector56.begin(), singleRP_sector56.end()); - fillersingle56.fill(); - - std::unique_ptr> multiRP_sector45V(new edm::ValueMap()); - edm::ValueMap::Filler fillermulti45(*multiRP_sector45V); - fillermulti45.insert(hRecoProtonsMultiRP, multiRP_sector45.begin(), multiRP_sector45.end()); - fillermulti45.fill(); - - std::unique_ptr> multiRP_sector56V(new edm::ValueMap()); - edm::ValueMap::Filler fillermulti56(*multiRP_sector56V); - fillermulti56.insert(hRecoProtonsMultiRP, multiRP_sector56.begin(), multiRP_sector56.end()); - fillermulti56.fill(); + std::unique_ptr> multiRP_armV(new edm::ValueMap()); + edm::ValueMap::Filler fillermultiArm(*multiRP_armV); + fillermultiArm.insert(hRecoProtonsMultiRP, multiRP_arm.begin(), multiRP_arm.end()); + fillermultiArm.fill(); // build track table auto ppsTab = std::make_unique(trackX.size(), "PPSLocalTrack", false); ppsTab->addColumn("singleRPProtonIdx", singleRPProtonIdx, "local track - proton correspondence"); ppsTab->addColumn("multiRPProtonIdx", multiRPProtonIdx, "local track - proton correspondence"); ppsTab->addColumn("x", trackX, "local track x", 16); - ppsTab->addColumn("xUnc", trackXUnc, "local track x uncertainty", 8); ppsTab->addColumn("y", trackY, "local track y", 13); - ppsTab->addColumn("yUnc", trackYUnc, "local track y uncertainty", 8); ppsTab->addColumn("time", trackTime, "local track time", 16); ppsTab->addColumn("timeUnc", trackTimeUnc, "local track time uncertainty", 13); ppsTab->addColumn("decRPId", decRPId, "local track detector dec id"); @@ -200,10 +172,7 @@ class ProtonProducer : public edm::global::EDProducer<> { // save output iEvent.put(std::move(protonRPIdV), "protonRPId"); - iEvent.put(std::move(singleRP_sector45V), "singleRPsector45"); - iEvent.put(std::move(singleRP_sector56V), "singleRPsector56"); - iEvent.put(std::move(multiRP_sector45V), "multiRPsector45"); - iEvent.put(std::move(multiRP_sector56V), "multiRPsector56"); + iEvent.put(std::move(multiRP_armV), "arm"); iEvent.put(std::move(ppsTab), "ppsTrackTable"); } diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index 88d7ba7268b1c..ffa4593d447d4 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -22,14 +22,10 @@ skipNonExistingSrc = cms.bool(True), variables = cms.PSet( xi = Var("xi",float,doc="xi or dp/p",precision=12), - xiUnc = Var("xiError",float,doc="uncertainty on xi or dp/p",precision=8), thetaY = Var("thetaY",float,doc="th y",precision=13), - thetaYUnc = Var("thetaYError",float,doc="theta Y uncertainty",precision=8), ), externalVariables = cms.PSet( decRPId = ExtVar("protonTable:protonRPId",int,doc="Detector ID",precision=8), - sector45 = ExtVar("protonTable:singleRPsector45",bool,doc="LHC sector 45"), - sector56 = ExtVar("protonTable:singleRPsector56",bool,doc="LHC sector 56"), ), ) @@ -43,24 +39,15 @@ skipNonExistingSrc = cms.bool(True), variables = cms.PSet( xi = Var("xi",float,doc="xi or dp/p",precision=12), - xiUnc = Var("xiError",float,doc="uncertainty on xi or dp/p",precision=8), - vtxY = Var("vy()",float,doc="vertex y",precision=11), - vtxYUnc = Var("vyError",float,doc="vy Error",precision=8), - pt = Var("pt",float,doc="pt",precision=15), thetaX = Var("thetaX",float,doc="theta x",precision=13), - thetaXUnc = Var("thetaXError",float,doc="theta X uncertainty",precision=8), thetaY = Var("thetaY",float,doc="theta y",precision=13), - thetaYUnc = Var("thetaYError",float,doc="theta Y uncertainty",precision=8), - chi2 = Var("chi2",float,doc="chi 2",precision=15), - ndof = Var("ndof()",int, doc="n dof", precision=8), - t = Var("t",float,doc="t",precision=13), - validFit = Var("validFit",bool,doc="valid Fit"), + t = Var("t",float,doc="Mandelstam variable t",precision=13), + validFit = Var("validFit && (chi2 < 0.1)",bool,doc="valid Fit && chi2 < 0.1"), time = Var("time()",float,doc="time",precision=16), timeUnc = Var("timeError",float,doc="time uncertainty",precision=13), ), externalVariables = cms.PSet( - sector45 = ExtVar("protonTable:multiRPsector45",bool,doc="LHC sector 45"), - sector56 = ExtVar("protonTable:multiRPsector56",bool,doc="LHC sector 56"), + arm = ExtVar("protonTable:arm",int,doc="0 = sector45, 1 = sector56"), ), ) From 7f92de5e0dbe28bdcfbe99ab83ad8f6278d81670 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Wed, 14 Oct 2020 20:07:59 -0500 Subject: [PATCH 17/29] code checks fix --- PhysicsTools/NanoAOD/plugins/ProtonProducer.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index d35d83fc4a93f..adcaa72783ef8 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -73,8 +73,7 @@ class ProtonProducer : public edm::global::EDProducer<> { std::vector multiRP_arm; // book output variables for tracks - std::vector trackX, trackY, trackTime, trackTimeUnc, localSlopeX, localSlopeY, - normalizedChi2; + std::vector trackX, trackY, trackTime, trackTimeUnc, localSlopeX, localSlopeY, normalizedChi2; std::vector singleRPProtonIdx, multiRPProtonIdx, decRPId, numFitPoints, pixelRecoInfo, rpType; // process single-RP protons @@ -95,7 +94,7 @@ class ProtonProducer : public edm::global::EDProducer<> { multiRP_arm.reserve(num_proton); for (const auto &proton : *hRecoProtonsMultiRP) { - multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); + multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); } } From 76151d068699d1e9570b210bb726f9f1902bbd76 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Thu, 15 Oct 2020 09:28:48 -0500 Subject: [PATCH 18/29] updated nanoDQM with POG recommended variables --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 172 ++++----------------- 1 file changed, 32 insertions(+), 140 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index a898eb3d16789..31439d9f7aad2 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -67,12 +67,9 @@ Plot1D('dxyErr', 'dxyErr', 20, 0, 0.2, 'dxy uncertainty, in cm'), Plot1D('dz', 'dz', 20, -0.3, 0.3, 'dz (with sign) wrt first PV, in cm'), Plot1D('dzErr', 'dzErr', 20, 0, 0.2, 'dz uncertainty, in cm'), - Plot1D('eCorr', 'eCorr', 20, 0.8, 1.2, 'ratio of the calibrated energy/miniaod energy'), Plot1D('eInvMinusPInv', 'eInvMinusPInv', 20, -0.1, 0.1, '1/E_SC - 1/p_trk'), Plot1D('energyErr', 'energyErr', 20, 0, 90, 'energy error of the cluster-track combination'), Plot1D('eta', 'eta', 20, -3, 3, 'eta'), - Plot1D('genPartFlav', 'genPartFlav', 20, 0, 30, 'Flavour of genParticle for MC matching to status==1 electrons or photons: 1 = prompt electron (including gamma*->mu mu), 15 = electron from prompt tau, 22 = prompt photon (likely conversion), 5 = electron from b, 4 = electron from c, 3 = electron from light or unknown, 0 = unmatched'), - NoPlot('genPartIdx'), Plot1D('hoe', 'hoe', 20, 0, 1, 'H over E'), Plot1D('ip3d', 'ip3d', 20, 0, 0.2, '3D impact parameter wrt first PV, in cm'), Plot1D('isPFcand', 'isPFcand', 2, -0.5, 1.5, 'electron is PF candidate'), @@ -149,8 +146,6 @@ Plot1D('deepTag_ZvsQCD', 'deepTag_ZvsQCD', 20, 0, 1, 'DeepBoostedJet tagger Z vs QCD discriminator'), NoPlot('electronIdx3SJ'), Plot1D('eta', 'eta', 20, -4, 4, 'eta'), - NoPlot('genJetAK8Idx'), - Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), Plot1D('jetId', 'jetId', 8, -0.5, 7.5, 'Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto'), Plot1D('lsf3', 'lsf3', 20, -1, 1, 'Lepton Subjet Fraction (3 subjets)'), Plot1D('mass', 'mass', 20, 0, 300, 'mass'), @@ -158,8 +153,6 @@ NoPlot('muonIdx3SJ'), Plot1D('n2b1', 'n2b1', 20, 0, 1, 'N2 (beta=1)'), Plot1D('n3b1', 'n3b1', 20, 0, 5, 'N3 (beta=1)'), - Plot1D('nBHadrons', 'nBHadrons', 4, -0.5, 3.5, 'number of b-hadrons'), - Plot1D('nCHadrons', 'nCHadrons', 4, -0.5, 3.5, 'number of c-hadrons'), Plot1D('particleNetMD_QCD', 'particleNetMD_QCD', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw QCD score'), Plot1D('particleNetMD_Xbb', 'particleNetMD_Xbb', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw X->bb score. For X->bb vs QCD tagging, use Xbb/(Xbb+QCD)'), Plot1D('particleNetMD_Xcc', 'particleNetMD_Xcc', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw X->cc score. For X->cc vs QCD tagging, use Xcc/(Xcc+QCD)'), @@ -188,7 +181,6 @@ Plot1D('BadChargedCandidateFilter', 'BadChargedCandidateFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('BadChargedCandidateSummer16Filter', 'BadChargedCandidateSummer16Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('BadPFMuonFilter', 'BadPFMuonFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), - Plot1D('BadPFMuonDzFilter', 'BadPFMuonDzFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('BadPFMuonSummer16Filter', 'BadPFMuonSummer16Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('CSCTightHalo2015Filter', 'CSCTightHalo2015Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('CSCTightHaloFilter', 'CSCTightHaloFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), @@ -201,12 +193,10 @@ Plot1D('METFilters', 'METFilters', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('chargedHadronTrackResolutionFilter', 'chargedHadronTrackResolutionFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('ecalBadCalibFilter', 'ecalBadCalibFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), - Plot1D('ecalBadCalibFilterV2', 'ecalBadCalibFilterV2', 1, 0.5, 1.5, 'Bad ECAL calib flag (updated xtal list)'), Plot1D('ecalLaserCorrFilter', 'ecalLaserCorrFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('eeBadScFilter', 'eeBadScFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('globalSuperTightHalo2016Filter', 'globalSuperTightHalo2016Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('globalTightHalo2016Filter', 'globalTightHalo2016Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), - Plot1D('hfNoisyHitsFilter', 'hfNoisyHitsFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('goodVertices', 'goodVertices', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('hcalLaserEventFilter', 'hcalLaserEventFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('muonBadTrackFilter', 'muonBadTrackFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), @@ -228,86 +218,6 @@ Plot1D('relIso03', 'relIso03', 20, 0, 2, 'relative isolation in a 0.3 cone without CHS'), ) ), - GenDressedLepton = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 25, -0.5, 24.5, 'Dressed leptons from Rivet-based ParticleLevelProducer'), - Plot1D('eta', 'eta', 20, -7, 7, 'eta'), - Plot1D('hasTauAnc', 'hasTauAnc', 2, -0.5, 1.5, 'true if Dressed lepton has a tau as ancestor'), - Plot1D('mass', 'mass', 20, 0, 200, 'mass'), - Plot1D('pdgId', 'pdgId', 40, -20, 20, 'pdgId'), - Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('pt', 'pt', 20, 0, 200, 'pt'), - ) - ), - GenIsolatedPhoton = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 10, -0.5, 9.5, 'Isolated photons from Rivet-based ParticleLevelProducer'), - Plot1D('eta', 'eta', 20, -7, 7, 'eta'), - NoPlot('mass'), - Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('pt', 'pt', 20, 0, 200, 'pt'), - ) - ), - GenJet = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 25, -0.5, 24.5, 'slimmedGenJets, i.e. ak4 Jets made with visible genparticles'), - Plot1D('eta', 'eta', 20, -7, 7, 'eta'), - Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), - Plot1D('mass', 'mass', 20, 0, 200, 'mass'), - Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'), - Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('pt', 'pt', 20, 0, 200, 'pt'), - ) - ), - GenJetAK8 = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 25, -0.5, 24.5, 'slimmedGenJetAK8, i.e. ak8 Jets made with visible genparticles'), - Plot1D('eta', 'eta', 20, -7, 7, 'eta'), - Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), - Plot1D('mass', 'mass', 20, 0, 200, 'mass'), - Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'), - Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('pt', 'pt', 20, 0, 200, 'pt'), - ) - ), - GenMET = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('pt', 'pt', 20, 0, 400, 'pt'), - ) - ), - GenPart = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 40, -0.5, 124.5, 'interesting gen particles '), - Plot1D('eta', 'eta', 20, -30000, 30000, 'eta'), - NoPlot('genPartIdxMother'), - Plot1D('mass', 'mass', 20, 0, 300, 'Mass stored for all particles with mass > 10 GeV and photons with mass > 1 GeV. For other particles you can lookup from PDGID'), - Plot1D('pdgId', 'pdgId', 20, -6000, 6000, 'PDG id'), - Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('pt', 'pt', 20, 0, 200, 'pt'), - Plot1D('status', 'status', 20, 0, 100, 'Particle status. 1=stable'), - Plot1D('statusFlags', 'statusFlags', 32768, 0, 32768, 'gen status flags stored bitwise, bits are: 0 : isPrompt, 1 : isDecayedLeptonHadron, 2 : isTauDecayProduct, 3 : isPromptTauDecayProduct, 4 : isDirectTauDecayProduct, 5 : isDirectPromptTauDecayProduct, 6 : isDirectHadronDecayProduct, 7 : isHardProcess, 8 : fromHardProcess, 9 : isHardProcessTauDecayProduct, 10 : isDirectHardProcessTauDecayProduct, 11 : fromHardProcessBeforeFSR, 12 : isFirstCopy, 13 : isLastCopy, 14 : isLastCopyBeforeFSR, '), - ) - ), - GenVisTau = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 4, -0.5, 3.5, 'gen hadronic taus '), - Plot1D('charge', 'charge', 3, -1.5, 1.5, 'charge'), - Plot1D('eta', 'eta', 20, -5, 5, 'eta'), - NoPlot('genPartIdxMother'), - Plot1D('mass', 'mass', 20, 0, 2, 'mass'), - Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('pt', 'pt', 20, 0, 200, 'pt'), - Plot1D('status', 'status', 16, -0.5, 15.5, 'Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other'), - ) - ), IsoTrack = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( @@ -356,8 +266,10 @@ NoPlot('electronIdx1'), NoPlot('electronIdx2'), Plot1D('eta', 'eta', 20, -6, 6, 'eta'), - NoPlot('genJetIdx'), - Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), + Plot1D('hfadjacentEtaStripsSize', 'hfadjacentEtaStripsSize', 10, 0, 10, 'eta size of the strips next to the central tower strip in HF (noise discriminating variable)'), + Plot1D('hfcentralEtaStripSize', 'hfcentralEtaStripSize', 10, 0, 10, 'eta size of the central tower strip in HF (noise discriminating variable)'), + Plot1D('hfsigmaEtaEta', 'hfsigmaEtaEta', 20, 0, 0.2, 'sigmaEtaEta for HF jets (noise discriminating variable)'), + Plot1D('hfsigmaPhiPhi', 'hfsigmaPhiPhi', 20, 0, 0.2, 'sigmaPhiPhi for HF jets (noise discriminating variable)'), Plot1D('jetId', 'jetId', 8, -0.5, 7.5, 'Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto'), Plot1D('mass', 'mass', 20, 0, 200, 'mass'), Plot1D('muEF', 'muEF', 20, 0, 1, 'muon Energy Fraction'), @@ -369,16 +281,11 @@ Plot1D('nMuons', 'nMuons', 4, -0.5, 3.5, 'number of muons in the jet'), Plot1D('neEmEF', 'neEmEF', 20, 0, 1, 'charged Electromagnetic EnergyFraction'), Plot1D('neHEF', 'neHEF', 20, 0, 1, 'neutral Hadron Energy Fraction'), - Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'), Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), Plot1D('pt', 'pt', 20, 0, 400, 'pt'), Plot1D('puId', 'puId', 8, -0.5, 7.5, 'Pilup ID flags'), Plot1D('puIdDisc', 'puIdDisc', 20, -1, 1, 'Pilup ID discriminant with 102X (2018) training'), Plot1D('qgl', 'qgl', 20, 0, 1, 'Quark vs Gluon likelihood discriminator'), - Plot1D('hfsigmaEtaEta', 'hfsigmaEtaEta', 20, 0, 0.2, 'sigmaEtaEta for HF jets (noise discriminating variable)'), - Plot1D('hfsigmaPhiPhi', 'hfsigmaPhiPhi', 20, 0, 0.2, 'sigmaPhiPhi for HF jets (noise discriminating variable)'), - Plot1D('hfcentralEtaStripSize', 'hfcentralEtaStripSize', 10, 0, 10, 'eta size of the central tower strip in HF (noise discriminating variable)'), - Plot1D('hfadjacentEtaStripsSize', 'hfadjacentEtaStripsSize', 10, 0, 10, 'eta size of the strips next to the central tower strip in HF (noise discriminating variable)'), Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'), ) ), @@ -390,8 +297,6 @@ Plot1D('covXX', 'covXX', 20, 0, 40000, 'xx element of met covariance matrix'), Plot1D('covXY', 'covXY', 20, -8000, 8000, 'xy element of met covariance matrix'), Plot1D('covYY', 'covYY', 20, 0, 50000, 'yy element of met covariance matrix'), - Plot1D('fiducialGenPhi', 'fiducialGenPhi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('fiducialGenPt', 'fiducialGenPt', 20, 0, 400, 'pt'), Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), Plot1D('pt', 'pt', 20, 0, 400, 'pt'), Plot1D('significance', 'significance', 20, 0, 200, 'MET significance'), @@ -414,8 +319,6 @@ Plot1D('dzErr', 'dzErr', 20, 0, 0.2, 'dz uncertainty, in cm'), Plot1D('eta', 'eta', 20, -2.5, 2.5, 'eta'), NoPlot('fsrPhotonIdx'), - Plot1D('genPartFlav', 'genPartFlav', 16, -0.5, 15.5, 'Flavour of genParticle for MC matching to status==1 muons: 1 = prompt muon (including gamma*->mu mu), 15 = muon from prompt tau, 5 = muon from b, 4 = muon from c, 3 = muon from light or unknown, 0 = unmatched'), - NoPlot('genPartIdx'), Plot1D('highPtId', 'highPtId', 3, -0.5, 2.5, 'POG highPt muon ID (1 = tracker high pT, 2 = global high pT, which includes tracker high pT)'), Plot1D('highPurity', 'highPurity', 2, -0.5, 1.5, 'inner track is high purity'), Plot1D('inTimeMuon', 'inTimeMuon', 2, -0.5, 1.5, 'inTimeMuon ID'), @@ -448,6 +351,7 @@ Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), Plot1D('pt', 'pt', 20, 0, 200, 'pt'), Plot1D('ptErr', 'ptErr', 20, 0, 20, 'ptError of the muon track'), + Plot1D('puppiIsoId', 'puppiIsoId', 4, -0.5, 3.5, 'PuppiIsoId from miniAOD selector (1=Loose, 2=Medium, 3=Tight)'), Plot1D('segmentComp', 'segmentComp', 20, 0, 1, 'muon segment compatibility'), Plot1D('sip3d', 'sip3d', 20, 0, 20, '3D impact parameter significance wrt first PV'), Profile1D('softId', 'softId', 'pt', 20, 0, 40, 'POG Soft muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)'), @@ -468,6 +372,25 @@ Plot1D('z', 'z', 20, -20, 20, 'Z position of other primary vertices, excluding the main PV'), ) ), + PPSLocalTrack = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 34, -0.5, 33.5, 'ppsLocalTrack variables'), + Plot1D('decRPId', 'decRPId', 20, 0, 200, 'local track detector dec id'), + Plot1D('localSlopeX', 'localSlopeX', 20, -0.2, 0.2, 'track horizontal angle'), + Plot1D('localSlopeY', 'localSlopeY', 20, -0.2, 0.2, 'track vertical angle'), + NoPlot('multiRPProtonIdx'), + Plot1D('normalizedChi2', 'normalizedChi2', 20, 0, 5, 'chi2 over NDF'), + Plot1D('numFitPoints', 'numFitPoints', 7, -0.5, 6.5, 'number of points used for fit'), + Plot1D('pixelRecoInfo', 'pixelRecoInfo', 6, -0.5, 5.5, 'flag if a ROC was shifted by a bunchx'), + Plot1D('rpType', 'rpType', 2, 3.5, 5.5, 'strip=3, pixel=4, diamond=5, timing=6'), + NoPlot('singleRPProtonIdx'), + Plot1D('time', 'time', 20, -7, 7, 'local track time'), + Plot1D('timeUnc', 'timeUnc', 20, 0, 0.3, 'local track time uncertainty'), + Plot1D('x', 'x', 20, 2, 30, 'local track x'), + Plot1D('y', 'y', 20, -20, 20, 'local track y'), + ) + ), PV = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( @@ -489,13 +412,10 @@ Plot1D('cleanmask', 'cleanmask', 1, 0.5, 1.5, 'simple cleaning mask with priority to leptons'), Plot1D('cutBased', 'cutBased', 4, -0.5, 3.5, 'cut-based ID bitmap, Fall17V2, (0:fail, 1:loose, 2:medium, 3:tight)'), Plot1D('cutBased_Fall17V1Bitmap', 'cutBased_Fall17V1Bitmap', 8, -0.5, 7.5, 'cut-based ID bitmap, Fall17V1, 2^(0:loose, 1:medium, 2:tight).'), - Plot1D('eCorr', 'eCorr', 20, 0.8, 1.2, 'ratio of the calibrated energy/miniaod energy'), NoPlot('electronIdx'), Plot1D('electronVeto', 'electronVeto', 2, -0.5, 1.5, 'pass electron veto'), Plot1D('energyErr', 'energyErr', 20, 0, 300, 'energy error of the cluster from regression'), Plot1D('eta', 'eta', 20, -3, 3, 'eta'), - Plot1D('genPartFlav', 'genPartFlav', 14, -0.5, 13.5, 'Flavour of genParticle for MC matching to status==1 photons or electrons: 1 = prompt photon, 13 = prompt electron, 0 = unknown or unmatched'), - NoPlot('genPartIdx'), Plot1D('hoe', 'hoe', 20, 0, 0.6, 'H over E'), Plot1D('isScEtaEB', 'isScEtaEB', 2, -0.5, 1.5, 'is supercluster eta within barrel acceptance'), Plot1D('isScEtaEE', 'isScEtaEE', 2, -0.5, 1.5, 'is supercluster eta within endcap acceptance'), @@ -521,60 +441,36 @@ sels = cms.PSet(), plots = cms.VPSet( Count1D('_size', 3, -0.5, 2.5, 'bon'), - Plot1D('multiRP_chi2', 'multiRP_chi2', 20, 0, 6e-07, 'chi 2'), - Plot1D('multiRP_ndof', 'multiRP_ndof', 1, -0.5, 0.5, 'n dof'), - Plot1D('multiRP_pt', 'multiRP_pt', 20, 0.06, 2, 'pt'), - Plot1D('multiRP_sector45', 'multiRP_sector45', 2, -0.5, 1.5, 'LHC sector 45'), - Plot1D('multiRP_sector56', 'multiRP_sector56', 2, -0.5, 1.5, 'LHC sector 56'), - Plot1D('multiRP_t', 'multiRP_t', 20, -2, -0.02, 't'), + Plot1D('multiRP_arm', 'multiRP_arm', 2, -0.5, 1.5, '0 = sector45, 1 = sector56'), + Plot1D('multiRP_t', 'multiRP_t', 20, -500, -0.003, 'Mandelstam variable t'), Plot1D('multiRP_thetaX', 'multiRP_thetaX', 20, -0.0004, 0.0004, 'scattering angle in the y direction'), - Plot1D('multiRP_thetaXUnc', 'multiRP_thetaXUnc', 20, 9e-06, 9e-06, 'theta X uncertainty'), Plot1D('multiRP_thetaY', 'multiRP_thetaY', 20, -0.001, 0.001, 'scattering angle in the x direction'), - Plot1D('multiRP_thetaYUnc', 'multiRP_thetaYUnc', 20, 2e-05, 2e-05, 'theta Y uncertainty'), Plot1D('multiRP_time', 'multiRP_time', 20, -1000, -1000, 'time'), Plot1D('multiRP_timeUnc', 'multiRP_timeUnc', 20, 0, 0, 'time uncertainty'), Plot1D('multiRP_validFit', 'multiRP_validFit', 2, -0.5, 1.5, 'valid Fit'), - Plot1D('multiRP_vtxY', 'multiRP_vtxY', 20, -0.07, 0.07, 'vertex y'), - Plot1D('multiRP_vtxYUnc', 'multiRP_vtxYUnc', 20, 0.02, 0.02, 'vy Error'), Plot1D('multiRP_xi', 'multiRP_xi', 20, 0, 0.3, 'fractional momentum loss'), - Plot1D('multiRP_xiUnc', 'multiRP_xiUnc', 20, 0.003, 0.003, 'uncertainty on xi or dp/p'), Plot1D('singleRP_decRPId', 'singleRP_decRPId', 20, 0, 200, 'Detector ID'), - Plot1D('singleRP_sector45', 'singleRP_sector45', 2, -0.5, 1.5, 'LHC sector 45'), - Plot1D('singleRP_sector56', 'singleRP_sector56', 2, -0.5, 1.5, 'LHC sector 56'), Plot1D('singleRP_thetaY', 'singleRP_thetaY', 20, -0.003, 0.003, 'th y'), - Plot1D('singleRP_thetaYUnc', 'singleRP_thetaYUnc', 20, 0, 0.0002, 'theta Y uncertainty'), Plot1D('singleRP_xi', 'singleRP_xi', 20, 0.03, 0.2, 'xi or dp/p'), - Plot1D('singleRP_xiUnc', 'singleRP_xiUnc', 20, 6e-05, 0.0005, 'uncertainty on xi or dp/p'), - ) - ), - Pileup = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Plot1D('gpudensity', 'gpudensity', 20, 0, 0.9, 'Generator-level PU vertices / mm'), - Plot1D('nPU', 'nPU', 20, 0, 60, 'the number of pileup interactions that have been added to the event in the current bunch crossing'), - Plot1D('nTrueInt', 'nTrueInt', 20, 0, 60, 'the true mean number of the poisson distribution for this event from which the number of interactions each bunch crossing has been sampled'), - Plot1D('pudensity', 'pudensity', 5, -0.5, 4.5, 'PU vertices / mm'), - Plot1D('sumEOOT', 'sumEOOT', 20, 0, 800, 'number of early out of time pileup'), - Plot1D('sumLOOT', 'sumLOOT', 20, 0, 300, 'number of late out of time pileup'), ) ), PuppiMET = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('phiJERUp', 'phiJERUp', 20, -3.14159, 3.14159, 'JER up phi'), Plot1D('phiJERDown', 'phiJERDown', 20, -3.14159, 3.14159, 'JER down phi'), - Plot1D('phiJESUp', 'phiJESUp', 20, -3.14159, 3.14159, 'JES up phi'), + Plot1D('phiJERUp', 'phiJERUp', 20, -3.14159, 3.14159, 'JER up phi'), Plot1D('phiJESDown', 'phiJESDown', 20, -3.14159, 3.14159, 'JES down phi'), - Plot1D('phiUnclusteredUp', 'phiUnclusteredUp', 20, -3.14159, 3.14159, 'Unclustered up phi'), + Plot1D('phiJESUp', 'phiJESUp', 20, -3.14159, 3.14159, 'JES up phi'), Plot1D('phiUnclusteredDown', 'phiUnclusteredDown', 20, -3.14159, 3.14159, 'Unclustered down phi'), + Plot1D('phiUnclusteredUp', 'phiUnclusteredUp', 20, -3.14159, 3.14159, 'Unclustered up phi'), Plot1D('pt', 'pt', 20, 0, 400, 'pt'), - Plot1D('ptJERUp', 'ptJERUp', 20, 0, 400, 'JER up pt'), Plot1D('ptJERDown', 'ptJERDown', 20, 0, 400, 'JER down pt'), - Plot1D('ptJESUp', 'ptJESUp', 20, 0, 400, 'JES up pt'), + Plot1D('ptJERUp', 'ptJERUp', 20, 0, 400, 'JER up pt'), Plot1D('ptJESDown', 'ptJESDown', 20, 0, 400, 'JES down pt'), - Plot1D('ptUnclusteredUp', 'ptUnclusteredUp', 20, 0, 400, 'Unclustered up pt'), + Plot1D('ptJESUp', 'ptJESUp', 20, 0, 400, 'JES up pt'), Plot1D('ptUnclusteredDown', 'ptUnclusteredDown', 20, 0, 400, 'Unclustered down pt'), + Plot1D('ptUnclusteredUp', 'ptUnclusteredUp', 20, 0, 400, 'Unclustered up pt'), Plot1D('sumEt', 'sumEt', 20, 200, 3000, 'scalar sum of Et'), ) ), @@ -634,8 +530,6 @@ Plot1D('mass', 'mass', 20, -200, 200, 'mass'), Plot1D('n2b1', 'n2b1', 20, 0, 1, 'N2 (beta=1)'), Plot1D('n3b1', 'n3b1', 20, 0, 5, 'N3 (beta=1)'), - Plot1D('nBHadrons', 'nBHadrons', 4, -0.5, 3.5, 'number of b-hadrons'), - Plot1D('nCHadrons', 'nCHadrons', 4, -0.5, 3.5, 'number of c-hadrons'), Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), Plot1D('pt', 'pt', 20, 0, 200, 'pt'), Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'), @@ -656,8 +550,6 @@ Plot1D('dxy', 'dxy', 20, -1000, 1000, 'd_{xy} of lead track with respect to PV, in cm (with sign)'), Plot1D('dz', 'dz', 20, -20, 20, 'd_{z} of lead track with respect to PV, in cm (with sign)'), Plot1D('eta', 'eta', 20, -3, 3, 'eta'), - Plot1D('genPartFlav', 'genPartFlav', 6, -0.5, 5.5, 'Flavour of genParticle for MC matching to status==2 taus: 1 = prompt electron, 2 = prompt muon, 3 = tau->e decay, 4 = tau->mu decay, 5 = hadronic tau decay, 0 = unknown or unmatched'), - NoPlot('genPartIdx'), Plot1D('idAntiEle', 'idAntiEle', 32, -0.5, 31.5, 'Anti-electron MVA discriminator V6: bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight, 16 = VTight'), Plot1D('idAntiEle2018', 'idAntiEle2018', 32, -0.5, 31.5, 'Anti-electron MVA discriminator V6 (2018): bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight, 16 = VTight'), Plot1D('idAntiEleDeadECal', 'idAntiEleDeadECal', 2, -0.5, 1.5, "tauID('againstElectronDeadECAL')"), From 833a81fe93b7038a2f0c69b773615daec5c76553 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Wed, 28 Oct 2020 10:51:12 -0500 Subject: [PATCH 19/29] Added proton filter and removed excess proton variables --- PhysicsTools/NanoAOD/plugins/BuildFile.xml | 1 + .../NanoAOD/plugins/ProtonProducer.cc | 13 +- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 178 ++++++++++- PhysicsTools/NanoAOD/python/protons_cff.py | 19 +- .../plugins/PPSProtonFilter.cc | 276 ++++++++++++++++++ 5 files changed, 460 insertions(+), 27 deletions(-) create mode 100644 RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc diff --git a/PhysicsTools/NanoAOD/plugins/BuildFile.xml b/PhysicsTools/NanoAOD/plugins/BuildFile.xml index b90cf33c63a40..cc738fcb67535 100644 --- a/PhysicsTools/NanoAOD/plugins/BuildFile.xml +++ b/PhysicsTools/NanoAOD/plugins/BuildFile.xml @@ -22,6 +22,7 @@ + diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index adcaa72783ef8..e43c37371e781 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -50,7 +50,7 @@ class ProtonProducer : public edm::global::EDProducer<> { mayConsume(ps.getParameter("tagRecoProtonsMulti"))), tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))) { produces>("protonRPId"); - produces>("arm"); + produces>("arm"); produces("ppsTrackTable"); } ~ProtonProducer() override {} @@ -73,7 +73,8 @@ class ProtonProducer : public edm::global::EDProducer<> { std::vector multiRP_arm; // book output variables for tracks - std::vector trackX, trackY, trackTime, trackTimeUnc, localSlopeX, localSlopeY, normalizedChi2; + std::vector trackX, trackY, trackTime, trackTimeUnc, localSlopeX, localSlopeY, + normalizedChi2; std::vector singleRPProtonIdx, multiRPProtonIdx, decRPId, numFitPoints, pixelRecoInfo, rpType; // process single-RP protons @@ -94,7 +95,7 @@ class ProtonProducer : public edm::global::EDProducer<> { multiRP_arm.reserve(num_proton); for (const auto &proton : *hRecoProtonsMultiRP) { - multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); + multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); } } @@ -147,6 +148,7 @@ class ProtonProducer : public edm::global::EDProducer<> { fillerID.insert(hRecoProtonsSingleRP, singleRP_RPId.begin(), singleRP_RPId.end()); fillerID.fill(); + // Testing std::unique_ptr> multiRP_armV(new edm::ValueMap()); edm::ValueMap::Filler fillermultiArm(*multiRP_armV); fillermultiArm.insert(hRecoProtonsMultiRP, multiRP_arm.begin(), multiRP_arm.end()); @@ -161,12 +163,7 @@ class ProtonProducer : public edm::global::EDProducer<> { ppsTab->addColumn("time", trackTime, "local track time", 16); ppsTab->addColumn("timeUnc", trackTimeUnc, "local track time uncertainty", 13); ppsTab->addColumn("decRPId", decRPId, "local track detector dec id"); - ppsTab->addColumn("numFitPoints", numFitPoints, "number of points used for fit"); - ppsTab->addColumn("pixelRecoInfo", pixelRecoInfo, "flag if a ROC was shifted by a bunchx"); - ppsTab->addColumn("normalizedChi2", normalizedChi2, "chi2 over NDF", 8); ppsTab->addColumn("rpType", rpType, "strip=3, pixel=4, diamond=5, timing=6"); - ppsTab->addColumn("localSlopeX", localSlopeX, "track horizontal angle", 11); - ppsTab->addColumn("localSlopeY", localSlopeY, "track vertical angle", 11); ppsTab->setDoc("ppsLocalTrack variables"); // save output diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 31439d9f7aad2..97ad4382cc072 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -67,9 +67,12 @@ Plot1D('dxyErr', 'dxyErr', 20, 0, 0.2, 'dxy uncertainty, in cm'), Plot1D('dz', 'dz', 20, -0.3, 0.3, 'dz (with sign) wrt first PV, in cm'), Plot1D('dzErr', 'dzErr', 20, 0, 0.2, 'dz uncertainty, in cm'), + Plot1D('eCorr', 'eCorr', 20, 0.8, 1.2, 'ratio of the calibrated energy/miniaod energy'), Plot1D('eInvMinusPInv', 'eInvMinusPInv', 20, -0.1, 0.1, '1/E_SC - 1/p_trk'), Plot1D('energyErr', 'energyErr', 20, 0, 90, 'energy error of the cluster-track combination'), Plot1D('eta', 'eta', 20, -3, 3, 'eta'), + Plot1D('genPartFlav', 'genPartFlav', 20, 0, 30, 'Flavour of genParticle for MC matching to status==1 electrons or photons: 1 = prompt electron (including gamma*->mu mu), 15 = electron from prompt tau, 22 = prompt photon (likely conversion), 5 = electron from b, 4 = electron from c, 3 = electron from light or unknown, 0 = unmatched'), + NoPlot('genPartIdx'), Plot1D('hoe', 'hoe', 20, 0, 1, 'H over E'), Plot1D('ip3d', 'ip3d', 20, 0, 0.2, '3D impact parameter wrt first PV, in cm'), Plot1D('isPFcand', 'isPFcand', 2, -0.5, 1.5, 'electron is PF candidate'), @@ -121,10 +124,13 @@ Plot1D('btagCMVA', 'btagCMVA', 20, -1, 1, 'CMVA V2 btag discriminator'), Plot1D('btagCSVV2', 'btagCSVV2', 20, -1, 1, ' pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)'), Plot1D('btagDDBvL', 'btagDDBvL', 20, -1, 1, 'DeepDoubleX (mass-decorrelated) discriminator for H(Z)->bb vs QCD'), + Plot1D('btagDDBvLV2', 'btagDDBvLV2', 20, 0, 1, 'DeepDoubleX V2(mass-decorrelated) discriminator for H(Z)->bb vs QCD'), Plot1D('btagDDBvL_noMD', 'btagDDBvL_noMD', 20, 0, 1, 'DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->bb vs QCD'), Plot1D('btagDDCvB', 'btagDDCvB', 20, -1, 1, 'DeepDoubleX (mass-decorrelated) discriminator for H(Z)->cc vs H(Z)->bb'), + Plot1D('btagDDCvBV2', 'btagDDCvBV2', 20, 0, 1, 'DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs H(Z)->bb'), Plot1D('btagDDCvB_noMD', 'btagDDCvB_noMD', 20, 0, 1, 'DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->cc vs H(Z)->bb'), Plot1D('btagDDCvL', 'btagDDCvL', 20, -1, 1, 'DeepDoubleX (mass-decorrelated) discriminator for H(Z)->cc vs QCD'), + Plot1D('btagDDCvLV2', 'btagDDCvLV2', 20, 0, 1, 'DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs QCD'), Plot1D('btagDDCvL_noMD', 'btagDDCvL_noMD', 20, 0, 1, 'DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->cc vs QCD'), Plot1D('btagDeepB', 'btagDeepB', 20, -1, 1, 'Deep B+BB btag discriminator'), Plot1D('btagHbb', 'btagHbb', 20, -1, 1, 'Higgs to BB tagger discriminator'), @@ -146,6 +152,8 @@ Plot1D('deepTag_ZvsQCD', 'deepTag_ZvsQCD', 20, 0, 1, 'DeepBoostedJet tagger Z vs QCD discriminator'), NoPlot('electronIdx3SJ'), Plot1D('eta', 'eta', 20, -4, 4, 'eta'), + NoPlot('genJetAK8Idx'), + Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), Plot1D('jetId', 'jetId', 8, -0.5, 7.5, 'Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto'), Plot1D('lsf3', 'lsf3', 20, -1, 1, 'Lepton Subjet Fraction (3 subjets)'), Plot1D('mass', 'mass', 20, 0, 300, 'mass'), @@ -153,6 +161,8 @@ NoPlot('muonIdx3SJ'), Plot1D('n2b1', 'n2b1', 20, 0, 1, 'N2 (beta=1)'), Plot1D('n3b1', 'n3b1', 20, 0, 5, 'N3 (beta=1)'), + Plot1D('nBHadrons', 'nBHadrons', 4, -0.5, 3.5, 'number of b-hadrons'), + Plot1D('nCHadrons', 'nCHadrons', 4, -0.5, 3.5, 'number of c-hadrons'), Plot1D('particleNetMD_QCD', 'particleNetMD_QCD', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw QCD score'), Plot1D('particleNetMD_Xbb', 'particleNetMD_Xbb', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw X->bb score. For X->bb vs QCD tagging, use Xbb/(Xbb+QCD)'), Plot1D('particleNetMD_Xcc', 'particleNetMD_Xcc', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw X->cc score. For X->cc vs QCD tagging, use Xcc/(Xcc+QCD)'), @@ -181,6 +191,7 @@ Plot1D('BadChargedCandidateFilter', 'BadChargedCandidateFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('BadChargedCandidateSummer16Filter', 'BadChargedCandidateSummer16Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('BadPFMuonFilter', 'BadPFMuonFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), + Plot1D('BadPFMuonDzFilter', 'BadPFMuonDzFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('BadPFMuonSummer16Filter', 'BadPFMuonSummer16Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('CSCTightHalo2015Filter', 'CSCTightHalo2015Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('CSCTightHaloFilter', 'CSCTightHaloFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), @@ -193,10 +204,12 @@ Plot1D('METFilters', 'METFilters', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('chargedHadronTrackResolutionFilter', 'chargedHadronTrackResolutionFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('ecalBadCalibFilter', 'ecalBadCalibFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), + Plot1D('ecalBadCalibFilterV2', 'ecalBadCalibFilterV2', 1, 0.5, 1.5, 'Bad ECAL calib flag (updated xtal list)'), Plot1D('ecalLaserCorrFilter', 'ecalLaserCorrFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('eeBadScFilter', 'eeBadScFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('globalSuperTightHalo2016Filter', 'globalSuperTightHalo2016Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('globalTightHalo2016Filter', 'globalTightHalo2016Filter', 2, -0.5, 1.5, 'Trigger/flag bit'), + Plot1D('hfNoisyHitsFilter', 'hfNoisyHitsFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('goodVertices', 'goodVertices', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('hcalLaserEventFilter', 'hcalLaserEventFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), Plot1D('muonBadTrackFilter', 'muonBadTrackFilter', 2, -0.5, 1.5, 'Trigger/flag bit'), @@ -218,6 +231,86 @@ Plot1D('relIso03', 'relIso03', 20, 0, 2, 'relative isolation in a 0.3 cone without CHS'), ) ), + GenDressedLepton = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 25, -0.5, 24.5, 'Dressed leptons from Rivet-based ParticleLevelProducer'), + Plot1D('eta', 'eta', 20, -7, 7, 'eta'), + Plot1D('hasTauAnc', 'hasTauAnc', 2, -0.5, 1.5, 'true if Dressed lepton has a tau as ancestor'), + Plot1D('mass', 'mass', 20, 0, 200, 'mass'), + Plot1D('pdgId', 'pdgId', 40, -20, 20, 'pdgId'), + Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('pt', 'pt', 20, 0, 200, 'pt'), + ) + ), + GenIsolatedPhoton = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 10, -0.5, 9.5, 'Isolated photons from Rivet-based ParticleLevelProducer'), + Plot1D('eta', 'eta', 20, -7, 7, 'eta'), + NoPlot('mass'), + Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('pt', 'pt', 20, 0, 200, 'pt'), + ) + ), + GenJet = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 25, -0.5, 24.5, 'slimmedGenJets, i.e. ak4 Jets made with visible genparticles'), + Plot1D('eta', 'eta', 20, -7, 7, 'eta'), + Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), + Plot1D('mass', 'mass', 20, 0, 200, 'mass'), + Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'), + Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('pt', 'pt', 20, 0, 200, 'pt'), + ) + ), + GenJetAK8 = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 25, -0.5, 24.5, 'slimmedGenJetAK8, i.e. ak8 Jets made with visible genparticles'), + Plot1D('eta', 'eta', 20, -7, 7, 'eta'), + Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), + Plot1D('mass', 'mass', 20, 0, 200, 'mass'), + Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'), + Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('pt', 'pt', 20, 0, 200, 'pt'), + ) + ), + GenMET = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('pt', 'pt', 20, 0, 400, 'pt'), + ) + ), + GenPart = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 40, -0.5, 124.5, 'interesting gen particles '), + Plot1D('eta', 'eta', 20, -30000, 30000, 'eta'), + NoPlot('genPartIdxMother'), + Plot1D('mass', 'mass', 20, 0, 300, 'Mass stored for all particles with mass > 10 GeV and photons with mass > 1 GeV. For other particles you can lookup from PDGID'), + Plot1D('pdgId', 'pdgId', 20, -6000, 6000, 'PDG id'), + Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('pt', 'pt', 20, 0, 200, 'pt'), + Plot1D('status', 'status', 20, 0, 100, 'Particle status. 1=stable'), + Plot1D('statusFlags', 'statusFlags', 32768, 0, 32768, 'gen status flags stored bitwise, bits are: 0 : isPrompt, 1 : isDecayedLeptonHadron, 2 : isTauDecayProduct, 3 : isPromptTauDecayProduct, 4 : isDirectTauDecayProduct, 5 : isDirectPromptTauDecayProduct, 6 : isDirectHadronDecayProduct, 7 : isHardProcess, 8 : fromHardProcess, 9 : isHardProcessTauDecayProduct, 10 : isDirectHardProcessTauDecayProduct, 11 : fromHardProcessBeforeFSR, 12 : isFirstCopy, 13 : isLastCopy, 14 : isLastCopyBeforeFSR, '), + ) + ), + GenVisTau = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 4, -0.5, 3.5, 'gen hadronic taus '), + Plot1D('charge', 'charge', 3, -1.5, 1.5, 'charge'), + Plot1D('eta', 'eta', 20, -5, 5, 'eta'), + NoPlot('genPartIdxMother'), + Plot1D('mass', 'mass', 20, 0, 2, 'mass'), + Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('pt', 'pt', 20, 0, 200, 'pt'), + Plot1D('status', 'status', 16, -0.5, 15.5, 'Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other'), + ) + ), IsoTrack = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( @@ -252,8 +345,13 @@ Plot1D('btagCSVV2', 'btagCSVV2', 20, -1, 1, ' pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)'), Plot1D('btagDeepB', 'btagDeepB', 20, -1, 1, 'Deep B+BB btag discriminator'), Plot1D('btagDeepC', 'btagDeepC', 20, 0, 1, 'DeepCSV charm btag discriminator'), + Plot1D('btagDeepCvB', 'btagDeepCvB', 20, -1, 1, 'DeepCSV c vs b+bb discriminator'), + Plot1D('btagDeepCvL', 'btagDeepCvL', 20, -1, 1, 'DeepCSV c vs udsg discriminator'), Plot1D('btagDeepFlavB', 'btagDeepFlavB', 20, 0, 1, 'DeepFlavour b+bb tag discriminator'), Plot1D('btagDeepFlavC', 'btagDeepFlavC', 20, 0, 1, 'DeepFlavour charm tag discriminator'), + Plot1D('btagDeepFlavCvB', 'btagDeepFlavCvB', 20, -1, 1, 'DeepJet c vs b+bb+lepb discriminator'), + Plot1D('btagDeepFlavCvL', 'btagDeepFlavCvL', 20, -1, 1, 'DeepJet c vs uds+g discriminator'), + Plot1D('btagDeepFlavQG', 'btagDeepFlavQG', 20, -1, 1, 'DeepJet g vs uds discriminator'), Plot1D('cRegCorr', 'cRegCorr', 20, 0.6, 2, 'pt correction for c-jet energy regression'), Plot1D('cRegRes', 'cRegRes', 20, 0.05, 0.4, 'res on pt corrected with c-jet regression'), Plot1D('chEmEF', 'chEmEF', 20, 0, 1, 'charged Electromagnetic Energy Fraction'), @@ -266,10 +364,8 @@ NoPlot('electronIdx1'), NoPlot('electronIdx2'), Plot1D('eta', 'eta', 20, -6, 6, 'eta'), - Plot1D('hfadjacentEtaStripsSize', 'hfadjacentEtaStripsSize', 10, 0, 10, 'eta size of the strips next to the central tower strip in HF (noise discriminating variable)'), - Plot1D('hfcentralEtaStripSize', 'hfcentralEtaStripSize', 10, 0, 10, 'eta size of the central tower strip in HF (noise discriminating variable)'), - Plot1D('hfsigmaEtaEta', 'hfsigmaEtaEta', 20, 0, 0.2, 'sigmaEtaEta for HF jets (noise discriminating variable)'), - Plot1D('hfsigmaPhiPhi', 'hfsigmaPhiPhi', 20, 0, 0.2, 'sigmaPhiPhi for HF jets (noise discriminating variable)'), + NoPlot('genJetIdx'), + Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), Plot1D('jetId', 'jetId', 8, -0.5, 7.5, 'Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto'), Plot1D('mass', 'mass', 20, 0, 200, 'mass'), Plot1D('muEF', 'muEF', 20, 0, 1, 'muon Energy Fraction'), @@ -281,14 +377,44 @@ Plot1D('nMuons', 'nMuons', 4, -0.5, 3.5, 'number of muons in the jet'), Plot1D('neEmEF', 'neEmEF', 20, 0, 1, 'charged Electromagnetic EnergyFraction'), Plot1D('neHEF', 'neHEF', 20, 0, 1, 'neutral Hadron Energy Fraction'), + Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'), Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), Plot1D('pt', 'pt', 20, 0, 400, 'pt'), Plot1D('puId', 'puId', 8, -0.5, 7.5, 'Pilup ID flags'), Plot1D('puIdDisc', 'puIdDisc', 20, -1, 1, 'Pilup ID discriminant with 102X (2018) training'), Plot1D('qgl', 'qgl', 20, 0, 1, 'Quark vs Gluon likelihood discriminator'), + Plot1D('hfsigmaEtaEta', 'hfsigmaEtaEta', 20, 0, 0.2, 'sigmaEtaEta for HF jets (noise discriminating variable)'), + Plot1D('hfsigmaPhiPhi', 'hfsigmaPhiPhi', 20, 0, 0.2, 'sigmaPhiPhi for HF jets (noise discriminating variable)'), + Plot1D('hfcentralEtaStripSize', 'hfcentralEtaStripSize', 10, 0, 10, 'eta size of the central tower strip in HF (noise discriminating variable)'), + Plot1D('hfadjacentEtaStripsSize', 'hfadjacentEtaStripsSize', 10, 0, 10, 'eta size of the strips next to the central tower strip in HF (noise discriminating variable)'), Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'), ) ), + LHEPart = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 20, 0, 20, 'LHE particles'), + Plot1D('eta', 'eta', 20, -30000, 30000, 'eta'), + Plot1D('pdgId', 'pdgId', 20, -6000, 6000, 'PDG id'), + Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('pt', 'pt', 20, 0, 200, 'pt'), + ) + ), + LHEPdfWeight = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 1000, 0, 2000, 'LHE PDF weights'), + Plot1D('', '', 100, 0, 2, 'all weights'), + ) + ), + LHEScaleWeight = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 20, 0, 20, 'LHE scale weights'), + Plot1D('', '', 100, 0, 2, 'all weights'), + ) + ), + MET = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( @@ -297,6 +423,8 @@ Plot1D('covXX', 'covXX', 20, 0, 40000, 'xx element of met covariance matrix'), Plot1D('covXY', 'covXY', 20, -8000, 8000, 'xy element of met covariance matrix'), Plot1D('covYY', 'covYY', 20, 0, 50000, 'yy element of met covariance matrix'), + Plot1D('fiducialGenPhi', 'fiducialGenPhi', 20, -3.14159, 3.14159, 'phi'), + Plot1D('fiducialGenPt', 'fiducialGenPt', 20, 0, 400, 'pt'), Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), Plot1D('pt', 'pt', 20, 0, 400, 'pt'), Plot1D('significance', 'significance', 20, 0, 200, 'MET significance'), @@ -319,6 +447,8 @@ Plot1D('dzErr', 'dzErr', 20, 0, 0.2, 'dz uncertainty, in cm'), Plot1D('eta', 'eta', 20, -2.5, 2.5, 'eta'), NoPlot('fsrPhotonIdx'), + Plot1D('genPartFlav', 'genPartFlav', 16, -0.5, 15.5, 'Flavour of genParticle for MC matching to status==1 muons: 1 = prompt muon (including gamma*->mu mu), 15 = muon from prompt tau, 5 = muon from b, 4 = muon from c, 3 = muon from light or unknown, 0 = unmatched'), + NoPlot('genPartIdx'), Plot1D('highPtId', 'highPtId', 3, -0.5, 2.5, 'POG highPt muon ID (1 = tracker high pT, 2 = global high pT, which includes tracker high pT)'), Plot1D('highPurity', 'highPurity', 2, -0.5, 1.5, 'inner track is high purity'), Plot1D('inTimeMuon', 'inTimeMuon', 2, -0.5, 1.5, 'inTimeMuon ID'), @@ -351,7 +481,6 @@ Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), Plot1D('pt', 'pt', 20, 0, 200, 'pt'), Plot1D('ptErr', 'ptErr', 20, 0, 20, 'ptError of the muon track'), - Plot1D('puppiIsoId', 'puppiIsoId', 4, -0.5, 3.5, 'PuppiIsoId from miniAOD selector (1=Loose, 2=Medium, 3=Tight)'), Plot1D('segmentComp', 'segmentComp', 20, 0, 1, 'muon segment compatibility'), Plot1D('sip3d', 'sip3d', 20, 0, 20, '3D impact parameter significance wrt first PV'), Profile1D('softId', 'softId', 'pt', 20, 0, 40, 'POG Soft muon ID (using the relaxed cuts in the data Run 2016 B-F periods, and standard cuts elsewhere)'), @@ -391,6 +520,13 @@ Plot1D('y', 'y', 20, -20, 20, 'local track y'), ) ), + PSWeight = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Plot1D('', '', 20, 0, 2, 'All PS weights (w_var / w_nominal)'), + Count1D('_size', 46, -0.5, 45.5, 'Number of PS weights'), + ) + ), PV = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( @@ -412,10 +548,13 @@ Plot1D('cleanmask', 'cleanmask', 1, 0.5, 1.5, 'simple cleaning mask with priority to leptons'), Plot1D('cutBased', 'cutBased', 4, -0.5, 3.5, 'cut-based ID bitmap, Fall17V2, (0:fail, 1:loose, 2:medium, 3:tight)'), Plot1D('cutBased_Fall17V1Bitmap', 'cutBased_Fall17V1Bitmap', 8, -0.5, 7.5, 'cut-based ID bitmap, Fall17V1, 2^(0:loose, 1:medium, 2:tight).'), + Plot1D('eCorr', 'eCorr', 20, 0.8, 1.2, 'ratio of the calibrated energy/miniaod energy'), NoPlot('electronIdx'), Plot1D('electronVeto', 'electronVeto', 2, -0.5, 1.5, 'pass electron veto'), Plot1D('energyErr', 'energyErr', 20, 0, 300, 'energy error of the cluster from regression'), Plot1D('eta', 'eta', 20, -3, 3, 'eta'), + Plot1D('genPartFlav', 'genPartFlav', 14, -0.5, 13.5, 'Flavour of genParticle for MC matching to status==1 photons or electrons: 1 = prompt photon, 13 = prompt electron, 0 = unknown or unmatched'), + NoPlot('genPartIdx'), Plot1D('hoe', 'hoe', 20, 0, 0.6, 'H over E'), Plot1D('isScEtaEB', 'isScEtaEB', 2, -0.5, 1.5, 'is supercluster eta within barrel acceptance'), Plot1D('isScEtaEE', 'isScEtaEE', 2, -0.5, 1.5, 'is supercluster eta within endcap acceptance'), @@ -454,23 +593,34 @@ Plot1D('singleRP_xi', 'singleRP_xi', 20, 0.03, 0.2, 'xi or dp/p'), ) ), + Pileup = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Plot1D('gpudensity', 'gpudensity', 20, 0, 0.9, 'Generator-level PU vertices / mm'), + Plot1D('nPU', 'nPU', 20, 0, 60, 'the number of pileup interactions that have been added to the event in the current bunch crossing'), + Plot1D('nTrueInt', 'nTrueInt', 20, 0, 60, 'the true mean number of the poisson distribution for this event from which the number of interactions each bunch crossing has been sampled'), + Plot1D('pudensity', 'pudensity', 5, -0.5, 4.5, 'PU vertices / mm'), + Plot1D('sumEOOT', 'sumEOOT', 20, 0, 800, 'number of early out of time pileup'), + Plot1D('sumLOOT', 'sumLOOT', 20, 0, 300, 'number of late out of time pileup'), + ) + ), PuppiMET = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('phiJERDown', 'phiJERDown', 20, -3.14159, 3.14159, 'JER down phi'), Plot1D('phiJERUp', 'phiJERUp', 20, -3.14159, 3.14159, 'JER up phi'), - Plot1D('phiJESDown', 'phiJESDown', 20, -3.14159, 3.14159, 'JES down phi'), + Plot1D('phiJERDown', 'phiJERDown', 20, -3.14159, 3.14159, 'JER down phi'), Plot1D('phiJESUp', 'phiJESUp', 20, -3.14159, 3.14159, 'JES up phi'), - Plot1D('phiUnclusteredDown', 'phiUnclusteredDown', 20, -3.14159, 3.14159, 'Unclustered down phi'), + Plot1D('phiJESDown', 'phiJESDown', 20, -3.14159, 3.14159, 'JES down phi'), Plot1D('phiUnclusteredUp', 'phiUnclusteredUp', 20, -3.14159, 3.14159, 'Unclustered up phi'), + Plot1D('phiUnclusteredDown', 'phiUnclusteredDown', 20, -3.14159, 3.14159, 'Unclustered down phi'), Plot1D('pt', 'pt', 20, 0, 400, 'pt'), - Plot1D('ptJERDown', 'ptJERDown', 20, 0, 400, 'JER down pt'), Plot1D('ptJERUp', 'ptJERUp', 20, 0, 400, 'JER up pt'), - Plot1D('ptJESDown', 'ptJESDown', 20, 0, 400, 'JES down pt'), + Plot1D('ptJERDown', 'ptJERDown', 20, 0, 400, 'JER down pt'), Plot1D('ptJESUp', 'ptJESUp', 20, 0, 400, 'JES up pt'), - Plot1D('ptUnclusteredDown', 'ptUnclusteredDown', 20, 0, 400, 'Unclustered down pt'), + Plot1D('ptJESDown', 'ptJESDown', 20, 0, 400, 'JES down pt'), Plot1D('ptUnclusteredUp', 'ptUnclusteredUp', 20, 0, 400, 'Unclustered up pt'), + Plot1D('ptUnclusteredDown', 'ptUnclusteredDown', 20, 0, 400, 'Unclustered down pt'), Plot1D('sumEt', 'sumEt', 20, 200, 3000, 'scalar sum of Et'), ) ), @@ -508,6 +658,7 @@ Plot1D('x', 'x', 20, -0.5, 0.5, 'secondary vertex X position, in cm'), Plot1D('y', 'y', 20, -0.5, 0.5, 'secondary vertex Y position, in cm'), Plot1D('z', 'z', 20, -10, 10, 'secondary vertex Z position, in cm'), + Plot1D('ntracks', 'ntracks', 11, -0.5, 10.5, 'number of tracks'), ) ), SoftActivityJet = cms.PSet( @@ -527,9 +678,12 @@ Plot1D('btagCSVV2', 'btagCSVV2', 20, -1, 1, ' pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)'), Plot1D('btagDeepB', 'btagDeepB', 20, -1, 1, 'Deep B+BB btag discriminator'), Plot1D('eta', 'eta', 20, -4, 4, 'eta'), + Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), Plot1D('mass', 'mass', 20, -200, 200, 'mass'), Plot1D('n2b1', 'n2b1', 20, 0, 1, 'N2 (beta=1)'), Plot1D('n3b1', 'n3b1', 20, 0, 5, 'N3 (beta=1)'), + Plot1D('nBHadrons', 'nBHadrons', 4, -0.5, 3.5, 'number of b-hadrons'), + Plot1D('nCHadrons', 'nCHadrons', 4, -0.5, 3.5, 'number of c-hadrons'), Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), Plot1D('pt', 'pt', 20, 0, 200, 'pt'), Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'), @@ -550,6 +704,8 @@ Plot1D('dxy', 'dxy', 20, -1000, 1000, 'd_{xy} of lead track with respect to PV, in cm (with sign)'), Plot1D('dz', 'dz', 20, -20, 20, 'd_{z} of lead track with respect to PV, in cm (with sign)'), Plot1D('eta', 'eta', 20, -3, 3, 'eta'), + Plot1D('genPartFlav', 'genPartFlav', 6, -0.5, 5.5, 'Flavour of genParticle for MC matching to status==2 taus: 1 = prompt electron, 2 = prompt muon, 3 = tau->e decay, 4 = tau->mu decay, 5 = hadronic tau decay, 0 = unknown or unmatched'), + NoPlot('genPartIdx'), Plot1D('idAntiEle', 'idAntiEle', 32, -0.5, 31.5, 'Anti-electron MVA discriminator V6: bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight, 16 = VTight'), Plot1D('idAntiEle2018', 'idAntiEle2018', 32, -0.5, 31.5, 'Anti-electron MVA discriminator V6 (2018): bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight, 16 = VTight'), Plot1D('idAntiEleDeadECal', 'idAntiEleDeadECal', 2, -0.5, 1.5, "tauID('againstElectronDeadECAL')"), diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index ffa4593d447d4..d3e87ca0a4b60 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -6,14 +6,16 @@ from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff import run2_nanoAOD_94X2016 from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 +filteredProtons = cms.EDProducer("PPSProtonFilter") + protonTable = cms.EDProducer("ProtonProducer", - tagRecoProtonsSingle = cms.InputTag("ctppsProtons", "singleRP"), - tagRecoProtonsMulti = cms.InputTag("ctppsProtons", "multiRP"), + tagRecoProtonsSingle = cms.InputTag("filteredProtons", "singleRP"), + tagRecoProtonsMulti = cms.InputTag("filteredProtons", "multiRP"), tagTrackLite = cms.InputTag("ctppsLocalTrackLiteProducer") ) singleRPTable = cms.EDProducer("SimpleProtonTrackFlatTableProducer", - src = cms.InputTag("ctppsProtons","singleRP"), + src = cms.InputTag("filteredProtons","singleRP"), cut = cms.string(""), name = cms.string("Proton_singleRP"), doc = cms.string("bon"), @@ -22,7 +24,7 @@ skipNonExistingSrc = cms.bool(True), variables = cms.PSet( xi = Var("xi",float,doc="xi or dp/p",precision=12), - thetaY = Var("thetaY",float,doc="th y",precision=13), + thetaY = Var("thetaY",float,doc="th y",precision=10), ), externalVariables = cms.PSet( decRPId = ExtVar("protonTable:protonRPId",int,doc="Detector ID",precision=8), @@ -30,7 +32,7 @@ ) multiRPTable = cms.EDProducer("SimpleProtonTrackFlatTableProducer", - src = cms.InputTag("ctppsProtons","multiRP"), + src = cms.InputTag("filteredProtons","multiRP"), cut = cms.string(""), name = cms.string("Proton_multiRP"), doc = cms.string("bon"), @@ -42,7 +44,7 @@ thetaX = Var("thetaX",float,doc="theta x",precision=13), thetaY = Var("thetaY",float,doc="theta y",precision=13), t = Var("t",float,doc="Mandelstam variable t",precision=13), - validFit = Var("validFit && (chi2 < 0.1)",bool,doc="valid Fit && chi2 < 0.1"), + validFit = Var("validFit && (chi2 < 0.1)",bool,doc="valid Fit"), time = Var("time()",float,doc="time",precision=16), timeUnc = Var("timeError",float,doc="time uncertainty",precision=13), ), @@ -52,10 +54,11 @@ ) protonTables = cms.Sequence( - protonTable + filteredProtons + +protonTable +singleRPTable +multiRPTable ) -for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1: +for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016: modifier.toReplaceWith(protonTables, cms.Sequence()) diff --git a/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc b/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc new file mode 100644 index 0000000000000..848d269b1f6e7 --- /dev/null +++ b/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc @@ -0,0 +1,276 @@ +/**************************************************************************** + * Authors: + * Jan Kaspar + ****************************************************************************/ + +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +/// Module to apply Proton POG quality criteria. +class PPSProtonFilter : public edm::stream::EDProducer<> { +public: + explicit PPSProtonFilter(const edm::ParameterSet &); + ~PPSProtonFilter() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + +private: + void produce(edm::Event &, const edm::EventSetup &) override; + void endStream() override; + + edm::EDGetTokenT tracksToken_; + + unsigned int verbosity_; + + double tracks_all_local_angle_x_max_, tracks_all_local_angle_y_max_; + + std::vector tracks_pixel_forbidden_RecoInfo_values_; + unsigned int tracks_pixel_number_of_hits_min_; + double tracks_pixel_normalised_chi_sq_max_; + + bool protons_single_rp_include_; + edm::EDGetTokenT protons_single_rp_input_token_; + std::string protons_single_rp_output_label_; + + bool protons_multi_rp_include_; + edm::EDGetTokenT protons_multi_rp_input_token_; + std::string protons_multi_rp_output_label_; + + bool protons_multi_rp_check_valid_fit_; + double protons_multi_rp_chi_sq_max_; + double protons_multi_rp_normalised_chi_sq_max_; + + /// counters + unsigned int n_protons_single_rp_all, n_protons_single_rp_kept; + unsigned int n_protons_multi_rp_all, n_protons_multi_rp_kept; + + /// check one track + bool IsTrackOK(const CTPPSLocalTrackLite &tr, unsigned int idx, std::ostringstream &log); +}; + +//---------------------------------------------------------------------------------------------------- + +PPSProtonFilter::PPSProtonFilter(const edm::ParameterSet &iConfig) + : verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), + n_protons_single_rp_all(0), + n_protons_single_rp_kept(0), + n_protons_multi_rp_all(0), + n_protons_multi_rp_kept(0) { + const auto &tracks_all = iConfig.getParameterSet("tracks_all"); + tracks_all_local_angle_x_max_ = tracks_all.getParameter("local_angle_x_max"); + tracks_all_local_angle_y_max_ = tracks_all.getParameter("local_angle_y_max"); + + const auto &tracks_pixel = iConfig.getParameterSet("tracks_pixel"); + tracks_pixel_forbidden_RecoInfo_values_ = + tracks_pixel.getParameter>("forbidden_RecoInfo_values"); + tracks_pixel_number_of_hits_min_ = tracks_pixel.getParameter("number_of_hits_min"); + tracks_pixel_normalised_chi_sq_max_ = tracks_pixel.getParameter("normalised_chi_sq_max"); + + const auto &protons_single_rp = iConfig.getParameterSet("protons_single_rp"); + protons_single_rp_include_ = protons_single_rp.getParameter("include"); + protons_single_rp_input_token_ = + consumes(protons_single_rp.getParameter("input_tag")); + protons_single_rp_output_label_ = protons_single_rp.getParameter("output_label"); + + const auto &protons_multi_rp = iConfig.getParameterSet("protons_multi_rp"); + protons_multi_rp_include_ = protons_multi_rp.getParameter("include"); + protons_multi_rp_input_token_ = + consumes(protons_multi_rp.getParameter("input_tag")); + protons_multi_rp_output_label_ = protons_multi_rp.getParameter("output_label"); + protons_multi_rp_check_valid_fit_ = protons_multi_rp.getParameter("check_valid_fit"); + protons_multi_rp_chi_sq_max_ = protons_multi_rp.getParameter("chi_sq_max"); + protons_multi_rp_normalised_chi_sq_max_ = protons_multi_rp.getParameter("normalised_chi_sq_max"); + + if (protons_single_rp_include_) + produces(protons_single_rp_output_label_); + + if (protons_multi_rp_include_) + produces(protons_multi_rp_output_label_); +} + +//---------------------------------------------------------------------------------------------------- + +void PPSProtonFilter::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { + edm::ParameterSetDescription desc; + + desc.addUntracked("verbosity", 0)->setComment("verbosity level"); + + edm::ParameterSetDescription tracks_all; + tracks_all.add("local_angle_x_max", 0.020) + ->setComment("maximum absolute value of local horizontal angle, in rad"); + tracks_all.add("local_angle_y_max", 0.020) + ->setComment("maximum absolute value of local horizontal angle, in rad"); + desc.add("tracks_all", tracks_all)->setComment("settings for all tracks"); + + edm::ParameterSetDescription tracks_pixel; + const std::vector def_for_RecoInfo_vals = { + (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::allShiftedPlanes, + (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::mixedPlanes}; + tracks_pixel.add>("forbidden_RecoInfo_values", def_for_RecoInfo_vals) + ->setComment("list of forbidden RecoInfo values"); + tracks_pixel.add("number_of_hits_min", 0)->setComment("minimum required number of hits"); + tracks_pixel.add("normalised_chi_sq_max", 1E100)->setComment("maximum tolerated chi square / ndof"); + desc.add("tracks_pixel", tracks_pixel) + ->setComment("specific settings for pixel-RP tracks"); + + edm::ParameterSetDescription protons_single_rp; + protons_single_rp.add("include", true)->setComment("flag whether single-RP protons should be processed"); + protons_single_rp.add("input_tag", edm::InputTag("ctppsProtons", "singleRP"))->setComment("input tag"); + protons_single_rp.add("output_label", "singleRP")->setComment("output label"); + desc.add("protons_single_rp", protons_single_rp) + ->setComment("settings for single-RP protons"); + + edm::ParameterSetDescription protons_multi_rp; + protons_multi_rp.add("include", true)->setComment("flag whether multi-RP protons should be processed"); + protons_multi_rp.add("input_tag", edm::InputTag("ctppsProtons", "multiRP"))->setComment("input tag"); + protons_multi_rp.add("output_label", "multiRP")->setComment("output label"); + protons_multi_rp.add("check_valid_fit", true)->setComment("flag whether validFit should be checked"); + protons_multi_rp.add("chi_sq_max", 1E-4)->setComment("maximum tolerated value of chi square"); + protons_multi_rp.add("normalised_chi_sq_max", 1E100) + ->setComment("maximum tolerated value of chi square / ndof, applied only if ndof > 0"); + desc.add("protons_multi_rp", protons_multi_rp) + ->setComment("settings for multi-RP protons"); + + descriptions.add("ppsProtonFilter", desc); +} + +//---------------------------------------------------------------------------------------------------- + +bool PPSProtonFilter::IsTrackOK(const CTPPSLocalTrackLite &tr, unsigned int idx, std::ostringstream &log) { + bool ok = true; + + // checks for all tracks + ok &= (std::abs(tr.tx()) < tracks_all_local_angle_x_max_); + ok &= (std::abs(tr.ty()) < tracks_all_local_angle_y_max_); + + // pixel checks + const CTPPSDetId rpId(tr.rpId()); + if (rpId.subdetId() == CTPPSDetId::sdTrackingPixel) { + ok &= (find(tracks_pixel_forbidden_RecoInfo_values_.begin(), + tracks_pixel_forbidden_RecoInfo_values_.end(), + (unsigned int)tr.pixelTrackRecoInfo()) == tracks_pixel_forbidden_RecoInfo_values_.end()); + ok &= (tr.numberOfPointsUsedForFit() >= tracks_pixel_number_of_hits_min_); + ok &= (tr.chiSquaredOverNDF() <= tracks_pixel_normalised_chi_sq_max_); + } + + if (!ok && verbosity_) + log << "track idx=" << idx << " does not fulfil criteria." << std::endl; + + return ok; +} + +//---------------------------------------------------------------------------------------------------- + +void PPSProtonFilter::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { + std::ostringstream ssLog; + + // process single-RP protons + if (protons_single_rp_include_) { + edm::Handle hInputProtons; + iEvent.getByToken(protons_single_rp_input_token_, hInputProtons); + + std::unique_ptr pOutputProtons(new reco::ForwardProtonCollection); + + for (unsigned int pr_idx = 0; pr_idx < hInputProtons->size(); ++pr_idx) { + const auto &proton = hInputProtons->at(pr_idx); + + bool keep = true; + + // no specific checks for single-RP protons + + // test contributing tracks + for (const auto &tr_ref : proton.contributingLocalTracks()) { + if (!keep) + break; + + keep &= IsTrackOK(*tr_ref, tr_ref.key(), ssLog); + } + + n_protons_single_rp_all++; + + if (keep) { + n_protons_single_rp_kept++; + pOutputProtons->push_back(proton); + } else { + if (verbosity_) + ssLog << "single-RP proton idx=" << pr_idx << " excluded." << std::endl; + } + } + + iEvent.put(std::move(pOutputProtons), protons_single_rp_output_label_); + } + + // process multi-RP protons + if (protons_multi_rp_include_) { + edm::Handle hInputProtons; + iEvent.getByToken(protons_multi_rp_input_token_, hInputProtons); + + std::unique_ptr pOutputProtons(new reco::ForwardProtonCollection); + + for (unsigned int pr_idx = 0; pr_idx < hInputProtons->size(); ++pr_idx) { + const auto &proton = hInputProtons->at(pr_idx); + + bool keep = true; + + // multi-RP proton checks + if (protons_multi_rp_check_valid_fit_) + keep &= proton.validFit(); + + keep &= (proton.chi2() <= protons_multi_rp_chi_sq_max_); + + if (proton.ndof() > 0) + keep &= (proton.normalizedChi2() <= protons_multi_rp_normalised_chi_sq_max_); + + // test contributing tracks + for (const auto &tr_ref : proton.contributingLocalTracks()) { + if (!keep) + break; + + keep &= IsTrackOK(*tr_ref, tr_ref.key(), ssLog); + } + + n_protons_multi_rp_all++; + + if (keep) { + n_protons_multi_rp_kept++; + pOutputProtons->push_back(proton); + } else { + if (verbosity_) + ssLog << "multi-RP proton idx=" << pr_idx << " excluded." << std::endl; + } + } + + iEvent.put(std::move(pOutputProtons), protons_multi_rp_output_label_); + } + + if (verbosity_ && !ssLog.str().empty()) + edm::LogInfo("PPS") << ssLog.str(); +} + +//---------------------------------------------------------------------------------------------------- + +void PPSProtonFilter::endStream() { + edm::LogInfo("PPS") + << "single-RP protons: total=" << n_protons_single_rp_all << ", kept=" << n_protons_single_rp_kept + << " --> keep rate=" + << ((n_protons_single_rp_all > 0) ? double(n_protons_single_rp_kept) / n_protons_single_rp_all * 100. : 0.) + << "%\n" + << "multi-RP protons: total=" << n_protons_multi_rp_all << ", kept=" << n_protons_multi_rp_kept + << " --> keep rate=" + << ((n_protons_multi_rp_all > 0) ? double(n_protons_multi_rp_kept) / n_protons_multi_rp_all * 100. : 0.) << "%"; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(PPSProtonFilter); From 25243c20db61a0ba054ead56ec25a6dfb50aa65b Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Wed, 28 Oct 2020 11:19:47 -0500 Subject: [PATCH 20/29] Updated with code checks --- PhysicsTools/NanoAOD/plugins/ProtonProducer.cc | 7 +++---- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 6 ------ PhysicsTools/NanoAOD/python/protons_cff.py | 1 - 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index e43c37371e781..93a9efa4cd11a 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -50,7 +50,7 @@ class ProtonProducer : public edm::global::EDProducer<> { mayConsume(ps.getParameter("tagRecoProtonsMulti"))), tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))) { produces>("protonRPId"); - produces>("arm"); + produces>("arm"); produces("ppsTrackTable"); } ~ProtonProducer() override {} @@ -73,8 +73,7 @@ class ProtonProducer : public edm::global::EDProducer<> { std::vector multiRP_arm; // book output variables for tracks - std::vector trackX, trackY, trackTime, trackTimeUnc, localSlopeX, localSlopeY, - normalizedChi2; + std::vector trackX, trackY, trackTime, trackTimeUnc, localSlopeX, localSlopeY, normalizedChi2; std::vector singleRPProtonIdx, multiRPProtonIdx, decRPId, numFitPoints, pixelRecoInfo, rpType; // process single-RP protons @@ -95,7 +94,7 @@ class ProtonProducer : public edm::global::EDProducer<> { multiRP_arm.reserve(num_proton); for (const auto &proton : *hRecoProtonsMultiRP) { - multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); + multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); } } diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 97ad4382cc072..0c3b5d33df4bc 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -506,12 +506,7 @@ plots = cms.VPSet( Count1D('_size', 34, -0.5, 33.5, 'ppsLocalTrack variables'), Plot1D('decRPId', 'decRPId', 20, 0, 200, 'local track detector dec id'), - Plot1D('localSlopeX', 'localSlopeX', 20, -0.2, 0.2, 'track horizontal angle'), - Plot1D('localSlopeY', 'localSlopeY', 20, -0.2, 0.2, 'track vertical angle'), NoPlot('multiRPProtonIdx'), - Plot1D('normalizedChi2', 'normalizedChi2', 20, 0, 5, 'chi2 over NDF'), - Plot1D('numFitPoints', 'numFitPoints', 7, -0.5, 6.5, 'number of points used for fit'), - Plot1D('pixelRecoInfo', 'pixelRecoInfo', 6, -0.5, 5.5, 'flag if a ROC was shifted by a bunchx'), Plot1D('rpType', 'rpType', 2, 3.5, 5.5, 'strip=3, pixel=4, diamond=5, timing=6'), NoPlot('singleRPProtonIdx'), Plot1D('time', 'time', 20, -7, 7, 'local track time'), @@ -586,7 +581,6 @@ Plot1D('multiRP_thetaY', 'multiRP_thetaY', 20, -0.001, 0.001, 'scattering angle in the x direction'), Plot1D('multiRP_time', 'multiRP_time', 20, -1000, -1000, 'time'), Plot1D('multiRP_timeUnc', 'multiRP_timeUnc', 20, 0, 0, 'time uncertainty'), - Plot1D('multiRP_validFit', 'multiRP_validFit', 2, -0.5, 1.5, 'valid Fit'), Plot1D('multiRP_xi', 'multiRP_xi', 20, 0, 0.3, 'fractional momentum loss'), Plot1D('singleRP_decRPId', 'singleRP_decRPId', 20, 0, 200, 'Detector ID'), Plot1D('singleRP_thetaY', 'singleRP_thetaY', 20, -0.003, 0.003, 'th y'), diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index d3e87ca0a4b60..86ed727ec2991 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -44,7 +44,6 @@ thetaX = Var("thetaX",float,doc="theta x",precision=13), thetaY = Var("thetaY",float,doc="theta y",precision=13), t = Var("t",float,doc="Mandelstam variable t",precision=13), - validFit = Var("validFit && (chi2 < 0.1)",bool,doc="valid Fit"), time = Var("time()",float,doc="time",precision=16), timeUnc = Var("timeError",float,doc="time uncertainty",precision=13), ), From 5b7877dd025bf7d6330bce2beb50cd2b0c6afbf5 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Wed, 28 Oct 2020 16:26:45 -0500 Subject: [PATCH 21/29] Another attempt at code checks --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 6 +++ .../plugins/PPSProtonFilter.cc | 48 +++++++++---------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 0c3b5d33df4bc..97ad4382cc072 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -506,7 +506,12 @@ plots = cms.VPSet( Count1D('_size', 34, -0.5, 33.5, 'ppsLocalTrack variables'), Plot1D('decRPId', 'decRPId', 20, 0, 200, 'local track detector dec id'), + Plot1D('localSlopeX', 'localSlopeX', 20, -0.2, 0.2, 'track horizontal angle'), + Plot1D('localSlopeY', 'localSlopeY', 20, -0.2, 0.2, 'track vertical angle'), NoPlot('multiRPProtonIdx'), + Plot1D('normalizedChi2', 'normalizedChi2', 20, 0, 5, 'chi2 over NDF'), + Plot1D('numFitPoints', 'numFitPoints', 7, -0.5, 6.5, 'number of points used for fit'), + Plot1D('pixelRecoInfo', 'pixelRecoInfo', 6, -0.5, 5.5, 'flag if a ROC was shifted by a bunchx'), Plot1D('rpType', 'rpType', 2, 3.5, 5.5, 'strip=3, pixel=4, diamond=5, timing=6'), NoPlot('singleRPProtonIdx'), Plot1D('time', 'time', 20, -7, 7, 'local track time'), @@ -581,6 +586,7 @@ Plot1D('multiRP_thetaY', 'multiRP_thetaY', 20, -0.001, 0.001, 'scattering angle in the x direction'), Plot1D('multiRP_time', 'multiRP_time', 20, -1000, -1000, 'time'), Plot1D('multiRP_timeUnc', 'multiRP_timeUnc', 20, 0, 0, 'time uncertainty'), + Plot1D('multiRP_validFit', 'multiRP_validFit', 2, -0.5, 1.5, 'valid Fit'), Plot1D('multiRP_xi', 'multiRP_xi', 20, 0, 0.3, 'fractional momentum loss'), Plot1D('singleRP_decRPId', 'singleRP_decRPId', 20, 0, 200, 'Detector ID'), Plot1D('singleRP_thetaY', 'singleRP_thetaY', 20, -0.003, 0.003, 'th y'), diff --git a/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc b/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc index 848d269b1f6e7..443962f1b5f7c 100644 --- a/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc +++ b/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc @@ -62,31 +62,31 @@ class PPSProtonFilter : public edm::stream::EDProducer<> { //---------------------------------------------------------------------------------------------------- PPSProtonFilter::PPSProtonFilter(const edm::ParameterSet &iConfig) - : verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), - n_protons_single_rp_all(0), - n_protons_single_rp_kept(0), - n_protons_multi_rp_all(0), - n_protons_multi_rp_kept(0) { + : verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), + n_protons_single_rp_all(0), + n_protons_single_rp_kept(0), + n_protons_multi_rp_all(0), + n_protons_multi_rp_kept(0) { const auto &tracks_all = iConfig.getParameterSet("tracks_all"); tracks_all_local_angle_x_max_ = tracks_all.getParameter("local_angle_x_max"); tracks_all_local_angle_y_max_ = tracks_all.getParameter("local_angle_y_max"); const auto &tracks_pixel = iConfig.getParameterSet("tracks_pixel"); tracks_pixel_forbidden_RecoInfo_values_ = - tracks_pixel.getParameter>("forbidden_RecoInfo_values"); + tracks_pixel.getParameter>("forbidden_RecoInfo_values"); tracks_pixel_number_of_hits_min_ = tracks_pixel.getParameter("number_of_hits_min"); tracks_pixel_normalised_chi_sq_max_ = tracks_pixel.getParameter("normalised_chi_sq_max"); const auto &protons_single_rp = iConfig.getParameterSet("protons_single_rp"); protons_single_rp_include_ = protons_single_rp.getParameter("include"); protons_single_rp_input_token_ = - consumes(protons_single_rp.getParameter("input_tag")); + consumes(protons_single_rp.getParameter("input_tag")); protons_single_rp_output_label_ = protons_single_rp.getParameter("output_label"); const auto &protons_multi_rp = iConfig.getParameterSet("protons_multi_rp"); protons_multi_rp_include_ = protons_multi_rp.getParameter("include"); protons_multi_rp_input_token_ = - consumes(protons_multi_rp.getParameter("input_tag")); + consumes(protons_multi_rp.getParameter("input_tag")); protons_multi_rp_output_label_ = protons_multi_rp.getParameter("output_label"); protons_multi_rp_check_valid_fit_ = protons_multi_rp.getParameter("check_valid_fit"); protons_multi_rp_chi_sq_max_ = protons_multi_rp.getParameter("chi_sq_max"); @@ -108,28 +108,28 @@ void PPSProtonFilter::fillDescriptions(edm::ConfigurationDescriptions &descripti edm::ParameterSetDescription tracks_all; tracks_all.add("local_angle_x_max", 0.020) - ->setComment("maximum absolute value of local horizontal angle, in rad"); + ->setComment("maximum absolute value of local horizontal angle, in rad"); tracks_all.add("local_angle_y_max", 0.020) - ->setComment("maximum absolute value of local horizontal angle, in rad"); + ->setComment("maximum absolute value of local horizontal angle, in rad"); desc.add("tracks_all", tracks_all)->setComment("settings for all tracks"); edm::ParameterSetDescription tracks_pixel; const std::vector def_for_RecoInfo_vals = { - (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::allShiftedPlanes, - (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::mixedPlanes}; + (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::allShiftedPlanes, + (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::mixedPlanes}; tracks_pixel.add>("forbidden_RecoInfo_values", def_for_RecoInfo_vals) - ->setComment("list of forbidden RecoInfo values"); + ->setComment("list of forbidden RecoInfo values"); tracks_pixel.add("number_of_hits_min", 0)->setComment("minimum required number of hits"); tracks_pixel.add("normalised_chi_sq_max", 1E100)->setComment("maximum tolerated chi square / ndof"); desc.add("tracks_pixel", tracks_pixel) - ->setComment("specific settings for pixel-RP tracks"); + ->setComment("specific settings for pixel-RP tracks"); edm::ParameterSetDescription protons_single_rp; protons_single_rp.add("include", true)->setComment("flag whether single-RP protons should be processed"); protons_single_rp.add("input_tag", edm::InputTag("ctppsProtons", "singleRP"))->setComment("input tag"); protons_single_rp.add("output_label", "singleRP")->setComment("output label"); desc.add("protons_single_rp", protons_single_rp) - ->setComment("settings for single-RP protons"); + ->setComment("settings for single-RP protons"); edm::ParameterSetDescription protons_multi_rp; protons_multi_rp.add("include", true)->setComment("flag whether multi-RP protons should be processed"); @@ -138,9 +138,9 @@ void PPSProtonFilter::fillDescriptions(edm::ConfigurationDescriptions &descripti protons_multi_rp.add("check_valid_fit", true)->setComment("flag whether validFit should be checked"); protons_multi_rp.add("chi_sq_max", 1E-4)->setComment("maximum tolerated value of chi square"); protons_multi_rp.add("normalised_chi_sq_max", 1E100) - ->setComment("maximum tolerated value of chi square / ndof, applied only if ndof > 0"); + ->setComment("maximum tolerated value of chi square / ndof, applied only if ndof > 0"); desc.add("protons_multi_rp", protons_multi_rp) - ->setComment("settings for multi-RP protons"); + ->setComment("settings for multi-RP protons"); descriptions.add("ppsProtonFilter", desc); } @@ -262,13 +262,13 @@ void PPSProtonFilter::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) void PPSProtonFilter::endStream() { edm::LogInfo("PPS") - << "single-RP protons: total=" << n_protons_single_rp_all << ", kept=" << n_protons_single_rp_kept - << " --> keep rate=" - << ((n_protons_single_rp_all > 0) ? double(n_protons_single_rp_kept) / n_protons_single_rp_all * 100. : 0.) - << "%\n" - << "multi-RP protons: total=" << n_protons_multi_rp_all << ", kept=" << n_protons_multi_rp_kept - << " --> keep rate=" - << ((n_protons_multi_rp_all > 0) ? double(n_protons_multi_rp_kept) / n_protons_multi_rp_all * 100. : 0.) << "%"; + << "single-RP protons: total=" << n_protons_single_rp_all << ", kept=" << n_protons_single_rp_kept + << " --> keep rate=" + << ((n_protons_single_rp_all > 0) ? double(n_protons_single_rp_kept) / n_protons_single_rp_all * 100. : 0.) + << "%\n" + << "multi-RP protons: total=" << n_protons_multi_rp_all << ", kept=" << n_protons_multi_rp_kept + << " --> keep rate=" + << ((n_protons_multi_rp_all > 0) ? double(n_protons_multi_rp_kept) / n_protons_multi_rp_all * 100. : 0.) << "%"; } //---------------------------------------------------------------------------------------------------- From c8df93af7664bbd94e21a42e517f743492a2b05b Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Wed, 28 Oct 2020 16:53:52 -0500 Subject: [PATCH 22/29] Removed unnecessary variables --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 61 ---------------------- 1 file changed, 61 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 97ad4382cc072..5b82cb9018cb5 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -124,13 +124,10 @@ Plot1D('btagCMVA', 'btagCMVA', 20, -1, 1, 'CMVA V2 btag discriminator'), Plot1D('btagCSVV2', 'btagCSVV2', 20, -1, 1, ' pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)'), Plot1D('btagDDBvL', 'btagDDBvL', 20, -1, 1, 'DeepDoubleX (mass-decorrelated) discriminator for H(Z)->bb vs QCD'), - Plot1D('btagDDBvLV2', 'btagDDBvLV2', 20, 0, 1, 'DeepDoubleX V2(mass-decorrelated) discriminator for H(Z)->bb vs QCD'), Plot1D('btagDDBvL_noMD', 'btagDDBvL_noMD', 20, 0, 1, 'DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->bb vs QCD'), Plot1D('btagDDCvB', 'btagDDCvB', 20, -1, 1, 'DeepDoubleX (mass-decorrelated) discriminator for H(Z)->cc vs H(Z)->bb'), - Plot1D('btagDDCvBV2', 'btagDDCvBV2', 20, 0, 1, 'DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs H(Z)->bb'), Plot1D('btagDDCvB_noMD', 'btagDDCvB_noMD', 20, 0, 1, 'DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->cc vs H(Z)->bb'), Plot1D('btagDDCvL', 'btagDDCvL', 20, -1, 1, 'DeepDoubleX (mass-decorrelated) discriminator for H(Z)->cc vs QCD'), - Plot1D('btagDDCvLV2', 'btagDDCvLV2', 20, 0, 1, 'DeepDoubleX V2 (mass-decorrelated) discriminator for H(Z)->cc vs QCD'), Plot1D('btagDDCvL_noMD', 'btagDDCvL_noMD', 20, 0, 1, 'DeepDoubleX discriminator (no mass-decorrelation) for H(Z)->cc vs QCD'), Plot1D('btagDeepB', 'btagDeepB', 20, -1, 1, 'Deep B+BB btag discriminator'), Plot1D('btagHbb', 'btagHbb', 20, -1, 1, 'Higgs to BB tagger discriminator'), @@ -345,13 +342,8 @@ Plot1D('btagCSVV2', 'btagCSVV2', 20, -1, 1, ' pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)'), Plot1D('btagDeepB', 'btagDeepB', 20, -1, 1, 'Deep B+BB btag discriminator'), Plot1D('btagDeepC', 'btagDeepC', 20, 0, 1, 'DeepCSV charm btag discriminator'), - Plot1D('btagDeepCvB', 'btagDeepCvB', 20, -1, 1, 'DeepCSV c vs b+bb discriminator'), - Plot1D('btagDeepCvL', 'btagDeepCvL', 20, -1, 1, 'DeepCSV c vs udsg discriminator'), Plot1D('btagDeepFlavB', 'btagDeepFlavB', 20, 0, 1, 'DeepFlavour b+bb tag discriminator'), Plot1D('btagDeepFlavC', 'btagDeepFlavC', 20, 0, 1, 'DeepFlavour charm tag discriminator'), - Plot1D('btagDeepFlavCvB', 'btagDeepFlavCvB', 20, -1, 1, 'DeepJet c vs b+bb+lepb discriminator'), - Plot1D('btagDeepFlavCvL', 'btagDeepFlavCvL', 20, -1, 1, 'DeepJet c vs uds+g discriminator'), - Plot1D('btagDeepFlavQG', 'btagDeepFlavQG', 20, -1, 1, 'DeepJet g vs uds discriminator'), Plot1D('cRegCorr', 'cRegCorr', 20, 0.6, 2, 'pt correction for c-jet energy regression'), Plot1D('cRegRes', 'cRegRes', 20, 0.05, 0.4, 'res on pt corrected with c-jet regression'), Plot1D('chEmEF', 'chEmEF', 20, 0, 1, 'charged Electromagnetic Energy Fraction'), @@ -390,31 +382,6 @@ Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'), ) ), - LHEPart = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 20, 0, 20, 'LHE particles'), - Plot1D('eta', 'eta', 20, -30000, 30000, 'eta'), - Plot1D('pdgId', 'pdgId', 20, -6000, 6000, 'PDG id'), - Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'), - Plot1D('pt', 'pt', 20, 0, 200, 'pt'), - ) - ), - LHEPdfWeight = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 1000, 0, 2000, 'LHE PDF weights'), - Plot1D('', '', 100, 0, 2, 'all weights'), - ) - ), - LHEScaleWeight = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 20, 0, 20, 'LHE scale weights'), - Plot1D('', '', 100, 0, 2, 'all weights'), - ) - ), - MET = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( @@ -501,32 +468,6 @@ Plot1D('z', 'z', 20, -20, 20, 'Z position of other primary vertices, excluding the main PV'), ) ), - PPSLocalTrack = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Count1D('_size', 34, -0.5, 33.5, 'ppsLocalTrack variables'), - Plot1D('decRPId', 'decRPId', 20, 0, 200, 'local track detector dec id'), - Plot1D('localSlopeX', 'localSlopeX', 20, -0.2, 0.2, 'track horizontal angle'), - Plot1D('localSlopeY', 'localSlopeY', 20, -0.2, 0.2, 'track vertical angle'), - NoPlot('multiRPProtonIdx'), - Plot1D('normalizedChi2', 'normalizedChi2', 20, 0, 5, 'chi2 over NDF'), - Plot1D('numFitPoints', 'numFitPoints', 7, -0.5, 6.5, 'number of points used for fit'), - Plot1D('pixelRecoInfo', 'pixelRecoInfo', 6, -0.5, 5.5, 'flag if a ROC was shifted by a bunchx'), - Plot1D('rpType', 'rpType', 2, 3.5, 5.5, 'strip=3, pixel=4, diamond=5, timing=6'), - NoPlot('singleRPProtonIdx'), - Plot1D('time', 'time', 20, -7, 7, 'local track time'), - Plot1D('timeUnc', 'timeUnc', 20, 0, 0.3, 'local track time uncertainty'), - Plot1D('x', 'x', 20, 2, 30, 'local track x'), - Plot1D('y', 'y', 20, -20, 20, 'local track y'), - ) - ), - PSWeight = cms.PSet( - sels = cms.PSet(), - plots = cms.VPSet( - Plot1D('', '', 20, 0, 2, 'All PS weights (w_var / w_nominal)'), - Count1D('_size', 46, -0.5, 45.5, 'Number of PS weights'), - ) - ), PV = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( @@ -658,7 +599,6 @@ Plot1D('x', 'x', 20, -0.5, 0.5, 'secondary vertex X position, in cm'), Plot1D('y', 'y', 20, -0.5, 0.5, 'secondary vertex Y position, in cm'), Plot1D('z', 'z', 20, -10, 10, 'secondary vertex Z position, in cm'), - Plot1D('ntracks', 'ntracks', 11, -0.5, 10.5, 'number of tracks'), ) ), SoftActivityJet = cms.PSet( @@ -678,7 +618,6 @@ Plot1D('btagCSVV2', 'btagCSVV2', 20, -1, 1, ' pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)'), Plot1D('btagDeepB', 'btagDeepB', 20, -1, 1, 'Deep B+BB btag discriminator'), Plot1D('eta', 'eta', 20, -4, 4, 'eta'), - Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'), Plot1D('mass', 'mass', 20, -200, 200, 'mass'), Plot1D('n2b1', 'n2b1', 20, 0, 1, 'N2 (beta=1)'), Plot1D('n3b1', 'n3b1', 20, 0, 5, 'N3 (beta=1)'), From 9e322a0fb419be4e7dd93880111ec7366adf4984 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Fri, 30 Oct 2020 14:51:56 -0500 Subject: [PATCH 23/29] implemented suggestions from perrotta --- PhysicsTools/NanoAOD/python/protons_cff.py | 5 +- ...Filter.cc => PPSFilteredProtonProducer.cc} | 70 +++++++++---------- .../python/ppsFilteredProtonProducer_cfi.py | 3 + 3 files changed, 41 insertions(+), 37 deletions(-) rename RecoPPS/ProtonReconstruction/plugins/{PPSProtonFilter.cc => PPSFilteredProtonProducer.cc} (80%) create mode 100644 RecoPPS/ProtonReconstruction/python/ppsFilteredProtonProducer_cfi.py diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index 86ed727ec2991..f9f237e7ca51e 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -5,8 +5,9 @@ from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff import run2_nanoAOD_94XMiniAODv2 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff import run2_nanoAOD_94X2016 from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 +from RecoPPS.ProtonReconstruction.ppsFilteredProtonProducer_cfi import * -filteredProtons = cms.EDProducer("PPSProtonFilter") +filteredProtons = ppsFilteredProtonProducer.clone() protonTable = cms.EDProducer("ProtonProducer", tagRecoProtonsSingle = cms.InputTag("filteredProtons", "singleRP"), @@ -59,5 +60,5 @@ +multiRPTable ) -for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016: +for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1: modifier.toReplaceWith(protonTables, cms.Sequence()) diff --git a/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc b/RecoPPS/ProtonReconstruction/plugins/PPSFilteredProtonProducer.cc similarity index 80% rename from RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc rename to RecoPPS/ProtonReconstruction/plugins/PPSFilteredProtonProducer.cc index 443962f1b5f7c..07a057421a520 100644 --- a/RecoPPS/ProtonReconstruction/plugins/PPSProtonFilter.cc +++ b/RecoPPS/ProtonReconstruction/plugins/PPSFilteredProtonProducer.cc @@ -1,7 +1,7 @@ /**************************************************************************** * Authors: - * Jan Kaspar - ****************************************************************************/ + * Jan Kaspar +****************************************************************************/ #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" @@ -18,10 +18,10 @@ //---------------------------------------------------------------------------------------------------- /// Module to apply Proton POG quality criteria. -class PPSProtonFilter : public edm::stream::EDProducer<> { +class PPSFilteredProtonProducer : public edm::stream::EDProducer<> { public: - explicit PPSProtonFilter(const edm::ParameterSet &); - ~PPSProtonFilter() override = default; + explicit PPSFilteredProtonProducer(const edm::ParameterSet &); + ~PPSFilteredProtonProducer() override = default; static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); @@ -31,7 +31,7 @@ class PPSProtonFilter : public edm::stream::EDProducer<> { edm::EDGetTokenT tracksToken_; - unsigned int verbosity_; + bool verbosity_; double tracks_all_local_angle_x_max_, tracks_all_local_angle_y_max_; @@ -61,32 +61,32 @@ class PPSProtonFilter : public edm::stream::EDProducer<> { //---------------------------------------------------------------------------------------------------- -PPSProtonFilter::PPSProtonFilter(const edm::ParameterSet &iConfig) - : verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), - n_protons_single_rp_all(0), - n_protons_single_rp_kept(0), - n_protons_multi_rp_all(0), - n_protons_multi_rp_kept(0) { +PPSFilteredProtonProducer::PPSFilteredProtonProducer(const edm::ParameterSet &iConfig) + : verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), + n_protons_single_rp_all(0), + n_protons_single_rp_kept(0), + n_protons_multi_rp_all(0), + n_protons_multi_rp_kept(0) { const auto &tracks_all = iConfig.getParameterSet("tracks_all"); tracks_all_local_angle_x_max_ = tracks_all.getParameter("local_angle_x_max"); tracks_all_local_angle_y_max_ = tracks_all.getParameter("local_angle_y_max"); const auto &tracks_pixel = iConfig.getParameterSet("tracks_pixel"); tracks_pixel_forbidden_RecoInfo_values_ = - tracks_pixel.getParameter>("forbidden_RecoInfo_values"); + tracks_pixel.getParameter>("forbidden_RecoInfo_values"); tracks_pixel_number_of_hits_min_ = tracks_pixel.getParameter("number_of_hits_min"); tracks_pixel_normalised_chi_sq_max_ = tracks_pixel.getParameter("normalised_chi_sq_max"); const auto &protons_single_rp = iConfig.getParameterSet("protons_single_rp"); protons_single_rp_include_ = protons_single_rp.getParameter("include"); protons_single_rp_input_token_ = - consumes(protons_single_rp.getParameter("input_tag")); + consumes(protons_single_rp.getParameter("input_tag")); protons_single_rp_output_label_ = protons_single_rp.getParameter("output_label"); const auto &protons_multi_rp = iConfig.getParameterSet("protons_multi_rp"); protons_multi_rp_include_ = protons_multi_rp.getParameter("include"); protons_multi_rp_input_token_ = - consumes(protons_multi_rp.getParameter("input_tag")); + consumes(protons_multi_rp.getParameter("input_tag")); protons_multi_rp_output_label_ = protons_multi_rp.getParameter("output_label"); protons_multi_rp_check_valid_fit_ = protons_multi_rp.getParameter("check_valid_fit"); protons_multi_rp_chi_sq_max_ = protons_multi_rp.getParameter("chi_sq_max"); @@ -101,28 +101,28 @@ PPSProtonFilter::PPSProtonFilter(const edm::ParameterSet &iConfig) //---------------------------------------------------------------------------------------------------- -void PPSProtonFilter::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { +void PPSFilteredProtonProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.addUntracked("verbosity", 0)->setComment("verbosity level"); + desc.addUntracked("verbosity", 0)->setComment("verbosity level"); edm::ParameterSetDescription tracks_all; tracks_all.add("local_angle_x_max", 0.020) - ->setComment("maximum absolute value of local horizontal angle, in rad"); + ->setComment("maximum absolute value of local horizontal angle, in rad"); tracks_all.add("local_angle_y_max", 0.020) - ->setComment("maximum absolute value of local horizontal angle, in rad"); + ->setComment("maximum absolute value of local horizontal angle, in rad"); desc.add("tracks_all", tracks_all)->setComment("settings for all tracks"); edm::ParameterSetDescription tracks_pixel; const std::vector def_for_RecoInfo_vals = { - (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::allShiftedPlanes, - (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::mixedPlanes}; + (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::allShiftedPlanes, + (unsigned int)CTPPSpixelLocalTrackReconstructionInfo::mixedPlanes}; tracks_pixel.add>("forbidden_RecoInfo_values", def_for_RecoInfo_vals) - ->setComment("list of forbidden RecoInfo values"); + ->setComment("list of forbidden RecoInfo values"); tracks_pixel.add("number_of_hits_min", 0)->setComment("minimum required number of hits"); tracks_pixel.add("normalised_chi_sq_max", 1E100)->setComment("maximum tolerated chi square / ndof"); desc.add("tracks_pixel", tracks_pixel) - ->setComment("specific settings for pixel-RP tracks"); + ->setComment("specific settings for pixel-RP tracks"); edm::ParameterSetDescription protons_single_rp; protons_single_rp.add("include", true)->setComment("flag whether single-RP protons should be processed"); @@ -142,12 +142,12 @@ void PPSProtonFilter::fillDescriptions(edm::ConfigurationDescriptions &descripti desc.add("protons_multi_rp", protons_multi_rp) ->setComment("settings for multi-RP protons"); - descriptions.add("ppsProtonFilter", desc); + descriptions.add("ppsFilteredProtonProducer", desc); } //---------------------------------------------------------------------------------------------------- -bool PPSProtonFilter::IsTrackOK(const CTPPSLocalTrackLite &tr, unsigned int idx, std::ostringstream &log) { +bool PPSFilteredProtonProducer::IsTrackOK(const CTPPSLocalTrackLite &tr, unsigned int idx, std::ostringstream &log) { bool ok = true; // checks for all tracks @@ -172,7 +172,7 @@ bool PPSProtonFilter::IsTrackOK(const CTPPSLocalTrackLite &tr, unsigned int idx, //---------------------------------------------------------------------------------------------------- -void PPSProtonFilter::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { +void PPSFilteredProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { std::ostringstream ssLog; // process single-RP protons @@ -260,17 +260,17 @@ void PPSProtonFilter::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) //---------------------------------------------------------------------------------------------------- -void PPSProtonFilter::endStream() { +void PPSFilteredProtonProducer::endStream() { edm::LogInfo("PPS") - << "single-RP protons: total=" << n_protons_single_rp_all << ", kept=" << n_protons_single_rp_kept - << " --> keep rate=" - << ((n_protons_single_rp_all > 0) ? double(n_protons_single_rp_kept) / n_protons_single_rp_all * 100. : 0.) - << "%\n" - << "multi-RP protons: total=" << n_protons_multi_rp_all << ", kept=" << n_protons_multi_rp_kept - << " --> keep rate=" - << ((n_protons_multi_rp_all > 0) ? double(n_protons_multi_rp_kept) / n_protons_multi_rp_all * 100. : 0.) << "%"; + << "single-RP protons: total=" << n_protons_single_rp_all << ", kept=" << n_protons_single_rp_kept + << " --> keep rate=" + << ((n_protons_single_rp_all > 0) ? double(n_protons_single_rp_kept) / n_protons_single_rp_all * 100. : 0.) + << "%\n" + << "multi-RP protons: total=" << n_protons_multi_rp_all << ", kept=" << n_protons_multi_rp_kept + << " --> keep rate=" + << ((n_protons_multi_rp_all > 0) ? double(n_protons_multi_rp_kept) / n_protons_multi_rp_all * 100. : 0.) << "%"; } //---------------------------------------------------------------------------------------------------- -DEFINE_FWK_MODULE(PPSProtonFilter); +DEFINE_FWK_MODULE(PPSFilteredProtonProducer); diff --git a/RecoPPS/ProtonReconstruction/python/ppsFilteredProtonProducer_cfi.py b/RecoPPS/ProtonReconstruction/python/ppsFilteredProtonProducer_cfi.py new file mode 100644 index 0000000000000..46c147a9e6aff --- /dev/null +++ b/RecoPPS/ProtonReconstruction/python/ppsFilteredProtonProducer_cfi.py @@ -0,0 +1,3 @@ +import FWCore.ParameterSet.Config as cms + +ppsFilteredProtonProducer = cms.EDProducer("PPSFilteredProtonProducer") From e25b018cce55a4b2673b10e1469f68df7359056a Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Sat, 31 Oct 2020 17:58:31 -0500 Subject: [PATCH 24/29] removed duplicate config file --- .../python/ppsFilteredProtonProducer_cfi.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 RecoPPS/ProtonReconstruction/python/ppsFilteredProtonProducer_cfi.py diff --git a/RecoPPS/ProtonReconstruction/python/ppsFilteredProtonProducer_cfi.py b/RecoPPS/ProtonReconstruction/python/ppsFilteredProtonProducer_cfi.py deleted file mode 100644 index 46c147a9e6aff..0000000000000 --- a/RecoPPS/ProtonReconstruction/python/ppsFilteredProtonProducer_cfi.py +++ /dev/null @@ -1,3 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -ppsFilteredProtonProducer = cms.EDProducer("PPSFilteredProtonProducer") From f558b4eca7b8edf7ca03cbe18142672a93d619ff Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 16 Nov 2020 12:07:49 -0600 Subject: [PATCH 25/29] removed singleRP protons and only storing contributing tracks for multiRP protons --- .../NanoAOD/plugins/ProtonProducer.cc | 114 ++++-------------- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 17 ++- PhysicsTools/NanoAOD/python/protons_cff.py | 26 +--- 3 files changed, 39 insertions(+), 118 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index 93a9efa4cd11a..e345c97fcc480 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -44,12 +44,8 @@ class ProtonProducer : public edm::global::EDProducer<> { public: ProtonProducer(edm::ParameterSet const &ps) - : tokenRecoProtonsSingleRP_( - mayConsume(ps.getParameter("tagRecoProtonsSingle"))), - tokenRecoProtonsMultiRP_( - mayConsume(ps.getParameter("tagRecoProtonsMulti"))), - tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))) { - produces>("protonRPId"); + : tokenRecoProtonsMultiRP_( + mayConsume(ps.getParameter("tagRecoProtonsMulti"))) { produces>("arm"); produces("ppsTrackTable"); } @@ -57,97 +53,35 @@ class ProtonProducer : public edm::global::EDProducer<> { // ------------ method called to produce the data ------------ void produce(edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override { - // Get Forward Proton handles - edm::Handle hRecoProtonsSingleRP; - iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); - + // Get Forward Proton handle edm::Handle hRecoProtonsMultiRP; iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); - // Get PPS Local Track handle - edm::Handle> ppsTracksLite; - iEvent.getByToken(tokenTracksLite_, ppsTracksLite); - // book output variables for protons - std::vector singleRP_RPId; std::vector multiRP_arm; // book output variables for tracks - std::vector trackX, trackY, trackTime, trackTimeUnc, localSlopeX, localSlopeY, normalizedChi2; - std::vector singleRPProtonIdx, multiRPProtonIdx, decRPId, numFitPoints, pixelRecoInfo, rpType; - - // process single-RP protons - { - const auto &num_proton = hRecoProtonsSingleRP->size(); - singleRP_RPId.reserve(num_proton); - - for (const auto &proton : *hRecoProtonsSingleRP) { - CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId()); - unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); - singleRP_RPId.push_back(rpDecId); - } - } - - // process multi-RP protons - { - const auto &num_proton = hRecoProtonsMultiRP->size(); - multiRP_arm.reserve(num_proton); - - for (const auto &proton : *hRecoProtonsMultiRP) { - multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); - } - } - - // process local tracks - for (unsigned int tr_idx = 0; tr_idx < ppsTracksLite->size(); ++tr_idx) { - const auto &tr = ppsTracksLite->at(tr_idx); - - CTPPSDetId rpId(tr.rpId()); - unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); - - decRPId.push_back(rpDecId); - rpType.push_back(rpId.subdetId()); - - trackX.push_back(tr.x()); - trackY.push_back(tr.y()); - trackTime.push_back(tr.time()); - trackTimeUnc.push_back(tr.timeUnc()); - numFitPoints.push_back(tr.numberOfPointsUsedForFit()); - pixelRecoInfo.push_back(static_cast(tr.pixelTrackRecoInfo())); - normalizedChi2.push_back(tr.chiSquaredOverNDF()); - localSlopeX.push_back(tr.tx()); - localSlopeY.push_back(tr.ty()); - - signed int singleRP_idx = -1; - for (unsigned int p_idx = 0; p_idx < hRecoProtonsSingleRP->size(); ++p_idx) { - const auto &proton = hRecoProtonsSingleRP->at(p_idx); - - for (const auto &ref : proton.contributingLocalTracks()) { - if (ref.key() == tr_idx) - singleRP_idx = p_idx; - } + std::vector trackX, trackY, trackTime, trackTimeUnc; + std::vector multiRPProtonIdx, decRPId, rpType; + + for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) { + const auto &proton = hRecoProtonsMultiRP->at(p_idx); + multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); + + for (const auto &ref : proton.contributingLocalTracks()) { + multiRPProtonIdx.push_back(p_idx); + CTPPSDetId rpId(ref->rpId()); + unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); + decRPId.push_back(rpDecId); + rpType.push_back(rpId.subdetId()); + trackX.push_back(ref->x()); + trackY.push_back(ref->y()); + trackTime.push_back(ref->time()); + trackTimeUnc.push_back(ref->timeUnc()); } - singleRPProtonIdx.push_back(singleRP_idx); - - signed int multiRP_idx = -1; - for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) { - const auto &proton = hRecoProtonsMultiRP->at(p_idx); - - for (const auto &ref : proton.contributingLocalTracks()) { - if (ref.key() == tr_idx) - multiRP_idx = p_idx; - } - } - multiRPProtonIdx.push_back(multiRP_idx); } - + // update proton tables - std::unique_ptr> protonRPIdV(new edm::ValueMap()); - edm::ValueMap::Filler fillerID(*protonRPIdV); - fillerID.insert(hRecoProtonsSingleRP, singleRP_RPId.begin(), singleRP_RPId.end()); - fillerID.fill(); - - // Testing std::unique_ptr> multiRP_armV(new edm::ValueMap()); edm::ValueMap::Filler fillermultiArm(*multiRP_armV); fillermultiArm.insert(hRecoProtonsMultiRP, multiRP_arm.begin(), multiRP_arm.end()); @@ -155,7 +89,6 @@ class ProtonProducer : public edm::global::EDProducer<> { // build track table auto ppsTab = std::make_unique(trackX.size(), "PPSLocalTrack", false); - ppsTab->addColumn("singleRPProtonIdx", singleRPProtonIdx, "local track - proton correspondence"); ppsTab->addColumn("multiRPProtonIdx", multiRPProtonIdx, "local track - proton correspondence"); ppsTab->addColumn("x", trackX, "local track x", 16); ppsTab->addColumn("y", trackY, "local track y", 13); @@ -166,7 +99,6 @@ class ProtonProducer : public edm::global::EDProducer<> { ppsTab->setDoc("ppsLocalTrack variables"); // save output - iEvent.put(std::move(protonRPIdV), "protonRPId"); iEvent.put(std::move(multiRP_armV), "arm"); iEvent.put(std::move(ppsTab), "ppsTrackTable"); } @@ -174,16 +106,12 @@ class ProtonProducer : public edm::global::EDProducer<> { // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.add("tagRecoProtonsSingle")->setComment("singleRP proton collection"); desc.add("tagRecoProtonsMulti")->setComment("multiRP proton collection"); - desc.add("tagTrackLite")->setComment("pps local tracks lite collection"); descriptions.add("ProtonProducer", desc); } protected: - const edm::EDGetTokenT tokenRecoProtonsSingleRP_; const edm::EDGetTokenT tokenRecoProtonsMultiRP_; - const edm::EDGetTokenT> tokenTracksLite_; }; DEFINE_FWK_MODULE(ProtonProducer); diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 5b82cb9018cb5..8eafd6a36b677 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -468,6 +468,19 @@ Plot1D('z', 'z', 20, -20, 20, 'Z position of other primary vertices, excluding the main PV'), ) ), + PPSLocalTrack = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 26, -0.5, 25.5, 'ppsLocalTrack variables'), + Plot1D('decRPId', 'decRPId', 20, 0, 200, 'local track detector dec id'), + NoPlot('multiRPProtonIdx'), + Plot1D('rpType', 'rpType', 2, 3.5, 5.5, 'strip=3, pixel=4, diamond=5, timing=6'), + Plot1D('time', 'time', 20, -2, 2, 'local track time'), + Plot1D('timeUnc', 'timeUnc', 20, 0, 0.3, 'local track time uncertainty'), + Plot1D('x', 'x', 20, 2, 30, 'local track x'), + Plot1D('y', 'y', 20, -20, 20, 'local track y'), + ) + ), PV = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( @@ -527,11 +540,7 @@ Plot1D('multiRP_thetaY', 'multiRP_thetaY', 20, -0.001, 0.001, 'scattering angle in the x direction'), Plot1D('multiRP_time', 'multiRP_time', 20, -1000, -1000, 'time'), Plot1D('multiRP_timeUnc', 'multiRP_timeUnc', 20, 0, 0, 'time uncertainty'), - Plot1D('multiRP_validFit', 'multiRP_validFit', 2, -0.5, 1.5, 'valid Fit'), Plot1D('multiRP_xi', 'multiRP_xi', 20, 0, 0.3, 'fractional momentum loss'), - Plot1D('singleRP_decRPId', 'singleRP_decRPId', 20, 0, 200, 'Detector ID'), - Plot1D('singleRP_thetaY', 'singleRP_thetaY', 20, -0.003, 0.003, 'th y'), - Plot1D('singleRP_xi', 'singleRP_xi', 20, 0.03, 0.2, 'xi or dp/p'), ) ), Pileup = cms.PSet( diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index f9f237e7ca51e..6ecdd8faae261 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -7,29 +7,14 @@ from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 from RecoPPS.ProtonReconstruction.ppsFilteredProtonProducer_cfi import * -filteredProtons = ppsFilteredProtonProducer.clone() +filteredProtons = ppsFilteredProtonProducer.clone( + protons_single_rp = cms.PSet( + include = cms.bool(False) + ) +) protonTable = cms.EDProducer("ProtonProducer", - tagRecoProtonsSingle = cms.InputTag("filteredProtons", "singleRP"), tagRecoProtonsMulti = cms.InputTag("filteredProtons", "multiRP"), - tagTrackLite = cms.InputTag("ctppsLocalTrackLiteProducer") -) - -singleRPTable = cms.EDProducer("SimpleProtonTrackFlatTableProducer", - src = cms.InputTag("filteredProtons","singleRP"), - cut = cms.string(""), - name = cms.string("Proton_singleRP"), - doc = cms.string("bon"), - singleton = cms.bool(False), - extension = cms.bool(False), - skipNonExistingSrc = cms.bool(True), - variables = cms.PSet( - xi = Var("xi",float,doc="xi or dp/p",precision=12), - thetaY = Var("thetaY",float,doc="th y",precision=10), - ), - externalVariables = cms.PSet( - decRPId = ExtVar("protonTable:protonRPId",int,doc="Detector ID",precision=8), - ), ) multiRPTable = cms.EDProducer("SimpleProtonTrackFlatTableProducer", @@ -56,7 +41,6 @@ protonTables = cms.Sequence( filteredProtons +protonTable - +singleRPTable +multiRPTable ) From 10264f0030c3ba81d0f514fabf78088e7a2d34c5 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 16 Nov 2020 12:38:47 -0600 Subject: [PATCH 26/29] code check fixes --- .../NanoAOD/plugins/ProtonProducer.cc | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index e345c97fcc480..e4adb22ea7296 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -45,7 +45,7 @@ class ProtonProducer : public edm::global::EDProducer<> { public: ProtonProducer(edm::ParameterSet const &ps) : tokenRecoProtonsMultiRP_( - mayConsume(ps.getParameter("tagRecoProtonsMulti"))) { + mayConsume(ps.getParameter("tagRecoProtonsMulti"))) { produces>("arm"); produces("ppsTrackTable"); } @@ -69,18 +69,18 @@ class ProtonProducer : public edm::global::EDProducer<> { multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); for (const auto &ref : proton.contributingLocalTracks()) { - multiRPProtonIdx.push_back(p_idx); - CTPPSDetId rpId(ref->rpId()); - unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); - decRPId.push_back(rpDecId); - rpType.push_back(rpId.subdetId()); - trackX.push_back(ref->x()); - trackY.push_back(ref->y()); - trackTime.push_back(ref->time()); - trackTimeUnc.push_back(ref->timeUnc()); + multiRPProtonIdx.push_back(p_idx); + CTPPSDetId rpId(ref->rpId()); + unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); + decRPId.push_back(rpDecId); + rpType.push_back(rpId.subdetId()); + trackX.push_back(ref->x()); + trackY.push_back(ref->y()); + trackTime.push_back(ref->time()); + trackTimeUnc.push_back(ref->timeUnc()); } } - + // update proton tables std::unique_ptr> multiRP_armV(new edm::ValueMap()); edm::ValueMap::Filler fillermultiArm(*multiRP_armV); From 960358d516351ff2dd84f1a309d412625a069538 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Mon, 16 Nov 2020 12:43:10 -0600 Subject: [PATCH 27/29] update to master --- .../NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc | 4 ++++ PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc index 5df583d99c311..9f0d23477ef13 100644 --- a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc +++ b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc @@ -15,9 +15,13 @@ typedef SimpleFlatTableProducer SimpleProtonTrackFlatTableP #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" typedef SimpleFlatTableProducer SimpleLocalTrackFlatTableProducer; +#include "DataFormats/Math/interface/Point3D.h" +typedef EventSingletonSimpleFlatTableProducer SimpleXYZPointFlatTableProducer; + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SimpleCandidateFlatTableProducer); DEFINE_FWK_MODULE(SimpleGenEventFlatTableProducer); DEFINE_FWK_MODULE(SimpleHTXSFlatTableProducer); DEFINE_FWK_MODULE(SimpleProtonTrackFlatTableProducer); DEFINE_FWK_MODULE(SimpleLocalTrackFlatTableProducer); +DEFINE_FWK_MODULE(SimpleXYZPointFlatTableProducer); diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 8eafd6a36b677..fd7fe5c35f317 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -481,6 +481,13 @@ Plot1D('y', 'y', 20, -20, 20, 'local track y'), ) ), + PSWeight = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Plot1D('', '', 20, 0, 2, 'All PS weights (w_var / w_nominal)'), + Count1D('_size', 46, -0.5, 45.5, 'Number of PS weights'), + ) + ), PV = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( From 4425dc4caf318cb4568a9a40bfd40bd675c9d3e5 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Fri, 20 Nov 2020 07:25:23 -0600 Subject: [PATCH 28/29] configurable option to store singleRP protons --- .../NanoAOD/plugins/ProtonProducer.cc | 128 ++++++++++++++++-- PhysicsTools/NanoAOD/python/protons_cff.py | 27 +++- 2 files changed, 141 insertions(+), 14 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc index e4adb22ea7296..4769073b5549a 100644 --- a/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/ProtonProducer.cc @@ -45,9 +45,15 @@ class ProtonProducer : public edm::global::EDProducer<> { public: ProtonProducer(edm::ParameterSet const &ps) : tokenRecoProtonsMultiRP_( - mayConsume(ps.getParameter("tagRecoProtonsMulti"))) { + mayConsume(ps.getParameter("tagRecoProtonsMulti"))), + tokenRecoProtonsSingleRP_( + mayConsume(ps.getParameter("tagRecoProtonsSingle"))), + tokenTracksLite_(mayConsume>(ps.getParameter("tagTrackLite"))), + storeSingleRPProtons_(ps.getParameter("storeSingleRPProtons")) { produces>("arm"); produces("ppsTrackTable"); + if (storeSingleRPProtons_) + produces>("protonRPId"); } ~ProtonProducer() override {} @@ -57,27 +63,106 @@ class ProtonProducer : public edm::global::EDProducer<> { edm::Handle hRecoProtonsMultiRP; iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); + edm::Handle hRecoProtonsSingleRP; + iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); + + // Get PPS Local Track handle + edm::Handle> ppsTracksLite; + iEvent.getByToken(tokenTracksLite_, ppsTracksLite); + // book output variables for protons std::vector multiRP_arm; // book output variables for tracks std::vector trackX, trackY, trackTime, trackTimeUnc; std::vector multiRPProtonIdx, decRPId, rpType; + std::vector singleRPProtonIdx, singleRP_protonRPId; + + if (storeSingleRPProtons_) { + // process single-RP protons + { + const auto &num_proton = hRecoProtonsSingleRP->size(); + singleRP_protonRPId.reserve(num_proton); + + for (const auto &proton : *hRecoProtonsSingleRP) { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId()); + unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); + singleRP_protonRPId.push_back(rpDecId); + } + } + + // process multi-RP protons + { + const auto &num_proton = hRecoProtonsMultiRP->size(); + multiRP_arm.reserve(num_proton); + + for (const auto &proton : *hRecoProtonsMultiRP) { + multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); + } + } + + // process local tracks + for (unsigned int tr_idx = 0; tr_idx < ppsTracksLite->size(); ++tr_idx) { + const auto &tr = ppsTracksLite->at(tr_idx); - for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) { - const auto &proton = hRecoProtonsMultiRP->at(p_idx); - multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); + bool found = false; - for (const auto &ref : proton.contributingLocalTracks()) { - multiRPProtonIdx.push_back(p_idx); - CTPPSDetId rpId(ref->rpId()); + CTPPSDetId rpId(tr.rpId()); unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); - decRPId.push_back(rpDecId); - rpType.push_back(rpId.subdetId()); - trackX.push_back(ref->x()); - trackY.push_back(ref->y()); - trackTime.push_back(ref->time()); - trackTimeUnc.push_back(ref->timeUnc()); + + signed int singleRP_idx = -1; + for (unsigned int p_idx = 0; p_idx < hRecoProtonsSingleRP->size(); ++p_idx) { + const auto &proton = hRecoProtonsSingleRP->at(p_idx); + + for (const auto &ref : proton.contributingLocalTracks()) { + if (ref.key() == tr_idx) { + singleRP_idx = p_idx; + found = true; + } + } + } + + signed int multiRP_idx = -1; + for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) { + const auto &proton = hRecoProtonsMultiRP->at(p_idx); + + for (const auto &ref : proton.contributingLocalTracks()) { + if (ref.key() == tr_idx) { + multiRP_idx = p_idx; + found = true; + } + } + } + + if (found) { + singleRPProtonIdx.push_back(singleRP_idx); + multiRPProtonIdx.push_back(multiRP_idx); + decRPId.push_back(rpDecId); + rpType.push_back(rpId.subdetId()); + trackX.push_back(tr.x()); + trackY.push_back(tr.y()); + trackTime.push_back(tr.time()); + trackTimeUnc.push_back(tr.timeUnc()); + } + } + } + + else { + for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) { + const auto &proton = hRecoProtonsMultiRP->at(p_idx); + multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0); + + for (const auto &ref : proton.contributingLocalTracks()) { + multiRPProtonIdx.push_back(p_idx); + CTPPSDetId rpId(ref->rpId()); + unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp(); + decRPId.push_back(rpDecId); + rpType.push_back(rpId.subdetId()); + trackX.push_back(ref->x()); + trackY.push_back(ref->y()); + trackTime.push_back(ref->time()); + trackTimeUnc.push_back(ref->timeUnc()); + } } } @@ -87,9 +172,18 @@ class ProtonProducer : public edm::global::EDProducer<> { fillermultiArm.insert(hRecoProtonsMultiRP, multiRP_arm.begin(), multiRP_arm.end()); fillermultiArm.fill(); + std::unique_ptr> protonRPIdV(new edm::ValueMap()); + edm::ValueMap::Filler fillerID(*protonRPIdV); + if (storeSingleRPProtons_) { + fillerID.insert(hRecoProtonsSingleRP, singleRP_protonRPId.begin(), singleRP_protonRPId.end()); + fillerID.fill(); + } + // build track table auto ppsTab = std::make_unique(trackX.size(), "PPSLocalTrack", false); ppsTab->addColumn("multiRPProtonIdx", multiRPProtonIdx, "local track - proton correspondence"); + if (storeSingleRPProtons_) + ppsTab->addColumn("singleRPProtonIdx", singleRPProtonIdx, "local track - proton correspondence"); ppsTab->addColumn("x", trackX, "local track x", 16); ppsTab->addColumn("y", trackY, "local track y", 13); ppsTab->addColumn("time", trackTime, "local track time", 16); @@ -101,17 +195,25 @@ class ProtonProducer : public edm::global::EDProducer<> { // save output iEvent.put(std::move(multiRP_armV), "arm"); iEvent.put(std::move(ppsTab), "ppsTrackTable"); + if (storeSingleRPProtons_) + iEvent.put(std::move(protonRPIdV), "protonRPId"); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; desc.add("tagRecoProtonsMulti")->setComment("multiRP proton collection"); + desc.add("tagRecoProtonsSingle")->setComment("singleRP proton collection"); + desc.add("tagTrackLite")->setComment("pps local tracks lite collection"); + desc.add("storeSingleRPProtons")->setComment("flag to store singleRP protons and associated tracks"); descriptions.add("ProtonProducer", desc); } protected: const edm::EDGetTokenT tokenRecoProtonsMultiRP_; + const edm::EDGetTokenT tokenRecoProtonsSingleRP_; + const edm::EDGetTokenT> tokenTracksLite_; + const bool storeSingleRPProtons_; }; DEFINE_FWK_MODULE(ProtonProducer); diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index 6ecdd8faae261..959e3a71921d0 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -7,15 +7,21 @@ from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff import run2_nanoAOD_102Xv1 from RecoPPS.ProtonReconstruction.ppsFilteredProtonProducer_cfi import * +singleRPProtons = True + filteredProtons = ppsFilteredProtonProducer.clone( protons_single_rp = cms.PSet( - include = cms.bool(False) + include = cms.bool(singleRPProtons) ) ) protonTable = cms.EDProducer("ProtonProducer", tagRecoProtonsMulti = cms.InputTag("filteredProtons", "multiRP"), + tagTrackLite = cms.InputTag("ctppsLocalTrackLiteProducer"), + storeSingleRPProtons = cms.bool(singleRPProtons) ) +protonTable.tagRecoProtonsSingle = cms.InputTag("filteredProtons" if singleRPProtons else "ctppsProtons","singleRP") + multiRPTable = cms.EDProducer("SimpleProtonTrackFlatTableProducer", src = cms.InputTag("filteredProtons","multiRP"), @@ -38,11 +44,30 @@ ), ) +singleRPTable = cms.EDProducer("SimpleProtonTrackFlatTableProducer", + src = cms.InputTag("filteredProtons","singleRP"), + cut = cms.string(""), + name = cms.string("Proton_singleRP"), + doc = cms.string("bon"), + singleton = cms.bool(False), + extension = cms.bool(True), + skipNonExistingSrc = cms.bool(True), + variables = cms.PSet( + xi = Var("xi",float,doc="xi or dp/p",precision=12), + thetaY = Var("thetaY",float,doc="th y",precision=10), + ), + externalVariables = cms.PSet( + decRPId = ExtVar("protonTable:protonRPId",int,doc="Detector ID",precision=8), + ), +) + protonTables = cms.Sequence( filteredProtons +protonTable +multiRPTable ) +if singleRPProtons: protonTables.insert(protonTables.index(multiRPTable),singleRPTable) + for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1: modifier.toReplaceWith(protonTables, cms.Sequence()) From 9be39945e56f3f1be88c3f1b499167e7adb18586 Mon Sep 17 00:00:00 2001 From: Justin Williams Date: Tue, 24 Nov 2020 16:30:51 -0600 Subject: [PATCH 29/29] Updated name of tables in dqm --- PhysicsTools/NanoAOD/python/nanoDQM_cfi.py | 25 +++++++++++++++------- PhysicsTools/NanoAOD/python/protons_cff.py | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py index 9a7d0ad978d0d..7ef08b85c3bc7 100644 --- a/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py +++ b/PhysicsTools/NanoAOD/python/nanoDQM_cfi.py @@ -581,17 +581,26 @@ NoPlot('vidNestedWPBitmap'), ) ), - Proton = cms.PSet( + Proton_multiRP = cms.PSet( sels = cms.PSet(), plots = cms.VPSet( Count1D('_size', 3, -0.5, 2.5, 'bon'), - Plot1D('multiRP_arm', 'multiRP_arm', 2, -0.5, 1.5, '0 = sector45, 1 = sector56'), - Plot1D('multiRP_t', 'multiRP_t', 20, -500, -0.003, 'Mandelstam variable t'), - Plot1D('multiRP_thetaX', 'multiRP_thetaX', 20, -0.0004, 0.0004, 'scattering angle in the y direction'), - Plot1D('multiRP_thetaY', 'multiRP_thetaY', 20, -0.001, 0.001, 'scattering angle in the x direction'), - Plot1D('multiRP_time', 'multiRP_time', 20, -1000, -1000, 'time'), - Plot1D('multiRP_timeUnc', 'multiRP_timeUnc', 20, 0, 0, 'time uncertainty'), - Plot1D('multiRP_xi', 'multiRP_xi', 20, 0, 0.3, 'fractional momentum loss'), + Plot1D('arm', 'arm', 2, -0.5, 1.5, '0 = sector45, 1 = sector56'), + Plot1D('t', 't', 20, -500, -0.003, 'Mandelstam variable t'), + Plot1D('thetaX', 'thetaX', 20, -0.0004, 0.0004, 'scattering angle in the y direction'), + Plot1D('thetaY', 'thetaY', 20, -0.001, 0.001, 'scattering angle in the x direction'), + Plot1D('time', 'time', 20, -1000, -1000, 'time'), + Plot1D('timeUnc', 'timeUnc', 20, 0, 0, 'time uncertainty'), + Plot1D('xi', 'xi', 20, 0, 0.3, 'fractional momentum loss'), + ) + ), + Proton_singleRP = cms.PSet( + sels = cms.PSet(), + plots = cms.VPSet( + Count1D('_size', 3, -0.5, 2.5, 'bon'), + Plot1D('xi', 'xi', 20, 0, 0.3, 'fractional momentum loss'), + Plot1D('thetaY', 'thetaY', 20, -0.001, 0.001, 'scattering angle in the x direction'), + Plot1D('decRPId', 'decRPId', 20, 0, 200, 'Detector ID'), ) ), Pileup = cms.PSet( diff --git a/PhysicsTools/NanoAOD/python/protons_cff.py b/PhysicsTools/NanoAOD/python/protons_cff.py index 959e3a71921d0..95a017cdac2a9 100644 --- a/PhysicsTools/NanoAOD/python/protons_cff.py +++ b/PhysicsTools/NanoAOD/python/protons_cff.py @@ -50,7 +50,7 @@ name = cms.string("Proton_singleRP"), doc = cms.string("bon"), singleton = cms.bool(False), - extension = cms.bool(True), + extension = cms.bool(False), skipNonExistingSrc = cms.bool(True), variables = cms.PSet( xi = Var("xi",float,doc="xi or dp/p",precision=12),