CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
EgammaHLTExtraProducer Class Reference
Inheritance diagram for EgammaHLTExtraProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  Tokens
 

Public Member Functions

 EgammaHLTExtraProducer (const edm::ParameterSet &pset)
 
void produce (edm::StreamID streamID, edm::Event &event, const edm::EventSetup &eventSetup) const override
 
 ~EgammaHLTExtraProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

std::unique_ptr< reco::PFClusterCollectionfilterPFClusIso (const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &egTrigObjs, const edm::Handle< reco::PFClusterCollection > &pfClus, float maxDR2=0.4 *0.4) const
 
template<typename RecHitCollection >
std::unique_ptr< RecHitCollection > filterRecHits (const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &egTrigObjs, const edm::Handle< RecHitCollection > &recHits, const CaloGeometry &geom, float maxDR2=0.4 *0.4) const
 
std::unique_ptr< reco::TrackCollectionfilterTrks (const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &egTrigObjs, const edm::Handle< reco::TrackCollection > &trks, float maxDR2=0.4 *0.4) const
 

Static Private Member Functions

static reco::GsfTrackRefVector matchingGsfTrks (const reco::SuperClusterRef &scRef, const edm::Handle< reco::GsfTrackCollection > &gsfTrksHandle)
 
static void setGsfTracks (trigger::EgammaObject &egTrigObj, const edm::Handle< reco::GsfTrackCollection > &gsfTrksHandle)
 
static void setSeeds (trigger::EgammaObject &egTrigObj, edm::Handle< reco::ElectronSeedCollection > &eleSeedsHandle)
 
static void setVars (trigger::EgammaObject &egTrigObj, const reco::RecoEcalCandidateRef &ecalCandRef, const std::vector< edm::Handle< reco::RecoEcalCandidateIsolationMap >> &valueMapHandles)
 

Private Attributes

edm::ESGetToken< CaloGeometry, CaloGeometryRecord > const caloGeomToken_
 
float minPtToSaveHits_
 
std::vector< double > recHitCountThresholds_
 
bool saveHitsPlusHalfPi_
 
bool saveHitsPlusPi_
 
const Tokens tokens_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 78 of file EgammaHLTExtraProducer.cc.

Constructor & Destructor Documentation

◆ EgammaHLTExtraProducer()

EgammaHLTExtraProducer::EgammaHLTExtraProducer ( const edm::ParameterSet pset)
explicit

Definition at line 196 of file EgammaHLTExtraProducer.cc.

References edm::EDConsumerBase::esConsumes().

199  minPtToSaveHits_(pset.getParameter<double>("minPtToSaveHits")),
200  saveHitsPlusPi_(pset.getParameter<bool>("saveHitsPlusPi")),
201  saveHitsPlusHalfPi_(pset.getParameter<bool>("saveHitsPlusHalfPi")),
202  recHitCountThresholds_(pset.getParameter<std::vector<double>>("recHitCountThresholds")) {
203  consumesMany<reco::RecoEcalCandidateIsolationMap>();
204 
205  for (auto& tokenLabel : tokens_.egCands) {
206  produces<trigger::EgammaObjectCollection>(tokenLabel.second);
207  }
208  for (auto& tokenLabel : tokens_.ecal) {
209  produces<EcalRecHitCollection>(tokenLabel.second);
210  for (const auto& thres : recHitCountThresholds_) {
211  produces<int>("countEcalRecHits" + tokenLabel.second + "Thres" + convertToProdNameStr(thres) + "GeV");
212  }
213  }
214  for (auto& tokenLabel : tokens_.hcal) {
215  produces<HBHERecHitCollection>(tokenLabel.second);
216  for (const auto& thres : recHitCountThresholds_) {
217  produces<int>("countHcalRecHits" + tokenLabel.second + "Thres" + convertToProdNameStr(thres) + "GeV");
218  }
219  }
220  for (auto& tokenLabel : tokens_.trks) {
221  produces<reco::TrackCollection>(tokenLabel.second);
222  }
223  for (auto& tokenLabel : tokens_.pfClusIso) {
224  produces<reco::PFClusterCollection>(tokenLabel.second);
225  }
226 }
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > const caloGeomToken_
std::vector< std::pair< edm::EDGetTokenT< reco::PFClusterCollection >, std::string > > pfClusIso
std::vector< std::pair< edm::EDGetTokenT< reco::TrackCollection >, std::string > > trks
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< std::pair< edm::EDGetTokenT< HBHERecHitCollection >, std::string > > hcal
std::vector< double > recHitCountThresholds_
std::vector< std::pair< edm::EDGetTokenT< EcalRecHitCollection >, std::string > > ecal
std::vector< std::pair< EgObjTokens, std::string > > egCands

