Skip to content

[NGT] Introduce NanoAOD flavour for Phase 2 HLT #48091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2f6b378
First version of HLT NanoAOD ntuplizer
elenavernazza Apr 3, 2025
42ca407
Add Photons and Electrons NanoAOD branches using ScoutingEGammaProducer
elenavernazza Apr 17, 2025
7d15062
Adding GenPart NanoAOD branches
elenavernazza Apr 17, 2025
0b29a03
Add Muons NanoAOD branches from HLTMuonValidation
elenavernazza Apr 17, 2025
44f183a
Add GeneralTracks and PixelTracks NanoAOD branches
elenavernazza Apr 17, 2025
ae4312b
Add check for PV and PF handles
elenavernazza Apr 25, 2025
91d8ae4
Update eta range EGamma
elenavernazza Apr 25, 2025
e1d747b
Add PF candidates and jets tables
elenavernazza Apr 25, 2025
6d137d8
Modify DeepFlavour jet tag producer to create ValueMap for the NanoAO…
elenavernazza May 8, 2025
3f460eb
Adding jet inputTag for hltPfDeepFlavourJetTagsModEta2p4_cfi.py
elenavernazza May 8, 2025
8b42834
Add sanity filter for HLT and DST in NANOAODSIMoutput and hltNanoProd…
elenavernazza May 8, 2025
a0689d0
Remove warning for OutputModule
elenavernazza May 12, 2025
7711401
Add missing modules for Electrons and Photons in NGT scouting menu
elenavernazza May 12, 2025
d4af803
split the NGTScouting and regular phase-2 HLT menu nano sequences
mmusich May 15, 2025
458df74
Correct and integrate FlatTableProducer for PF candidates and jets
elenavernazza May 15, 2025
9361fda
Update html style for inspectNanoFile
elenavernazza May 15, 2025
395c5ad
Rename NanoAOD flavour to Phase2HLT
elenavernazza May 15, 2025
b822075
Add workflow for NanoAOD at HLT: offsets 759 (for Standard menu) and …
elenavernazza May 15, 2025
2b63327
Format checks
elenavernazza May 15, 2025
97037fa
produce valueMap DeepFlavourONNXJetTagsProducer only on demand
elenavernazza May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,7 @@ def setup_(self, step, stepName, stepDict, k, properties):
stepDict[stepName][k] = merge([stepDict[step][k]])
def condition(self, fragment, stepList, key, hasHarvest):
return fragment=="TTbar_14TeV" and 'Run4' in key

