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

[91X] Offline DQM modules for L1 Trigger, Stage 2 CaloLayer2 (Electrons + Photons) #18099

Merged
merged 8 commits into from Apr 5, 2017
167 changes: 167 additions & 0 deletions DQMOffline/L1Trigger/interface/L1TEGammaOffline.h
@@ -0,0 +1,167 @@
#ifndef L1TEGammaOffline_H
#define L1TEGammaOffline_H

//Framework
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

//event
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"

//DQM
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"

//Candidate handling
#include "DataFormats/Candidate/interface/Candidate.h"

// Electron & photon collections
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"

// Vertex utilities
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

// Trigger
#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/HLTReco/interface/TriggerObject.h"
#include "DataFormats/HLTReco/interface/TriggerEvent.h"

// stage2 collections:
#include "DataFormats/L1Trigger/interface/EGamma.h"

class L1TEGammaOffline: public DQMEDAnalyzer {

public:

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

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);

private:
bool passesLooseEleId(reco::GsfElectron const& electron) const;
bool passesMediumEleId(reco::GsfElectron const& electron) const;
void bookElectronHistos(DQMStore::IBooker &);
void bookPhotonHistos(DQMStore::IBooker &);

//other functions
double Distance(const reco::Candidate & c1, const reco::Candidate & c2);
double DistancePhi(const reco::Candidate & c1, const reco::Candidate & c2);
double calcDeltaPhi(double phi1, double phi2);

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);

math::XYZPoint PVPoint_;

//variables from config file
edm::EDGetTokenT<reco::GsfElectronCollection> theGsfElectronCollection_;
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_;
std::string histFolder_;
std::string efficiencyFolder_;

edm::EDGetTokenT<l1t::EGammaBxCollection> stage2CaloLayer2EGammaToken_;

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

std::vector<double> photonEfficiencyThresholds_;
std::vector<double> photonEfficiencyBins_;

reco::GsfElectron tagElectron_;
reco::GsfElectron probeElectron_;
double tagAndProbleInvariantMass_;

// TODO: add turn-on cuts (vectors of doubles)
// Histograms
MonitorElement* h_nVertex_;
MonitorElement* h_tagAndProbeMass_;

// electron reco vs L1
MonitorElement* h_L1EGammaETvsElectronET_EB_;
MonitorElement* h_L1EGammaETvsElectronET_EE_;
MonitorElement* h_L1EGammaETvsElectronET_EB_EE_;

MonitorElement* h_L1EGammaPhivsElectronPhi_EB_;
MonitorElement* h_L1EGammaPhivsElectronPhi_EE_;
MonitorElement* h_L1EGammaPhivsElectronPhi_EB_EE_;

MonitorElement* h_L1EGammaEtavsElectronEta_;

// electron resolutions
MonitorElement* h_resolutionElectronET_EB_;
MonitorElement* h_resolutionElectronET_EE_;
MonitorElement* h_resolutionElectronET_EB_EE_;

MonitorElement* h_resolutionElectronPhi_EB_;
MonitorElement* h_resolutionElectronPhi_EE_;
MonitorElement* h_resolutionElectronPhi_EB_EE_;

MonitorElement* h_resolutionElectronEta_;

// electron turn-ons
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_;

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

// photons
MonitorElement* h_L1EGammaETvsPhotonET_EB_;
MonitorElement* h_L1EGammaETvsPhotonET_EE_;
MonitorElement* h_L1EGammaETvsPhotonET_EB_EE_;

MonitorElement* h_L1EGammaPhivsPhotonPhi_EB_;
MonitorElement* h_L1EGammaPhivsPhotonPhi_EE_;
MonitorElement* h_L1EGammaPhivsPhotonPhi_EB_EE_;

MonitorElement* h_L1EGammaEtavsPhotonEta_;

// electron resolutions
MonitorElement* h_resolutionPhotonET_EB_;
MonitorElement* h_resolutionPhotonET_EE_;
MonitorElement* h_resolutionPhotonET_EB_EE_;

MonitorElement* h_resolutionPhotonPhi_EB_;
MonitorElement* h_resolutionPhotonPhi_EE_;
MonitorElement* h_resolutionPhotonPhi_EB_EE_;

MonitorElement* h_resolutionPhotonEta_;

// electron turn-ons
std::map<double, MonitorElement*> h_efficiencyPhotonET_EB_pass_;
std::map<double, MonitorElement*> h_efficiencyPhotonET_EE_pass_;
std::map<double, MonitorElement*> h_efficiencyPhotonET_EB_EE_pass_;

