Skip to content

Commit bee74ce

Browse files
authored
Merge pull request #45047 from missirol/devel_hltL1TSeedIndexCheck
guard against invalid output products from `HLTL1TSeed`
2 parents a50a5d7 + 34ac1a4 commit bee74ce

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

HLTrigger/HLTfilters/plugins/HLTL1TSeed.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,14 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
950950
<< "\nNo muons added to filterproduct." << endl;
951951
} else {
952952
for (std::list<int>::const_iterator itObj = listMuon.begin(); itObj != listMuon.end(); ++itObj) {
953+
// skip invalid indices
954+
if (*itObj < 0 or unsigned(*itObj) >= muons->size(0)) {
955+
edm::LogWarning("HLTL1TSeed")
956+
<< "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::MuonBxCollection):"
957+
<< " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << muons->size(0) << ")";
958+
continue;
959+
}
960+
953961
// Transform to index for Bx = 0 to begin of BxVector
954962
unsigned int index = muons->begin(0) - muons->begin() + *itObj;
955963

@@ -970,6 +978,14 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
970978
<< "\nNo muon showers added to filterproduct." << endl;
971979
} else {
972980
for (std::list<int>::const_iterator itObj = listMuonShower.begin(); itObj != listMuonShower.end(); ++itObj) {
981+
// skip invalid indices
982+
if (*itObj < 0 or unsigned(*itObj) >= muonShowers->size(0)) {
983+
edm::LogWarning("HLTL1TSeed")
984+
<< "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::MuonShowerBxCollection):"
985+
<< " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << muonShowers->size(0) << ")";
986+
continue;
987+
}
988+
973989
// Transform to index for Bx = 0 to begin of BxVector
974990
unsigned int index = muonShowers->begin(0) - muonShowers->begin() + *itObj;
975991

@@ -989,6 +1005,14 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
9891005
<< "\nNo egammas added to filterproduct." << endl;
9901006
} else {
9911007
for (std::list<int>::const_iterator itObj = listEG.begin(); itObj != listEG.end(); ++itObj) {
1008+
// skip invalid indices
1009+
if (*itObj < 0 or unsigned(*itObj) >= egammas->size(0)) {
1010+
edm::LogWarning("HLTL1TSeed")
1011+
<< "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::EGammaBxCollection):"
1012+
<< " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << egammas->size(0) << ")";
1013+
continue;
1014+
}
1015+
9921016
// Transform to begin of BxVector
9931017
unsigned int index = egammas->begin(0) - egammas->begin() + *itObj;
9941018

@@ -1009,6 +1033,14 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
10091033
<< "\nNo jets added to filterproduct." << endl;
10101034
} else {
10111035
for (std::list<int>::const_iterator itObj = listJet.begin(); itObj != listJet.end(); ++itObj) {
1036+
// skip invalid indices
1037+
if (*itObj < 0 or unsigned(*itObj) >= jets->size(0)) {
1038+
edm::LogWarning("HLTL1TSeed")
1039+
<< "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::JetBxCollection):"
1040+
<< " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << jets->size(0) << ")";
1041+
continue;
1042+
}
1043+
10121044
// Transform to begin of BxVector
10131045
unsigned int index = jets->begin(0) - jets->begin() + *itObj;
10141046

@@ -1029,6 +1061,14 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
10291061
<< "\nNo taus added to filterproduct." << endl;
10301062
} else {
10311063
for (std::list<int>::const_iterator itObj = listTau.begin(); itObj != listTau.end(); ++itObj) {
1064+
// skip invalid indices
1065+
if (*itObj < 0 or unsigned(*itObj) >= taus->size(0)) {
1066+
edm::LogWarning("HLTL1TSeed")
1067+
<< "Invalid index from the L1ObjectMap (L1uGT emulator), will be ignored (l1t::TauBxCollection):"
1068+
<< " index=" << *itObj << " (size of unpacked L1T objects in BX0 = " << taus->size(0) << ")";
1069+
continue;
1070+
}
1071+
10321072
// Transform to begin of BxVector
10331073
unsigned int index = taus->begin(0) - taus->begin() + *itObj;
10341074

0 commit comments

Comments
 (0)