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

[10X] [L1T] [DQM] Adding HLT object matching for tag electron in EGamma #21829

Merged
merged 6 commits into from
Jan 29, 2018
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
38 changes: 38 additions & 0 deletions DQMOffline/L1Trigger/interface/L1TCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <string>

#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/HLTReco/interface/TriggerEvent.h"
#include "DataFormats/HLTReco/interface/TriggerObject.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

namespace dqmoffline {
namespace l1t {

std::vector<unsigned int>
getTriggerIndices(const std::vector<std::string> &requestedTriggers,
const std::vector<std::string> &triggersInEvent);

std::vector<bool> getTriggerResults(const std::vector<unsigned int> &triggers,
const edm::TriggerResults &triggerResults);

std::vector<unsigned int>
getFiredTriggerIndices(const std::vector<unsigned int> &triggers,
const std::vector<bool> &triggerResults);

bool passesAnyTriggerFromList(const std::vector<unsigned int> &triggers,
const edm::TriggerResults &triggerResults);

trigger::TriggerObjectCollection
getTriggerObjects(const std::vector<edm::InputTag> &hltFilters,
const trigger::TriggerEvent &triggerEvent);

std::vector<edm::InputTag>
getHLTFilters(const std::vector<unsigned int> &triggers,
const HLTConfigProvider &hltConfig,
const std::string triggerProcess);

trigger::TriggerObjectCollection
getMatchedTriggerObjects(double eta, double phi, double maxDeltaR,
const trigger::TriggerObjectCollection triggerObjects);
} // l1t
} // dqmoffline
14 changes: 10 additions & 4 deletions DQMOffline/L1Trigger/interface/L1TEGammaOffline.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//event
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