◆ ~EgammaHLTExtraProducer()

EgammaHLTExtraProducer::~EgammaHLTExtraProducer ( )
inlineoverride

Definition at line 81 of file EgammaHLTExtraProducer.cc.

81 {}

Member Function Documentation

◆ fillDescriptions()

void EgammaHLTExtraProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 228 of file EgammaHLTExtraProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, HLT_2022v15_cff::InputTag, AlCaHLTBitMon_QueryRunRegistry::string, and trackerHitRTTI::vector.

228  {
230  desc.add<double>("minPtToSaveHits", 0.);
231  desc.add<bool>("saveHitsPlusPi", false);
232  desc.add<bool>("saveHitsPlusHalfPi", true);
233  desc.add<std::vector<double>>("recHitCountThresholds", std::vector{0., 0.5, 1.0, 1.5, 2.0});
234 
235  edm::ParameterSetDescription egCandsDesc;
236  egCandsDesc.add<edm::InputTag>("ecalCands", edm::InputTag(""));
237  egCandsDesc.add<edm::InputTag>("pixelSeeds", edm::InputTag(""));
238  egCandsDesc.add<edm::InputTag>("gsfTracks", edm::InputTag(""));
239  egCandsDesc.add<std::string>("label", "");
240  std::vector<edm::ParameterSet> egCandsDefaults(1);
241  egCandsDefaults[0].addParameter("ecalCands", edm::InputTag("hltEgammaCandidates"));
242  egCandsDefaults[0].addParameter("pixelSeeds", edm::InputTag("hltEgammaElectronPixelSeeds"));
243  egCandsDefaults[0].addParameter("gsfTracks", edm::InputTag("hltEgammaGsfTracks"));
244  egCandsDefaults[0].addParameter("label", std::string(""));
245 
246  edm::ParameterSetDescription tokenLabelDesc;
247  tokenLabelDesc.add<edm::InputTag>("src", edm::InputTag(""));
248  tokenLabelDesc.add<std::string>("label", "");
249  std::vector<edm::ParameterSet> ecalDefaults(2);
250  ecalDefaults[0].addParameter("src", edm::InputTag("hltEcalRecHit", "EcalRecHitsEB"));
251  ecalDefaults[0].addParameter("label", std::string("EcalRecHitsEB"));
252  ecalDefaults[1].addParameter("src", edm::InputTag("hltEcalRecHit", "EcalRecHitsEE"));
253  ecalDefaults[1].addParameter("label", std::string("EcalRecHitsEE"));
254  std::vector<edm::ParameterSet> hcalDefaults(1);
255  hcalDefaults[0].addParameter("src", edm::InputTag("hltHbhereco"));
256  hcalDefaults[0].addParameter("label", std::string(""));
257  std::vector<edm::ParameterSet> trksDefaults(1);
258  trksDefaults[0].addParameter("src", edm::InputTag("generalTracks"));
259  trksDefaults[0].addParameter("label", std::string(""));
260  std::vector<edm::ParameterSet> pfClusIsoDefaults(3);
261  pfClusIsoDefaults[0].addParameter("src", edm::InputTag("hltParticleFlowClusterECALL1Seeded"));
262  pfClusIsoDefaults[0].addParameter("label", std::string("Ecal"));
263  pfClusIsoDefaults[1].addParameter("src", edm::InputTag("hltParticleFlowClusterECALUnseeded"));
264  pfClusIsoDefaults[1].addParameter("label", std::string("EcalUnseeded"));
265  pfClusIsoDefaults[2].addParameter("src", edm::InputTag("hltParticleFlowClusterHCAL"));
266  pfClusIsoDefaults[2].addParameter("label", std::string("Hcal"));
267 
268  desc.addVPSet("egCands", egCandsDesc, egCandsDefaults);
269  desc.addVPSet("ecal", tokenLabelDesc, ecalDefaults);
270  desc.addVPSet("hcal", tokenLabelDesc, hcalDefaults);
271  desc.addVPSet("trks", tokenLabelDesc, trksDefaults);
272  desc.addVPSet("pfClusIso", tokenLabelDesc, pfClusIsoDefaults);
273 
274  descriptions.add(("hltEgammaHLTExtraProducer"), desc);
275 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ filterPFClusIso()

std::unique_ptr< reco::PFClusterCollection > EgammaHLTExtraProducer::filterPFClusIso ( const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &  egTrigObjs,
const edm::Handle< reco::PFClusterCollection > &  pfClus,
float  maxDR2 = 0.4 * 0.4 
) const
private

Definition at line 497 of file EgammaHLTExtraProducer.cc.

References reco::deltaR2(), PVValHelper::eta, edm::HandleBase::isValid(), minPtToSaveHits_, phi, saveHitsPlusHalfPi_, and saveHitsPlusPi_.

Referenced by produce().

500  {
501  auto filteredPFClus = std::make_unique<reco::PFClusterCollection>();
502  if (!pfClus.isValid())
503  return filteredPFClus;
504 
505  std::vector<std::pair<float, float>> etaPhis;
506  for (const auto& egTrigObjs : egTrigObjColls) {
507  for (const auto& egTrigObj : *egTrigObjs) {
508  if (egTrigObj.pt() >= minPtToSaveHits_) {
509  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi()});
510  if (saveHitsPlusPi_)
511  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159});
513  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159 / 2.});
514  }
515  }
516  }
517  auto deltaR2Match = [&etaPhis, &maxDR2](float eta, float phi) {
518  for (auto& etaPhi : etaPhis) {
519  if (reco::deltaR2(eta, phi, etaPhi.first, etaPhi.second) < maxDR2)
520  return true;
521  }
522  return false;
523  };
524 
525  for (auto& clus : *pfClus) {
526  if (deltaR2Match(clus.eta(), clus.phi()))
527  filteredPFClus->push_back(clus);
528  }
529  return filteredPFClus;
530 }
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
bool isValid() const
Definition: HandleBase.h:70

