Skip to content

Commit

Permalink
use hltConfig in dqmBeginRun and switch from getByLabel to getByToken
Browse files Browse the repository at this point in the history
  • Loading branch information
silviodonato committed Jul 31, 2015
1 parent 61cf4d0 commit 9c473f0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 32 deletions.
17 changes: 10 additions & 7 deletions DQMOffline/Trigger/interface/BTVHLTOfflineSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class BTVHLTOfflineSource : public DQMEDAnalyzer {
private:
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const & run, edm::EventSetup const & c) override;

virtual void dqmBeginRun(edm::Run const& run, edm::EventSetup const& c) override;

//helper functions
//virtual bool validPathHLT(std::string path);
//virtual bool isHLTPathAccepted(std::string pathName);
Expand All @@ -71,13 +72,15 @@ class BTVHLTOfflineSource : public DQMEDAnalyzer {
//
edm::InputTag triggerSummaryLabel_;
edm::InputTag triggerResultsLabel_;
edm::InputTag offlineCSVLabelPF_;
edm::InputTag offlineCSVLabelCalo_;
edm::InputTag hltFastPVLabel_;
edm::InputTag hltPFPVLabel_;
edm::InputTag hltCaloPVLabel_;
edm::InputTag offlinePVLabel_;

edm::EDGetTokenT<reco::JetTagCollection> offlineCSVTokenPF_;
edm::EDGetTokenT<reco::JetTagCollection> offlineCSVTokenCalo_;

edm::EDGetTokenT<std::vector<reco::Vertex> > hltFastPVToken_;
edm::EDGetTokenT<std::vector<reco::Vertex> > hltPFPVToken_;
edm::EDGetTokenT<std::vector<reco::Vertex> > hltCaloPVToken_;
edm::EDGetTokenT<std::vector<reco::Vertex> > offlinePVToken_;

edm::EDGetTokenT <edm::TriggerResults> triggerResultsToken;
edm::EDGetTokenT <edm::TriggerResults> triggerResultsFUToken;
edm::EDGetTokenT <trigger::TriggerEvent> triggerSummaryToken;
Expand Down
61 changes: 36 additions & 25 deletions DQMOffline/Trigger/src/BTVHLTOfflineSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ BTVHLTOfflineSource::BTVHLTOfflineSource(const edm::ParameterSet& iConfig)
triggerResultsFUToken = consumes <edm::TriggerResults> (edm::InputTag(triggerResultsLabel_.label(),triggerResultsLabel_.instance(),std::string("FU")));
csvCaloTagsToken_ = consumes<reco::JetTagCollection> (edm::InputTag("hltCombinedSecondaryVertexBJetTagsCalo"));
csvPfTagsToken_ = consumes<reco::JetTagCollection> (edm::InputTag("hltCombinedSecondaryVertexBJetTagsPF"));
offlineCSVLabelPF_ = iConfig.getParameter<edm::InputTag>("offlineCSVLabelPF");
offlineCSVLabelCalo_ = iConfig.getParameter<edm::InputTag>("offlineCSVLabelCalo");
hltFastPVLabel_ = iConfig.getParameter<edm::InputTag>("hltFastPVLabel");
hltPFPVLabel_ = iConfig.getParameter<edm::InputTag>("hltPFPVLabel");
hltCaloPVLabel_ = iConfig.getParameter<edm::InputTag>("hltCaloPVLabel");
offlinePVLabel_ = iConfig.getParameter<edm::InputTag>("offlinePVLabel");
offlineCSVTokenPF_ = consumes<reco::JetTagCollection> (iConfig.getParameter<edm::InputTag>("offlineCSVLabelPF"));
offlineCSVTokenCalo_ = consumes<reco::JetTagCollection> (iConfig.getParameter<edm::InputTag>("offlineCSVLabelCalo"));
// hltFastPVLabel_ = iConfig.getParameter<edm::InputTag>("hltFastPVLabel");
hltFastPVToken_ = consumes<std::vector<reco::Vertex> > (iConfig.getParameter<edm::InputTag>("hltFastPVLabel"));
hltPFPVToken_ = consumes<std::vector<reco::Vertex> > (iConfig.getParameter<edm::InputTag>("hltPFPVLabel"));
hltCaloPVToken_ = consumes<std::vector<reco::Vertex> > (iConfig.getParameter<edm::InputTag>("hltCaloPVLabel"));
offlinePVToken_ = consumes<std::vector<reco::Vertex> > (iConfig.getParameter<edm::InputTag>("offlinePVLabel"));

//
std::vector<edm::ParameterSet> paths = iConfig.getParameter<std::vector<edm::ParameterSet> >("pathPairs");
Expand All @@ -80,6 +81,15 @@ BTVHLTOfflineSource::~BTVHLTOfflineSource()
// (e.g. close files, deallocate resources etc.)
}

//------------------------------------------------------------------------//
void BTVHLTOfflineSource::dqmBeginRun(const edm::Run& run, const edm::EventSetup& c)
{
bool changed(true);
if (!hltConfig_.init(run, c, processname_, changed)) {
LogDebug("BTVHLTOfflineSource") << "HLTConfigProvider failed to initialize.";
}

}
//------------------------------------------------------------------------//
void
BTVHLTOfflineSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
Expand Down Expand Up @@ -124,13 +134,13 @@ BTVHLTOfflineSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iS
//------------ Offline Objects ------

