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

Fix trigger matching issues in L1Trigger DQMOffline #39691

Merged
merged 4 commits into from
Oct 17, 2022
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
1 change: 1 addition & 0 deletions DQMOffline/L1Trigger/interface/L1TMuonDQMOffline.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Common/interface/TriggerNames.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand Down
2 changes: 1 addition & 1 deletion DQMOffline/L1Trigger/python/L1TEtSumJetOffline_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
from L1Trigger.L1TNtuples.L1TPFMetNoMuProducer_cfi import l1tPFMetNoMu

l1tPFMetNoMuForDQM = l1tPFMetNoMu.clone(
pfMETCollection= 'pfMETT1',
pfMETCollection= 'pfMet', ## Was 'pfMETT1', threw errors - AWB 2022.09.28
muonCollection= 'muons'
)

Expand Down
15 changes: 13 additions & 2 deletions DQMOffline/L1Trigger/src/L1TCommon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,19 @@ namespace dqmoffline {
const std::string triggerProcess) {
std::vector<edm::InputTag> results;
for (auto trigger : triggers) {
unsigned int hltIndexOffset(2);
unsigned int moduleIndex = hltConfig.size(trigger) - hltIndexOffset;
// For some reason various modules now come *after* "hltBoolEnd"
// Really just want module one index before "hltBoolEnd" - AWB 2022.09.28
unsigned int moduleIndex = 999999;
for (int ii = 0; ii < int(hltConfig.size(trigger)); ii++) {
if (hltConfig.moduleLabels(trigger)[ii] == "hltBoolEnd") {
moduleIndex = ii - 1;
break;
}
}
if (moduleIndex == 999999) {
edm::LogError("L1TCommon") << " Found no module label in trigger " << trigger << std::endl;
continue;
}
const std::vector<std::string> &modules(hltConfig.moduleLabels(trigger));
std::string module(modules[moduleIndex]);
edm::InputTag filterInputTag = edm::InputTag(module, "", triggerProcess);
Expand Down
89 changes: 78 additions & 11 deletions DQMOffline/L1Trigger/src/L1TMuonDQMOffline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ L1TMuonDQMOffline::L1TMuonDQMOffline(const ParameterSet& ps)
m_minTagProbeDR(0.5),
m_maxHltMuonDR(0.1) {
if (m_verbose)
cout << "[L1TMuonDQMOffline:] ____________ Storage initialization ____________ " << endl;
edm::LogInfo("L1TMuonDQMOffline") << "____________ Storage initialization ____________ " << endl;

for (const auto& cutsPSet : m_cutsVPSet) {
const auto qCut = cutsPSet.getUntrackedParameter<int>("qualCut");
Expand All @@ -176,7 +176,7 @@ L1TMuonDQMOffline::~L1TMuonDQMOffline() {}
//----------------------------------------------------------------------
void L1TMuonDQMOffline::dqmBeginRun(const edm::Run& run, const edm::EventSetup& iSetup) {
if (m_verbose)
cout << "[L1TMuonDQMOffline:] Called beginRun." << endl;
edm::LogInfo("L1TMuonDQMOffline") << "Called beginRun." << endl;
bool changed = true;
m_hltConfig.init(run, iSetup, m_trigProcess, changed);
}
Expand All @@ -201,15 +201,20 @@ void L1TMuonDQMOffline::bookHistograms(DQMStore::IBooker& ibooker, const edm::Ru
if (tmpName.Contains(tNamePattern)) {
tIndex = int(ipath);
m_trigIndices.push_back(tIndex);
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline") << "Found trigger " << tmpName << " with index " << tIndex << endl;
}
}
if (tIndex < 0 && m_verbose)
cout << "[L1TMuonDQMOffline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
edm::LogInfo("L1TMuonDQMOffline") << "Warning: Could not find trigger " << (*trigNamesIt) << endl;
}
}

//_____________________________________________________________________
void L1TMuonDQMOffline::analyze(const Event& iEvent, const EventSetup& eventSetup) {
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline") << "\nProcessing new event in analyze" << endl;

auto const propagator = m_propagatorSetup.init(eventSetup);

Handle<reco::MuonCollection> muons;
Expand All @@ -225,6 +230,22 @@ void L1TMuonDQMOffline::analyze(const Event& iEvent, const EventSetup& eventSetu
edm::Handle<trigger::TriggerEvent> trigEvent;
iEvent.getByToken(m_trigInputTag, trigEvent);

// Only process event if at least one trigger fired
bool pass_HLT = false;
for (const auto& tIndex : m_trigIndices) {
if (trigResults->accept(tIndex)) {
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline") << "Fired trigger " << m_hltConfig.triggerName(tIndex) << endl;
pass_HLT = true;
break;
}
}
if (not pass_HLT) {
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline") << "Did not fire any triggers - quitting" << endl;
return;
}

const auto nVtx = getNVertices(vertex);
const Vertex primaryVertex = getPrimaryVertex(vertex, beamSpot);

Expand All @@ -234,7 +255,9 @@ void L1TMuonDQMOffline::analyze(const Event& iEvent, const EventSetup& eventSetu
getMuonGmtPairs(gmtCands, propagator);

if (m_verbose)
cout << "[L1TMuonDQMOffline:] Computing efficiencies" << endl;
edm::LogInfo("L1TMuonDQMOffline") << "Computing efficiencies with " << m_MuonGmtPairs.size() << " muonGmtPairs, "
<< m_TightMuons.size() << " tight muons, " << m_ProbeMuons.size()
<< " probe muons" << endl;

vector<MuonGmtPair>::const_iterator muonGmtPairsIt = m_MuonGmtPairs.begin();
vector<MuonGmtPair>::const_iterator muonGmtPairsEnd = m_MuonGmtPairs.end();
Expand All @@ -261,6 +284,10 @@ void L1TMuonDQMOffline::analyze(const Event& iEvent, const EventSetup& eventSetu
if (muonGmtPairsIt->gmtQual() >= qualCut) {
std::get<2>(histoKeyRes) = qualLevel;
m_ResolutionHistos[histoKeyRes]->Fill(varToFill);
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline")
<< "Filled resolution histo[" << std::get<0>(histoKeyRes) << ", " << std::get<1>(histoKeyRes)
<< ", " << std::get<2>(histoKeyRes) << "] with " << varToFill << endl;
}
}
}
Expand Down Expand Up @@ -294,17 +321,27 @@ void L1TMuonDQMOffline::analyze(const Event& iEvent, const EventSetup& eventSetu
// Fill denominators
if (var == kEffEta) {
m_EfficiencyDenEtaHistos[gmtPtCut]->Fill(varToFill);
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline")
<< "Filled eff denom eta histo[" << gmtPtCut << "] with " << varToFill << endl;
} else {
std::get<0>(histoKeyEffDenVar) = var;
// Fill for the global eta and for TF eta region that the probe muon is in
for (const auto regToFill : regsToFill) {
if (var == kEffPt) {
if (cutsCounter == 0) {
m_EfficiencyDenPtHistos[regToFill]->Fill(varToFill);
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline")
<< "Filled eff denom pT histo[" << regToFill << "] with " << varToFill << endl;
}
} else {
std::get<2>(histoKeyEffDenVar) = regToFill;
m_EfficiencyDenVarHistos[histoKeyEffDenVar]->Fill(varToFill);
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline") << "Filled eff denom histo[" << std::get<0>(histoKeyEffDenVar)
<< ", " << std::get<1>(histoKeyEffDenVar) << ", "
<< std::get<2>(histoKeyEffDenVar) << "] with " << varToFill << endl;
}
}
}
Expand All @@ -315,12 +352,21 @@ void L1TMuonDQMOffline::analyze(const Event& iEvent, const EventSetup& eventSetu
if (var == kEffEta) {
m_histoKeyEffNumEtaType histoKeyEffNumEta = {gmtPtCut, qualLevel};
m_EfficiencyNumEtaHistos[histoKeyEffNumEta]->Fill(varToFill);
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline")
<< "Filled eff num eta histo[" << std::get<0>(histoKeyEffNumEta) << ", "
<< std::get<1>(histoKeyEffNumEta) << "] with " << varToFill << endl;
} else {
std::get<3>(histoKeyEffNumVar) = qualLevel;
// Fill for the global eta and for TF eta region that the probe muon is in
for (const auto regToFill : regsToFill) {
std::get<2>(histoKeyEffNumVar) = regToFill;
m_EfficiencyNumVarHistos[histoKeyEffNumVar]->Fill(varToFill);
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline")
<< "Filled eff num histo[" << std::get<0>(histoKeyEffNumVar) << ", "
<< std::get<1>(histoKeyEffNumVar) << ", " << std::get<2>(histoKeyEffNumVar) << ", "
<< std::get<3>(histoKeyEffNumVar) << "] with " << varToFill << endl;
}
}
}
Expand All @@ -331,13 +377,13 @@ void L1TMuonDQMOffline::analyze(const Event& iEvent, const EventSetup& eventSetu
}

if (m_verbose)
cout << "[L1TMuonDQMOffline:] Computation finished" << endl;
edm::LogInfo("L1TMuonDQMOffline") << "Computation finished" << endl;
}

//_____________________________________________________________________
void L1TMuonDQMOffline::bookControlHistos(DQMStore::IBooker& ibooker) {
if (m_verbose)
cout << "[L1TMuonDQMOffline:] Booking Control Plot Histos" << endl;
edm::LogInfo("L1TMuonDQMOffline") << "Booking Control Plot Histos" << endl;

ibooker.setCurrentFolder(m_HistFolder + "/control_variables");

Expand Down Expand Up @@ -412,7 +458,7 @@ void L1TMuonDQMOffline::bookEfficiencyHistos(DQMStore::IBooker& ibooker) {

void L1TMuonDQMOffline::bookResolutionHistos(DQMStore::IBooker& ibooker) {
if (m_verbose)
cout << "[L1TMuonOffline:] Booking Resolution Plot Histos" << endl;
edm::LogInfo("L1TMuonDQMOffline") << "Booking Resolution Plot Histos" << endl;
ibooker.setCurrentFolder(m_HistFolder + "/resolution");

for (const auto var : m_resTypes) {
Expand Down Expand Up @@ -478,7 +524,7 @@ const reco::Vertex L1TMuonDQMOffline::getPrimaryVertex(Handle<VertexCollection>&
//_____________________________________________________________________
void L1TMuonDQMOffline::getTightMuons(edm::Handle<reco::MuonCollection>& muons, const Vertex& vertex) {
if (m_verbose)
cout << "[L1TMuonDQMOffline:] Getting tight muons" << endl;
edm::LogInfo("L1TMuonDQMOffline") << "Getting tight muons" << endl;
m_TightMuons.clear();
MuonCollection::const_iterator muonIt = muons->begin();
MuonCollection::const_iterator muonEnd = muons->end();
Expand All @@ -495,7 +541,7 @@ void L1TMuonDQMOffline::getTightMuons(edm::Handle<reco::MuonCollection>& muons,
void L1TMuonDQMOffline::getProbeMuons(Handle<edm::TriggerResults>& trigResults,
edm::Handle<trigger::TriggerEvent>& trigEvent) {
if (m_verbose)
cout << "[L1TMuonDQMOffline:] getting probe muons" << endl;
edm::LogInfo("L1TMuonDQMOffline") << "getting probe muons" << endl;
m_ProbeMuons.clear();
std::vector<const reco::Muon*> tagMuonsInHist;

Expand Down Expand Up @@ -557,7 +603,7 @@ void L1TMuonDQMOffline::getMuonGmtPairs(edm::Handle<l1t::MuonBxCollection>& gmtC
PropagateToMuon const& propagator) {
m_MuonGmtPairs.clear();
if (m_verbose)
cout << "[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
edm::LogInfo("L1TMuonDQMOffline") << "Getting muon GMT pairs" << endl;

vector<const reco::Muon*>::const_iterator probeMuIt = m_ProbeMuons.begin();
vector<const reco::Muon*>::const_iterator probeMuEnd = m_ProbeMuons.end();
Expand Down Expand Up @@ -598,15 +644,36 @@ double L1TMuonDQMOffline::matchHlt(edm::Handle<TriggerEvent>& triggerEvent, cons

for (; trigIndexIt != trigIndexEnd; ++trigIndexIt) {
const vector<string> moduleLabels(m_hltConfig.moduleLabels(*trigIndexIt));
const unsigned moduleIndex = m_hltConfig.size((*trigIndexIt)) - 2;
// For some reason various modules now come *after* "hltBoolEnd"
// Really just want module one index before "hltBoolEnd" - AWB 2022.09.28
// const unsigned moduleIndex = m_hltConfig.size((*trigIndexIt)) - 2;
unsigned int moduleIndex = 999999;
for (int ii = 0; ii < int(moduleLabels.size()); ii++) {
if (moduleLabels[ii] == "hltBoolEnd") {
moduleIndex = ii - 1;
break;
}
}
if (moduleIndex == 999999) {
edm::LogError("L1TMuonDQMOffline") << "Found no module label in trigger " << (*trigIndexIt) << endl;
continue;
}

const unsigned hltFilterIndex = triggerEvent->filterIndex(InputTag(moduleLabels[moduleIndex], "", m_trigProcess));

if (hltFilterIndex < triggerEvent->sizeFilters()) {
const Keys triggerKeys(triggerEvent->filterKeys(hltFilterIndex));
const Vids triggerVids(triggerEvent->filterIds(hltFilterIndex));
const unsigned nTriggers = triggerVids.size();

for (size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline") << "Found trigObject with pt = " << trigObject.pt()
<< ", eta = " << trigObject.eta() << ", phi = " << trigObject.phi() << endl;
if (m_verbose)
edm::LogInfo("L1TMuonDQMOffline") << "Compare to muon with pt = " << (*mu).pt() << ", eta = " << (*mu).eta()
<< ", phi = " << (*mu).phi() << endl;
double dRtmp = deltaR((*mu), trigObject);
if (dRtmp < matchDeltaR)
matchDeltaR = dRtmp;
Expand Down