◆ filterRecHits()

template<typename RecHitCollection >
std::unique_ptr< RecHitCollection > EgammaHLTExtraProducer::filterRecHits ( const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &  egTrigObjs,
const edm::Handle< RecHitCollection > &  recHits,
const CaloGeometry geom,
float  maxDR2 = 0.4 * 0.4 
) const
private

Definition at line 407 of file EgammaHLTExtraProducer.cc.

References reco::deltaR2(), PVValHelper::eta, Exception, relativeConstraints::geom, hit::id, minPtToSaveHits_, phi, FastTrackerRecHitMaskProducer_cfi::recHits, saveHitsPlusHalfPi_, saveHitsPlusPi_, and GeomDetEnumerators::subDetGeom.

Referenced by produce().

411  {
412  auto filteredHits = std::make_unique<RecHitCollection>();
413  if (!recHits.isValid())
414  return filteredHits;
415 
416  std::vector<std::pair<float, float>> etaPhis;
417  for (const auto& egTrigObjs : egTrigObjColls) {
418  for (const auto& egTrigObj : *egTrigObjs) {
419  if (egTrigObj.pt() >= minPtToSaveHits_) {
420  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi()});
421  if (saveHitsPlusPi_)
422  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159});
424  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159 / 2.});
425  }
426  }
427  }
428  auto deltaR2Match = [&etaPhis, &maxDR2](const GlobalPoint& pos) {
429  float eta = pos.eta();
430  float phi = pos.phi();
431  for (auto& etaPhi : etaPhis) {
432  if (reco::deltaR2(eta, phi, etaPhi.first, etaPhi.second) < maxDR2)
433  return true;
434  }
435  return false;
436  };
437 
438  for (auto& hit : *recHits) {
439  const CaloSubdetectorGeometry* subDetGeom = geom.getSubdetectorGeometry(hit.id());
440  if (subDetGeom) {
441  auto cellGeom = subDetGeom->getGeometry(hit.id());
442  if (deltaR2Match(cellGeom->getPosition()))
443  filteredHits->push_back(hit);
444  } else {
445  throw cms::Exception("GeomError") << "could not get geometry for det id " << hit.id().rawId();
446  }
447  }
448  return filteredHits;
449 }
constexpr SubDetector subDetGeom[21]
unsigned int id
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16

