53 std::vector<RectangularEtaPhiRegion>&,
57 template <
typename T1>
68 :
minEt_(para.getParameter<double>(
"minEt")),
69 maxEt_(para.getParameter<double>(
"maxEt")),
72 token_(consumesColl.consumes<T1>(para.getParameter<edm::
InputTag>(
"inputColl"))) {}
75 template <
typename T2>
76 static typename T2::const_iterator
beginIt(
const T2& coll) {
79 template <
typename T2>
80 static typename T2::const_iterator
endIt(
const T2& coll) {
83 template <
typename T2>
87 template <
typename T2>
93 template <
typename RecHitType>
120 template <
typename RecHitType>
124 para.getParameter<std::vector<edm::ParameterSet>>(
"l1InputRegions");
125 for (
auto&
pset : l1InputRegions) {
127 l1RegionData_.emplace_back(createL1RegionData(
130 consumesCollector()));
132 recHitLabels_ = para.getParameter<std::vector<edm::InputTag>>(
"recHitLabels");
133 productLabels_ = para.getParameter<std::vector<std::string>>(
"productLabels");
135 for (
unsigned int collNr = 0; collNr < recHitLabels_.size(); collNr++) {
136 recHitTokens_.push_back(consumes<RecHitCollectionType>(recHitLabels_[collNr]));
137 produces<RecHitCollectionType>(productLabels_[collNr]);
140 template <
typename RecHitType>
143 std::vector<std::string> productTags;
144 productTags.push_back(
"EcalRegionalRecHitsEB");
145 productTags.push_back(
"EcalRegionalRecHitsEE");
146 desc.
add<std::vector<std::string>>(
"productLabels", productTags);
148 recHitLabels.push_back(
edm::InputTag(
"hltEcalRegionalEgammaRecHit:EcalRecHitsEB"));
149 recHitLabels.push_back(
edm::InputTag(
"hltEcalRegionalEgammaRecHit:EcalRecHitsEE"));
150 recHitLabels.push_back(
edm::InputTag(
"hltESRegionalEgammaRecHit:EcalRecHitsES"));
158 emIsoPSet.
addParameter<
double>(
"regionEtaMargin", 0.14);
161 l1InputRegions.push_back(emIsoPSet);
166 emNonIsoPSet.
addParameter<
double>(
"regionEtaMargin", 0.14);
167 emNonIsoPSet.
addParameter<
double>(
"regionPhiMargin", 0.4);
169 l1InputRegions.push_back(emNonIsoPSet);
181 l1InputRegions.push_back(egPSet);
190 l1InputRegions.push_back(jetPSet);
194 l1InputRegionDesc.
add<
double>(
"minEt");
195 l1InputRegionDesc.
add<
double>(
"maxEt");
196 l1InputRegionDesc.
add<
double>(
"regionEtaMargin");
197 l1InputRegionDesc.
add<
double>(
"regionPhiMargin");
199 desc.
addVPSet(
"l1InputRegions", l1InputRegionDesc, l1InputRegions);
204 template <
typename RecHitType>
207 auto const& caloGeom = setup.
getData(caloGeometryToken_);
210 auto const& l1CaloGeom = setup.
getData(l1CaloGeometryToken_);
212 std::vector<RectangularEtaPhiRegion>
regions;
213 std::for_each(l1RegionData_.begin(),
216 input->getEtaPhiRegions(event, regions, l1CaloGeom);
219 for (
size_t recHitCollNr = 0; recHitCollNr < recHitTokens_.size(); recHitCollNr++) {
221 event.getByToken(recHitTokens_[recHitCollNr], recHits);
225 <<
" named " << recHitLabels_[recHitCollNr].encode() << std::endl;
229 auto filteredRecHits = std::make_unique<RecHitCollectionType>();
231 if (!recHits->empty()) {
233 if (!regions.empty()) {
235 auto this_cell = subDetGeom->
getGeometry(recHit.id());
236 for (
const auto&
region : regions) {
237 if (
region.inRegion(this_cell->etaPos(), this_cell->phiPos())) {
238 filteredRecHits->push_back(recHit);
246 event.put(
std::move(filteredRecHits), productLabels_[recHitCollNr]);
250 template <
typename RecHitType>
253 if (type ==
"L1EmParticle") {
255 }
else if (type ==
"L1JetParticle") {
257 }
else if (type ==
"L1MuonParticle") {
259 }
else if (type ==
"EGamma") {
261 }
else if (type ==
"Jet") {
263 }
else if (type ==
"Muon") {
265 }
else if (type ==
"Tau") {
271 <<
" is not recognised, this means the rec-hit you think you are keeping may not be and you should fix this "
272 "error as it can lead to hard to find efficiency loses"
277 template <
typename L1CollType>
279 std::vector<RectangularEtaPhiRegion>&
regions,
282 event.getByToken(token_, l1Cands);
284 for (
auto l1CandIt = beginIt(*l1Cands); l1CandIt != endIt(*l1Cands); ++l1CandIt) {
285 if (l1CandIt->et() >= minEt_ && l1CandIt->et() < maxEt_) {
286 double etaLow = l1CandIt->eta() - regionEtaMargin_;
287 double etaHigh = l1CandIt->eta() + regionEtaMargin_;
288 double phiLow = l1CandIt->phi() - regionPhiMargin_;
289 double phiHigh = l1CandIt->phi() + regionPhiMargin_;
298 std::vector<RectangularEtaPhiRegion>&
regions,
301 event.getByToken(token_, l1Cands);
303 for (
const auto& l1Cand : *l1Cands) {
304 if (l1Cand.et() >= minEt_ && l1Cand.et() < maxEt_) {
306 int etaIndex = l1Cand.gctJetCand()->etaIndex();
307 int phiIndex = l1Cand.gctJetCand()->phiIndex();
315 etaLow -= regionEtaMargin_;
316 etaHigh += regionEtaMargin_;
317 phiLow -= regionPhiMargin_;
318 phiHigh += regionPhiMargin_;
327 std::vector<RectangularEtaPhiRegion>&
regions,
330 event.getByToken(token_, l1Cands);
332 for (
const auto& l1Cand : *l1Cands) {
333 if (l1Cand.et() >= minEt_ && l1Cand.et() < maxEt_) {
335 int etaIndex = l1Cand.gctEmCand()->etaIndex();
336 int phiIndex = l1Cand.gctEmCand()->phiIndex();
344 etaLow -= regionEtaMargin_;
345 etaHigh += regionEtaMargin_;
346 phiLow -= regionPhiMargin_;
347 phiHigh += regionPhiMargin_;
virtual void getEtaPhiRegions(const edm::Event &, std::vector< RectangularEtaPhiRegion > &, const L1CaloGeometry &) const =0
const_iterator end(int bx) const
HLTRecHitInAllL1RegionsProducer< EcalUncalibratedRecHit > HLTEcalUncalibratedRecHitInAllL1RegionsProducer
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
edm::ConsumesCollector consumesColl(consumesCollector())
double etaBinHighEdge(unsigned int etaIndex, bool central=true) const
double etaBinLowEdge(unsigned int etaIndex, bool central=true) const
std::vector< std::unique_ptr< L1RegionDataBase > > l1RegionData_
constexpr SubDetector subDetGeom[21]
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< L1CaloGeometry, L1CaloGeometryRecord > l1CaloGeometryToken_
L1RegionData(const edm::ParameterSet ¶, edm::ConsumesCollector &consumesColl)
virtual ~L1RegionDataBase()
static BXVector< T2 >::const_iterator beginIt(const BXVector< T2 > &coll)
HLTRecHitInAllL1RegionsProducer(const edm::ParameterSet &ps)
std::string defaultModuleLabel()
std::vector< edm::InputTag > recHitLabels_
Log< level::Error, false > LogError
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
static std::string const input
void getEtaPhiRegions(const edm::Event &, std::vector< RectangularEtaPhiRegion > &, const L1CaloGeometry &) const override
bool getData(T &iHolder) const
std::vector< std::string > productLabels_
HLTRecHitInAllL1RegionsProducer< EcalRecHit > HLTEcalRecHitInAllL1RegionsProducer
void addParameter(std::string const &name, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< T1 > token_
static T2::const_iterator endIt(const T2 &coll)
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~HLTRecHitInAllL1RegionsProducer() override
static BXVector< T2 >::const_iterator endIt(const BXVector< T2 > &coll)
static T2::const_iterator beginIt(const T2 &coll)
double emJetPhiBinLowEdge(unsigned int phiIndex) const
std::vector< edm::EDGetTokenT< RecHitCollectionType > > recHitTokens_
const_iterator begin(int bx) const
L1RegionDataBase * createL1RegionData(const std::string &, const edm::ParameterSet &, edm::ConsumesCollector &&)
double emJetPhiBinHighEdge(unsigned int phiIndex) const