//DQM
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
Expand Down Expand Up @@ -71,6 +72,7 @@ class L1TEGammaOffline: public DQMEDAnalyzer {
void fillElectrons(edm::Event const& e, const unsigned int nVertex);
void fillPhotons(edm::Event const& e, const unsigned int nVertex);
bool findTagAndProbePair(edm::Handle<reco::GsfElectronCollection> const& electrons);
bool matchesAnHLTObject(double eta, double phi) const;

math::XYZPoint PVPoint_;

Expand All @@ -79,10 +81,10 @@ class L1TEGammaOffline: public DQMEDAnalyzer {
edm::EDGetTokenT<std::vector<reco::Photon> > thePhotonCollection_;
edm::EDGetTokenT<reco::VertexCollection> thePVCollection_;
edm::EDGetTokenT<reco::BeamSpot> theBSCollection_;
edm::EDGetTokenT<trigger::TriggerEvent> triggerEvent_;
edm::EDGetTokenT<edm::TriggerResults> triggerResults_;
edm::InputTag triggerFilter_;
std::string triggerPath_;
edm::EDGetTokenT<trigger::TriggerEvent> triggerInputTag_;
edm::EDGetTokenT<edm::TriggerResults> triggerResultsInputTag_;
std::string triggerProcess_;
std::vector<std::string> triggerNames_;
std::string histFolder_;
std::string efficiencyFolder_;

Expand All @@ -100,6 +102,10 @@ class L1TEGammaOffline: public DQMEDAnalyzer {
reco::GsfElectron probeElectron_;
double tagAndProbleInvariantMass_;

HLTConfigProvider hltConfig_;
std::vector<unsigned int> triggerIndices_;
edm::TriggerResults triggerResults_;
trigger::TriggerEvent triggerEvent_;
dqmoffline::l1t::HistDefinitions histDefinitions_;

// TODO: add turn-on cuts (vectors of doubles)
Expand Down
15 changes: 11 additions & 4 deletions DQMOffline/L1Trigger/interface/L1TStage2CaloLayer2Offline.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//event
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

//DQM
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
Expand Down Expand Up @@ -104,6 +105,8 @@ class L1TStage2CaloLayer2Offline: public DQMEDAnalyzer {
void fillEnergySums(edm::Event const& e, const unsigned int nVertex);
void fillJets(edm::Event const& e, const unsigned int nVertex);

bool doesNotOverlapWithHLTObjects(const l1t::Jet & jet) const;

//private variables
math::XYZPoint PVPoint_;

Expand All @@ -113,10 +116,10 @@ class L1TStage2CaloLayer2Offline: public DQMEDAnalyzer {
edm::EDGetTokenT<reco::CaloMETCollection> thecaloETMHFCollection_;
edm::EDGetTokenT<reco::VertexCollection> thePVCollection_;
edm::EDGetTokenT<reco::BeamSpot> theBSCollection_;
edm::EDGetTokenT<trigger::TriggerEvent> triggerEvent_;
edm::EDGetTokenT<edm::TriggerResults> triggerResults_;
edm::InputTag triggerFilter_;
std::string triggerPath_;
edm::EDGetTokenT<trigger::TriggerEvent> triggerInputTag_;
edm::EDGetTokenT<edm::TriggerResults> triggerResultsInputTag_;
std::string triggerProcess_;
std::vector<std::string> triggerNames_;
std::string histFolder_;
std::string efficiencyFolder_;

Expand All @@ -138,6 +141,10 @@ class L1TStage2CaloLayer2Offline: public DQMEDAnalyzer {
double recoHTTMaxEta_;
double recoMHTMaxEta_;

HLTConfigProvider hltConfig_;
std::vector<unsigned int> triggerIndices_;
edm::TriggerResults triggerResults_;
trigger::TriggerEvent triggerEvent_;
dqmoffline::l1t::HistDefinitions histDefinitions_;

// TODO: add turn-on cuts (vectors of doubles)
Expand Down
11 changes: 6 additions & 5 deletions DQMOffline/L1Trigger/python/L1TEGammaOffline_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
PVCollection=cms.InputTag("offlinePrimaryVerticesWithBS"),
beamSpotCollection=cms.InputTag("offlineBeamSpot"),

TriggerEvent=cms.InputTag('hltTriggerSummaryAOD', '', 'HLT'),
TriggerResults=cms.InputTag('TriggerResults', '', 'HLT'),
# last filter of HLTEle27WP80Sequence
TriggerFilter=cms.InputTag('hltEle27WP80TrackIsoFilter', '', 'HLT'),
TriggerPath=cms.string('HLT_Ele27_WP80_v13'),
triggerInputTag=cms.InputTag('hltTriggerSummaryAOD', '', 'HLT'),
triggerProcess=cms.string('HLT'),
triggerResults=cms.InputTag('TriggerResults', '', 'HLT'),
triggerNames = cms.vstring(
'HLT_Ele32_WPTight_Gsf_v*',
),

stage2CaloLayer2EGammaSource=cms.InputTag("caloStage2Digis", "EGamma"),

Expand Down
17 changes: 11 additions & 6 deletions DQMOffline/L1Trigger/python/L1TStage2CaloLayer2Offline_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@
PVCollection=cms.InputTag("offlinePrimaryVerticesWithBS"),
beamSpotCollection=cms.InputTag("offlineBeamSpot"),

TriggerEvent=cms.InputTag('hltTriggerSummaryAOD', '', 'HLT'),
TriggerResults=cms.InputTag('TriggerResults', '', 'HLT'),
# last filter of HLTEle27WP80Sequence
TriggerFilter=cms.InputTag('hltEle27WP80TrackIsoFilter', '', 'HLT'),
TriggerPath=cms.string('HLT_Ele27_WP80_v13'),

triggerInputTag=cms.InputTag('hltTriggerSummaryAOD', '', 'HLT'),
triggerProcess=cms.string('HLT'),
triggerResults=cms.InputTag('TriggerResults', '', 'HLT'),
triggerNames = cms.vstring(
'HLT_IsoMu18_v*',
'HLT_IsoMu20_v*',
'HLT_IsoMu22_v*',
'HLT_IsoMu24_v*',
'HLT_IsoMu27_v*',
'HLT_IsoMu30_v*',
),

stage2CaloLayer2JetSource=cms.InputTag("caloStage2Digis", "Jet"),
stage2CaloLayer2EtSumSource=cms.InputTag("caloStage2Digis", "EtSum"),
Expand Down
135 changes: 135 additions & 0 deletions DQMOffline/L1Trigger/src/L1TCommon.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#include "DQMOffline/L1Trigger/interface/L1TCommon.h"
#include "DataFormats/Math/interface/deltaR.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <iostream>

namespace dqmoffline {
namespace l1t {

std::vector<unsigned int>
getTriggerIndices(const std::vector<std::string> &requestedTriggers,
const std::vector<std::string> &triggersInEvent) {
std::vector<unsigned int> triggerIndices;

for (auto requestedTriggerName : requestedTriggers) {
std::string name(requestedTriggerName);
std::size_t wildcarPosition = name.find("*");
if (wildcarPosition != std::string::npos) {
// take everything up to the wildcard
name = name.substr(0, wildcarPosition - 1);
}

unsigned int triggerIndex = 0;
for (auto triggerName : triggersInEvent) {
if (triggerName.find(name) != std::string::npos) {
triggerIndices.push_back(triggerIndex);
break;
}
++triggerIndex;
}
}
return triggerIndices;
}

std::vector<bool> getTriggerResults(const std::vector<unsigned int> &triggers,
const edm::TriggerResults &triggerResults) {
std::vector<bool> results;
results.resize(triggers.size());

for (unsigned int index = 0; index < triggers.size(); ++index) {

if (triggers[index] >= triggerResults.size()) {
results[index] = false;
continue;
}

if (triggerResults.accept(triggers[index])) {
results[index] = true;
} else {
results[index] = false;
}
}
return results;
}

std::vector<unsigned int>
getFiredTriggerIndices(const std::vector<unsigned int> &triggers,
const std::vector<bool> &triggerResults) {
std::vector<unsigned int> results;
// std::copy_if instead?
for (unsigned int i = 0; i < triggerResults.size(); ++i) {
if (triggerResults[i]) {
results.push_back(triggers[i]);
}
}
return results;
}

bool passesAnyTriggerFromList(const std::vector<unsigned int> &triggers,
const edm::TriggerResults &triggerResults) {
std::vector<bool> results =
dqmoffline::l1t::getTriggerResults(triggers, triggerResults);
if (std::count(results.begin(), results.end(), true) == 0) {
return false;
}
return true;
}

trigger::TriggerObjectCollection
getTriggerObjects(const std::vector<edm::InputTag> &hltFilters,
const trigger::TriggerEvent &triggerEvent) {
trigger::TriggerObjectCollection triggerObjects = triggerEvent.getObjects();
trigger::TriggerObjectCollection results;

for (auto filter : hltFilters) {
const unsigned filterIndex = triggerEvent.filterIndex(filter);

if (filterIndex < triggerEvent.sizeFilters()) {
const trigger::Keys triggerKeys(triggerEvent.filterKeys(filterIndex));
const size_t nTriggers = triggerEvent.filterIds(filterIndex).size();
for (size_t i = 0; i < nTriggers; ++i) {
results.push_back(triggerObjects[triggerKeys[i]]);
}
}
}
// sort by ET
typedef trigger::TriggerObject trigObj;
std::sort(results.begin(), results.end(),
[](const trigObj &obj1, const trigObj &obj2) {
return obj1.et() > obj2.et();
});
return results;
}

std::vector<edm::InputTag>
getHLTFilters(const std::vector<unsigned int> &triggers,
const HLTConfigProvider &hltConfig,
const std::string triggerProcess) {
std::vector<edm::InputTag> results;
for (auto trigger : triggers) {
unsigned int hltIndexOffset(2);
unsigned int moduleIndex = hltConfig.size(trigger) - hltIndexOffset;
const std::vector<std::string> modules(hltConfig.moduleLabels(trigger));
std::string module(modules[moduleIndex]);
edm::InputTag filterInputTag = edm::InputTag(module, "", triggerProcess);
results.push_back(filterInputTag);
}
return results;
}

trigger::TriggerObjectCollection getMatchedTriggerObjects(
double eta, double phi, double maxDeltaR,
const trigger::TriggerObjectCollection triggerObjects) {
trigger::TriggerObjectCollection results;
typedef trigger::TriggerObject trigObj;
std::copy_if(triggerObjects.begin(), triggerObjects.end(),
std::back_inserter(results),
[eta, phi, maxDeltaR](const trigObj &obj) {
return deltaR(obj.eta(), obj.phi(), eta, phi) < maxDeltaR;
});
return results;
}

} // l1t
} // dqmoffline
Loading