// we could drop the map here, but L1TEfficiency_Harvesting expects
// identical names except for the suffix
std::map<double, MonitorElement*> h_efficiencyPhotonET_EB_total_;
std::map<double, MonitorElement*> h_efficiencyPhotonET_EE_total_;
std::map<double, MonitorElement*> h_efficiencyPhotonET_EB_EE_total_;

};

#endif
58 changes: 58 additions & 0 deletions DQMOffline/L1Trigger/python/L1TEGammaDiff_cfi.py
@@ -0,0 +1,58 @@
import FWCore.ParameterSet.Config as cms
from DQMOffline.L1Trigger import L1TEGammaOffline_cfi

variables = {
'electron': L1TEGammaOffline_cfi.electronEfficiencyThresholds,
}

plots = {
'electron': [
"efficiencyElectronET_EB", "efficiencyElectronET_EE",
"efficiencyElectronET_EB_EE"
],
}

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

resolution_plots = [
"resolutionElectronET_EB", "resolutionElectronET_EE",
"resolutionElectronET_EB_EE", "resolutionElectronPhi_EB", "resolutionElectronPhi_EE",
"resolutionElectronPhi_EB_EE", "resolutionElectronEta",
#
"resolutionPhotonET_EB", "resolutionPhotonET_EE",
"resolutionPhotonET_EB_EE", "resolutionPhotonPhi_EB", "resolutionPhotonPhi_EE",
"resolutionPhotonPhi_EB_EE", "resolutionPhotonEta",
]
plots2D = [
'L1EGammaETvsElectronET_EB', 'L1EGammaETvsElectronET_EE', 'L1EGammaETvsElectronET_EB_EE',
'L1EGammaPhivsElectronPhi_EB', 'L1EGammaPhivsElectronPhi_EE', 'L1EGammaPhivsElectronPhi_EB_EE',
'L1EGammaEtavsElectronEta',
#
'L1EGammaETvsPhotonET_EB', 'L1EGammaETvsPhotonET_EE', 'L1EGammaETvsPhotonET_EB_EE',
'L1EGammaPhivsPhotonPhi_EB', 'L1EGammaPhivsPhotonPhi_EE', 'L1EGammaPhivsPhotonPhi_EB_EE',
'L1EGammaEtavsPhotonEta',
]

allPlots = []
allPlots.extend(allEfficiencyPlots)
allPlots.extend(resolution_plots)
allPlots.extend(plots2D)

from DQMOffline.L1Trigger.L1TDiffHarvesting_cfi import l1tDiffHarvesting
l1tEGammaEmuDiff = l1tDiffHarvesting.clone(
plotCfgs=cms.untracked.VPSet(
cms.untracked.PSet( # EMU comparison
dir1=cms.untracked.string("L1T/L1TEGamma"),
dir2=cms.untracked.string("L1TEMU/L1TEGamma"),
outputDir=cms.untracked.string(
"L1TEMU/L1TEGamma/Comparison"),
plots=cms.untracked.vstring(allPlots)
),
)
)
47 changes: 47 additions & 0 deletions DQMOffline/L1Trigger/python/L1TEGammaEfficiency_cfi.py
@@ -0,0 +1,47 @@
import FWCore.ParameterSet.Config as cms
from DQMOffline.L1Trigger import L1TEGammaOffline_cfi

variables = {
'electron': L1TEGammaOffline_cfi.electronEfficiencyThresholds,
'photon': L1TEGammaOffline_cfi.photonEfficiencyThresholds,
}

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

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

from DQMOffline.L1Trigger.L1TEfficiencyHarvesting2_cfi import l1tEfficiencyHarvesting
l1tEGammaEfficiency = l1tEfficiencyHarvesting.clone(
plotCfgs=cms.untracked.VPSet(
cms.untracked.PSet(
numeratorDir=cms.untracked.string("L1T/L1TEGamma/efficiency_raw"),
outputDir=cms.untracked.string("L1T/L1TEGamma"),
numeratorSuffix=cms.untracked.string("_Num"),
denominatorSuffix=cms.untracked.string("_Den"),
plots=cms.untracked.vstring(allEfficiencyPlots)
),
cms.untracked.PSet(
numeratorDir=cms.untracked.string(
"L1TEMU/L1TEGamma/efficiency_raw"),
outputDir=cms.untracked.string("L1TEMU/L1TEGamma"),
numeratorSuffix=cms.untracked.string("_Num"),
denominatorSuffix=cms.untracked.string("_Den"),
plots=cms.untracked.vstring(allEfficiencyPlots)
),
)
)
47 changes: 47 additions & 0 deletions DQMOffline/L1Trigger/python/L1TEGammaOffline_cfi.py
@@ -0,0 +1,47 @@
import FWCore.ParameterSet.Config as cms

