diff --git a/Configuration/PyReleaseValidation/python/relval_Run4.py b/Configuration/PyReleaseValidation/python/relval_Run4.py index 0f59a438a0053..abf770014f7c1 100644 --- a/Configuration/PyReleaseValidation/python/relval_Run4.py +++ b/Configuration/PyReleaseValidation/python/relval_Run4.py @@ -80,6 +80,7 @@ numWFIB.extend([prefixDet+34.759]) # HLTTiming75e33 + NANO numWFIB.extend([prefixDet+34.77]) # NGTScouting numWFIB.extend([prefixDet+34.771]) # NGTScouting + NANO +numWFIB.extend([prefixDet+34.772]) # NGTScouting + NANO (including validation) for numWF in numWFIB: workflows[numWF] = _upgrade_workflows[numWF] diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 226c4f25423e7..d019213282a2e 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -1974,6 +1974,17 @@ def condition(self, fragment, stepList, key, hasHarvest): upgradeWFs['NGTScoutingWithNano'].step2 = { '-s':'DIGI:pdigi_valid,L1TrackTrigger,L1,L1P2GT,DIGI2RAW,HLT:NGTScouting,NANO:@NGTScouting', '--datatier':'GEN-SIM-DIGI-RAW,NANOAODSIM', + '--procModifiers': 'ngtScouting', + '--eventcontent':'FEVTDEBUGHLT,NANOAODSIM' +} + +upgradeWFs['NGTScoutingWithNanoValid'] = deepcopy(upgradeWFs['HLTPhaseWithNano']) +upgradeWFs['NGTScoutingWithNanoValid'].suffix = '_NGTScoutingWithNanoVal' +upgradeWFs['NGTScoutingWithNanoValid'].offset = 0.772 +upgradeWFs['NGTScoutingWithNanoValid'].step2 = { + '-s':'DIGI:pdigi_valid,L1TrackTrigger,L1,L1P2GT,DIGI2RAW,HLT:NGTScouting,VALIDATION:@hltValidation,NANO:@NGTScoutingVal', + '--datatier':'GEN-SIM-DIGI-RAW,NANOAODSIM', + '--procModifiers': 'ngtScouting', '--eventcontent':'FEVTDEBUGHLT,NANOAODSIM' } diff --git a/Configuration/PyReleaseValidation/scripts/runTheMatrix.py b/Configuration/PyReleaseValidation/scripts/runTheMatrix.py index c8a3e24962323..e01e5f817c87a 100755 --- a/Configuration/PyReleaseValidation/scripts/runTheMatrix.py +++ b/Configuration/PyReleaseValidation/scripts/runTheMatrix.py @@ -161,10 +161,11 @@ def runSelected(opt): 29634.756, # HLT phase-2 timing menu trimmed tracking 29634.7561, # HLT phase-2 timing menu Alpaka, trimmed tracking 29634.7562, # HLT phase-2 timing menu Alpaka, trimmed tracking, single tracking iteration variant - 29634.759, # HLT phase-2 timing menu Alpaka, single tracking iteration, LST seeding + CKF building variant - 29634.757, # HLT phase-2 timing menu, with NANO:@Phase2HLT + 29634.757, # HLT phase-2 timing menu Alpaka, single tracking iteration, LST seeding + CKF building variant + 29634.759, # HLT phase-2 timing menu, with NANO:@Phase2HLT 29634.77, # HLT phase-2 NGT Scouting menu - 29634.771] # HLT phase-2 NGT Scouting menu, with NANO:@NGTScouting + 29634.771, # HLT phase-2 NGT Scouting menu, with NANO:@NGTScouting + 29634.772] # HLT phase-2 NGT Scouting menu, with NANO:@NGTScoutingVal } predefinedSet['limited'] = ( diff --git a/HLTrigger/NGTScouting/plugins/BuildFile.xml b/HLTrigger/NGTScouting/plugins/BuildFile.xml index f064f4b0dda77..46629d37c5c83 100644 --- a/HLTrigger/NGTScouting/plugins/BuildFile.xml +++ b/HLTrigger/NGTScouting/plugins/BuildFile.xml @@ -1,18 +1,17 @@ - - - - - - - - + - + + + + + + + + - + - diff --git a/HLTrigger/NGTScouting/plugins/HLTElectronTableProducer.cc b/HLTrigger/NGTScouting/plugins/HLTElectronTableProducer.cc index 23cc292dac076..84a0e67892b0f 100644 --- a/HLTrigger/NGTScouting/plugins/HLTElectronTableProducer.cc +++ b/HLTrigger/NGTScouting/plugins/HLTElectronTableProducer.cc @@ -1,21 +1,17 @@ #include // user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" - +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "DataFormats/NanoAOD/interface/FlatTable.h" +#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" - +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/StreamID.h" - -#include "CommonTools/Utils/interface/StringCutObjectSelector.h" - -#include "DataFormats/NanoAOD/interface/FlatTable.h" - #include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h" -#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h" + typedef SimpleFlatTableProducer HLTElectronTableProducer; #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/HLTrigger/NGTScouting/plugins/HLTPhotonTableProducer.cc b/HLTrigger/NGTScouting/plugins/HLTPhotonTableProducer.cc index fcf314b071b81..33338f1fc9e8c 100644 --- a/HLTrigger/NGTScouting/plugins/HLTPhotonTableProducer.cc +++ b/HLTrigger/NGTScouting/plugins/HLTPhotonTableProducer.cc @@ -1,21 +1,17 @@ #include // user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" - +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "DataFormats/NanoAOD/interface/FlatTable.h" +#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" - +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/StreamID.h" - -#include "CommonTools/Utils/interface/StringCutObjectSelector.h" - -#include "DataFormats/NanoAOD/interface/FlatTable.h" - #include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h" -#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h" + typedef SimpleFlatTableProducer HLTPhotonTableProducer; #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/HLTrigger/NGTScouting/plugins/HLTTauTableProducer.cc b/HLTrigger/NGTScouting/plugins/HLTTauTableProducer.cc new file mode 100644 index 0000000000000..775be14a138ad --- /dev/null +++ b/HLTrigger/NGTScouting/plugins/HLTTauTableProducer.cc @@ -0,0 +1,151 @@ +#include "DataFormats/NanoAOD/interface/FlatTable.h" +#include "DataFormats/TauReco/interface/PFTauTransverseImpactParameterAssociation.h" +#include "DataFormats/TauReco/interface/TauDiscriminatorContainer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class HLTTauTableProducer : public edm::global::EDProducer<> { +public: + using TauCollection = edm::View; + using TauIPVector = edm::AssociationVector>; + using TauDiscrMap = reco::TauDiscriminatorContainer; + // TauCollection = deeptau.TauCollection; + // using TauDeepTauVector = edm::AssociationVector>; + HLTTauTableProducer(const edm::ParameterSet& cfg) + : tableName_(cfg.getParameter("tableName")), + skipNonExistingSrc_(cfg.getParameter("skipNonExistingSrc")), + tauToken_(mayConsume(cfg.getParameter("taus"))), + tauIPToken_(mayConsume(cfg.getParameter("tauTransverseImpactParameters"))), + deepTauVSeToken_(mayConsume(cfg.getParameter("deepTauVSe"))), + deepTauVSmuToken_(mayConsume(cfg.getParameter("deepTauVSmu"))), + deepTauVSjetToken_(mayConsume(cfg.getParameter("deepTauVSjet"))), + precision_(cfg.getParameter("precision")) { + produces(tableName_); + } + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("tableName", "hltHpsPFTau") + ->setComment("Table name, needs to be the same as the main Tau table"); + desc.add("skipNonExistingSrc", false) + ->setComment("whether or not to skip producing the table on absent input product"); + desc.add("taus", edm::InputTag("")); + desc.add("tauTransverseImpactParameters", edm::InputTag("")); + desc.add("deepTauVSe", edm::InputTag("")); + desc.add("deepTauVSmu", edm::InputTag("")); + desc.add("deepTauVSjet", edm::InputTag("")); + desc.add("precision", 7); + descriptions.addWithDefaultLabel(desc); + } + +private: + void produce(edm::StreamID id, edm::Event& event, const edm::EventSetup& setup) const override { + const auto tausHandle = event.getHandle(tauToken_); + const size_t nTaus = tausHandle.isValid() ? (*tausHandle).size() : 0; + + // resize all output vectors + static constexpr float default_value = std::numeric_limits::quiet_NaN(); + + std::vector deepTauVSe(nTaus, default_value); + std::vector deepTauVSmu(nTaus, default_value); + std::vector deepTauVSjet(nTaus, default_value); + + // source: RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc + std::vector dxy(nTaus, default_value); + std::vector dxy_error(nTaus, default_value); + std::vector ip3d(nTaus, default_value); + std::vector ip3d_error(nTaus, default_value); + std::vector hasSecondaryVertex(nTaus, default_value); + std::vector flightLength_x(nTaus, default_value); + std::vector flightLength_y(nTaus, default_value); + std::vector flightLength_z(nTaus, default_value); + std::vector flightLengthSig(nTaus, default_value); + std::vector secondaryVertex_x(nTaus, default_value); + std::vector secondaryVertex_y(nTaus, default_value); + std::vector secondaryVertex_z(nTaus, default_value); + + if (tausHandle.isValid() || !(this->skipNonExistingSrc_)) { + const auto& tausProductId = tausHandle.id(); + const auto& tausIPHandle = event.getHandle(tauIPToken_); + const auto& deepTauVSeMapHandle = event.getHandle(deepTauVSeToken_); + const auto& deepTauVSmuMapHandle = event.getHandle(deepTauVSmuToken_); + const auto& deepTauVSjetMapHandle = event.getHandle(deepTauVSjetToken_); + + for (size_t tau_index = 0; tau_index < nTaus; ++tau_index) { + if (deepTauVSeMapHandle.isValid() || !(this->skipNonExistingSrc_)) { + deepTauVSe[tau_index] = deepTauVSeMapHandle->get(tausProductId, tau_index).rawValues.at(0); + } else { + edm::LogWarning("HLTTauTableProducer") << " Invalid handle for DeeTauVse score input collection"; + } + + if (deepTauVSmuMapHandle.isValid() || !(this->skipNonExistingSrc_)) { + deepTauVSmu[tau_index] = deepTauVSmuMapHandle->get(tausProductId, tau_index).rawValues.at(0); + } else { + edm::LogWarning("HLTTauTableProducer") << " Invalid handle for DeeTauVsMu score input collection"; + } + + if (deepTauVSjetMapHandle.isValid() || !(this->skipNonExistingSrc_)) { + deepTauVSjet[tau_index] = deepTauVSjetMapHandle->get(tausProductId, tau_index).rawValues.at(0); + } else { + edm::LogWarning("HLTTauTableProducer") << " Invalid handle for DeeTauVsJet score input collection"; + } + + if (tausIPHandle.isValid() || !(this->skipNonExistingSrc_)) { + dxy[tau_index] = tausIPHandle->value(tau_index)->dxy(); + dxy_error[tau_index] = tausIPHandle->value(tau_index)->dxy_error(); + ip3d[tau_index] = tausIPHandle->value(tau_index)->ip3d(); + ip3d_error[tau_index] = tausIPHandle->value(tau_index)->ip3d_error(); + hasSecondaryVertex[tau_index] = tausIPHandle->value(tau_index)->hasSecondaryVertex(); + flightLength_x[tau_index] = tausIPHandle->value(tau_index)->flightLength().x(); + flightLength_y[tau_index] = tausIPHandle->value(tau_index)->flightLength().y(); + flightLength_z[tau_index] = tausIPHandle->value(tau_index)->flightLength().z(); + flightLengthSig[tau_index] = tausIPHandle->value(tau_index)->flightLengthSig(); + + if (hasSecondaryVertex[tau_index] > 0) { + secondaryVertex_x[tau_index] = tausIPHandle->value(tau_index)->secondaryVertex()->x(); + secondaryVertex_y[tau_index] = tausIPHandle->value(tau_index)->secondaryVertex()->y(); + secondaryVertex_z[tau_index] = tausIPHandle->value(tau_index)->secondaryVertex()->z(); + } + } else { + edm::LogWarning("HLTTauTableProducer") << " Invalid handle for Tau IP input collection"; + } + } + } else { + edm::LogWarning("HLTTauTableProducer") << " Invalid handle for PFTau candidate input collection"; + } + + auto tauTable = std::make_unique(nTaus, tableName_, /*singleton*/ false, /*extension*/ true); + tauTable->addColumn("dxy", dxy, "tau transverse impact parameter", precision_); + tauTable->addColumn("dxy_error", dxy_error, " dxy_error ", precision_); + tauTable->addColumn("ip3d", ip3d, " ip3d ", precision_); + tauTable->addColumn("ip3d_error", ip3d_error, " ip3d_error ", precision_); + tauTable->addColumn("hasSecondaryVertex", hasSecondaryVertex, " hasSecondaryVertex ", precision_); + tauTable->addColumn("flightLength_x", flightLength_x, "flightLength_x", precision_); + tauTable->addColumn("flightLength_y", flightLength_y, "flightLength_y", precision_); + tauTable->addColumn("flightLength_z", flightLength_z, "flightLength_z", precision_); + tauTable->addColumn("flightLengthSig", flightLengthSig, "flightLengthSig", precision_); + tauTable->addColumn("secondaryVertex_x", secondaryVertex_x, "secondaryVertex_x", precision_); + tauTable->addColumn("secondaryVertex_y", secondaryVertex_y, "secondaryVertex_y", precision_); + tauTable->addColumn("secondaryVertex_z", secondaryVertex_z, "secondaryVertex_z", precision_); + tauTable->addColumn("deepTauVSe", deepTauVSe, "tau vs electron discriminator", precision_); + tauTable->addColumn("deepTauVSmu", deepTauVSmu, "tau vs muon discriminator", precision_); + tauTable->addColumn("deepTauVSjet", deepTauVSjet, "tau vs jet discriminator", precision_); + + event.put(std::move(tauTable), tableName_); + } + +private: + const std::string tableName_; + const bool skipNonExistingSrc_; + const edm::EDGetTokenT tauToken_; + const edm::EDGetTokenT tauIPToken_; + const edm::EDGetTokenT deepTauVSeToken_, deepTauVSmuToken_, deepTauVSjetToken_; + const unsigned int precision_; +}; + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(HLTTauTableProducer); diff --git a/HLTrigger/NGTScouting/plugins/HLTVertexTableProducer.cc b/HLTrigger/NGTScouting/plugins/HLTVertexTableProducer.cc index d2cf14365a4c4..6b410713457cc 100644 --- a/HLTrigger/NGTScouting/plugins/HLTVertexTableProducer.cc +++ b/HLTrigger/NGTScouting/plugins/HLTVertexTableProducer.cc @@ -1,28 +1,22 @@ #include // user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" - +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" +#include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/NanoAOD/interface/FlatTable.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/VertexReco/interface/Vertex.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" - +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/StreamID.h" - -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" - -#include "CommonTools/Utils/interface/StringCutObjectSelector.h" - -#include "DataFormats/NanoAOD/interface/FlatTable.h" -#include "RecoVertex/VertexTools/interface/VertexDistance3D.h" -#include "RecoVertex/VertexTools/interface/VertexDistanceXY.h" #include "RecoVertex/VertexPrimitives/interface/ConvertToFromReco.h" #include "RecoVertex/VertexPrimitives/interface/VertexState.h" -#include "DataFormats/Common/interface/ValueMap.h" - -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "RecoVertex/VertexTools/interface/VertexDistance3D.h" +#include "RecoVertex/VertexTools/interface/VertexDistanceXY.h" // // class declaration @@ -37,6 +31,7 @@ class HLTVertexTableProducer : public edm::stream::EDProducer<> { void produce(edm::Event&, const edm::EventSetup&) override; // ----------member data --------------------------- + const bool skipNonExistingSrc_; const edm::EDGetTokenT> pvs_; const edm::EDGetTokenT pfc_; const edm::EDGetTokenT> pvsScore_; @@ -51,16 +46,15 @@ class HLTVertexTableProducer : public edm::stream::EDProducer<> { // HLTVertexTableProducer::HLTVertexTableProducer(const edm::ParameterSet& params) - : pvs_(consumes>(params.getParameter("pvSrc"))), + : skipNonExistingSrc_(params.getParameter("skipNonExistingSrc")), + pvs_(consumes>(params.getParameter("pvSrc"))), pfc_(consumes(params.getParameter("pfSrc"))), pvsScore_(consumes>(params.getParameter("pvSrc"))), goodPvCut_(params.getParameter("goodPvCut"), true), goodPvCutString_(params.getParameter("goodPvCut")), pvName_(params.getParameter("pvName")), dlenMin_(params.getParameter("dlenMin")), - dlenSigMin_(params.getParameter("dlenSigMin")) - -{ + dlenSigMin_(params.getParameter("dlenSigMin")) { produces("PV"); produces>(); } @@ -75,83 +69,92 @@ void HLTVertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& //vertex collection auto pvsIn = iEvent.getHandle(pvs_); - if (!pvsIn.isValid()) { - edm::LogWarning("HLTVertexTableProducer") - << "Invalid handle for " << pvName_ << " in primary vertex input collection"; - return; - } - const auto& pvsScoreProd = iEvent.get(pvsScore_); - - //pf candidates collection - auto pfcIn = iEvent.getHandle(pfc_); - if (!pfcIn.isValid()) { - edm::LogWarning("HLTVertexTableProducer") - << "Invalid handle for " << pvName_ << " in PF candidate input collection"; - return; - } + const size_t nPVs = pvsIn.isValid() ? (*pvsIn).size() : 0; + + static constexpr float default_value = std::numeric_limits::quiet_NaN(); + + std::vector v_ndof(nPVs, default_value); + std::vector v_chi2(nPVs, default_value); + std::vector v_x(nPVs, default_value); + std::vector v_y(nPVs, default_value); + std::vector v_z(nPVs, default_value); + std::vector v_xError(nPVs, default_value); + std::vector v_yError(nPVs, default_value); + std::vector v_zError(nPVs, default_value); + std::vector v_is_good(nPVs, 0); + std::vector v_nTracks(nPVs, 0); + std::vector v_pv_score(nPVs, default_value); + std::vector v_pv_sumpt2(nPVs, default_value); + std::vector v_pv_sumpx(nPVs, default_value); + std::vector v_pv_sumpy(nPVs, default_value); + + if (pvsIn.isValid() || !(this->skipNonExistingSrc_)) { + const auto& pvs = *pvsIn; + const auto& pvsScoreProd = iEvent.get(pvsScore_); + + auto pfcIn = iEvent.getHandle(pfc_); + const bool isPfcValid = pfcIn.isValid(); + + for (size_t i = 0; i < nPVs; ++i) { + const auto& pv = pvs[i]; + const auto& pos = pv.position(); + + v_ndof[i] = pv.ndof(); + v_chi2[i] = pv.normalizedChi2(); + v_x[i] = pv.x(); + v_y[i] = pv.y(); + v_z[i] = pv.z(); + v_xError[i] = pv.xError(); + v_yError[i] = pv.yError(); + v_zError[i] = pv.zError(); + v_nTracks[i] = pv.nTracks(); + v_is_good[i] = goodPvCut_(pv); + v_pv_score[i] = pvsScoreProd.get(pvsIn.id(), i); + + float sumpt2 = 0.f, sumpx = 0.f, sumpy = 0.f; + + if (isPfcValid || !(this->skipNonExistingSrc_)) { + for (const auto& obj : *pfcIn) { + if (obj.charge() == 0 || !obj.trackRef().isNonnull()) + continue; + + const auto dz = std::abs(obj.trackRef()->dz(pos)); + if (dz >= 0.2) + continue; + + bool isClosest = true; + for (size_t j = 0; j < nPVs; ++j) { + if (j == i) + continue; + const auto dz_j = std::abs(obj.trackRef()->dz(pvs[j].position())); + if (dz_j < dz) { + isClosest = false; + break; + } + } - std::vector v_ndof; - std::vector v_chi2; - std::vector v_x; - std::vector v_y; - std::vector v_z; - std::vector v_xError; - std::vector v_yError; - std::vector v_zError; - std::vector v_is_good; - std::vector v_nTracks; - std::vector v_pv_score; - std::vector v_pv_sumpt2; - std::vector v_pv_sumpx; - std::vector v_pv_sumpy; - - for (size_t i = 0; i < (*pvsIn).size(); i++) { - v_ndof.push_back((*pvsIn)[i].ndof()); - v_chi2.push_back((*pvsIn)[i].normalizedChi2()); - v_x.push_back((*pvsIn)[i].x()); - v_y.push_back((*pvsIn)[i].y()); - v_z.push_back((*pvsIn)[i].z()); - v_xError.push_back((*pvsIn)[i].xError()); - v_yError.push_back((*pvsIn)[i].yError()); - v_zError.push_back((*pvsIn)[i].zError()); - v_nTracks.push_back((*pvsIn)[i].nTracks()); - v_is_good.push_back(goodPvCut_((*pvsIn)[i])); - v_pv_score.push_back(pvsScoreProd.get(pvsIn.id(), i)); - - float pv_sumpt2 = 0; - float pv_sumpx = 0; - float pv_sumpy = 0; - for (const auto& obj : *pfcIn) { - // skip neutrals - if (obj.charge() == 0) - continue; - double dz = fabs(obj.trackRef()->dz((*pvsIn)[i].position())); - bool include_pfc = false; - if (dz < 0.2) { - include_pfc = true; - for (size_t j = 0; j < (*pvsIn).size() && j != i; j++) { - double newdz = fabs(obj.trackRef()->dz((*pvsIn)[j].position())); - if (newdz < dz) { - include_pfc = false; - break; + if (isClosest) { + const float pt = obj.pt(); + sumpt2 += pt * pt; + sumpx += obj.px(); + sumpy += obj.py(); } - } // this pf candidate belongs to other PV - } - if (include_pfc) { - float pfc_pt = obj.pt(); - pv_sumpt2 += pfc_pt * pfc_pt; - pv_sumpx += obj.px(); - pv_sumpy += obj.py(); + } + } else { + edm::LogWarning("HLTVertexTableProducer") + << " Invalid handle for " << pvName_ << " in PF candidate input collection"; } + v_pv_sumpt2[i] = sumpt2; + v_pv_sumpx[i] = sumpx; + v_pv_sumpy[i] = sumpy; } - - v_pv_sumpt2.push_back(pv_sumpt2); - v_pv_sumpx.push_back(pv_sumpx); - v_pv_sumpy.push_back(pv_sumpy); + } else { + edm::LogWarning("HLTVertexTableProducer") + << " Invalid handle for " << pvName_ << " in primary vertex input collection"; } //table for all primary vertices - auto pvTable = std::make_unique((*pvsIn).size(), pvName_, true); + auto pvTable = std::make_unique(nPVs, pvName_, true); pvTable->addColumn("ndof", v_ndof, "primary vertex number of degrees of freedom", 8); pvTable->addColumn("chi2", v_chi2, "primary vertex reduced chi2", 8); pvTable->addColumn("x", v_x, "primary vertex x coordinate", 10); @@ -178,15 +181,15 @@ void HLTVertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& void HLTVertexTableProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; + desc.add("skipNonExistingSrc", false) + ->setComment("whether or not to skip producing the table on absent input product"); desc.add("pvName")->setComment("name of the flat table ouput"); desc.add("pvSrc")->setComment( "std::vector and ValueMap primary vertex input collections"); desc.add("pfSrc")->setComment("reco::PFCandidateCollection PF candidates input collections"); desc.add("goodPvCut")->setComment("selection on the primary vertex"); - desc.add("dlenMin")->setComment("minimum value of dl to select secondary vertex"); desc.add("dlenSigMin")->setComment("minimum value of dl significance to select secondary vertex"); - descriptions.addWithDefaultLabel(desc); } diff --git a/HLTrigger/NGTScouting/python/HLTNanoProducer_cff.py b/HLTrigger/NGTScouting/python/HLTNanoProducer_cff.py index d8a081030426a..80ee532ad6dbf 100644 --- a/HLTrigger/NGTScouting/python/HLTNanoProducer_cff.py +++ b/HLTrigger/NGTScouting/python/HLTNanoProducer_cff.py @@ -1,9 +1,17 @@ import FWCore.ParameterSet.Config as cms +from PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi import * +from PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi import * from PhysicsTools.NanoAOD.common_cff import * - +from PhysicsTools.NanoAOD.jetMC_cff import * from PhysicsTools.NanoAOD.genparticles_cff import * +from PhysicsTools.PatAlgos.slimming.genParticles_cff import * +from PhysicsTools.PatAlgos.slimming.packedGenParticles_cfi import * from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import * +from PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi import * +from PhysicsTools.PatAlgos.slimming.slimmedGenJets_cfi import * +from RecoJets.Configuration.GenJetParticles_cff import * +from RecoJets.Configuration.RecoGenJets_cff import * from HLTrigger.NGTScouting.hltVertices_cfi import * from HLTrigger.NGTScouting.hltEGammaPacker_cfi import * from HLTrigger.NGTScouting.hltPhotons_cfi import * @@ -13,13 +21,28 @@ from HLTrigger.NGTScouting.hltJets_cfi import * from HLTrigger.NGTScouting.hltTaus_cfi import * from HLTrigger.NGTScouting.hltTracksters_cfi import * +from HLTrigger.NGTScouting.hltSums_cfi import * from HLTrigger.NGTScouting.hltTriggerAcceptFilter_cfi import hltTriggerAcceptFilter,dstTriggerAcceptFilter -hltNanoProducer = cms.Sequence( - prunedGenParticles +NanoGenTable = cms.Sequence( + prunedGenParticlesWithStatusOne + + prunedGenParticles + finalGenParticles + genParticleTable - + hltTriggerAcceptFilter + + genParticlesForJetsNoNu + + ak4GenJetsNoNu + + selectedHadronsAndPartonsForGenJetsFlavourInfos + + packedGenParticles + + slimmedGenJets + + ak4GenJetFlavourInfos + + slimmedGenJetsFlavourInfos + + genJetTable + + genJetFlavourTable +) + +hltNanoProducer = cms.Sequence( + NanoGenTable + #+ hltTriggerAcceptFilter + hltVertexTable + hltPixelTrackTable + hltGeneralTrackTable @@ -31,12 +54,14 @@ + hltPFCandidateTable + hltJetTable + hltTrackstersTable + + hltTauTable + + hltTauExtTable + + METTable + + HTTable ) dstNanoProducer = cms.Sequence( - prunedGenParticles - + finalGenParticles - + genParticleTable + NanoGenTable + dstTriggerAcceptFilter + hltVertexTable + hltPixelTrackTable @@ -50,12 +75,16 @@ + hltJetTable + hltTauTable + hltTrackstersTable + + hltTauExtTable + + METTable + + HTTable ) def hltNanoCustomize(process): if hasattr(process, "NANOAODSIMoutput"): - process.prunedGenParticles.src = "genParticles" + # process.genJetTable.cut = "pt > 10" + # process.genJetFlavourTable.deltaR = 0.3 process.genParticleTable.externalVariables = cms.PSet() # remove iso as external variable from PhysicsTools/NanoAOD/python/genparticles_cff.py:37 (hopefully temporarily) process.NANOAODSIMoutput.outputCommands.append( "keep nanoaodFlatTable_*Table*_*_*" diff --git a/HLTrigger/NGTScouting/python/hltElectrons_cfi.py b/HLTrigger/NGTScouting/python/hltElectrons_cfi.py index 66d2b6eea4afe..c247450452b29 100644 --- a/HLTrigger/NGTScouting/python/hltElectrons_cfi.py +++ b/HLTrigger/NGTScouting/python/hltElectrons_cfi.py @@ -3,6 +3,7 @@ ##################### Tables for final output and docs ########################## hltElectronTable = cms.EDProducer("HLTElectronTableProducer", + skipNonExistingSrc = cms.bool(True), src = cms.InputTag("hltEgammaPacker"), cut = cms.string(""), name = cms.string("hltElectron"), diff --git a/HLTrigger/NGTScouting/python/hltJets_cfi.py b/HLTrigger/NGTScouting/python/hltJets_cfi.py index 2954b870d3680..01f310ae63a24 100644 --- a/HLTrigger/NGTScouting/python/hltJets_cfi.py +++ b/HLTrigger/NGTScouting/python/hltJets_cfi.py @@ -2,6 +2,7 @@ from PhysicsTools.NanoAOD.common_cff import * hltPFCandidateTable = cms.EDProducer("SimplePFCandidateFlatTableProducer", + skipNonExistingSrc = cms.bool(True), src = cms.InputTag("hltParticleFlowTmp"), name = cms.string("hltPFCandidate"), cut = cms.string(""), @@ -15,6 +16,7 @@ ) hltJetTable = cms.EDProducer("SimplePFJetFlatTableProducer", + skipNonExistingSrc = cms.bool(True), src = cms.InputTag("hltAK4PFPuppiJets"), name = cms.string("hltAK4PuppiJet"), cut = cms.string(""), diff --git a/HLTrigger/NGTScouting/python/hltMuons_cfi.py b/HLTrigger/NGTScouting/python/hltMuons_cfi.py index 4378d2493eabf..fb257086271da 100644 --- a/HLTrigger/NGTScouting/python/hltMuons_cfi.py +++ b/HLTrigger/NGTScouting/python/hltMuons_cfi.py @@ -4,6 +4,7 @@ hltMuonTable = cms.EDProducer( "SimpleTriggerTrackFlatTableProducer", + skipNonExistingSrc = cms.bool(True), src = cms.InputTag("hltPhase2L3MuonIdTracks"), cut = cms.string(""), name = cms.string("hltMuon"), diff --git a/HLTrigger/NGTScouting/python/hltPhotons_cfi.py b/HLTrigger/NGTScouting/python/hltPhotons_cfi.py index 308999cc4da84..d443e762b12a4 100644 --- a/HLTrigger/NGTScouting/python/hltPhotons_cfi.py +++ b/HLTrigger/NGTScouting/python/hltPhotons_cfi.py @@ -3,6 +3,7 @@ ##################### Tables for final output and docs ########################## hltPhotonTable = cms.EDProducer("HLTPhotonTableProducer", + skipNonExistingSrc = cms.bool(True), src = cms.InputTag("hltEgammaPacker"), cut = cms.string(""), name = cms.string("hltPhoton"), diff --git a/HLTrigger/NGTScouting/python/hltSums_cfi.py b/HLTrigger/NGTScouting/python/hltSums_cfi.py new file mode 100644 index 0000000000000..60944a029f2f0 --- /dev/null +++ b/HLTrigger/NGTScouting/python/hltSums_cfi.py @@ -0,0 +1,28 @@ +import FWCore.ParameterSet.Config as cms +from PhysicsTools.NanoAOD.common_cff import * + +METTable = cms.EDProducer( + "SimpleMETFlatTableProducer", + src = cms.InputTag("hltPFPuppiMETTypeOne"), + name = cms.string("hltPFPuppiMET"), + doc = cms.string("HLT PF Puppi MET (TypeOne) information"), + extension = cms.bool(False), + skipNonExistingSrc = cms.bool(True), + singleton = cms.bool(True), + variables = cms.PSet( + pt = Var("sumEt", "float", doc = "MET p_T (GeV)"), + ), +) + +HTTable = cms.EDProducer( + "SimpleMETFlatTableProducer", + src = cms.InputTag("hltPFPuppiMHT"), + name = cms.string("hltPFPuppiHT"), + doc = cms.string("HLT PF Puppi HT information"), + extension = cms.bool(False), + skipNonExistingSrc = cms.bool(True), + singleton = cms.bool(True), + variables = cms.PSet( + pt = Var("sumEt", "float", doc = "HT p_T (GeV)"), + ), +) diff --git a/HLTrigger/NGTScouting/python/hltTaus_cfi.py b/HLTrigger/NGTScouting/python/hltTaus_cfi.py index 6d326c54163f7..42e875558c210 100644 --- a/HLTrigger/NGTScouting/python/hltTaus_cfi.py +++ b/HLTrigger/NGTScouting/python/hltTaus_cfi.py @@ -2,6 +2,7 @@ from PhysicsTools.NanoAOD.common_cff import * hltTauTable = cms.EDProducer("SimplePFTauCandidateFlatTableProducer", + skipNonExistingSrc = cms.bool(True), src = cms.InputTag("hltHpsPFTauProducer"), name = cms.string("hltHpsPFTau"), cut = cms.string(""), @@ -32,3 +33,14 @@ jetIsValid = Var("jetRef.isNonnull && jetRef.isAvailable", bool, doc = "jet is valid"), ), ) + +hltTauExtTable = cms.EDProducer("HLTTauTableProducer", + tableName = cms.string("hltHpsPFTau"), + skipNonExistingSrc = cms.bool(True), + taus = cms.InputTag( "hltHpsPFTauProducer" ), + deepTauVSe = cms.InputTag("hltHpsPFTauDeepTauProducer", "VSe"), + deepTauVSmu = cms.InputTag("hltHpsPFTauDeepTauProducer", "VSmu"), + deepTauVSjet = cms.InputTag("hltHpsPFTauDeepTauProducer", "VSjet"), + tauTransverseImpactParameters = cms.InputTag( "hltHpsPFTauTransverseImpactParametersForDeepTau" ), + precision = cms.int32(7), + ) diff --git a/HLTrigger/NGTScouting/python/hltTracks_cfi.py b/HLTrigger/NGTScouting/python/hltTracks_cfi.py index 77cbba90eea71..ae0f772e9e05a 100644 --- a/HLTrigger/NGTScouting/python/hltTracks_cfi.py +++ b/HLTrigger/NGTScouting/python/hltTracks_cfi.py @@ -3,6 +3,7 @@ hltPixelTrackTable = cms.EDProducer( "SimpleTriggerTrackFlatTableProducer", + skipNonExistingSrc = cms.bool(True), src = cms.InputTag("hltPhase2PixelTracks"), cut = cms.string(""), name = cms.string("hltPixelTrack"), @@ -15,14 +16,23 @@ dXY = Var("dxy()", "float", doc = "dXY (cm)"), dZ = Var("dz()", "float", doc = "dZ (cm)"), t0 = Var("t0()", "float", doc = "t0 (ns)"), + vx = Var("vx()", "float", doc = "vx (cm)"), + vy = Var("vy()", "float", doc = "vy (cm)"), + vz = Var("vz()", "float", doc = "vz (cm)"), + charge = Var("charge()", "float", doc = "charge"), nPixelHits = Var("hitPattern().numberOfValidPixelHits()", "int16", doc = ""), nTrkLays = Var("hitPattern().trackerLayersWithMeasurement()", "int16", doc = ""), - nMuHits = Var("hitPattern().numberOfValidMuonHits()", "int16", doc = "") + chi2 = Var("chi2()", "float", doc = "Track chi2"), + ndof = Var("ndof()", "float", doc = "Number of degrees of freedom"), + #isLoose = Var("quality('loose')", "bool", doc = "Loose track flag"), + isTight = Var("quality('tight')", "bool", doc = "Tight track flag"), + isHighPurity = Var("quality('highPurity')", "bool", doc = "High-purity track flag"), ) ) hltGeneralTrackTable = cms.EDProducer( "SimpleTriggerTrackFlatTableProducer", + skipNonExistingSrc = cms.bool(True), src = cms.InputTag("hltGeneralTracks"), cut = cms.string(""), name = cms.string("hltGeneralTrack"), @@ -35,8 +45,13 @@ dXY = Var("dxy()", "float", doc = "dXY (cm)"), dZ = Var("dz()", "float", doc = "dZ (cm)"), t0 = Var("t0()", "float", doc = "t0 (ns)"), + vx = Var("vx()", "float", doc = "vx (cm)"), + vy = Var("vy()", "float", doc = "vy (cm)"), + vz = Var("vz()", "float", doc = "vz (cm)"), + charge = Var("charge()", "float", doc = "charge"), nPixelHits = Var("hitPattern().numberOfValidPixelHits()", "int16", doc = ""), nTrkLays = Var("hitPattern().trackerLayersWithMeasurement()", "int16", doc = ""), - nMuHits = Var("hitPattern().numberOfValidMuonHits()", "int16", doc = "") + chi2 = Var("chi2()", "float", doc = "Track chi2"), + ndof = Var("ndof()", "float", doc = "Number of degrees of freedom"), ) ) diff --git a/HLTrigger/NGTScouting/python/hltTracksters_cfi.py b/HLTrigger/NGTScouting/python/hltTracksters_cfi.py index b2a11bdfaf92c..5983c16013490 100644 --- a/HLTrigger/NGTScouting/python/hltTracksters_cfi.py +++ b/HLTrigger/NGTScouting/python/hltTracksters_cfi.py @@ -8,6 +8,7 @@ ### Tracksters hltTrackstersTable = cms.EDProducer( "TracksterCollectionTableProducer", + skipNonExistingSrc = cms.bool(True), src=cms.InputTag("hltTiclTrackstersMerge"), cut=cms.string(""), name=cms.string("tracksters"), diff --git a/HLTrigger/NGTScouting/python/hltVertices_cfi.py b/HLTrigger/NGTScouting/python/hltVertices_cfi.py index 87c9baca099a6..ceb5585bf77f8 100644 --- a/HLTrigger/NGTScouting/python/hltVertices_cfi.py +++ b/HLTrigger/NGTScouting/python/hltVertices_cfi.py @@ -1,13 +1,12 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -##################### Tables for final output and docs ########################## -hltVertexTable = cms.EDProducer( - "HLTVertexTableProducer", - pvSrc = cms.InputTag("hltOfflinePrimaryVertices"), - goodPvCut = cms.string("!isFake && ndof >= 4.0 && abs(z) <= 24.0 && abs(position.Rho) <= 2.0"), - pfSrc = cms.InputTag("hltParticleFlowTmp"), - dlenMin = cms.double(0), - dlenSigMin = cms.double(3), - pvName = cms.string("hltPrimaryVertex"), -) +hltVertexTable = cms.EDProducer("HLTVertexTableProducer", + skipNonExistingSrc = cms.bool(True), + pvSrc = cms.InputTag("hltOfflinePrimaryVertices"), + goodPvCut = cms.string("!isFake && ndof >= 4.0 && abs(z) <= 24.0 && abs(position.Rho) <= 2.0"), + pfSrc = cms.InputTag("hltParticleFlowTmp"), + dlenMin = cms.double(0), + dlenSigMin = cms.double(3), + pvName = cms.string("hltPrimaryVertex"), + ) diff --git a/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h b/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h index ede9fc88ae740..7d4d8a4e8d814 100644 --- a/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h +++ b/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h @@ -148,8 +148,8 @@ class ValueMapVariableBase : public ExtVariable { edm::Handle> vmap; iEvent.getByToken(token_, vmap); std::vector vals; + vals.resize(selptrs.size()); if (vmap.isValid() || !skipNonExistingSrc_) { - vals.resize(selptrs.size()); for (unsigned int i = 0, n = vals.size(); i < n; ++i) { // calls the overloaded method to either get the valuemap value directly, or a function of the object value. vals[i] = this->eval(vmap, selptrs[i]); diff --git a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc index e82478fad7be0..addeac4ce0ade 100644 --- a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc +++ b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc @@ -5,6 +5,9 @@ typedef SimpleFlatTableProducer SimpleCandidateFlatTableProduce #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" typedef SimpleFlatTableProducer SimplePFCandidateFlatTableProducer; +#include "DataFormats/METReco/interface/MET.h" +typedef SimpleFlatTableProducer SimpleMETFlatTableProducer; + #include "DataFormats/TauReco/interface/PFTau.h" typedef SimpleFlatTableProducer SimplePFTauCandidateFlatTableProducer; @@ -76,6 +79,7 @@ typedef SimpleFlatTableProducer SimpleCompositeCandidat #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SimpleCandidateFlatTableProducer); DEFINE_FWK_MODULE(SimplePFCandidateFlatTableProducer); +DEFINE_FWK_MODULE(SimpleMETFlatTableProducer); DEFINE_FWK_MODULE(SimplePFTauCandidateFlatTableProducer); DEFINE_FWK_MODULE(SimpleCandidateCollectionFlatTableProducer); DEFINE_FWK_MODULE(SimpleTrackFlatTableProducer); diff --git a/SimMuon/MCTruth/plugins/MuonTrackProducer.cc b/SimMuon/MCTruth/plugins/MuonTrackProducer.cc index 45c327a6b1680..4327a5a314c2d 100644 --- a/SimMuon/MCTruth/plugins/MuonTrackProducer.cc +++ b/SimMuon/MCTruth/plugins/MuonTrackProducer.cc @@ -59,20 +59,25 @@ MuonTrackProducer::MuonTrackProducer(const edm::ParameterSet &parset) void MuonTrackProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { edm::Handle muonCollectionH = iEvent.getHandle(muonsToken); - if (ignoreMissingMuonCollection && !muonCollectionH.isValid()) + + std::unique_ptr selectedTracks(new reco::TrackCollection); + std::unique_ptr selectedTrackExtras(new reco::TrackExtraCollection()); + std::unique_ptr selectedTrackHits(new TrackingRecHitCollection()); + + if (ignoreMissingMuonCollection && !muonCollectionH.isValid()) { edm::LogVerbatim("MuonTrackProducer") << "\n ignoring missing muon collection."; - else { + iEvent.put(std::move(selectedTracks)); + iEvent.put(std::move(selectedTrackExtras)); + iEvent.put(std::move(selectedTrackHits)); + + } else { const DTRecSegment4DCollection &dtSegmentCollection = iEvent.get(inputDTRecSegment4DToken_); const CSCSegmentCollection &cscSegmentCollection = iEvent.get(inputCSCSegmentToken_); const TrackerTopology &ttopo = iSetup.getData(ttopoToken_); - std::unique_ptr selectedTracks(new reco::TrackCollection); - std::unique_ptr selectedTrackExtras(new reco::TrackExtraCollection()); - std::unique_ptr selectedTrackHits(new TrackingRecHitCollection()); - - reco::TrackRefProd rTracks = iEvent.getRefBeforePut(); + //reco::TrackRefProd rTracks = iEvent.getRefBeforePut(); reco::TrackExtraRefProd rTrackExtras = iEvent.getRefBeforePut(); TrackingRecHitRefProd rHits = iEvent.getRefBeforePut();