From 435cb208b25a543a678e8a5b2f1a09ab243111bb Mon Sep 17 00:00:00 2001 From: Jakob Date: Sun, 19 Apr 2020 13:24:30 +0200 Subject: [PATCH 1/3] decrease event size by storing PFCandidates with half precision float point format --- HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc index c7d8243064f49..6f4f9ff0ae21d 100644 --- a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc +++ b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc @@ -39,6 +39,8 @@ Description: Producer for ScoutingPFJets from reco::PFJet objects, ScoutingVerte #include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/Math/interface/libminifloat.h" + class HLTScoutingPFProducer : public edm::global::EDProducer<> { public: explicit HLTScoutingPFProducer(const edm::ParameterSet &); @@ -60,6 +62,7 @@ class HLTScoutingPFProducer : public edm::global::EDProducer<> { const double pfJetEtaCut; const double pfCandidatePtCut; const double pfCandidateEtaCut; + const bool storeWithHalfPrecisionFloatingPoint; const bool doJetTags; const bool doCandidates; @@ -81,6 +84,7 @@ HLTScoutingPFProducer::HLTScoutingPFProducer(const edm::ParameterSet &iConfig) pfJetEtaCut(iConfig.getParameter("pfJetEtaCut")), pfCandidatePtCut(iConfig.getParameter("pfCandidatePtCut")), pfCandidateEtaCut(iConfig.getParameter("pfCandidateEtaCut")), + storeWithHalfPrecisionFloatingPoint(iConfig.getParameter("storeWithHalfPrecisionFloatingPoint")), doJetTags(iConfig.getParameter("doJetTags")), doCandidates(iConfig.getParameter("doCandidates")), doMet(iConfig.getParameter("doMet")) { @@ -151,7 +155,14 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event &iEvent, edm:: break; ++index_counter; } - outPFCandidates->emplace_back(cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId(), vertex_index); + + if(storeWithHalfPrecisionFloatingPoint) { + outPFCandidates->emplace_back(MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.pt())), MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.eta())), MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.phi())), MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.mass())), cand.pdgId(), vertex_index); + } + else { + outPFCandidates->emplace_back(cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId(), vertex_index); + } + } } } @@ -253,6 +264,7 @@ void HLTScoutingPFProducer::fillDescriptions(edm::ConfigurationDescriptions &des desc.add("pfJetEtaCut", 3.0); desc.add("pfCandidatePtCut", 0.6); desc.add("pfCandidateEtaCut", 5.0); + desc.add("storeWithHalfPrecisionFloatingPoint", false); desc.add("doJetTags", true); desc.add("doCandidates", true); desc.add("doMet", true); From be726b07f1258436dbc57acf6020504f638cbe8f Mon Sep 17 00:00:00 2001 From: Jakob Date: Sun, 19 Apr 2020 14:07:46 +0200 Subject: [PATCH 2/3] clang format --- .../JetMET/plugins/HLTScoutingPFProducer.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc index 6f4f9ff0ae21d..8063de8f1775b 100644 --- a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc +++ b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc @@ -156,13 +156,16 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event &iEvent, edm:: ++index_counter; } - if(storeWithHalfPrecisionFloatingPoint) { - outPFCandidates->emplace_back(MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.pt())), MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.eta())), MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.phi())), MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.mass())), cand.pdgId(), vertex_index); - } - else { - outPFCandidates->emplace_back(cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId(), vertex_index); - } - + if (storeWithHalfPrecisionFloatingPoint) { + outPFCandidates->emplace_back(MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.pt())), + MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.eta())), + MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.phi())), + MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.mass())), + cand.pdgId(), + vertex_index); + } else { + outPFCandidates->emplace_back(cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId(), vertex_index); + } } } } From 70f4902d0ae193f8106045e05569dd4b17631022 Mon Sep 17 00:00:00 2001 From: Jakob Date: Fri, 1 May 2020 16:32:52 +0200 Subject: [PATCH 3/3] change to adjustable precision via MiniFloatConverter::reduceMantissaToNbitsRounding --- .../JetMET/plugins/HLTScoutingPFProducer.cc | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc index 8063de8f1775b..33093fe7c23ba 100644 --- a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc +++ b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc @@ -62,7 +62,7 @@ class HLTScoutingPFProducer : public edm::global::EDProducer<> { const double pfJetEtaCut; const double pfCandidatePtCut; const double pfCandidateEtaCut; - const bool storeWithHalfPrecisionFloatingPoint; + const int mantissaPrecision; const bool doJetTags; const bool doCandidates; @@ -84,7 +84,7 @@ HLTScoutingPFProducer::HLTScoutingPFProducer(const edm::ParameterSet &iConfig) pfJetEtaCut(iConfig.getParameter("pfJetEtaCut")), pfCandidatePtCut(iConfig.getParameter("pfCandidatePtCut")), pfCandidateEtaCut(iConfig.getParameter("pfCandidateEtaCut")), - storeWithHalfPrecisionFloatingPoint(iConfig.getParameter("storeWithHalfPrecisionFloatingPoint")), + mantissaPrecision(iConfig.getParameter("mantissaPrecision")), doJetTags(iConfig.getParameter("doJetTags")), doCandidates(iConfig.getParameter("doCandidates")), doMet(iConfig.getParameter("doMet")) { @@ -156,16 +156,12 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event &iEvent, edm:: ++index_counter; } - if (storeWithHalfPrecisionFloatingPoint) { - outPFCandidates->emplace_back(MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.pt())), - MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.eta())), - MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.phi())), - MiniFloatConverter::float16to32(MiniFloatConverter::float32to16(cand.mass())), - cand.pdgId(), - vertex_index); - } else { - outPFCandidates->emplace_back(cand.pt(), cand.eta(), cand.phi(), cand.mass(), cand.pdgId(), vertex_index); - } + outPFCandidates->emplace_back(MiniFloatConverter::reduceMantissaToNbitsRounding(cand.pt(), mantissaPrecision), + MiniFloatConverter::reduceMantissaToNbitsRounding(cand.eta(), mantissaPrecision), + MiniFloatConverter::reduceMantissaToNbitsRounding(cand.phi(), mantissaPrecision), + MiniFloatConverter::reduceMantissaToNbitsRounding(cand.mass(), mantissaPrecision), + cand.pdgId(), + vertex_index); } } } @@ -267,7 +263,7 @@ void HLTScoutingPFProducer::fillDescriptions(edm::ConfigurationDescriptions &des desc.add("pfJetEtaCut", 3.0); desc.add("pfCandidatePtCut", 0.6); desc.add("pfCandidateEtaCut", 5.0); - desc.add("storeWithHalfPrecisionFloatingPoint", false); + desc.add("mantissaPrecision", 23); desc.add("doJetTags", true); desc.add("doCandidates", true); desc.add("doMet", true);