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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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_
 
edm::GetterOfProducts< reco::RecoEcalCandidateIsolationMapgetterOfProducts_
 
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 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 80 of file EgammaHLTExtraProducer.cc.

Constructor & Destructor Documentation

◆ EgammaHLTExtraProducer()

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

Definition at line 199 of file EgammaHLTExtraProducer.cc.

References edm::EDConsumerBase::esConsumes().

202  minPtToSaveHits_(pset.getParameter<double>("minPtToSaveHits")),
203  saveHitsPlusPi_(pset.getParameter<bool>("saveHitsPlusPi")),
204  saveHitsPlusHalfPi_(pset.getParameter<bool>("saveHitsPlusHalfPi")),
205  recHitCountThresholds_(pset.getParameter<std::vector<double>>("recHitCountThresholds")) {
208  for (auto& tokenLabel : tokens_.egCands) {
209  produces<trigger::EgammaObjectCollection>(tokenLabel.second);
210  }
211  for (auto& tokenLabel : tokens_.ecal) {
212  produces<EcalRecHitCollection>(tokenLabel.second);
213  for (const auto& thres : recHitCountThresholds_) {
214  produces<int>("countEcalRecHits" + tokenLabel.second + "Thres" + convertToProdNameStr(thres) + "GeV");
215  }
216  }
217  for (auto& tokenLabel : tokens_.hcal) {
218  produces<HBHERecHitCollection>(tokenLabel.second);
219  for (const auto& thres : recHitCountThresholds_) {
220  produces<int>("countHcalRecHits" + tokenLabel.second + "Thres" + convertToProdNameStr(thres) + "GeV");
221  }
222  }
223  for (auto& tokenLabel : tokens_.trks) {
224  produces<reco::TrackCollection>(tokenLabel.second);
225  }
226  for (auto& tokenLabel : tokens_.pfClusIso) {
227  produces<reco::PFClusterCollection>(tokenLabel.second);
228  }
229 }
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: ProducerBase.h:87
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
edm::GetterOfProducts< reco::RecoEcalCandidateIsolationMap > getterOfProducts_
std::vector< std::pair< EgObjTokens, std::string > > egCands

◆ ~EgammaHLTExtraProducer()

EgammaHLTExtraProducer::~EgammaHLTExtraProducer ( )
inlineoverride

Definition at line 83 of file EgammaHLTExtraProducer.cc.

83 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 231 of file EgammaHLTExtraProducer.cc.

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

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

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

Referenced by produce().

502  {
503  auto filteredPFClus = std::make_unique<reco::PFClusterCollection>();
504  if (!pfClus.isValid())
505  return filteredPFClus;
506 
507  std::vector<std::pair<float, float>> etaPhis;
508  for (const auto& egTrigObjs : egTrigObjColls) {
509  for (const auto& egTrigObj : *egTrigObjs) {
510  if (egTrigObj.pt() >= minPtToSaveHits_) {
511  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi()});
512  if (saveHitsPlusPi_)
513  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159});
515  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159 / 2.});
516  }
517  }
518  }
519  auto deltaR2Match = [&etaPhis, &maxDR2](float eta, float phi) {
520  for (auto& etaPhi : etaPhis) {
521  if (reco::deltaR2(eta, phi, etaPhi.first, etaPhi.second) < maxDR2)
522  return true;
523  }
524  return false;
525  };
526 
527  for (auto& clus : *pfClus) {
528  if (deltaR2Match(clus.eta(), clus.phi()))
529  filteredPFClus->push_back(clus);
530  }
531  return filteredPFClus;
532 }
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 409 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().

413  {
414  auto filteredHits = std::make_unique<RecHitCollection>();
415  if (!recHits.isValid())
416  return filteredHits;
417 
418  std::vector<std::pair<float, float>> etaPhis;
419  for (const auto& egTrigObjs : egTrigObjColls) {
420  for (const auto& egTrigObj : *egTrigObjs) {
421  if (egTrigObj.pt() >= minPtToSaveHits_) {
422  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi()});
423  if (saveHitsPlusPi_)
424  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159});
426  etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159 / 2.});
427  }
428  }
429  }
430  auto deltaR2Match = [&etaPhis, &maxDR2](const GlobalPoint& pos) {
431  float eta = pos.eta();
432  float phi = pos.phi();
433  for (auto& etaPhi : etaPhis) {
434  if (reco::deltaR2(eta, phi, etaPhi.first, etaPhi.second) < maxDR2)
435  return true;
436  }
437  return false;
438  };
439 
440  for (auto& hit : *recHits) {
441  const CaloSubdetectorGeometry* subDetGeom = geom.getSubdetectorGeometry(hit.id());
442  if (subDetGeom) {
443  auto cellGeom = subDetGeom->getGeometry(hit.id());
444  if (deltaR2Match(cellGeom->getPosition()))
445  filteredHits->push_back(hit);
446  } else {
447  throw cms::Exception("GeomError") << "could not get geometry for det id " << hit.id().rawId();
448  }
449  }
450  return filteredHits;
451 }
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 453 of file EgammaHLTExtraProducer.cc.

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

