Skip to content

Instantly share code, notes, and snippets.

@tmadlener
Last active May 16, 2017 16:07
Show Gist options
  • Save tmadlener/6728757f9efc723bb5cc07c1db9e6aa5 to your computer and use it in GitHub Desktop.
Save tmadlener/6728757f9efc723bb5cc07c1db9e6aa5 to your computer and use it in GitHub Desktop.
std::vector<std::string> m_trigPathNames; // taken from config
edm::Handle<edm::TriggerResults> trigResults;
event.getByToken(m_trigResultToken, trigResults); // Token from config
std::vector<int> trigRes{};
if (trigResults.isValid()) {
const edm::TriggerNames& triggerNames = event.triggerNames(*trigResults);
for (const auto& name : m_trigPathNames) {
auto trigBit = triggerNames.triggerIndex(edm::InputTag(name).label());
// std::cout << name << " " << trigBit << "/" << trigResults->size() <<"\n";
if (trigBit < trigResults->size() && trigResults->accept(trigBit) && !trigResults->error(trigBit)) {
trigRes.push_back(1);
} else {
trigRes.push_back(0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment