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 HLTRecHitInAllL1RegionsProducer<T> against empty collection of L1T candidates [13_0_X] #41467

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RecoEgamma/EgammaHLTProducers/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>
<use name="DataFormats/EgammaCandidates"/>
<use name="Geometry/CaloGeometry"/>
<use name="RecoEcal/EgammaCoreTools"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/TypeDemangler.h"

// Reco candidates (might not need)
#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
Expand Down Expand Up @@ -80,6 +81,10 @@ class L1RegionData : public L1RegionDataBase {
const edm::EventSetup&,
std::vector<RectangularEtaPhiRegion>&) const override;
template <typename T2>
bool isEmpty(const T2& coll) const {
return coll.empty();
}
template <typename T2>
static typename T2::const_iterator beginIt(const T2& coll) {
return coll.begin();
}
Expand All @@ -88,6 +93,10 @@ class L1RegionData : public L1RegionDataBase {
return coll.end();
}
template <typename T2>
bool isEmpty(const BXVector<T2>& coll) const {
return (coll.size() == 0 or coll.isEmpty(0));
}
template <typename T2>
static typename BXVector<T2>::const_iterator beginIt(const BXVector<T2>& coll) {
return coll.begin(0);
}
Expand Down Expand Up @@ -286,6 +295,13 @@ void L1RegionData<L1CollType>::getEtaPhiRegions(const edm::Event& event,
edm::Handle<L1CollType> l1Cands;
event.getByToken(token_, l1Cands);

if (isEmpty(*l1Cands)) {
LogDebug("HLTRecHitInAllL1RegionsProducerL1RegionData")
<< "The input collection of L1T candidates is empty (L1CollType = \""
<< edm::typeDemangle(typeid(L1CollType).name()) << "\"). No regions selected.";
return;
}

for (auto l1CandIt = beginIt(*l1Cands); l1CandIt != endIt(*l1Cands); ++l1CandIt) {
if (l1CandIt->et() >= minEt_ && l1CandIt->et() < maxEt_) {
double etaLow = l1CandIt->eta() - regionEtaMargin_;
Expand Down