Referenced by produce().

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

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

Referenced by setGsfTracks().

364  {
365  if (!gsfTrksHandle.isValid()) {
366  return reco::GsfTrackRefVector();
367  }
368 
369  reco::GsfTrackRefVector gsfTrkRefs(gsfTrksHandle.id());
370  for (size_t trkNr = 0; gsfTrksHandle.isValid() && trkNr < gsfTrksHandle->size(); trkNr++) {
371  reco::GsfTrackRef trkRef(gsfTrksHandle, trkNr);
372  edm::RefToBase<TrajectorySeed> seed = trkRef->extra()->seedRef();
374  edm::RefToBase<reco::CaloCluster> caloCluster = eleSeed->caloCluster();
375  reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>();
376  if (scRefFromTrk == scRef) {
377  gsfTrkRefs.push_back(trkRef);
378  }
379  }
380  return gsfTrkRefs;
381 }
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 280 of file EgammaHLTExtraProducer.cc.

References caloGeomToken_, submitPVResolutionJobs::count, EgammaHLTExtraProducer::Tokens::ecal, EgammaHLTExtraProducer::Tokens::egCands, edmPickEvents::event, options_cfi::eventSetup, filtered(), filterPFClusIso(), filterRecHits(), filterTrks(), getterOfProducts_, 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.

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

◆ setGsfTracks()

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

Definition at line 383 of file EgammaHLTExtraProducer.cc.

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

Referenced by produce().

384  {
385  egTrigObj.setGsfTracks(matchingGsfTrks(egTrigObj.superCluster(), gsfTrksHandle));
386 }
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 388 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().

389  {
390  if (!eleSeedsHandle.isValid()) {
392  } else {
393  reco::ElectronSeedRefVector trigObjSeeds(eleSeedsHandle.id());
394 
395  for (size_t seedNr = 0; eleSeedsHandle.isValid() && seedNr < eleSeedsHandle->size(); seedNr++) {
396  reco::ElectronSeedRef eleSeed(eleSeedsHandle, seedNr);
397  edm::RefToBase<reco::CaloCluster> caloCluster = eleSeed->caloCluster();
398  reco::SuperClusterRef scRefFromSeed = caloCluster.castTo<reco::SuperClusterRef>();
399 
400  if (scRefFromSeed == egTrigObj.superCluster()) {
401  trigObjSeeds.push_back(eleSeed);
402  }
403  }
404  egTrigObj.setSeeds(std::move(trigObjSeeds));
405  }
406 }
const reco::SuperClusterRef & superCluster() const
Definition: EgammaObject.h:25
ProductID id() const
Definition: HandleBase.cc:29
REF castTo() const
Definition: RefToBase.h:259
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 345 of file EgammaHLTExtraProducer.cc.

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

Referenced by produce().

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

Member Data Documentation

◆ caloGeomToken_

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

Definition at line 182 of file EgammaHLTExtraProducer.cc.

Referenced by produce().

◆ getterOfProducts_

edm::GetterOfProducts<reco::RecoEcalCandidateIsolationMap> EgammaHLTExtraProducer::getterOfProducts_
private

Definition at line 188 of file EgammaHLTExtraProducer.cc.

Referenced by produce().

◆ minPtToSaveHits_

float EgammaHLTExtraProducer::minPtToSaveHits_
private

Definition at line 184 of file EgammaHLTExtraProducer.cc.

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

◆ recHitCountThresholds_

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

Definition at line 187 of file EgammaHLTExtraProducer.cc.

Referenced by produce().

◆ saveHitsPlusHalfPi_

bool EgammaHLTExtraProducer::saveHitsPlusHalfPi_
private

Definition at line 186 of file EgammaHLTExtraProducer.cc.

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

◆ saveHitsPlusPi_

bool EgammaHLTExtraProducer::saveHitsPlusPi_
private

Definition at line 185 of file EgammaHLTExtraProducer.cc.

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

◆ tokens_

const Tokens EgammaHLTExtraProducer::tokens_
private

Definition at line 180 of file EgammaHLTExtraProducer.cc.

Referenced by produce().