◆ filterTrks()

std::unique_ptr< reco::TrackCollection > EgammaHLTExtraProducer::filterTrks ( const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &  egTrigObjs,
const edm::Handle< reco::TrackCollection > &  trks,
float  maxDR2 = 0.4 * 0.4 
) const
private

Definition at line 451 of file EgammaHLTExtraProducer.cc.

References reco::deltaR2(), PVValHelper::eta, minPtToSaveHits_, phi, saveHitsPlusHalfPi_, saveHitsPlusPi_, and hltEgammaHLTExtra_cfi::trks.

Referenced by produce().

454  {
455  auto filteredTrks = std::make_unique<reco::TrackCollection>();
456  if (!trks.isValid())
457  return filteredTrks;
458 
459  //so because each egamma object can have multiple eta/phi pairs
460  //easier to just make a temp vector and then copy that in with the +pi and +pi/2
461  std::vector<std::pair<float, float>> etaPhisTmp;
462  for (const auto& egTrigObjs : egTrigObjColls) {
463  for (const auto& egTrigObj : *egTrigObjs) {
464  if (egTrigObj.pt() >= minPtToSaveHits_) {
465  etaPhisTmp.push_back({egTrigObj.eta(), egTrigObj.phi()});
466  //also save the eta /phi of all gsf tracks with the object
467  for (const auto& gsfTrk : egTrigObj.gsfTracks()) {
468  etaPhisTmp.push_back({gsfTrk->eta(), gsfTrk->phi()});
469  }
470  }
471  }
472  }
473  std::vector<std::pair<float, float>> etaPhis;
474  for (const auto& etaPhi : etaPhisTmp) {
475  etaPhis.push_back(etaPhi);
476  if (saveHitsPlusPi_)
477  etaPhis.push_back({etaPhi.first, etaPhi.second + 3.14159});
479  etaPhis.push_back({etaPhi.first, etaPhi.second + 3.14159 / 2.});
480  }
481 
482  auto deltaR2Match = [&etaPhis, &maxDR2](float eta, float phi) {
483  for (auto& etaPhi : etaPhis) {
484  if (reco::deltaR2(eta, phi, etaPhi.first, etaPhi.second) < maxDR2)
485  return true;
486  }
487  return false;
488  };
489 
490  for (auto& trk : *trks) {
491  if (deltaR2Match(trk.eta(), trk.phi()))
492  filteredTrks->push_back(trk);
493  }
494  return filteredTrks;
495 }
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16

◆ matchingGsfTrks()

reco::GsfTrackRefVector EgammaHLTExtraProducer::matchingGsfTrks ( const reco::SuperClusterRef scRef,
const edm::Handle< reco::GsfTrackCollection > &  gsfTrksHandle 
)
staticprivate

Definition at line 361 of file EgammaHLTExtraProducer.cc.

References edm::HandleBase::id(), edm::HandleBase::isValid(), and fileCollector::seed.

Referenced by setGsfTracks().

362  {
363  if (!gsfTrksHandle.isValid()) {
364  return reco::GsfTrackRefVector();
365  }
366 
367  reco::GsfTrackRefVector gsfTrkRefs(gsfTrksHandle.id());
368  for (size_t trkNr = 0; gsfTrksHandle.isValid() && trkNr < gsfTrksHandle->size(); trkNr++) {
369  reco::GsfTrackRef trkRef(gsfTrksHandle, trkNr);
370  edm::RefToBase<TrajectorySeed> seed = trkRef->extra()->seedRef();
372  edm::RefToBase<reco::CaloCluster> caloCluster = eleSeed->caloCluster();
373  reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>();
374  if (scRefFromTrk == scRef) {
375  gsfTrkRefs.push_back(trkRef);
376  }
377  }
378  return gsfTrkRefs;
379 }
ProductID id() const
Definition: HandleBase.cc:29
edm::RefVector< GsfTrackCollection > GsfTrackRefVector
vector of reference to GsfTrack in the same collection
Definition: GsfTrackFwd.h:17
bool isValid() const
Definition: HandleBase.h:70

