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

Update trigger selection #4774

Merged
merged 3 commits into from Jul 24, 2014
Merged
Show file tree
Hide file tree
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
64 changes: 57 additions & 7 deletions DQMServices/StreamerIO/plugins/DQMStreamerReader.cc
Expand Up @@ -12,7 +12,7 @@

#include "DataFormats/Provenance/interface/ProductRegistry.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

#include "FWCore/Utilities/interface/RegexMatch.h"
#include "DQMStreamerReader.h"

#include <fstream>
Expand All @@ -22,6 +22,7 @@
#include <boost/format.hpp>
#include <boost/range.hpp>
#include <boost/filesystem.hpp>
#include "boost/algorithm/string.hpp"

#include <IOPool/Streamer/interface/DumpTools.h>

Expand All @@ -44,6 +45,8 @@ DQMStreamerReader::DQMStreamerReader(ParameterSet const& pset,
flagEndOfRunKills_ = pset.getUntrackedParameter<bool>("endOfRunKills");
flagDeleteDatFiles_ = pset.getUntrackedParameter<bool>("deleteDatFiles");

triggerSel();

reset_();
}

Expand Down Expand Up @@ -106,11 +109,18 @@ void DQMStreamerReader::openFile_(std::string newStreamerFile_) {
// dump the list of HLT trigger name from the header
// dumpInitHeader(header);

Strings tnames;
header->hltTriggerNames(tnames);

pset.addParameter<Strings>("SelectEvents", hltSel_);
eventSelector_.reset(new TriggerSelector(pset, tnames));
// if specific trigger selection is requested, check if the requested triggers
// match with trigger paths in the header file
if (!acceptAllEvt_){
Strings tnames;
header->hltTriggerNames(tnames);

pset.addParameter<Strings>("SelectEvents", hltSel_);
eventSelector_.reset(new TriggerSelector(pset, tnames));

// check if any trigger path name requested matches with trigger name in the header file
matchTriggerSel(tnames);
}

// our initialization
processedEventPerLs_ = 0;
Expand Down Expand Up @@ -294,8 +304,48 @@ bool DQMStreamerReader::checkNextEvent() {
return true;
}

/**
* If hlt trigger selection is '*', return a boolean variable to accept all events
*/
bool DQMStreamerReader::triggerSel() {
acceptAllEvt_ = false;
for (Strings::const_iterator i(hltSel_.begin()), end(hltSel_.end());
i!=end; ++i){
std::string hltPath(*i);
boost::erase_all(hltPath, " \t");
if (hltPath == "*") acceptAllEvt_ = true;
}
return acceptAllEvt_;
}

/**
* Check if hlt selection matches any trigger name taken from the header file
*/
bool DQMStreamerReader::matchTriggerSel(Strings const& tnames) {
matchTriggerSel_ = false;
for (Strings::const_iterator i(hltSel_.begin()), end(hltSel_.end());
i!=end; ++i){
std::string hltPath(*i);
boost::erase_all(hltPath, " \t");
std::vector<Strings::const_iterator> matches = regexMatch(tnames, hltPath);
if (matches.empty()){
edm::LogWarning("Trigger selection does not match any trigger path!!!") << std::endl;
matchTriggerSel_ = false;
}else{
matchTriggerSel_ = true;
}
}
return matchTriggerSel_;
}

/**
* Check the trigger path to accept event
*/
bool DQMStreamerReader::acceptEvent(const EventMsgView* evtmsg) {

if (acceptAllEvt_) return true;
if (!matchTriggerSel_) return false;

std::vector<unsigned char> hltTriggerBits_;
int hltTriggerCount_ = evtmsg->hltCount();
if (hltTriggerCount_ > 0) {
Expand All @@ -306,7 +356,7 @@ bool DQMStreamerReader::acceptEvent(const EventMsgView* evtmsg) {
if (eventSelector_->wantAll() ||
eventSelector_->acceptEvent(&hltTriggerBits_[0], evtmsg->hltCount())) {
return true;
} else {
}else{
return false;
}
}
Expand Down
5 changes: 5 additions & 0 deletions DQMServices/StreamerIO/plugins/DQMStreamerReader.h
Expand Up @@ -58,6 +58,11 @@ class DQMStreamerReader : public StreamerInputSource {
EventMsgView const* prepareNextEvent();
bool prepareNextFile();
bool acceptEvent( const EventMsgView*);

bool triggerSel();
bool matchTriggerSel(Strings const& tnames);
bool acceptAllEvt_;
bool matchTriggerSel_;

unsigned int runNumber_;
std::string runInputDir_;
Expand Down