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

[92X] Offline DQM extensions for L1T EGamma (calo layer 2) and fixes - backport #20232

Merged
merged 8 commits into from Oct 5, 2017
22 changes: 17 additions & 5 deletions DQMOffline/L1Trigger/interface/L1TEGammaOffline.h
Expand Up @@ -39,16 +39,16 @@ class L1TEGammaOffline: public DQMEDAnalyzer {
public:

L1TEGammaOffline(const edm::ParameterSet& ps);
virtual ~L1TEGammaOffline();
~L1TEGammaOffline() override;

protected:

void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override;
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
void analyze(edm::Event const& e, edm::EventSetup const& eSetup);
void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup);
void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup);
void endRun(edm::Run const& run, edm::EventSetup const& eSetup);
void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override;
void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override;
void endRun(edm::Run const& run, edm::EventSetup const& eSetup) override;

private:
bool passesLooseEleId(reco::GsfElectron const& electron) const;
Expand Down Expand Up @@ -83,6 +83,8 @@ class L1TEGammaOffline: public DQMEDAnalyzer {

std::vector<double> electronEfficiencyThresholds_;
std::vector<double> electronEfficiencyBins_;
double probeToL1Offset_;
std::vector<double>deepInspectionElectronThresholds_;

std::vector<double> photonEfficiencyThresholds_;
std::vector<double> photonEfficiencyBins_;
Expand Down Expand Up @@ -122,12 +124,22 @@ class L1TEGammaOffline: public DQMEDAnalyzer {
std::map<double, MonitorElement*> h_efficiencyElectronET_EB_pass_;
std::map<double, MonitorElement*> h_efficiencyElectronET_EE_pass_;
std::map<double, MonitorElement*> h_efficiencyElectronET_EB_EE_pass_;
std::map<double, MonitorElement*> h_efficiencyElectronPhi_vs_Eta_pass_;
// for deep inspection only
std::map<double, MonitorElement*> h_efficiencyElectronEta_pass_;
std::map<double, MonitorElement*> h_efficiencyElectronPhi_pass_;
std::map<double, MonitorElement*> h_efficiencyElectronNVertex_pass_;

// we could drop the map here, but L1TEfficiency_Harvesting expects
// identical names except for the suffix
std::map<double, MonitorElement*> h_efficiencyElectronET_EB_total_;
std::map<double, MonitorElement*> h_efficiencyElectronET_EE_total_;
std::map<double, MonitorElement*> h_efficiencyElectronET_EB_EE_total_;
std::map<double, MonitorElement*> h_efficiencyElectronPhi_vs_Eta_total_;
// for deep inspection only
std::map<double, MonitorElement*> h_efficiencyElectronEta_total_;
std::map<double, MonitorElement*> h_efficiencyElectronPhi_total_;
std::map<double, MonitorElement*> h_efficiencyElectronNVertex_total_;

// photons
MonitorElement* h_L1EGammaETvsPhotonET_EB_;
Expand Down
5 changes: 2 additions & 3 deletions DQMOffline/L1Trigger/interface/L1TEfficiencyHarvesting.h
Expand Up @@ -62,7 +62,6 @@ class L1TEfficiencyPlotHandler {
std::string denominatorSuffix_;

MonitorElement* h_efficiency_;

};

typedef std::vector<L1TEfficiencyPlotHandler> L1TEfficiencyPlotHandlerCollection;
Expand All @@ -76,11 +75,11 @@ class L1TEfficiencyHarvesting: public DQMEDHarvester {
public:

L1TEfficiencyHarvesting(const edm::ParameterSet& ps); // Constructor
virtual ~L1TEfficiencyHarvesting(); // Destructor
~L1TEfficiencyHarvesting() override; // Destructor

protected:

virtual void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override;
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override;
virtual void dqmEndLuminosityBlock(DQMStore::IGetter &igetter, edm::LuminosityBlock const& lumiBlock,
edm::EventSetup const& c);

Expand Down
21 changes: 20 additions & 1 deletion DQMOffline/L1Trigger/python/L1TEGammaEfficiency_cfi.py
Expand Up @@ -6,17 +6,30 @@
'photon': L1TEGammaOffline_cfi.photonEfficiencyThresholds,
}

deepInspectionThresholds = {
'electron': L1TEGammaOffline_cfi.deepInspectionElectronThresholds,
'photon': [],
}

plots = {
'electron': [
"efficiencyElectronET_EB", "efficiencyElectronET_EE",
"efficiencyElectronET_EB_EE"
"efficiencyElectronET_EB_EE", "efficiencyElectronPhi_vs_Eta",
],
'photon': [
"efficiencyPhotonET_EB", "efficiencyPhotonET_EE",
"efficiencyPhotonET_EB_EE"
]
}

deepInspectionPlots = {
'electron': [
'efficiencyElectronEta', 'efficiencyElectronPhi',
'efficiencyElectronNVertex'
],
'photon': [],
}

allEfficiencyPlots = []
add_plot = allEfficiencyPlots.append
for variable, thresholds in variables.iteritems():
Expand All @@ -25,6 +38,12 @@
plotName = '{0}_threshold_{1}'.format(plot, threshold)
add_plot(plotName)

for variable, thresholds in deepInspectionThresholds.iteritems():
for plot in deepInspectionPlots[variable]:
for threshold in thresholds:
plotName = '{0}_threshold_{1}'.format(plot, threshold)
add_plot(plotName)

from DQMOffline.L1Trigger.L1TEfficiencyHarvesting_cfi import l1tEfficiencyHarvesting
l1tEGammaEfficiency = l1tEfficiencyHarvesting.clone(
plotCfgs=cms.untracked.VPSet(
Expand Down
24 changes: 17 additions & 7 deletions DQMOffline/L1Trigger/python/L1TEGammaOffline_cfi.py
@@ -1,12 +1,21 @@
import FWCore.ParameterSet.Config as cms

electronEfficiencyThresholds = [36, 68, 128, 176]
electronEfficiencyThresholds = [34, 36, 38, 40, 42]

electronEfficiencyBins = []
electronEfficiencyBins.extend(list(xrange(0, 120, 10)))
electronEfficiencyBins.extend(list(xrange(120, 180, 20)))
electronEfficiencyBins.extend(list(xrange(180, 300, 40)))
electronEfficiencyBins.extend(list(xrange(300, 400, 100)))
electronEfficiencyBins.extend(list(xrange(2, 42, 2)))
electronEfficiencyBins.extend(list(xrange(42, 45, 3)))
electronEfficiencyBins.extend(list(xrange(45, 50, 5)))
electronEfficiencyBins.extend(list(xrange(50, 70, 10)))
electronEfficiencyBins.extend(list(xrange(70, 101, 30)))

# additional efficiency vs eta, phi and # vertices plots will
# be created for the following probe electron pT thresholds
deepInspectionElectronThresholds = [48, 50]

# offset for 2D efficiency plots, uses
# electronEfficiencyBins + probeToL1Offset (GeV)
probeToL1Offset = 10

# just copy for now
photonEfficiencyThresholds = electronEfficiencyThresholds
Expand All @@ -28,14 +37,15 @@
TriggerFilter=cms.InputTag('hltEle27WP80TrackIsoFilter', '', 'HLT'),
TriggerPath=cms.string('HLT_Ele27_WP80_v13'),


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

histFolder=cms.string('L1T/L1TEGamma'),

electronEfficiencyThresholds=cms.vdouble(electronEfficiencyThresholds),
electronEfficiencyBins=cms.vdouble(electronEfficiencyBins),

probeToL1Offset=cms.double(probeToL1Offset),
deepInspectionElectronThresholds=cms.vdouble([48, 50]),

photonEfficiencyThresholds=cms.vdouble(photonEfficiencyThresholds),
photonEfficiencyBins=cms.vdouble(photonEfficiencyBins),
)
Expand Down
10 changes: 5 additions & 5 deletions DQMOffline/L1Trigger/python/L1TStage2CaloLayer2Offline_cfi.py
Expand Up @@ -10,35 +10,35 @@
jetEfficiencyBins.extend(list(xrange(0, 120, 10)))
jetEfficiencyBins.extend(list(xrange(120, 180, 20)))
jetEfficiencyBins.extend(list(xrange(180, 300, 40)))
jetEfficiencyBins.extend(list(xrange(300, 400, 100)))
jetEfficiencyBins.extend(list(xrange(300, 401, 100)))

metEfficiencyBins = []
metEfficiencyBins.extend(list(xrange(0, 40, 4)))
metEfficiencyBins.extend(list(xrange(40, 70, 2)))
metEfficiencyBins.extend(list(xrange(70, 100, 5)))
metEfficiencyBins.extend(list(xrange(100, 160, 10)))
metEfficiencyBins.extend(list(xrange(160, 260, 20)))
metEfficiencyBins.extend(list(xrange(160, 261, 20)))

mhtEfficiencyBins = []
mhtEfficiencyBins.extend(list(xrange(30, 50, 1)))
mhtEfficiencyBins.extend(list(xrange(50, 80, 5)))
mhtEfficiencyBins.extend(list(xrange(80, 140, 10)))
mhtEfficiencyBins.extend(list(xrange(140, 200, 15)))
mhtEfficiencyBins.extend(list(xrange(200, 300, 20)))
mhtEfficiencyBins.extend(list(xrange(300, 400, 50)))
mhtEfficiencyBins.extend(list(xrange(300, 401, 50)))

ettEfficiencyBins = []
ettEfficiencyBins.extend(list(xrange(0, 30, 30)))
ettEfficiencyBins.extend(list(xrange(30, 50, 10)))
ettEfficiencyBins.extend(list(xrange(50, 90, 5)))
ettEfficiencyBins.extend(list(xrange(90, 140, 2)))
ettEfficiencyBins.extend(list(xrange(90, 141, 2)))

httEfficiencyBins = []
httEfficiencyBins.extend(list(xrange(0, 100, 5)))
httEfficiencyBins.extend(list(xrange(100, 200, 10)))
httEfficiencyBins.extend(list(xrange(200, 400, 20)))
httEfficiencyBins.extend(list(xrange(400, 500, 50)))
httEfficiencyBins.extend(list(xrange(500, 600, 10)))
httEfficiencyBins.extend(list(xrange(500, 601, 10)))

l1tStage2CaloLayer2OfflineDQM = cms.EDAnalyzer(
"L1TStage2CaloLayer2Offline",
Expand Down
6 changes: 3 additions & 3 deletions DQMOffline/L1Trigger/python/L1TTauOffline_cfi.py
Expand Up @@ -6,12 +6,12 @@
tauEfficiencyBins.extend(list(xrange(0, 120, 1)))
tauEfficiencyBins.extend(list(xrange(120, 180, 20)))
tauEfficiencyBins.extend(list(xrange(180, 300, 40)))
tauEfficiencyBins.extend(list(xrange(300, 400, 100)))
tauEfficiencyBins.extend(list(xrange(300, 401, 100)))

l1tTauOfflineDQM = cms.EDAnalyzer(
"L1TTauOffline",
verbose = cms.untracked.bool(False),

muonInputTag = cms.untracked.InputTag("muons"),
tauInputTag = cms.untracked.InputTag("hpsPFTauProducer"),
metInputTag = cms.untracked.InputTag("pfMet"),
Expand All @@ -31,7 +31,7 @@

tauEfficiencyThresholds=cms.vint32(tauEfficiencyThresholds),
tauEfficiencyBins=cms.vdouble(tauEfficiencyBins),

)

l1tTauOfflineDQMEmu = l1tTauOfflineDQM.clone(
Expand Down
73 changes: 64 additions & 9 deletions DQMOffline/L1Trigger/src/L1TEGammaOffline.cc
Expand Up @@ -11,10 +11,10 @@

#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstdio>
#include <string>
#include <sstream>
#include <math.h>
#include <cmath>
#include <algorithm>

//
Expand All @@ -37,6 +37,8 @@ L1TEGammaOffline::L1TEGammaOffline(const edm::ParameterSet& ps) :
consumes < l1t::EGammaBxCollection > (ps.getParameter < edm::InputTag > ("stage2CaloLayer2EGammaSource"))),
electronEfficiencyThresholds_(ps.getParameter < std::vector<double> > ("electronEfficiencyThresholds")),
electronEfficiencyBins_(ps.getParameter < std::vector<double> > ("electronEfficiencyBins")),
probeToL1Offset_(ps.getParameter <double> ("probeToL1Offset")),
deepInspectionElectronThresholds_(ps.getParameter < std::vector<double> > ("deepInspectionElectronThresholds")),
photonEfficiencyThresholds_(ps.getParameter < std::vector<double> > ("photonEfficiencyThresholds")),
photonEfficiencyBins_(ps.getParameter < std::vector<double> > ("photonEfficiencyBins")),
tagElectron_(),
Expand Down Expand Up @@ -115,12 +117,12 @@ void L1TEGammaOffline::fillElectrons(edm::Event const& e, const unsigned int nVe
edm::LogError("L1TEGammaOffline") << "invalid collection: GSF electrons " << std::endl;
return;
}
if (gsfElectrons->size() == 0) {
if (gsfElectrons->empty()) {
LogDebug("L1TEGammaOffline") << "empty collection: GSF electrons " << std::endl;
return;
}
if (!l1EGamma.isValid()) {
//edm::LogError("L1TEGammaOffline") << "invalid collection: L1 EGamma " << std::endl;
edm::LogError("L1TEGammaOffline") << "invalid collection: L1 EGamma " << std::endl;
return;
}
if (!findTagAndProbePair(gsfElectrons)) {
Expand Down Expand Up @@ -172,6 +174,27 @@ void L1TEGammaOffline::fillElectrons(edm::Event const& e, const unsigned int nVe
fill2DWithinLimits(h_L1EGammaEtavsElectronEta_, recoEta, l1Eta);
fillWithinLimits(h_resolutionElectronEta_, resolutionEta);

// plots for deeper inspection
for (auto threshold : deepInspectionElectronThresholds_) {
fillWithinLimits(h_efficiencyElectronEta_total_[threshold], recoEta);
fillWithinLimits(h_efficiencyElectronPhi_total_[threshold], recoPhi);
fillWithinLimits(h_efficiencyElectronNVertex_total_[threshold], nVertex);
if(recoEt > threshold){
fillWithinLimits(h_efficiencyElectronEta_pass_[threshold], recoEta);
fillWithinLimits(h_efficiencyElectronPhi_pass_[threshold], recoPhi);
fillWithinLimits(h_efficiencyElectronNVertex_pass_[threshold], nVertex);
}
}

for (auto threshold : electronEfficiencyThresholds_) {
fill2DWithinLimits(h_efficiencyElectronPhi_vs_Eta_total_[threshold],
recoEta, recoPhi);
if(l1Et > threshold + probeToL1Offset_){
fill2DWithinLimits(h_efficiencyElectronPhi_vs_Eta_pass_[threshold],
recoEta, recoPhi);
}
}

if (std::abs(recoEta) <= 1.479) { // barrel
// et
fill2DWithinLimits(h_L1EGammaETvsElectronET_EB_, recoEt, l1Et);
Expand Down Expand Up @@ -367,7 +390,7 @@ void L1TEGammaOffline::fillPhotons(edm::Event const& e, const unsigned int nVert
return;
}

if(photons->size() ==0){
if(photons->empty()){
LogDebug("L1TEGammaOffline") << "No photons found in event." << std::endl;
return;
}
Expand Down Expand Up @@ -486,7 +509,7 @@ void L1TEGammaOffline::endRun(edm::Run const& run, edm::EventSetup const& eSetup
void L1TEGammaOffline::bookElectronHistos(DQMStore::IBooker & ibooker)
{
ibooker.cd();
ibooker.setCurrentFolder(histFolder_.c_str());
ibooker.setCurrentFolder(histFolder_);
h_nVertex_ = ibooker.book1D("nVertex", "Number of event vertices in collection", 40, -0.5, 39.5);
h_tagAndProbeMass_ = ibooker.book1D("tagAndProbeMass", "Invariant mass of tag & probe pair", 100, 40, 140);
// electron reco vs L1
Expand Down Expand Up @@ -538,7 +561,7 @@ void L1TEGammaOffline::bookElectronHistos(DQMStore::IBooker & ibooker)
"electron #eta resolution (EB); (L1 EGamma #eta - GSF Electron #eta)/GSF Electron #eta; events", 120, -0.3, 0.3);

// electron turn-ons
ibooker.setCurrentFolder(efficiencyFolder_.c_str());
ibooker.setCurrentFolder(efficiencyFolder_);
std::vector<float> electronBins(electronEfficiencyBins_.begin(), electronEfficiencyBins_.end());
int nBins = electronBins.size() - 1;
float* electronBinArray = &(electronBins[0]);
Expand All @@ -554,6 +577,10 @@ void L1TEGammaOffline::bookElectronHistos(DQMStore::IBooker & ibooker)
h_efficiencyElectronET_EB_EE_pass_[threshold] = ibooker.book1D(
"efficiencyElectronET_EB_EE_threshold_" + str_threshold + "_Num",
"electron efficiency (EB+EE) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
h_efficiencyElectronPhi_vs_Eta_pass_[threshold] = ibooker.book2D(
"efficiencyElectronPhi_vs_Eta_threshold_" + str_threshold + "_Num",
"electron efficiency (numerator); GSF Electron #eta; GSF Electron #phi",
50, -2.5, 2.5, 32, -3.2, 3.2);

h_efficiencyElectronET_EB_total_[threshold] = ibooker.book1D(
"efficiencyElectronET_EB_threshold_" + str_threshold + "_Den",
Expand All @@ -564,15 +591,43 @@ void L1TEGammaOffline::bookElectronHistos(DQMStore::IBooker & ibooker)
h_efficiencyElectronET_EB_EE_total_[threshold] = ibooker.book1D(
"efficiencyElectronET_EB_EE_threshold_" + str_threshold + "_Den",
"electron efficiency (EB+EE) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
h_efficiencyElectronPhi_vs_Eta_total_[threshold] = ibooker.book2D(
"efficiencyElectronPhi_vs_Eta_threshold_" + str_threshold + "_Den",
"electron efficiency (denominator); GSF Electron #eta; GSF Electron #phi",
50, -2.5, 2.5, 32, -3.2, 3.2);
}

for (auto threshold: deepInspectionElectronThresholds_) {
std::string str_threshold = std::to_string(int(threshold));
h_efficiencyElectronEta_pass_[threshold] = ibooker.book1D(
"efficiencyElectronEta_threshold_" + str_threshold + "_Num",
"electron efficiency (numerator); GSF Electron #eta; events", 50, -2.5, 2.5);
h_efficiencyElectronPhi_pass_[threshold] = ibooker.book1D(
"efficiencyElectronPhi_threshold_" + str_threshold + "_Num",
"electron efficiency (numerator); GSF Electron #phi; events", 32, -3.2, 3.2);
h_efficiencyElectronNVertex_pass_[threshold] = ibooker.book1D(
"efficiencyElectronNVertex_threshold_" + str_threshold + "_Num",
"electron efficiency (numerator); Nvtx; events", 30, 0, 60);

h_efficiencyElectronEta_total_[threshold] = ibooker.book1D(
"efficiencyElectronEta_threshold_" + str_threshold + "_Den",
"electron efficiency (denominator); GSF Electron #eta; events", 50, -2.5, 2.5);
h_efficiencyElectronPhi_total_[threshold] = ibooker.book1D(
"efficiencyElectronPhi_threshold_" + str_threshold + "_Den",
"electron efficiency (denominator); GSF Electron #phi; events", 32, -3.2, 3.2);
h_efficiencyElectronNVertex_total_[threshold] = ibooker.book1D(
"efficiencyElectronNVertex_threshold_" + str_threshold + "_Den",
"electron efficiency (denominator); Nvtx; events", 30, 0, 60);
}


ibooker.cd();
}

void L1TEGammaOffline::bookPhotonHistos(DQMStore::IBooker & ibooker)
{
ibooker.cd();
ibooker.setCurrentFolder(histFolder_.c_str());
ibooker.setCurrentFolder(histFolder_);
h_L1EGammaETvsPhotonET_EB_ = ibooker.book2D("L1EGammaETvsPhotonET_EB",
"L1 EGamma E_{T} vs Photon E_{T} (EB); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)", 300, 0, 300, 300, 0, 300);
h_L1EGammaETvsPhotonET_EE_ = ibooker.book2D("L1EGammaETvsPhotonET_EE",
Expand Down Expand Up @@ -615,7 +670,7 @@ void L1TEGammaOffline::bookPhotonHistos(DQMStore::IBooker & ibooker)
"photon #eta resolution (EB); (L1 EGamma #eta - Photon #eta)/ Photon #eta; events", 120, -0.3, 0.3);

// photon turn-ons
ibooker.setCurrentFolder(efficiencyFolder_.c_str());
ibooker.setCurrentFolder(efficiencyFolder_);
std::vector<float> photonBins(photonEfficiencyBins_.begin(), photonEfficiencyBins_.end());
int nBins = photonBins.size() - 1;
float* photonBinArray = &(photonBins[0]);
Expand Down