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

Hlt tau validation conditional plotting4 #31117

Merged
merged 10 commits into from
Aug 13, 2020
3 changes: 2 additions & 1 deletion DQMOffline/Trigger/interface/HLTTauDQML1Plotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define HLTTauDQML1Plotter_h

#include "DQMOffline/Trigger/interface/HLTTauDQMPlotter.h"
#include "DQMOffline/Trigger/interface/HistoWrapper.h"

#include "FWCore/Utilities/interface/InputTag.h"

Expand All @@ -25,7 +26,7 @@ class HLTTauDQML1Plotter : private HLTTauDQMPlotter {

using HLTTauDQMPlotter::isValid;

void bookHistograms(DQMStore::IBooker& iBooker);
void bookHistograms(HistoWrapper& iWrapper, DQMStore::IBooker& iBooker);
void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup, const HLTTauDQMOfflineObjects& refC);

private:
Expand Down
6 changes: 4 additions & 2 deletions DQMOffline/Trigger/interface/HLTTauDQMOfflineSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"

//Plotters
#include "DQMOffline/Trigger/interface/HistoWrapper.h"
#include "DQMOffline/Trigger/interface/HLTTauDQML1Plotter.h"
#include "DQMOffline/Trigger/interface/HLTTauDQMPathPlotter.h"
#include "DQMOffline/Trigger/interface/HLTTauDQMPathSummaryPlotter.h"
Expand Down Expand Up @@ -44,12 +45,13 @@ class HLTTauDQMOfflineSource : public DQMEDAnalyzer {
edm::EDGetTokenT<trigger::TriggerEvent> triggerEventToken_;

// For path plotters
const std::string pathRegexString_;
const std::regex pathRegex_;
const std::string pathRegex_;
const int nPtBins_, nEtaBins_, nPhiBins_;
const double ptMax_, highPtMax_, l1MatchDr_, hltMatchDr_;
const std::string dqmBaseFolder_;

HistoWrapper* iWrapper;

HLTConfigProvider HLTCP_;

//Reference
Expand Down
3 changes: 2 additions & 1 deletion DQMOffline/Trigger/interface/HLTTauDQMPathPlotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "DQMOffline/Trigger/interface/HLTTauDQMPlotter.h"
#include "DQMOffline/Trigger/interface/HLTTauDQMPath.h"
#include "DQMOffline/Trigger/interface/HistoWrapper.h"

namespace edm {
class Event;
Expand Down Expand Up @@ -35,7 +36,7 @@ class HLTTauDQMPathPlotter : private HLTTauDQMPlotter {

using HLTTauDQMPlotter::isValid;

void bookHistograms(DQMStore::IBooker &iBooker);
void bookHistograms(HistoWrapper &iWrapper, DQMStore::IBooker &iBooker);

void analyze(const edm::TriggerResults &triggerResults,
const trigger::TriggerEvent &triggerEvent,
Expand Down
3 changes: 2 additions & 1 deletion DQMOffline/Trigger/interface/HLTTauDQMPathSummaryPlotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define HLTTauDQMPathSummaryPlotter_h

#include "DQMOffline/Trigger/interface/HLTTauDQMPlotter.h"
#include "DQMOffline/Trigger/interface/HistoWrapper.h"

#include <vector>

Expand All @@ -25,7 +26,7 @@ class HLTTauDQMPathSummaryPlotter : private HLTTauDQMPlotter {
using HLTTauDQMPlotter::isValid;

void setPathObjects(const std::vector<const HLTTauDQMPath*>& pathObjects) { pathObjects_ = pathObjects; }
void bookHistograms(DQMStore::IBooker& iBooker);
void bookHistograms(HistoWrapper& iWrapper, DQMStore::IBooker& iBooker);

void analyze(const edm::TriggerResults& triggerResults,
const trigger::TriggerEvent& triggerEvent,
Expand Down
6 changes: 5 additions & 1 deletion DQMOffline/Trigger/interface/HLTTauDQMTagAndProbePlotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "DQMOffline/Trigger/interface/HLTTauDQMPlotter.h"
#include "DQMOffline/Trigger/interface/HLTTauDQMPath.h"
#include "DQMOffline/Trigger/interface/HistoWrapper.h"

//#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
#include "FWCore/Common/interface/TriggerNames.h"
Expand All @@ -29,7 +30,10 @@ class HLTTauDQMTagAndProbePlotter : private HLTTauDQMPlotter {

using HLTTauDQMPlotter::isValid;

void bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &iRun, edm::EventSetup const &iSetup);
void bookHistograms(HistoWrapper &iWrapper,
DQMStore::IBooker &iBooker,
edm::Run const &iRun,
edm::EventSetup const &iSetup);

void analyze(edm::Event const &iEvent,
const edm::TriggerResults &triggerResults,
Expand Down
26 changes: 26 additions & 0 deletions DQMOffline/Trigger/interface/HistoWrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef __HistoWrapper__
#define __HistoWrapper__

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DQMServices/Core/interface/DQMStore.h"
typedef dqm::legacy::DQMStore DQMStore;
#include "DQMServices/Core/interface/MonitorElement.h"
typedef dqm::legacy::MonitorElement MonitorElement;

enum PL {kEverything, kVital};

class HistoWrapper {
public:
HistoWrapper(const edm::ParameterSet&);
~HistoWrapper();

MonitorElement* book1D(DQMStore::IBooker& iBooker, TString const &name, TString const &title, int const nchX, double const lowX, double const highX, int level = kEverything);
MonitorElement* book2D(DQMStore::IBooker& iBooker, TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int level = kEverything);

private:
PL plotlevel;
int cAllHistograms;
int cPlottedHistograms;
};
#endif
18 changes: 10 additions & 8 deletions DQMOffline/Trigger/plugins/HLTTauDQMOfflineSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ HLTTauDQMOfflineSource::HLTTauDQMOfflineSource(const edm::ParameterSet& ps)
triggerResultsToken_(consumes<edm::TriggerResults>(triggerResultsSrc_)),
triggerEventSrc_(ps.getUntrackedParameter<edm::InputTag>("TriggerEventSrc")),
triggerEventToken_(consumes<trigger::TriggerEvent>(triggerEventSrc_)),
pathRegexString_(ps.getUntrackedParameter<std::string>("Paths")),
pathRegex_(pathRegexString_),
pathRegex_(ps.getUntrackedParameter<std::string>("Paths")),
nPtBins_(ps.getUntrackedParameter<int>("PtHistoBins", 20)),
nEtaBins_(ps.getUntrackedParameter<int>("EtaHistoBins", 12)),
nPhiBins_(ps.getUntrackedParameter<int>("PhiHistoBins", 18)),
Expand All @@ -33,6 +32,8 @@ HLTTauDQMOfflineSource::HLTTauDQMOfflineSource(const edm::ParameterSet& ps)
edm::ParameterSet matching = ps.getParameter<edm::ParameterSet>("Matching");
doRefAnalysis_ = matching.getUntrackedParameter<bool>("doMatching");

iWrapper = new HistoWrapper(ps);

if (ps.exists("L1Plotter") && !ps.exists("TagAndProbe")) {
l1Plotter_ = std::make_unique<HLTTauDQML1Plotter>(ps.getUntrackedParameter<edm::ParameterSet>("L1Plotter"),
consumesCollector(),
Expand Down Expand Up @@ -76,9 +77,10 @@ void HLTTauDQMOfflineSource::dqmBeginRun(const edm::Run& iRun, const edm::EventS
// Find all paths to monitor
std::vector<std::string> foundPaths;
std::smatch what;
LogDebug("HLTTauDQMOffline") << "Looking for paths with regex " << pathRegexString_;
LogDebug("HLTTauDQMOffline") << "Looking for paths with regex " << pathRegex_;
const std::regex pathRegex(pathRegex_);
for (const std::string& pathName : HLTCP_.triggerNames()) {
if (std::regex_search(pathName, what, pathRegex_)) {
if (std::regex_search(pathName, what, pathRegex)) {
LogDebug("HLTTauDQMOffline") << "Found path " << pathName;
foundPaths.emplace_back(pathName);
}
Expand Down Expand Up @@ -164,16 +166,16 @@ void HLTTauDQMOfflineSource::bookHistograms(DQMStore::IBooker& iBooker,
const edm::Run& iRun,
const EventSetup& iSetup) {
if (l1Plotter_) {
l1Plotter_->bookHistograms(iBooker);
l1Plotter_->bookHistograms(*iWrapper, iBooker);
}
for (auto& pathPlotter : pathPlotters_) {
pathPlotter.bookHistograms(iBooker);
pathPlotter.bookHistograms(*iWrapper, iBooker);
}
for (auto& tpPlotter : tagandprobePlotters_) {
tpPlotter->bookHistograms(iBooker, iRun, iSetup);
tpPlotter->bookHistograms(*iWrapper, iBooker, iRun, iSetup);
}
if (pathSummaryPlotter_) {
pathSummaryPlotter_->bookHistograms(iBooker);
pathSummaryPlotter_->bookHistograms(*iWrapper, iBooker);
}
}

Expand Down
2 changes: 2 additions & 0 deletions DQMOffline/Trigger/plugins/HLTTauRefProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void HLTTauRefProducer::doPFTaus(edm::StreamID iID, edm::Event& iEvent) const {
pftau.phi() > phiMinPFTau_ && pftau.phi() < phiMaxPFTau_) {
reco::PFTauRef thePFTau{pftaus, i};
bool passAll{true};

for (auto const& token : PFTauDis_) {
edm::Handle<reco::PFTauDiscriminator> pftaudis;
if (iEvent.getByToken(token, pftaudis)) {
Expand All @@ -197,6 +198,7 @@ void HLTTauRefProducer::doPFTaus(edm::StreamID iID, edm::Event& iEvent) const {
break;
}
}

int idx = 0;
for (auto const& token : PFTauDisCont_) {
edm::Handle<reco::TauDiscriminatorContainer> pftaudis;
Expand Down
33 changes: 9 additions & 24 deletions DQMOffline/Trigger/python/HLTTauDQMOffline_cfi.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import FWCore.ParameterSet.Config as cms
from Configuration.ProcessModifiers.tau_readOldDiscriminatorFormat_cff import tau_readOldDiscriminatorFormat

hltTauDQMofflineProcess = "HLT"

#Ref Objects-------------------------------------------------------------------------------------------------------
TauRefProducer = cms.EDProducer("HLTTauRefProducer",

PFTaus = cms.untracked.PSet(
PFTauDiscriminatorContainers = cms.untracked.VInputTag(),
PFTauDiscriminatorContainerWPs = cms.untracked.vstring(),
PFTauDiscriminators = cms.untracked.VInputTag(
cms.InputTag("hpsPFTauDiscriminationByDecayModeFinding")
),
PFTauDiscriminatorContainers = cms.untracked.VInputTag(
cms.InputTag("hpsPFTauBasicDiscriminators"),
cms.InputTag("hpsPFTauDiscriminationByMuonRejection3"),
cms.InputTag("hpsPFTauDiscriminationByMVA6ElectronRejection")
),
PFTauDiscriminatorContainerWPs = cms.untracked.vstring(
"ByLooseCombinedIsolationDBSumPtCorr3Hits",
"ByLooseMuonRejection3",
"_Tight"
cms.InputTag("hpsPFTauDiscriminationByDecayModeFinding"),
cms.InputTag("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),
cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection3"),
cms.InputTag("hpsPFTauDiscriminationByMVA6TightElectronRejection")
),
doPFTaus = cms.untracked.bool(True),
ptMin = cms.untracked.double(15.0),
Expand Down Expand Up @@ -79,24 +73,15 @@
PhiMax = cms.untracked.double(3.15)
)

tau_readOldDiscriminatorFormat.toModify(TauRefProducer.PFTaus,
PFTauDiscriminators = cms.untracked.VInputTag(
cms.InputTag("hpsPFTauDiscriminationByDecayModeFinding"),
cms.InputTag("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),
cms.InputTag("hpsPFTauDiscriminationByLooseMuonRejection3"),
cms.InputTag("hpsPFTauDiscriminationByMVA6TightElectronRejection"),
cms.InputTag("hpsPFTauDiscriminationByDecayModeFinding")
),
PFTauDiscriminatorContainers = cms.untracked.VInputTag(),
PFTauDiscriminatorContainerWPs = cms.untracked.vstring()
)

#----------------------------------MONITORS--------------------------------------------------------------------------
kEverything = 0
kVital = 1

from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
hltTauOfflineMonitor_PFTaus = DQMEDAnalyzer('HLTTauDQMOfflineSource',
HLTProcessName = cms.untracked.string(hltTauDQMofflineProcess),
DQMBaseFolder = cms.untracked.string("HLT/TAU/PFTaus"),
PlotLevel = cms.untracked.int32(kVital),
TriggerResultsSrc = cms.untracked.InputTag("TriggerResults", "", hltTauDQMofflineProcess),
TriggerEventSrc = cms.untracked.InputTag("hltTriggerSummaryAOD", "", hltTauDQMofflineProcess),
L1Plotter = cms.untracked.PSet(
Expand Down
Loading