Skip to content

Commit

Permalink
guard HLTRecHitInAllL1RegionsProducer<T> against empty collection of …
Browse files Browse the repository at this point in the history
…L1T candidates
  • Loading branch information
missirol committed Apr 30, 2023
1 parent 2ce38b4 commit 980aeed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit 980aeed

Please sign in to comment.