Skip to content

Commit

Permalink
Merge pull request #40650 from missirol/devel_fix40494_125X
Browse files Browse the repository at this point in the history
guard against no L1T uGT digis in `L1TriggerResultsConverter` [`12_5_X`]
  • Loading branch information
cmsbuild authored Feb 1, 2023
2 parents 521a6d1 + 7ce4215 commit bcdfd7c
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions PhysicsTools/NanoAOD/plugins/L1TriggerResultsConverter.cc
Original file line number Diff line number Diff line change
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

0 comments on commit bcdfd7c

Please sign in to comment.