Skip to content

Commit 2ba4e54

Browse files
authored
Merge pull request #48425 from cms-ngt-hlt/ev_HLTNano_GenJets
Extend NanoAOD for NGT Phase 2 Scouting with Tau and Gen information
2 parents 0247d13 + d1c1816 commit 2ba4e54

21 files changed

+410
-154
lines changed

Configuration/PyReleaseValidation/python/relval_Run4.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
numWFIB.extend([prefixDet+34.759]) # HLTTiming75e33 + NANO
8181
numWFIB.extend([prefixDet+34.77]) # NGTScouting
8282
numWFIB.extend([prefixDet+34.771]) # NGTScouting + NANO
83+
numWFIB.extend([prefixDet+34.772]) # NGTScouting + NANO (including validation)
8384

8485
for numWF in numWFIB:
8586
workflows[numWF] = _upgrade_workflows[numWF]

Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,17 @@ def condition(self, fragment, stepList, key, hasHarvest):
19741974
upgradeWFs['NGTScoutingWithNano'].step2 = {
19751975
'-s':'DIGI:pdigi_valid,L1TrackTrigger,L1,L1P2GT,DIGI2RAW,HLT:NGTScouting,NANO:@NGTScouting',
19761976
'--datatier':'GEN-SIM-DIGI-RAW,NANOAODSIM',
1977+
'--procModifiers': 'ngtScouting',
1978+
'--eventcontent':'FEVTDEBUGHLT,NANOAODSIM'
1979+
}
1980+
1981+
upgradeWFs['NGTScoutingWithNanoValid'] = deepcopy(upgradeWFs['HLTPhaseWithNano'])
1982+
upgradeWFs['NGTScoutingWithNanoValid'].suffix = '_NGTScoutingWithNanoVal'
1983+
upgradeWFs['NGTScoutingWithNanoValid'].offset = 0.772
1984+
upgradeWFs['NGTScoutingWithNanoValid'].step2 = {
1985+
'-s':'DIGI:pdigi_valid,L1TrackTrigger,L1,L1P2GT,DIGI2RAW,HLT:NGTScouting,VALIDATION:@hltValidation,NANO:@NGTScoutingVal',
1986+
'--datatier':'GEN-SIM-DIGI-RAW,NANOAODSIM',
1987+
'--procModifiers': 'ngtScouting',
19771988
'--eventcontent':'FEVTDEBUGHLT,NANOAODSIM'
19781989
}
19791990

Configuration/PyReleaseValidation/scripts/runTheMatrix.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ def runSelected(opt):
161161
29634.756, # HLT phase-2 timing menu trimmed tracking
162162
29634.7561, # HLT phase-2 timing menu Alpaka, trimmed tracking
163163
29634.7562, # HLT phase-2 timing menu Alpaka, trimmed tracking, single tracking iteration variant
164-
29634.759, # HLT phase-2 timing menu Alpaka, single tracking iteration, LST seeding + CKF building variant
165-
29634.757, # HLT phase-2 timing menu, with NANO:@Phase2HLT
164+
29634.757, # HLT phase-2 timing menu Alpaka, single tracking iteration, LST seeding + CKF building variant
165+
29634.759, # HLT phase-2 timing menu, with NANO:@Phase2HLT
166166
29634.77, # HLT phase-2 NGT Scouting menu
167-
29634.771] # HLT phase-2 NGT Scouting menu, with NANO:@NGTScouting
167+
29634.771, # HLT phase-2 NGT Scouting menu, with NANO:@NGTScouting
168+
29634.772] # HLT phase-2 NGT Scouting menu, with NANO:@NGTScoutingVal
168169
}
169170

170171
predefinedSet['limited'] = (
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
<use name="FWCore/Common"/>
2-
<use name="FWCore/Framework"/>
3-
<use name="FWCore/ParameterSet"/>
4-
<use name="FWCore/Utilities"/>
5-
<use name="DataFormats/VertexReco"/>
6-
<use name="DataFormats/Candidate"/>
71
<use name="CommonTools/Utils"/>
8-
<use name="DataFormats/NanoAOD"/>
9-
<use name="RecoVertex/VertexTools"/>
2+
<use name="DataFormats/Candidate"/>
103
<use name="DataFormats/Common"/>
114
<use name="DataFormats/HGCalReco"/>
12-
<use name="DataFormats/PatCandidates"/>
5+
<use name="DataFormats/NanoAOD"/>
136
<use name="DataFormats/ParticleFlowCandidate"/>
7+
<use name="DataFormats/PatCandidates"/>
8+
<use name="DataFormats/Scouting"/>
149
<use name="DataFormats/StdDictionaries"/>
10+
<use name="DataFormats/VertexReco"/>
11+
<use name="FWCore/Common"/>
12+
<use name="FWCore/Framework"/>
13+
<use name="FWCore/ParameterSet"/>
14+
<use name="FWCore/Utilities"/>
1515
<use name="PhysicsTools/NanoAOD"/>
16-
<use name="DataFormats/Scouting"/>
16+
<use name="RecoVertex/VertexTools"/>
1717
<use name="boost"/>
18-

HLTrigger/NGTScouting/plugins/HLTElectronTableProducer.cc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
#include <memory>
22

33
// user include files
4-
#include "FWCore/Framework/interface/Frameworkfwd.h"
5-
#include "FWCore/Framework/interface/stream/EDProducer.h"
6-
4+
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
5+
#include "DataFormats/NanoAOD/interface/FlatTable.h"
6+
#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h"
77
#include "FWCore/Framework/interface/Event.h"
8+
#include "FWCore/Framework/interface/Frameworkfwd.h"
89
#include "FWCore/Framework/interface/MakerMacros.h"
9-
10+
#include "FWCore/Framework/interface/stream/EDProducer.h"
1011
#include "FWCore/ParameterSet/interface/ParameterSet.h"
1112
#include "FWCore/Utilities/interface/StreamID.h"
12-
13-
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
14-
15-
#include "DataFormats/NanoAOD/interface/FlatTable.h"
16-
1713
#include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h"
18-
#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h"
14+
1915
typedef SimpleFlatTableProducer<Run3ScoutingElectron> HLTElectronTableProducer;
2016

2117
#include "FWCore/Framework/interface/MakerMacros.h"

HLTrigger/NGTScouting/plugins/HLTPhotonTableProducer.cc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
#include <memory>
22

33
// user include files
4-
#include "FWCore/Framework/interface/Frameworkfwd.h"
5-
#include "FWCore/Framework/interface/stream/EDProducer.h"
6-
4+
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
5+
#include "DataFormats/NanoAOD/interface/FlatTable.h"
6+
#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h"
77
#include "FWCore/Framework/interface/Event.h"
8+
#include "FWCore/Framework/interface/Frameworkfwd.h"
89
#include "FWCore/Framework/interface/MakerMacros.h"
9-
10+
#include "FWCore/Framework/interface/stream/EDProducer.h"
1011
#include "FWCore/ParameterSet/interface/ParameterSet.h"
1112
#include "FWCore/Utilities/interface/StreamID.h"
12-
13-
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
14-
15-
#include "DataFormats/NanoAOD/interface/FlatTable.h"
16-
1713
#include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h"
18-
#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h"
14+
1915
typedef SimpleFlatTableProducer<Run3ScoutingPhoton> HLTPhotonTableProducer;
2016

2117
#include "FWCore/Framework/interface/MakerMacros.h"
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#include "DataFormats/NanoAOD/interface/FlatTable.h"
2+
#include "DataFormats/TauReco/interface/PFTauTransverseImpactParameterAssociation.h"
3+
#include "DataFormats/TauReco/interface/TauDiscriminatorContainer.h"
4+
#include "FWCore/Framework/interface/Event.h"
5+
#include "FWCore/Framework/interface/Frameworkfwd.h"
6+
#include "FWCore/Framework/interface/MakerMacros.h"
7+
#include "FWCore/Framework/interface/global/EDProducer.h"
8+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
9+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
10+
11+
class HLTTauTableProducer : public edm::global::EDProducer<> {
12+
public:
13+
using TauCollection = edm::View<reco::BaseTau>;
14+
using TauIPVector = edm::AssociationVector<reco::PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef>>;
15+
using TauDiscrMap = reco::TauDiscriminatorContainer;
16+
// TauCollection = deeptau.TauCollection;
17+
// using TauDeepTauVector = edm::AssociationVector<reco::PFTauRefProd, std::vector<reco::TauDiscriminatorContainer>>;
18+
HLTTauTableProducer(const edm::ParameterSet& cfg)
19+
: tableName_(cfg.getParameter<std::string>("tableName")),
20+
skipNonExistingSrc_(cfg.getParameter<bool>("skipNonExistingSrc")),
21+
tauToken_(mayConsume<TauCollection>(cfg.getParameter<edm::InputTag>("taus"))),
22+
tauIPToken_(mayConsume<TauIPVector>(cfg.getParameter<edm::InputTag>("tauTransverseImpactParameters"))),
23+
deepTauVSeToken_(mayConsume<TauDiscrMap>(cfg.getParameter<edm::InputTag>("deepTauVSe"))),
24+
deepTauVSmuToken_(mayConsume<TauDiscrMap>(cfg.getParameter<edm::InputTag>("deepTauVSmu"))),
25+
deepTauVSjetToken_(mayConsume<TauDiscrMap>(cfg.getParameter<edm::InputTag>("deepTauVSjet"))),
26+
precision_(cfg.getParameter<int>("precision")) {
27+
produces<nanoaod::FlatTable>(tableName_);
28+
}
29+
30+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
31+
edm::ParameterSetDescription desc;
32+
desc.add<std::string>("tableName", "hltHpsPFTau")
33+
->setComment("Table name, needs to be the same as the main Tau table");
34+
desc.add<bool>("skipNonExistingSrc", false)
35+
->setComment("whether or not to skip producing the table on absent input product");
36+
desc.add<edm::InputTag>("taus", edm::InputTag(""));
37+
desc.add<edm::InputTag>("tauTransverseImpactParameters", edm::InputTag(""));
38+
desc.add<edm::InputTag>("deepTauVSe", edm::InputTag(""));
39+
desc.add<edm::InputTag>("deepTauVSmu", edm::InputTag(""));
40+
desc.add<edm::InputTag>("deepTauVSjet", edm::InputTag(""));
41+
desc.add<int>("precision", 7);
42+
descriptions.addWithDefaultLabel(desc);
43+
}
44+
45+
private:
46+
void produce(edm::StreamID id, edm::Event& event, const edm::EventSetup& setup) const override {
47+
const auto tausHandle = event.getHandle(tauToken_);
48+
const size_t nTaus = tausHandle.isValid() ? (*tausHandle).size() : 0;
49+
50+
// resize all output vectors
51+
static constexpr float default_value = std::numeric_limits<float>::quiet_NaN();
52+
53+
std::vector<float> deepTauVSe(nTaus, default_value);
54+
std::vector<float> deepTauVSmu(nTaus, default_value);
55+
std::vector<float> deepTauVSjet(nTaus, default_value);
56+
57+
// source: RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc
58+
std::vector<float> dxy(nTaus, default_value);
59+
std::vector<float> dxy_error(nTaus, default_value);
60+
std::vector<float> ip3d(nTaus, default_value);
61+
std::vector<float> ip3d_error(nTaus, default_value);
62+
std::vector<float> hasSecondaryVertex(nTaus, default_value);
63+
std::vector<float> flightLength_x(nTaus, default_value);
64+
std::vector<float> flightLength_y(nTaus, default_value);
65+
std::vector<float> flightLength_z(nTaus, default_value);
66+
std::vector<float> flightLengthSig(nTaus, default_value);
67+
std::vector<float> secondaryVertex_x(nTaus, default_value);
68+
std::vector<float> secondaryVertex_y(nTaus, default_value);
69+
std::vector<float> secondaryVertex_z(nTaus, default_value);
70+
71+
if (tausHandle.isValid() || !(this->skipNonExistingSrc_)) {
72+
const auto& tausProductId = tausHandle.id();
73+
const auto& tausIPHandle = event.getHandle(tauIPToken_);
74+
const auto& deepTauVSeMapHandle = event.getHandle(deepTauVSeToken_);
75+
const auto& deepTauVSmuMapHandle = event.getHandle(deepTauVSmuToken_);
76+
const auto& deepTauVSjetMapHandle = event.getHandle(deepTauVSjetToken_);
77+
78+
for (size_t tau_index = 0; tau_index < nTaus; ++tau_index) {
79+
if (deepTauVSeMapHandle.isValid() || !(this->skipNonExistingSrc_)) {
80+
deepTauVSe[tau_index] = deepTauVSeMapHandle->get(tausProductId, tau_index).rawValues.at(0);
81+
} else {
82+
edm::LogWarning("HLTTauTableProducer") << " Invalid handle for DeeTauVse score input collection";
83+
}
84+
85+
if (deepTauVSmuMapHandle.isValid() || !(this->skipNonExistingSrc_)) {
86+
deepTauVSmu[tau_index] = deepTauVSmuMapHandle->get(tausProductId, tau_index).rawValues.at(0);
87+
} else {
88+
edm::LogWarning("HLTTauTableProducer") << " Invalid handle for DeeTauVsMu score input collection";
89+
}
90+
91+
if (deepTauVSjetMapHandle.isValid() || !(this->skipNonExistingSrc_)) {
92+
deepTauVSjet[tau_index] = deepTauVSjetMapHandle->get(tausProductId, tau_index).rawValues.at(0);
93+
} else {
94+
edm::LogWarning("HLTTauTableProducer") << " Invalid handle for DeeTauVsJet score input collection";
95+
}
96+
97+
if (tausIPHandle.isValid() || !(this->skipNonExistingSrc_)) {
98+
dxy[tau_index] = tausIPHandle->value(tau_index)->dxy();
99+
dxy_error[tau_index] = tausIPHandle->value(tau_index)->dxy_error();
100+
ip3d[tau_index] = tausIPHandle->value(tau_index)->ip3d();
101+
ip3d_error[tau_index] = tausIPHandle->value(tau_index)->ip3d_error();
102+
hasSecondaryVertex[tau_index] = tausIPHandle->value(tau_index)->hasSecondaryVertex();
103+
flightLength_x[tau_index] = tausIPHandle->value(tau_index)->flightLength().x();
104+
flightLength_y[tau_index] = tausIPHandle->value(tau_index)->flightLength().y();
105+
flightLength_z[tau_index] = tausIPHandle->value(tau_index)->flightLength().z();
106+
flightLengthSig[tau_index] = tausIPHandle->value(tau_index)->flightLengthSig();
107+
108+
if (hasSecondaryVertex[tau_index] > 0) {
109+
secondaryVertex_x[tau_index] = tausIPHandle->value(tau_index)->secondaryVertex()->x();
110+
secondaryVertex_y[tau_index] = tausIPHandle->value(tau_index)->secondaryVertex()->y();
111+
secondaryVertex_z[tau_index] = tausIPHandle->value(tau_index)->secondaryVertex()->z();
112+
}
113+
} else {
114+
edm::LogWarning("HLTTauTableProducer") << " Invalid handle for Tau IP input collection";
115+
}
116+
}
117+
} else {
118+
edm::LogWarning("HLTTauTableProducer") << " Invalid handle for PFTau candidate input collection";
119+
}
120+
121+
auto tauTable = std::make_unique<nanoaod::FlatTable>(nTaus, tableName_, /*singleton*/ false, /*extension*/ true);
122+
tauTable->addColumn<float>("dxy", dxy, "tau transverse impact parameter", precision_);
123+
tauTable->addColumn<float>("dxy_error", dxy_error, " dxy_error ", precision_);
124+
tauTable->addColumn<float>("ip3d", ip3d, " ip3d ", precision_);
125+
tauTable->addColumn<float>("ip3d_error", ip3d_error, " ip3d_error ", precision_);
126+
tauTable->addColumn<float>("hasSecondaryVertex", hasSecondaryVertex, " hasSecondaryVertex ", precision_);
127+
tauTable->addColumn<float>("flightLength_x", flightLength_x, "flightLength_x", precision_);
128+
tauTable->addColumn<float>("flightLength_y", flightLength_y, "flightLength_y", precision_);
129+
tauTable->addColumn<float>("flightLength_z", flightLength_z, "flightLength_z", precision_);
130+
tauTable->addColumn<float>("flightLengthSig", flightLengthSig, "flightLengthSig", precision_);
131+
tauTable->addColumn<float>("secondaryVertex_x", secondaryVertex_x, "secondaryVertex_x", precision_);
132+
tauTable->addColumn<float>("secondaryVertex_y", secondaryVertex_y, "secondaryVertex_y", precision_);
133+
tauTable->addColumn<float>("secondaryVertex_z", secondaryVertex_z, "secondaryVertex_z", precision_);
134+
tauTable->addColumn<float>("deepTauVSe", deepTauVSe, "tau vs electron discriminator", precision_);
135+
tauTable->addColumn<float>("deepTauVSmu", deepTauVSmu, "tau vs muon discriminator", precision_);
136+
tauTable->addColumn<float>("deepTauVSjet", deepTauVSjet, "tau vs jet discriminator", precision_);
137+
138+
event.put(std::move(tauTable), tableName_);
139+
}
140+
141+
private:
142+
const std::string tableName_;
143+
const bool skipNonExistingSrc_;
144+
const edm::EDGetTokenT<TauCollection> tauToken_;
145+
const edm::EDGetTokenT<TauIPVector> tauIPToken_;
146+
const edm::EDGetTokenT<TauDiscrMap> deepTauVSeToken_, deepTauVSmuToken_, deepTauVSjetToken_;
147+
const unsigned int precision_;
148+
};
149+
150+
#include "FWCore/Framework/interface/MakerMacros.h"
151+
DEFINE_FWK_MODULE(HLTTauTableProducer);

0 commit comments

Comments
 (0)