electronEfficiencyThresholds = [36, 68, 128, 176]

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)))

# just copy for now
photonEfficiencyThresholds = electronEfficiencyThresholds
photonEfficiencyBins = electronEfficiencyBins

l1tEGammaOfflineDQM = cms.EDAnalyzer(
"L1TEGammaOffline",
electronCollection=cms.InputTag("gedGsfElectrons"),
photonCollection=cms.InputTag("photons"),
caloJetCollection=cms.InputTag("ak4CaloJets"),
caloMETCollection=cms.InputTag("caloMet"),
conversionsCollection=cms.InputTag("allConversions"),
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'),


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

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

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

photonEfficiencyThresholds=cms.vdouble(photonEfficiencyThresholds),
photonEfficiencyBins=cms.vdouble(photonEfficiencyBins),
)

l1tEGammaOfflineDQMEmu = l1tEGammaOfflineDQM.clone(
stage2CaloLayer2EGammaSource=cms.InputTag("simCaloStage2Digis"),

histFolder=cms.string('L1TEMU/L1TEGamma'),
)
4 changes: 2 additions & 2 deletions DQMOffline/L1Trigger/python/L1TStage2CaloLayer2Diff_cfi.py
Expand Up @@ -41,8 +41,8 @@
'L1METPhivsCaloMETPhi', 'L1MHTPhivsRecoMHTPhi',
# jets
'L1JetETvsCaloJetET_HB', 'L1JetETvsCaloJetET_HE', 'L1JetETvsCaloJetET_HF',
'L1JetETvsCaloJetET_HB_HE', 'L1JetETvsCaloJetET_HB', 'L1JetETvsCaloJetET_HE',
'L1JetETvsCaloJetET_HF', 'L1JetETvsCaloJetET_HB_HE', 'L1JetEtavsCaloJetEta_HB',
'L1JetETvsCaloJetET_HB_HE', 'L1JetPhivsCaloJetPhi_HB', 'L1JetPhivsCaloJetPhi_HE',
'L1JetPhivsCaloJetPhi_HF', 'L1JetPhivsCaloJetPhi_HB_HE', 'L1JetEtavsCaloJetEta_HB',
]

allPlots = []
Expand Down
Expand Up @@ -3,9 +3,13 @@
from DQMOffline.L1Trigger.L1TStage2CaloLayer2Efficiency_cfi import *
from DQMOffline.L1Trigger.L1TStage2CaloLayer2Diff_cfi import *

from DQMOffline.L1Trigger.L1TEGammaEfficiency_cfi import *
from DQMOffline.L1Trigger.L1TEGammaDiff_cfi import *

# l1tStage2CaloLayer2EmuDiff uses plots produced by
# l1tStage2CaloLayer2Efficiency
DQMHarvestL1Trigger = cms.Sequence(
l1tStage2CaloLayer2Efficiency * l1tStage2CaloLayer2EmuDiff
l1tStage2CaloLayer2Efficiency * l1tStage2CaloLayer2EmuDiff *
l1tEGammaEfficiency * l1tEGammaEmuDiff
)

7 changes: 5 additions & 2 deletions DQMOffline/L1Trigger/python/L1TriggerDqmOffline_cff.py
Expand Up @@ -46,6 +46,7 @@
from DQMOffline.L1Trigger.L1TSync_Offline_cfi import *
from DQMOffline.L1Trigger.L1TEmulatorMonitorOffline_cff import *
from DQMOffline.L1Trigger.L1TStage2CaloLayer2Offline_cfi import *
from DQMOffline.L1Trigger.L1TEGammaOffline_cfi import *
l1TdeRCT.rctSourceData = 'gctDigis'

# DQM Offline Step 2 cfi/cff imports
Expand Down Expand Up @@ -139,7 +140,8 @@
l1TriggerOffline = cms.Sequence(
l1TriggerOnline *
dqmEnvL1TriggerReco *
l1tStage2CaloLayer2OfflineDQM
l1tStage2CaloLayer2OfflineDQM *
l1tEGammaOfflineDQM
)

#
Expand All @@ -151,7 +153,8 @@

l1TriggerEmulatorOffline = cms.Sequence(
l1TriggerEmulatorOnline *
l1tStage2CaloLayer2OfflineDQMEmu
l1tStage2CaloLayer2OfflineDQMEmu *
l1tEGammaOfflineDQMEmu
)
#

Expand Down