Skip to content

Commit

Permalink
Merge pull request cms-sw#43306 from lathomas/l1finalorbxmin1_fornano
Browse files Browse the repository at this point in the history
L1FinalOR decision in BX-1 and -2 in NANOAOD
  • Loading branch information
cmsbuild authored Nov 24, 2023
2 parents 70476dd + db6487f commit 7d5cb36
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions PhysicsTools/NanoAOD/plugins/L1TriggerResultsConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ void L1TriggerResultsConverter::beginRun(edm::Run const&, edm::EventSetup const&
if (store_unprefireable_bits_) {
names_.push_back("L1_UnprefireableEvent_TriggerRules");
names_.push_back("L1_UnprefireableEvent_FirstBxInTrain");
names_.push_back("L1_FinalOR_BXmin1");
names_.push_back("L1_FinalOR_BXmin2");
}
}
}
Expand All @@ -128,14 +130,24 @@ void L1TriggerResultsConverter::beginRun(edm::Run const&, edm::EventSetup const&

void L1TriggerResultsConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
const std::vector<bool>* wordp = nullptr;
const std::vector<bool>* wordp_bxmin1 = nullptr;
const std::vector<bool>* wordp_bxmin2 = nullptr;
bool unprefireable_bit_triggerrules = false;
bool unprefireable_bit_firstbxintrain = false;
bool l1FinalOR_bxmin1 = false;
bool l1FinalOR_bxmin2 = false;

if (!legacyL1_) {
const auto& resultsProd = iEvent.get(token_);
if (not resultsProd.isEmpty(0)) {
wordp = &resultsProd.at(0, 0).getAlgoDecisionFinal();
}
if (not resultsProd.isEmpty(-1)) {
wordp_bxmin1 = &resultsProd.at(-1, 0).getAlgoDecisionFinal();
}
if (not resultsProd.isEmpty(-2)) {
wordp_bxmin2 = &resultsProd.at(-2, 0).getAlgoDecisionFinal();
}
if (store_unprefireable_bits_) {
auto handleExtResults = iEvent.getHandle(token_ext_);
if (handleExtResults.isValid()) {
Expand All @@ -158,16 +170,22 @@ void L1TriggerResultsConverter::produce(edm::Event& iEvent, const edm::EventSetu
for (size_t nidx = 0; nidx < indices_size; nidx++) {
unsigned int const index = indices_[nidx];
bool result = wordp ? wordp->at(index) : false;
bool result_bxmin1 = wordp_bxmin1 ? wordp_bxmin1->at(index) : false;
bool result_bxmin2 = wordp_bxmin2 ? wordp_bxmin2->at(index) : false;
if (not mask_.empty())
result &= (mask_.at(index) != 0);
l1bitsAsHLTStatus[nidx] = edm::HLTPathStatus(result ? edm::hlt::Pass : edm::hlt::Fail);
//Stores the unprefirable event decision corresponding to events in the first bx of a train.
//In 2022/2023 the bx before that was manually masked.
//Technically this was done by enabling the L1_FirstBunchBeforeTrain bit in the L1 menu, and vetoing that bit after L1 Final OR is evaluated.
if (names_[nidx] == "L1_FirstBunchBeforeTrain" && !legacyL1_) {
const auto& resultsProd = iEvent.get(token_);
if (!(&resultsProd)->isEmpty(-1)) {
unprefireable_bit_firstbxintrain = (&resultsProd)->begin(-1)->getAlgoDecisionFinal(index);
if (!legacyL1_) {
if (names_[nidx] == "L1_FirstBunchBeforeTrain")
unprefireable_bit_firstbxintrain = result_bxmin1;
//Checks if any other seed was fired in BX-1 or -2
else if (result_bxmin1) {
l1FinalOR_bxmin1 = true;
} else if (result_bxmin2) {
l1FinalOR_bxmin2 = true;
}
}
}
Expand All @@ -176,6 +194,8 @@ void L1TriggerResultsConverter::produce(edm::Event& iEvent, const edm::EventSetu
edm::HLTPathStatus(unprefireable_bit_triggerrules ? edm::hlt::Pass : edm::hlt::Fail);
l1bitsAsHLTStatus[indices_size + 1] =
edm::HLTPathStatus(unprefireable_bit_firstbxintrain ? edm::hlt::Pass : edm::hlt::Fail);
l1bitsAsHLTStatus[indices_size + 2] = edm::HLTPathStatus(l1FinalOR_bxmin1 ? edm::hlt::Pass : edm::hlt::Fail);
l1bitsAsHLTStatus[indices_size + 3] = edm::HLTPathStatus(l1FinalOR_bxmin2 ? edm::hlt::Pass : edm::hlt::Fail);
}
//mimic HLT trigger bits for L1
auto out = std::make_unique<edm::TriggerResults>(l1bitsAsHLTStatus, names_);
Expand Down

0 comments on commit 7d5cb36

Please sign in to comment.