upgradeWFs['HLTTiming75e33'] = UpgradeWorkflow_HLT75e33Timing(
steps = [
'Reco',
Expand All @@ -1794,7 +1795,7 @@ def condition(self, fragment, stepList, key, hasHarvest):
'DigiTrigger',
'ALCA',
'ALCAPhase2',
'HARVESTGlobal'
'HARVESTGlobal',
'RecoGlobalFakeHLT',
'HLT75e33',
'HARVESTGlobal',
Expand Down Expand Up @@ -1920,6 +1921,61 @@ def condition(self, fragment, stepList, key, hasHarvest):
'-s':'HARVESTING:@hltValidation'
}

class UpgradeWorkflow_HLTPhase2_WithNano(UpgradeWorkflow):
def setup_(self, step, stepName, stepDict, k, properties):
# skip RECO, ALCA and HLT
if ('ALCA' in step) or ('Reco' in step) or ('HLT' in step) or ('HARVEST' in step):
stepDict[stepName][k] = None
elif 'DigiTrigger' in step:
stepDict[stepName][k] = merge([self.step2, stepDict[step][k]])
else:
stepDict[stepName][k] = merge([stepDict[step][k]])
def condition(self, fragment, stepList, key, hasHarvest):
return fragment=="TTbar_14TeV" and 'Run4' in key

upgradeWFs['HLTPhaseWithNano'] = UpgradeWorkflow_HLTPhase2_WithNano(
steps = [
'Reco',
'RecoGlobal',
'RecoNano',
'DigiTrigger',
'ALCA',
'ALCAPhase2',
'RecoGlobalFakeHLT',
'HLT75e33',
'HARVESTGlobal',
'HARVESTGlobalFakeHLT',
],
PU = [
'Reco',
'RecoGlobal',
'RecoNano',
'DigiTrigger',
'ALCA',
'ALCAPhase2',
'RecoGlobalFakeHLT',
'HLT75e33',
'HARVESTGlobal',
'HARVESTGlobalFakeHLT',
],
suffix = '_HLTPhaseWithNano',
offset = 0.759,
)
upgradeWFs['HLTPhaseWithNano'].step2 = {
'-s':'DIGI:pdigi_valid,L1TrackTrigger,L1,L1P2GT,DIGI2RAW,HLT:75e33,NANO:@Phase2HLT',
'--datatier':'GEN-SIM-DIGI-RAW,NANOAODSIM',
'--eventcontent':'FEVTDEBUGHLT,NANOAODSIM'
}

upgradeWFs['NGTScoutingWithNano'] = deepcopy(upgradeWFs['HLTPhaseWithNano'])
upgradeWFs['NGTScoutingWithNano'].suffix = '_NGTScoutingWithNano'
upgradeWFs['NGTScoutingWithNano'].offset = 0.771
upgradeWFs['NGTScoutingWithNano'].step2 = {
'-s':'DIGI:pdigi_valid,L1TrackTrigger,L1,L1P2GT,DIGI2RAW,HLT:NGTScouting,NANO:@NGTScouting',
'--datatier':'GEN-SIM-DIGI-RAW,NANOAODSIM',
'--eventcontent':'FEVTDEBUGHLT,NANOAODSIM'
}

class UpgradeWorkflow_HLTwDIGI75e33(UpgradeWorkflow):
def setup_(self, step, stepName, stepDict, k, properties):
if 'DigiTrigger' in step:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
mightGet = cms.optional.untracked.vstring,
model_path = cms.FileInPath('RecoBTag/Combined/data/DeepFlavourV02_PhaseII/DeepJet_retraining_phase2_new_inputs.onnx'),
output_names = cms.vstring(),
src = cms.InputTag("hltPfDeepFlavourTagInfosModEta2p4")
src = cms.InputTag("hltPfDeepFlavourTagInfosModEta2p4"),
produceValueMap = cms.untracked.bool(True),
jets = cms.InputTag("hltPFPuppiJetForBtagEta2p4")
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
mightGet = cms.optional.untracked.vstring,
model_path = cms.FileInPath('RecoBTag/Combined/data/DeepFlavourV02_PhaseII/DeepJet_retraining_phase2_new_inputs.onnx'),
output_names = cms.vstring(),
src = cms.InputTag("hltPfDeepFlavourTagInfos")
src = cms.InputTag("hltPfDeepFlavourTagInfos"),
produceValueMap = cms.untracked.bool(True),
jets = cms.InputTag("hltAK4PFPuppiJets")
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from ..modules.hltParticleFlowRecHitECALUnseeded_cfi import *
from ..modules.hltPhase2L3MuonCandidates_cfi import *
from ..modules.hltEgammaEleL1TrkIsoUnseeded_cfi import *
from ..modules.hltEgammaClusterShapeUnseeded_cfi import *
from ..modules.hltEgammaR9Unseeded_cfi import *
from ..modules.hltEgammaEcalPFClusterIsoUnseeded_cfi import *
from ..modules.hltEgammaEleGsfTrackIsoUnseeded_cfi import *
from ..modules.hltEgammaHcalPFClusterIsoUnseeded_cfi import *
from ..sequences.HLTAK4PFJetsReconstruction_cfi import *
from ..sequences.HLTAK4PFPuppiJetsReconstruction_cfi import *
from ..sequences.HLTBeginSequence_cfi import *
Expand Down Expand Up @@ -55,6 +60,11 @@
+ HLTElePixelMatchUnseededSequence
+ HLTGsfElectronUnseededSequence
+ hltEgammaEleL1TrkIsoUnseeded
+ hltEgammaClusterShapeUnseeded
+ hltEgammaR9Unseeded
+ hltEgammaEcalPFClusterIsoUnseeded
+ hltEgammaEleGsfTrackIsoUnseeded
+ hltEgammaHcalPFClusterIsoUnseeded
+ hltPhase2L3MuonCandidates
+ HLTPhase2L3MuonGeneralTracksSequence
+ HLTAK4PFJetsReconstruction
Expand Down
13 changes: 13 additions & 0 deletions HLTrigger/NGTScouting/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>
<use name="DataFormats/VertexReco"/>
<use name="DataFormats/Candidate"/>
<use name="CommonTools/Utils"/>
<use name="DataFormats/NanoAOD"/>
<use name="RecoVertex/VertexTools"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/PatCandidates"/>
<use name="DataFormats/ParticleFlowCandidate"/>
<use name="PhysicsTools/NanoAOD"/>
<use name="DataFormats/Scouting"/>
22 changes: 22 additions & 0 deletions HLTrigger/NGTScouting/plugins/HLTElectronTableProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#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 "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<Run3ScoutingElectron> HLTElectronTableProducer;

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(HLTElectronTableProducer);
22 changes: 22 additions & 0 deletions HLTrigger/NGTScouting/plugins/HLTPhotonTableProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#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 "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<Run3ScoutingPhoton> HLTPhotonTableProducer;

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(HLTPhotonTableProducer);
194 changes: 194 additions & 0 deletions HLTrigger/NGTScouting/plugins/HLTVertexTableProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#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 "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"

//
// class declaration
//

class HLTVertexTableProducer : public edm::stream::EDProducer<> {
public:
explicit HLTVertexTableProducer(const edm::ParameterSet&);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
void produce(edm::Event&, const edm::EventSetup&) override;

// ----------member data ---------------------------
const edm::EDGetTokenT<std::vector<reco::Vertex>> pvs_;
const edm::EDGetTokenT<reco::PFCandidateCollection> pfc_;
const edm::EDGetTokenT<edm::ValueMap<float>> pvsScore_;
const StringCutObjectSelector<reco::Vertex> goodPvCut_;
const std::string goodPvCutString_;
const std::string pvName_;
const double dlenMin_, dlenSigMin_;
};

//
// constructors
//

HLTVertexTableProducer::HLTVertexTableProducer(const edm::ParameterSet& params)
: pvs_(consumes<std::vector<reco::Vertex>>(params.getParameter<edm::InputTag>("pvSrc"))),
pfc_(consumes<reco::PFCandidateCollection>(params.getParameter<edm::InputTag>("pfSrc"))),
pvsScore_(consumes<edm::ValueMap<float>>(params.getParameter<edm::InputTag>("pvSrc"))),
goodPvCut_(params.getParameter<std::string>("goodPvCut"), true),
goodPvCutString_(params.getParameter<std::string>("goodPvCut")),
pvName_(params.getParameter<std::string>("pvName")),
dlenMin_(params.getParameter<double>("dlenMin")),
dlenSigMin_(params.getParameter<double>("dlenSigMin"))

{
produces<nanoaod::FlatTable>("PV");
produces<edm::PtrVector<reco::VertexCompositePtrCandidate>>();
}

//
// member functions
//

// ------------ method called to produce the data ------------
void HLTVertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;

//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;
}

