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

Make sure named bins are unique in HLTObjectsMonitor #25569

Merged
merged 3 commits into from
Jan 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 32 additions & 12 deletions DQM/HLTEvF/plugins/HLTObjectsMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <memory>
#include <sys/time.h>
#include <cstdlib>
#include <unordered_map>

// user include files
#include "DataFormats/Common/interface/TriggerResults.h"
Expand Down Expand Up @@ -37,7 +38,6 @@

#include "TLorentzVector.h"

#include <unordered_map>


struct hltPlot {
Expand Down Expand Up @@ -127,6 +127,7 @@ class HLTObjectsMonitor : public DQMEDAnalyzer {

MonitorElement* eventsPlot_;
std::vector<hltPlot> hltPlots_;
std::unordered_map<std::string, int> plotNamesToBins_;

bool debug_;

Expand Down Expand Up @@ -345,15 +346,20 @@ HLTObjectsMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet

// loop over path
int ibin = -1;
std::vector<bool> plottedPathIndices(plotNamesToBins_.size(),false);
for (auto & plot : hltPlots_) {
ibin++;
if ( plot.pathIDX <= 0 ) continue;

if ( triggerResults->accept(plot.pathIDX) ) {
if ( debug_ )
std::cout << plot.pathNAME << " --> bin: " << ibin << std::endl;
eventsPlot_->Fill(ibin);

//We only want to fill this once per pathNAME per event
auto index = plotNamesToBins_[plot.pathNAME];
if(not plottedPathIndices[index]) {
plottedPathIndices[index] = true;
if ( debug_ )
std::cout << plot.pathNAME << " --> bin: " << ibin << std::endl;
eventsPlot_->Fill(index);
}
const trigger::TriggerObjectCollection objects = triggerEvent->getObjects();
if ( hltConfig_.saveTags(plot.moduleNAME) ) {
if ( debug_ )
Expand Down Expand Up @@ -591,13 +597,27 @@ void HLTObjectsMonitor::bookHistograms(DQMStore::IBooker & ibooker, edm::Run con

std::string name = "eventsPerPath_"+label_;
std::string title = " events per path";
int nbins = hltPlots_.size();
eventsPlot_ = ibooker.book1D(name,title,nbins,-0.5,double(nbins)-0.5);
eventsPlot_->setAxisTitle("HLT path");
for ( int i=0; i<nbins; i++ ) {
eventsPlot_->setBinLabel(i+1,hltPlots_[i].pathNAME);
if ( debug_ )
std::cout << hltPlots_[i].pathNAME << " --> bin: " << i+1 << std::endl;

//We must avoid repeating the same pathNAME
{
std::unordered_map<std::string,int> uniqueNames;
for(auto const& p: hltPlots_) {
plotNamesToBins_[p.pathNAME] = -1;
}
int nbins = plotNamesToBins_.size();
eventsPlot_ = ibooker.book1D(name,title,nbins,-0.5,double(nbins)-0.5);
eventsPlot_->setAxisTitle("HLT path");
int i=0;
//keep the bin order the same as hltPlots_
for (auto const& p : hltPlots_) {
//only add a bin if this is the first time we've seen the name
if( -1 == plotNamesToBins_[p.pathNAME]) {
plotNamesToBins_[p.pathNAME] = ++i;
eventsPlot_->setBinLabel(i,p.pathNAME);
if ( debug_ )
std::cout << p.pathNAME << " --> bin: " << i << std::endl;
}
}
}

for (auto & plot : hltPlots_) {
Expand Down