◆ produce()

void EgammaHLTExtraProducer::produce ( edm::StreamID  streamID,
edm::Event event,
const edm::EventSetup eventSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 277 of file EgammaHLTExtraProducer.cc.

References caloGeomToken_, submitPVResolutionJobs::count, EgammaHLTExtraProducer::Tokens::ecal, EgammaHLTExtraProducer::Tokens::egCands, edmPickEvents::event, options_cfi::eventSetup, filtered(), filterPFClusIso(), filterRecHits(), filterTrks(), patZpeak::handle, EgammaHLTExtraProducer::Tokens::hcal, eostools::move(), EgammaHLTExtraProducer::Tokens::pfClusIso, recHitCountThresholds_, FastTrackerRecHitMaskProducer_cfi::recHits, setGsfTracks(), setSeeds(), setVars(), AlCaHLTBitMon_QueryRunRegistry::string, particleFlowZeroSuppressionECAL_cff::thresholds, tokens_, and EgammaHLTExtraProducer::Tokens::trks.

279  {
280  std::vector<edm::Handle<reco::RecoEcalCandidateIsolationMap>> valueMapHandles;
281  event.getManyByType(valueMapHandles);
282 
283  std::vector<std::unique_ptr<trigger::EgammaObjectCollection>> egTrigObjColls;
284  for (const auto& egCandsToken : tokens_.egCands) {
285  auto ecalCandsHandle = event.getHandle(egCandsToken.first.ecalCands);
286  auto gsfTrksHandle = event.getHandle(egCandsToken.first.gsfTracks);
287  auto pixelSeedsHandle = event.getHandle(egCandsToken.first.pixelSeeds);
288 
289  auto egTrigObjs = std::make_unique<trigger::EgammaObjectCollection>();
290  for (size_t candNr = 0; ecalCandsHandle.isValid() && candNr < ecalCandsHandle->size(); candNr++) {
291  reco::RecoEcalCandidateRef candRef(ecalCandsHandle, candNr);
292  egTrigObjs->push_back(*candRef);
293  auto& egTrigObj = egTrigObjs->back();
294  setVars(egTrigObj, candRef, valueMapHandles);
295  setGsfTracks(egTrigObj, gsfTrksHandle);
296  setSeeds(egTrigObj, pixelSeedsHandle);
297  }
298  egTrigObjColls.emplace_back(std::move(egTrigObjs));
299  }
300 
301  auto const caloGeomHandle = eventSetup.getHandle(caloGeomToken_);
302 
303  auto filterAndStoreRecHits = [caloGeomHandle, &event, this](const auto& egTrigObjs, const auto& tokenLabels) {
304  for (const auto& tokenLabel : tokenLabels) {
305  auto handle = event.getHandle(tokenLabel.first);
306  auto recHits = filterRecHits(egTrigObjs, handle, *caloGeomHandle);
307  event.put(std::move(recHits), tokenLabel.second);
308  }
309  };
310 
311  auto storeCountRecHits = [&event](const auto& tokenLabels, const auto& thresholds, const std::string& prefixLabel) {
312  for (const auto& tokenLabel : tokenLabels) {
313  auto handle = event.getHandle(tokenLabel.first);
314  auto count = countRecHits(handle, thresholds);
315  for (size_t thresNr = 0; thresNr < thresholds.size(); thresNr++) {
316  const auto& thres = thresholds[thresNr];
317  event.put(std::move(count[thresNr]),
318  prefixLabel + tokenLabel.second + "Thres" + convertToProdNameStr(thres) + "GeV");
319  }
320  }
321  };
322 
323  auto filterAndStore = [&event, this](const auto& egTrigObjs, const auto& tokenLabels, auto filterFunc) {
324  for (const auto& tokenLabel : tokenLabels) {
325  auto handle = event.getHandle(tokenLabel.first);
326  auto filtered = (this->*filterFunc)(egTrigObjs, handle, 0.4 * 0.4);
327  event.put(std::move(filtered), tokenLabel.second);
328  }
329  };
330 
331  filterAndStoreRecHits(egTrigObjColls, tokens_.ecal);
332  filterAndStoreRecHits(egTrigObjColls, tokens_.hcal);
333  storeCountRecHits(tokens_.ecal, recHitCountThresholds_, "countEcalRecHits");
334  storeCountRecHits(tokens_.hcal, recHitCountThresholds_, "countHcalRecHits");
335  filterAndStore(egTrigObjColls, tokens_.pfClusIso, &EgammaHLTExtraProducer::filterPFClusIso);
336  filterAndStore(egTrigObjColls, tokens_.trks, &EgammaHLTExtraProducer::filterTrks);
337 
338  for (size_t collNr = 0; collNr < egTrigObjColls.size(); collNr++) {
339  event.put(std::move(egTrigObjColls[collNr]), tokens_.egCands[collNr].second);
340  }
341 }
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > const caloGeomToken_
static void setGsfTracks(trigger::EgammaObject &egTrigObj, const edm::Handle< reco::GsfTrackCollection > &gsfTrksHandle)
static void setVars(trigger::EgammaObject &egTrigObj, const reco::RecoEcalCandidateRef &ecalCandRef, const std::vector< edm::Handle< reco::RecoEcalCandidateIsolationMap >> &valueMapHandles)
std::unique_ptr< reco::TrackCollection > filterTrks(const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &egTrigObjs, const edm::Handle< reco::TrackCollection > &trks, float maxDR2=0.4 *0.4) const
std::vector< std::pair< edm::EDGetTokenT< reco::PFClusterCollection >, std::string > > pfClusIso
std::vector< std::pair< edm::EDGetTokenT< reco::TrackCollection >, std::string > > trks
static const TGPicture * filtered(bool iBackgroundIsBlack)
std::unique_ptr< reco::PFClusterCollection > filterPFClusIso(const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &egTrigObjs, const edm::Handle< reco::PFClusterCollection > &pfClus, float maxDR2=0.4 *0.4) const
std::vector< std::pair< edm::EDGetTokenT< HBHERecHitCollection >, std::string > > hcal
std::vector< double > recHitCountThresholds_
std::vector< std::pair< edm::EDGetTokenT< EcalRecHitCollection >, std::string > > ecal
static void setSeeds(trigger::EgammaObject &egTrigObj, edm::Handle< reco::ElectronSeedCollection > &eleSeedsHandle)
std::unique_ptr< RecHitCollection > filterRecHits(const std::vector< std::unique_ptr< trigger::EgammaObjectCollection >> &egTrigObjs, const edm::Handle< RecHitCollection > &recHits, const CaloGeometry &geom, float maxDR2=0.4 *0.4) const
std::vector< std::pair< EgObjTokens, std::string > > egCands
def move(src, dest)
Definition: eostools.py:511

◆ setGsfTracks()

void EgammaHLTExtraProducer::setGsfTracks ( trigger::EgammaObject egTrigObj,
const edm::Handle< reco::GsfTrackCollection > &  gsfTrksHandle 
)
staticprivate

Definition at line 381 of file EgammaHLTExtraProducer.cc.

References matchingGsfTrks(), trigger::EgammaObject::setGsfTracks(), and trigger::EgammaObject::superCluster().

Referenced by produce().

382  {
383  egTrigObj.setGsfTracks(matchingGsfTrks(egTrigObj.superCluster(), gsfTrksHandle));
384 }
const reco::SuperClusterRef & superCluster() const
Definition: EgammaObject.h:25
static reco::GsfTrackRefVector matchingGsfTrks(const reco::SuperClusterRef &scRef, const edm::Handle< reco::GsfTrackCollection > &gsfTrksHandle)
void setGsfTracks(reco::GsfTrackRefVector trks)
Definition: EgammaObject.h:30

◆ setSeeds()

void EgammaHLTExtraProducer::setSeeds ( trigger::EgammaObject egTrigObj,
edm::Handle< reco::ElectronSeedCollection > &  eleSeedsHandle 
)
staticprivate

Definition at line 386 of file EgammaHLTExtraProducer.cc.

References edm::RefToBase< T >::castTo(), edm::HandleBase::id(), edm::HandleBase::isValid(), eostools::move(), trigger::EgammaObject::setSeeds(), and trigger::EgammaObject::superCluster().

Referenced by produce().

387  {
388  if (!eleSeedsHandle.isValid()) {
390  } else {
391  reco::ElectronSeedRefVector trigObjSeeds(eleSeedsHandle.id());
392 
393  for (size_t seedNr = 0; eleSeedsHandle.isValid() && seedNr < eleSeedsHandle->size(); seedNr++) {
394  reco::ElectronSeedRef eleSeed(eleSeedsHandle, seedNr);
395  edm::RefToBase<reco::CaloCluster> caloCluster = eleSeed->caloCluster();
396  reco::SuperClusterRef scRefFromSeed = caloCluster.castTo<reco::SuperClusterRef>();
397 
398  if (scRefFromSeed == egTrigObj.superCluster()) {
399  trigObjSeeds.push_back(eleSeed);
400  }
401  }
402  egTrigObj.setSeeds(std::move(trigObjSeeds));
403  }
404 }
const reco::SuperClusterRef & superCluster() const
Definition: EgammaObject.h:25
ProductID id() const
Definition: HandleBase.cc:29
REF castTo() const
Definition: RefToBase.h:257
void setSeeds(reco::ElectronSeedRefVector seeds)
Definition: EgammaObject.cc:11
bool isValid() const
Definition: HandleBase.h:70
def move(src, dest)
Definition: eostools.py:511

◆ setVars()

void EgammaHLTExtraProducer::setVars ( trigger::EgammaObject egTrigObj,
const reco::RecoEcalCandidateRef ecalCandRef,
const std::vector< edm::Handle< reco::RecoEcalCandidateIsolationMap >> &  valueMapHandles 
)
staticprivate

Definition at line 343 of file EgammaHLTExtraProducer.cc.

References eostools::move(), Skims_PA_cff::name, trigger::EgammaObject::setVars(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by produce().

346  {
347  std::vector<std::pair<std::string, float>> vars;
348  for (auto& valueMapHandle : valueMapHandles) {
349  auto mapIt = valueMapHandle->find(ecalCandRef);
350  if (mapIt != valueMapHandle->end()) {
351  std::string name = valueMapHandle.provenance()->moduleLabel();
352  if (!valueMapHandle.provenance()->productInstanceName().empty()) {
353  name += "_" + valueMapHandle.provenance()->productInstanceName();
354  }
355  vars.emplace_back(std::move(name), mapIt->val);
356  }
357  }
358  egTrigObj.setVars(std::move(vars));
359 }
void setVars(std::vector< std::pair< std::string, float >> vars)
Definition: EgammaObject.cc:59
vars
Definition: DeepTauId.cc:30
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ caloGeomToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> const EgammaHLTExtraProducer::caloGeomToken_
private

Definition at line 180 of file EgammaHLTExtraProducer.cc.

Referenced by produce().

◆ minPtToSaveHits_

float EgammaHLTExtraProducer::minPtToSaveHits_
private

Definition at line 182 of file EgammaHLTExtraProducer.cc.

Referenced by filterPFClusIso(), filterRecHits(), and filterTrks().

◆ recHitCountThresholds_

std::vector<double> EgammaHLTExtraProducer::recHitCountThresholds_
private

Definition at line 185 of file EgammaHLTExtraProducer.cc.

Referenced by produce().

◆ saveHitsPlusHalfPi_

bool EgammaHLTExtraProducer::saveHitsPlusHalfPi_
private

Definition at line 184 of file EgammaHLTExtraProducer.cc.

Referenced by filterPFClusIso(), filterRecHits(), and filterTrks().

◆ saveHitsPlusPi_

bool EgammaHLTExtraProducer::saveHitsPlusPi_
private

Definition at line 183 of file EgammaHLTExtraProducer.cc.

Referenced by filterPFClusIso(), filterRecHits(), and filterTrks().

◆ tokens_

const Tokens EgammaHLTExtraProducer::tokens_
private

Definition at line 178 of file EgammaHLTExtraProducer.cc.

Referenced by produce().