std::vector<float> v_ndof;
std::vector<float> v_chi2;
std::vector<float> v_x;
std::vector<float> v_y;
std::vector<float> v_z;
std::vector<float> v_xError;
std::vector<float> v_yError;
std::vector<float> v_zError;
std::vector<uint8_t> v_is_good;
std::vector<uint8_t> v_nTracks;
std::vector<float> v_pv_score;
std::vector<float> v_pv_sumpt2;
std::vector<float> v_pv_sumpx;
std::vector<float> 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;
}
} // 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();
}
}

v_pv_sumpt2.push_back(pv_sumpt2);
v_pv_sumpx.push_back(pv_sumpx);
v_pv_sumpy.push_back(pv_sumpy);
}

//table for all primary vertices
auto pvTable = std::make_unique<nanoaod::FlatTable>((*pvsIn).size(), pvName_, true);
pvTable->addColumn<float>("ndof", v_ndof, "primary vertex number of degrees of freedom", 8);
pvTable->addColumn<float>("chi2", v_chi2, "primary vertex reduced chi2", 8);
pvTable->addColumn<float>("x", v_x, "primary vertex x coordinate", 10);
pvTable->addColumn<float>("y", v_y, "primary vertex y coordinate", 10);
pvTable->addColumn<float>("z", v_z, "primary vertex z coordinate", 16);
pvTable->addColumn<float>("xError", v_xError, "primary vertex error in x coordinate", 10);
pvTable->addColumn<float>("yError", v_yError, "primary vertex error in y coordinate", 10);
pvTable->addColumn<float>("zError", v_zError, "primary vertex error in z coordinate", 16);
pvTable->addColumn<uint8_t>(
"isGood", v_is_good, "wheter the primary vertex passes selection: " + goodPvCutString_ + ")");
pvTable->addColumn<uint8_t>("nTracks", v_nTracks, "primary vertex number of associated tracks");
pvTable->addColumn<float>("score", v_pv_score, "primary vertex score, i.e. sum pt2 of clustered objects", 8);
pvTable->addColumn<float>(
"sumpt2", v_pv_sumpt2, "sum pt2 of pf charged candidates within dz=0.2 for the main primary vertex", 10);
pvTable->addColumn<float>(
"sumpx", v_pv_sumpx, "sum px of pf charged candidates within dz=0.2 for the main primary vertex", 10);
pvTable->addColumn<float>(
"sumpy", v_pv_sumpy, "sum py of pf charged candidates within dz=0.2 for the main primary vertex", 10);

iEvent.put(std::move(pvTable), "PV");
}

// ------------ fill 'descriptions' with the allowed parameters for the module ------------
void HLTVertexTableProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;

desc.add<std::string>("pvName")->setComment("name of the flat table ouput");
desc.add<edm::InputTag>("pvSrc")->setComment(
"std::vector<reco::Vertex> and ValueMap<float> primary vertex input collections");
desc.add<edm::InputTag>("pfSrc")->setComment("reco::PFCandidateCollection PF candidates input collections");
desc.add<std::string>("goodPvCut")->setComment("selection on the primary vertex");

desc.add<double>("dlenMin")->setComment("minimum value of dl to select secondary vertex");
desc.add<double>("dlenSigMin")->setComment("minimum value of dl significance to select secondary vertex");

descriptions.addWithDefaultLabel(desc);
}

// ------------ define this as a plug-in ------------
DEFINE_FWK_MODULE(HLTVertexTableProducer);
Loading