Skip to content

Commit 7d5cb36

Browse files
authored
Merge pull request cms-sw#43306 from lathomas/l1finalorbxmin1_fornano
L1FinalOR decision in BX-1 and -2 in NANOAOD
2 parents 70476dd + db6487f commit 7d5cb36

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

PhysicsTools/NanoAOD/plugins/L1TriggerResultsConverter.cc

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ void L1TriggerResultsConverter::beginRun(edm::Run const&, edm::EventSetup const&
120120
if (store_unprefireable_bits_) {
121121
names_.push_back("L1_UnprefireableEvent_TriggerRules");
122122
names_.push_back("L1_UnprefireableEvent_FirstBxInTrain");
123+
names_.push_back("L1_FinalOR_BXmin1");
124+
names_.push_back("L1_FinalOR_BXmin2");
123125
}
124126
}
125127
}
@@ -128,14 +130,24 @@ void L1TriggerResultsConverter::beginRun(edm::Run const&, edm::EventSetup const&
128130

129131
void L1TriggerResultsConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
130132
const std::vector<bool>* wordp = nullptr;
133+
const std::vector<bool>* wordp_bxmin1 = nullptr;
134+
const std::vector<bool>* wordp_bxmin2 = nullptr;
131135
bool unprefireable_bit_triggerrules = false;
132136
bool unprefireable_bit_firstbxintrain = false;
137+
bool l1FinalOR_bxmin1 = false;
138+
bool l1FinalOR_bxmin2 = false;
133139

134140
if (!legacyL1_) {
135141
const auto& resultsProd = iEvent.get(token_);
136142
if (not resultsProd.isEmpty(0)) {
137143
wordp = &resultsProd.at(0, 0).getAlgoDecisionFinal();
138144
}
145+
if (not resultsProd.isEmpty(-1)) {
146+
wordp_bxmin1 = &resultsProd.at(-1, 0).getAlgoDecisionFinal();
147+
}
148+
if (not resultsProd.isEmpty(-2)) {
149+
wordp_bxmin2 = &resultsProd.at(-2, 0).getAlgoDecisionFinal();
150+
}
139151
if (store_unprefireable_bits_) {
140152
auto handleExtResults = iEvent.getHandle(token_ext_);
141153
if (handleExtResults.isValid()) {
@@ -158,16 +170,22 @@ void L1TriggerResultsConverter::produce(edm::Event& iEvent, const edm::EventSetu
158170
for (size_t nidx = 0; nidx < indices_size; nidx++) {
159171
unsigned int const index = indices_[nidx];
160172
bool result = wordp ? wordp->at(index) : false;
173+
bool result_bxmin1 = wordp_bxmin1 ? wordp_bxmin1->at(index) : false;
174+
bool result_bxmin2 = wordp_bxmin2 ? wordp_bxmin2->at(index) : false;
161175
if (not mask_.empty())
162176
result &= (mask_.at(index) != 0);
163177
l1bitsAsHLTStatus[nidx] = edm::HLTPathStatus(result ? edm::hlt::Pass : edm::hlt::Fail);
164178
//Stores the unprefirable event decision corresponding to events in the first bx of a train.
165179
//In 2022/2023 the bx before that was manually masked.
166180
//Technically this was done by enabling the L1_FirstBunchBeforeTrain bit in the L1 menu, and vetoing that bit after L1 Final OR is evaluated.
167-
if (names_[nidx] == "L1_FirstBunchBeforeTrain" && !legacyL1_) {
168-
const auto& resultsProd = iEvent.get(token_);
169-
if (!(&resultsProd)->isEmpty(-1)) {
170-
unprefireable_bit_firstbxintrain = (&resultsProd)->begin(-1)->getAlgoDecisionFinal(index);
181+
if (!legacyL1_) {
182+
if (names_[nidx] == "L1_FirstBunchBeforeTrain")
183+
unprefireable_bit_firstbxintrain = result_bxmin1;
184+
//Checks if any other seed was fired in BX-1 or -2
185+
else if (result_bxmin1) {
186+
l1FinalOR_bxmin1 = true;
187+
} else if (result_bxmin2) {
188+
l1FinalOR_bxmin2 = true;
171189
}
172190
}
173191
}
@@ -176,6 +194,8 @@ void L1TriggerResultsConverter::produce(edm::Event& iEvent, const edm::EventSetu
176194
edm::HLTPathStatus(unprefireable_bit_triggerrules ? edm::hlt::Pass : edm::hlt::Fail);
177195
l1bitsAsHLTStatus[indices_size + 1] =
178196
edm::HLTPathStatus(unprefireable_bit_firstbxintrain ? edm::hlt::Pass : edm::hlt::Fail);
197+
l1bitsAsHLTStatus[indices_size + 2] = edm::HLTPathStatus(l1FinalOR_bxmin1 ? edm::hlt::Pass : edm::hlt::Fail);
198+
l1bitsAsHLTStatus[indices_size + 3] = edm::HLTPathStatus(l1FinalOR_bxmin2 ? edm::hlt::Pass : edm::hlt::Fail);
179199
}
180200
//mimic HLT trigger bits for L1
181201
auto out = std::make_unique<edm::TriggerResults>(l1bitsAsHLTStatus, names_);

0 commit comments

Comments
 (0)