Handle<reco::JetTagCollection> offlineJetTagHandlerPF;
iEvent.getByLabel(offlineCSVLabelPF_, offlineJetTagHandlerPF);
iEvent.getByToken(offlineCSVTokenPF_, offlineJetTagHandlerPF);

Handle<reco::JetTagCollection> offlineJetTagHandlerCalo;
iEvent.getByLabel(offlineCSVLabelCalo_, offlineJetTagHandlerCalo);
iEvent.getByToken(offlineCSVTokenCalo_, offlineJetTagHandlerCalo);

Handle<reco::VertexCollection> offlineVertexHandler;
iEvent.getByLabel(offlinePVLabel_, offlineVertexHandler);
iEvent.getByToken(offlinePVToken_, offlineVertexHandler);


//---------- Event counting (DEBUG) ----------
Expand Down Expand Up @@ -175,7 +185,7 @@ BTVHLTOfflineSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iS
}
}

iEvent.getByLabel(hltPFPVLabel_, VertexHandler);
iEvent.getByToken(hltPFPVToken_, VertexHandler);
if (VertexHandler.isValid())
{
v->getMEhisto_PVz()->Fill(VertexHandler->begin()->z());
Expand Down Expand Up @@ -213,14 +223,14 @@ BTVHLTOfflineSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iS
}
}

iEvent.getByLabel(hltFastPVLabel_, VertexHandler);
iEvent.getByToken(hltFastPVToken_, VertexHandler);
if (VertexHandler.isValid())
{
v->getMEhisto_PVz()->Fill(VertexHandler->begin()->z());
if (offlineVertexHandler.isValid()) v->getMEhisto_fastPVz_HLTMinusRECO()->Fill(VertexHandler->begin()->z()-offlineVertexHandler->begin()->z());
}

iEvent.getByLabel(hltCaloPVLabel_, VertexHandler);
iEvent.getByToken(hltCaloPVToken_, VertexHandler);
if (VertexHandler.isValid())
{
v->getMEhisto_fastPVz()->Fill(VertexHandler->begin()->z());
Expand All @@ -245,11 +255,12 @@ BTVHLTOfflineSource::bookHistograms(DQMStore::IBooker & iBooker, edm::Run const
iBooker.setCurrentFolder(dirname_);

//-------------- htlConfig_ ----------------------

bool changed(true);
if (!hltConfig_.init(run, c, processname_, changed)) {
LogDebug("BTVHLTOfflineSource") << "HLTConfigProvider failed to initialize.";
}

// REMOVE ME !
// bool changed(true);
// if (!hltConfig_.init(run, c, processname_, changed)) {
// LogDebug("BTVHLTOfflineSource") << "HLTConfigProvider failed to initialize.";
// }

//----------- Define hltPathsAll_ -----------------

Expand Down Expand Up @@ -295,42 +306,42 @@ BTVHLTOfflineSource::bookHistograms(DQMStore::IBooker & iBooker, edm::Run const
histoname = labelname+"_CSV";
title = labelname+"_CSV "+trigPath;
MonitorElement * CSV = iBooker.book1D(histoname.c_str(),title.c_str(),110,-0.1,1);
CSV->getTH1();
// CSV->getTH1();

histoname = labelname+"_Pt";
title = labelname+"_Pt "+trigPath;
MonitorElement * Pt = iBooker.book1D(histoname.c_str(),title.c_str(),100,0,400);
Pt->getTH1();
// Pt->getTH1();

histoname = labelname+"_Eta";
title = labelname+"_Eta "+trigPath;
MonitorElement * Eta = iBooker.book1D(histoname.c_str(),title.c_str(),60,-3.0,3.0);
Eta->getTH1();
// Eta->getTH1();

histoname = "RECOvsHLT_CSV";
title = "offline CSV vs online CSV "+trigPath;
MonitorElement * CSV_RECOvsHLT = iBooker.book2D(histoname.c_str(),title.c_str(),110,-0.1,1,110,-0.1,1);
CSV_RECOvsHLT->getTH2F();
// CSV_RECOvsHLT->getTH2F();

histoname = labelname+"_PVz";
title = "online z(PV) "+trigPath;
MonitorElement * PVz = iBooker.book1D(histoname.c_str(),title.c_str(),80,-20,20);
PVz->getTH1();
// PVz->getTH1();

histoname = labelname+"_fastPVz";
title = "online z(fastPV) "+trigPath;
MonitorElement * fastPVz = iBooker.book1D(histoname.c_str(),title.c_str(),80,-20,20);
fastPVz->getTH1();
// fastPVz->getTH1();

histoname = "HLTMinusRECO_PVz";
title = "online z(PV) - offline z(PV) "+trigPath;
MonitorElement * PVz_HLTMinusRECO = iBooker.book1D(histoname.c_str(),title.c_str(),200,-0.5,0.5);
PVz_HLTMinusRECO->getTH1();
// PVz_HLTMinusRECO->getTH1();

histoname = "HLTMinusRECO_fastPVz";
title = "online z(fastPV) - offline z(PV) "+trigPath;
MonitorElement * fastPVz_HLTMinusRECO = iBooker.book1D(histoname.c_str(),title.c_str(),100,-2,2);
fastPVz_HLTMinusRECO->getTH1();
// fastPVz_HLTMinusRECO->getTH1();

v->setHistos(CSV,Pt,Eta,CSV_RECOvsHLT,PVz,fastPVz,PVz_HLTMinusRECO,fastPVz_HLTMinusRECO);
}
Expand Down

0 comments on commit 9c473f0

Please sign in to comment.