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

guard against no L1T uGT digis in L1TriggerResultsConverter [12_4_X] #40651

Merged
merged 1 commit into from Feb 1, 2023
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
28 changes: 13 additions & 15 deletions PhysicsTools/NanoAOD/plugins/L1TriggerResultsConverter.cc
Expand Up @@ -125,18 +125,17 @@ void L1TriggerResultsConverter::beginRun(edm::Run const&, edm::EventSetup const&
// ------------ method called to produce the data ------------

void L1TriggerResultsConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;
const std::vector<bool>* wordp = nullptr;
bool unprefireable_bit = false;
if (!legacyL1_) {
edm::Handle<GlobalAlgBlkBxCollection> handleResults;
iEvent.getByToken(token_, handleResults);
wordp = &handleResults->at(0, 0).getAlgoDecisionFinal();
const auto& resultsProd = iEvent.get(token_);
if (not resultsProd.isEmpty(0)) {
wordp = &resultsProd.at(0, 0).getAlgoDecisionFinal();
}
if (store_unprefireable_bit_) {
edm::Handle<GlobalExtBlkBxCollection> handleExtResults;
iEvent.getByToken(token_ext_, handleExtResults);
auto handleExtResults = iEvent.getHandle(token_ext_);
if (handleExtResults.isValid()) {
if (handleExtResults->size() != 0) {
if (not handleExtResults->isEmpty(0)) {
unprefireable_bit = handleExtResults->at(0, 0).getExternalDecision(GlobalExtBlk::maxExternalConditions - 1);
}
} else {
Expand All @@ -149,18 +148,17 @@ void L1TriggerResultsConverter::produce(edm::Event& iEvent, const edm::EventSetu
iEvent.getByToken(tokenLegacy_, handleResults);
wordp = &handleResults->decisionWord();
}
auto const& word = *wordp;
HLTGlobalStatus l1bitsAsHLTStatus(names_.size());
edm::HLTGlobalStatus l1bitsAsHLTStatus(names_.size());
unsigned indices_size = indices_.size();
for (size_t nidx = 0; nidx < indices_size; nidx++) {
unsigned int index = indices_[nidx];
bool result = word[index];
if (!mask_.empty())
result &= (mask_[index] != 0);
l1bitsAsHLTStatus[nidx] = HLTPathStatus(result ? edm::hlt::Pass : edm::hlt::Fail);
unsigned int const index = indices_[nidx];
bool result = wordp ? wordp->at(index) : false;
if (not mask_.empty())
result &= (mask_.at(index) != 0);
l1bitsAsHLTStatus[nidx] = edm::HLTPathStatus(result ? edm::hlt::Pass : edm::hlt::Fail);
}
if (store_unprefireable_bit_)
l1bitsAsHLTStatus[indices_size] = HLTPathStatus(unprefireable_bit ? edm::hlt::Pass : edm::hlt::Fail);
l1bitsAsHLTStatus[indices_size] = edm::HLTPathStatus(unprefireable_bit ? edm::hlt::Pass : edm::hlt::Fail);
//mimic HLT trigger bits for L1
auto out = std::make_unique<edm::TriggerResults>(l1bitsAsHLTStatus, names_);
iEvent.put(std::move(out));
Expand Down