Skip to content
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

Updating the L1TrackObjectNtupleMaker with genJet information and using the SimVertex collection (Master) #45422

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 42 additions & 1 deletion L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
#include "SimDataFormats/TrackingHit/interface/PSimHit.h"
#include "SimDataFormats/Vertex/interface/SimVertex.h"
#include "SimTracker/TrackTriggerAssociation/interface/TTClusterAssociationMap.h"
#include "SimTracker/TrackTriggerAssociation/interface/TTStubAssociationMap.h"
#include "SimTracker/TrackTriggerAssociation/interface/TTTrackAssociationMap.h"
Expand Down Expand Up @@ -145,6 +146,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer<edm::one::SharedRes

edm::InputTag L1TrackInputTag; // L1 track collection
edm::InputTag MCTruthTrackInputTag; // MC truth collection
edm::InputTag SimVertexInputTag; // MC truth vertex collection
edm::InputTag L1TrackGTTInputTag; // L1 track collection
edm::InputTag L1TrackSelectedInputTag; // L1 track collection
edm::InputTag L1TrackSelectedEmulationInputTag; // L1 track collection
Expand Down Expand Up @@ -241,6 +243,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer<edm::one::SharedRes
edm::EDGetTokenT<std::vector<TrackingVertex>> TrackingVertexToken_;
edm::EDGetTokenT<std::vector<reco::GenJet>> GenJetToken_;
edm::EDGetTokenT<std::vector<reco::GenParticle>> GenParticleToken_;
edm::EDGetTokenT<std::vector<SimVertex>> SimVertexToken_;
edm::EDGetTokenT<l1t::VertexCollection> L1VertexToken_;
edm::EDGetTokenT<l1t::VertexWordCollection> L1VertexEmuToken_;

Expand Down Expand Up @@ -488,6 +491,11 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer<edm::one::SharedRes
std::vector<float>* m_trkfastjetExt_tp_sumpt;
std::vector<float>* m_trkfastjetExt_truetp_sumpt;

std::vector<float>* m_genjet_p;
std::vector<float>* m_genjet_phi;
std::vector<float>* m_genjet_eta;
std::vector<float>* m_genjet_pt;

std::vector<float>* m_trkjet_vz;
std::vector<float>* m_trkjet_p;
std::vector<float>* m_trkjet_phi;
Expand Down Expand Up @@ -586,6 +594,7 @@ L1TrackObjectNtupleMaker::L1TrackObjectNtupleMaker(edm::ParameterSet const& iCon
RecoVertexInputTag = iConfig.getParameter<InputTag>("RecoVertexInputTag");
RecoVertexEmuInputTag = iConfig.getParameter<InputTag>("RecoVertexEmuInputTag");
GenParticleInputTag = iConfig.getParameter<InputTag>("GenParticleInputTag");
SimVertexInputTag = iConfig.getParameter<InputTag>("SimVertexInputTag");

if (Displaced == "Prompt" || Displaced == "Both") {
L1TrackInputTag = iConfig.getParameter<edm::InputTag>("L1TrackInputTag");
Expand Down Expand Up @@ -722,6 +731,7 @@ L1TrackObjectNtupleMaker::L1TrackObjectNtupleMaker(edm::ParameterSet const& iCon
TrackingVertexToken_ = consumes<std::vector<TrackingVertex>>(TrackingVertexInputTag);
GenJetToken_ = consumes<std::vector<reco::GenJet>>(GenJetInputTag);
GenParticleToken_ = consumes<std::vector<reco::GenParticle>>(GenParticleInputTag);
SimVertexToken_ = consumes<std::vector<SimVertex>>(SimVertexInputTag);
L1VertexToken_ = consumes<l1t::VertexCollection>(RecoVertexInputTag);
L1VertexEmuToken_ = consumes<l1t::VertexWordCollection>(RecoVertexEmuInputTag);
tTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>(edm::ESInputTag("", ""));
Expand Down Expand Up @@ -1177,6 +1187,11 @@ void L1TrackObjectNtupleMaker::beginJob() {
m_pv_MC = new std::vector<float>;
m_MC_lep = new std::vector<int>;

m_genjet_eta = new std::vector<float>;
m_genjet_phi = new std::vector<float>;
m_genjet_p = new std::vector<float>;
m_genjet_pt = new std::vector<float>;

m_trkjet_eta = new std::vector<float>;
m_trkjet_vz = new std::vector<float>;
m_trkjet_phi = new std::vector<float>;
Expand Down Expand Up @@ -1444,6 +1459,10 @@ void L1TrackObjectNtupleMaker::beginJob() {
eventTree->Branch("gen_z0", &m_gen_z0);

if (SaveTrackJets) {
eventTree->Branch("genjet_eta", &m_genjet_eta);
eventTree->Branch("genjet_p", &m_genjet_p);
eventTree->Branch("genjet_pt", &m_genjet_pt);
eventTree->Branch("genjet_phi", &m_genjet_phi);
if (Displaced == "Prompt" || Displaced == "Both") {
eventTree->Branch("trkfastjet_eta", &m_trkfastjet_eta);
eventTree->Branch("trkfastjet_vz", &m_trkfastjet_vz);
Expand Down Expand Up @@ -1738,6 +1757,10 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
}

if (SaveTrackJets) {
m_genjet_eta->clear();
m_genjet_pt->clear();
m_genjet_phi->clear();
m_genjet_p->clear();
if (Displaced == "Prompt" || Displaced == "Both") {
m_trkjet_eta->clear();
m_trkjet_pt->clear();
Expand Down Expand Up @@ -1856,6 +1879,10 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
//Gen particles
edm::Handle<std::vector<reco::GenParticle>> GenParticleHandle;
iEvent.getByToken(GenParticleToken_, GenParticleHandle);
edm::Handle<std::vector<SimVertex>> SimVertexHandle;
iEvent.getByToken(SimVertexToken_, SimVertexHandle);
edm::Handle<std::vector<reco::GenJet>> GenJetHandle;
iEvent.getByToken(GenJetToken_, GenJetHandle);

//Vertex
edm::Handle<l1t::VertexCollection> L1PrimaryVertexHandle;
Expand Down Expand Up @@ -2009,11 +2036,17 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
}

trueMET = sqrt(trueMETx * trueMETx + trueMETy * trueMETy);
m_pv_MC->push_back(zvtx_gen);
} else {
edm::LogWarning("DataNotFound") << "\nWarning: GenParticleHandle not found in the event" << std::endl;
}

if (SimVertexHandle.isValid()) {
const SimVertex simPVh = *(SimVertexHandle->begin());
m_pv_MC->push_back(simPVh.position().z());
} else {
edm::LogWarning("DataNotFound") << "\nWarning: SimVertexHandle not found in the event" << std::endl;
}

// ----------------------------------------------------------------------------------------------
// loop over L1 stubs
// ----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -3129,6 +3162,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even
}

if (SaveTrackJets) {
if (GenJetHandle.isValid()) {
for (auto jetIter = GenJetHandle->begin(); jetIter != GenJetHandle->end(); ++jetIter) {
m_genjet_phi->push_back(jetIter->phi());
m_genjet_eta->push_back(jetIter->eta());
m_genjet_pt->push_back(jetIter->pt());
m_genjet_p->push_back(jetIter->p());
}
}
if (TrackFastJetsHandle.isValid() && (Displaced == "Prompt" || Displaced == "Both")) {
for (jetIter = TrackFastJetsHandle->begin(); jetIter != TrackFastJetsHandle->end(); ++jetIter) {
m_trkfastjet_vz->push_back(jetIter->jetVtx());
Expand Down
7 changes: 4 additions & 3 deletions L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
process.load('Configuration.StandardSequences.Services_cff')
process.load('Configuration.EventContent.EventContent_cff')
process.load('Configuration.StandardSequences.MagneticField_cff')
process.load('Configuration.Geometry.GeometryExtended2026D95Reco_cff')
process.load('Configuration.Geometry.GeometryExtended2026D95_cff')
process.load('Configuration.Geometry.GeometryExtended2026D110Reco_cff')
process.load('Configuration.Geometry.GeometryExtended2026D110_cff')
process.load('Configuration.StandardSequences.EndOfProcess_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')

Expand Down Expand Up @@ -61,7 +61,7 @@
useJobReport = cms.untracked.bool(False)
)

process.TFileService = cms.Service("TFileService", fileName = cms.string('GTTObjects_ttbar200PU_v2p2.root'), closeFileFast = cms.untracked.bool(True))
process.TFileService = cms.Service("TFileService", fileName = cms.string('GTTObjects_ttbar200PU_Spring23.root'), closeFileFast = cms.untracked.bool(True))


############################################################
Expand Down Expand Up @@ -277,6 +277,7 @@
TrackMHTExtendedInputTag = cms.InputTag("l1tTrackerHTMissExtended","L1TrackerHTMissExtended"),
TrackMHTEmuInputTag = cms.InputTag("l1tTrackerEmuHTMiss",process.l1tTrackerEmuHTMiss.L1MHTCollectionName.value()),
TrackMHTEmuExtendedInputTag = cms.InputTag("l1tTrackerEmuHTMissExtended",process.l1tTrackerEmuHTMissExtended.L1MHTCollectionName.value()),
SimVertexInputTag = cms.InputTag("g4SimHits",""),
GenParticleInputTag = cms.InputTag("genParticles",""),
RecoVertexInputTag=cms.InputTag("l1tVertexFinder", "L1Vertices"),
RecoVertexEmuInputTag=cms.InputTag("l1tVertexFinderEmulator", "L1VerticesEmulation"),
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/VertexFinder/python/l1tVertexProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Track word limits (256 binns): [-20.46912512, 20.46912512, 0.15991504]
FH_HistogramParameters = cms.vdouble(-20.46912512, 20.46912512, 0.15991504),
# The number of vertixes to return (i.e. N windows with the highest combined pT)
FH_NVtx = cms.uint32(10),
FH_NVtx = cms.uint32(1),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note that this should really be 1 in order to follow what the FW will do.

# fastHisto algorithm assumed vertex half-width [cm]
FH_VertexWidth = cms.double(.15),
# Window size of the sliding window
Expand Down