CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PhotonIsoProducer Class Reference
Inheritance diagram for PhotonIsoProducer:
edm::stream::EDFilter<> edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PhotonIsoProducer (const edm::ParameterSet &)
 
 ~PhotonIsoProducer () override
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
 EDFilter (const EDFilter &)=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
 
const EDFilteroperator= (const EDFilter &)=delete
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
 EDFilterBase (const EDFilterBase &)=delete
 
ModuleDescription const & moduleDescription () const
 
const EDFilterBaseoperator= (const EDFilterBase &)=delete
 
 ~EDFilterBase () 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)
 

Private Member Functions

bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

PFIsolationEstimator isolator
 
std::string nameIsoCh_
 
std::string nameIsoNh_
 
std::string nameIsoPh_
 
edm::EDGetTokenT< reco::PFCandidateCollectionparticleFlowToken_
 
edm::EDGetTokenT< reco::PhotonCollectionphotonToken_
 
bool verbose_
 
edm::EDGetTokenT< reco::VertexCollectionvertexToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase 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
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 25 of file PhotonIsoProducer.cc.

Constructor & Destructor Documentation

◆ PhotonIsoProducer()

PhotonIsoProducer::PhotonIsoProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 56 of file PhotonIsoProducer.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), PFIsolationEstimator::initializePhotonIsolation(), isolator, nameIsoCh_, nameIsoNh_, nameIsoPh_, particleFlowToken_, photonToken_, PFIsolationEstimator::setConeSize(), AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and vertexToken_.

56  {
57  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
58  vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexTag"));
59  photonToken_ = consumes<reco::PhotonCollection>(iConfig.getParameter<edm::InputTag>("photonTag"));
60  particleFlowToken_ = consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("particleFlowTag"));
61 
62  nameIsoCh_ = iConfig.getParameter<std::string>("nameValueMapIsoCh");
63  nameIsoPh_ = iConfig.getParameter<std::string>("nameValueMapIsoPh");
64  nameIsoNh_ = iConfig.getParameter<std::string>("nameValueMapIsoNh");
65 
66  produces<edm::ValueMap<double> >(nameIsoCh_);
67  produces<edm::ValueMap<double> >(nameIsoPh_);
68  produces<edm::ValueMap<double> >(nameIsoNh_);
69 
70  isolator.initializePhotonIsolation(kTRUE); //NOTE: this automatically set all the correct defaul veto values
71  isolator.setConeSize(0.3);
72 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::PhotonCollection > photonToken_
PFIsolationEstimator isolator
edm::EDGetTokenT< reco::PFCandidateCollection > particleFlowToken_
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
void initializePhotonIsolation(Bool_t bApplyVeto)
void setConeSize(float fValue=0.4)

◆ ~PhotonIsoProducer()

PhotonIsoProducer::~PhotonIsoProducer ( )
override

Definition at line 74 of file PhotonIsoProducer.cc.

74  {
75  // do anything here that needs to be done at desctruction time
76  // (e.g. close files, deallocate resources etc.)
77 }

Member Function Documentation

◆ filter()

bool PhotonIsoProducer::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDFilterBase.

Definition at line 84 of file PhotonIsoProducer.cc.

References PFIsolationEstimator::fGetIsolation(), edm::helper::Filler< Map >::fill(), PFIsolationEstimator::getIsolationCharged(), PFIsolationEstimator::getIsolationNeutral(), PFIsolationEstimator::getIsolationPhoton(), iEvent, edm::helper::Filler< Map >::insert(), isolator, eostools::move(), nameIsoCh_, nameIsoNh_, nameIsoPh_, particleFlowToken_, photonToken_, edm::Handle< T >::product(), verbose_, spclusmultinvestigator_cfi::vertexCollection, and vertexToken_.

84  {
85  std::unique_ptr<edm::ValueMap<double> > chIsoMap(new edm::ValueMap<double>());
86  edm::ValueMap<double>::Filler chFiller(*chIsoMap);
87 
88  std::unique_ptr<edm::ValueMap<double> > phIsoMap(new edm::ValueMap<double>());
89  edm::ValueMap<double>::Filler phFiller(*phIsoMap);
90 
91  std::unique_ptr<edm::ValueMap<double> > nhIsoMap(new edm::ValueMap<double>());
92  edm::ValueMap<double>::Filler nhFiller(*nhIsoMap);
93 
96 
98  iEvent.getByToken(photonToken_, phoCollection);
99  const reco::PhotonCollection* recoPho = phoCollection.product();
100 
101  // All PF Candidate for alternate isolation
103  iEvent.getByToken(particleFlowToken_, pfCandidatesH);
104  const reco::PFCandidateCollection thePfColl = *(pfCandidatesH.product());
105 
106  std::vector<double> chIsoValues;
107  std::vector<double> phIsoValues;
108  std::vector<double> nhIsoValues;
109  chIsoValues.reserve(phoCollection->size());
110  phIsoValues.reserve(phoCollection->size());
111  nhIsoValues.reserve(phoCollection->size());
112 
113  unsigned int ivtx = 0;
114  reco::VertexRef myVtxRef(vertexCollection, ivtx);
115 
116  for (reco::PhotonCollection::const_iterator aPho = recoPho->begin(); aPho != recoPho->end(); ++aPho) {
117  isolator.fGetIsolation(&*aPho, &thePfColl, myVtxRef, vertexCollection);
118 
119  if (verbose_) {
120  edm::LogPrint("PhotonIsoProducer") << " run " << iEvent.id().run() << " lumi " << iEvent.id().luminosityBlock()
121  << " event " << iEvent.id().event();
122  edm::LogPrint("PhotonIsoProducer") << " pt " << aPho->pt() << " eta " << aPho->eta() << " phi " << aPho->phi()
123  << " charge " << aPho->charge() << " : ";
124 
125  edm::LogPrint("PhotonIsoProducer") << " ChargedIso " << isolator.getIsolationCharged();
126  edm::LogPrint("PhotonIsoProducer") << " PhotonIso " << isolator.getIsolationPhoton();
127  edm::LogPrint("PhotonIsoProducer") << " NeutralHadron Iso " << isolator.getIsolationNeutral();
128  }
129 
130  chIsoValues.push_back(isolator.getIsolationCharged());
131  phIsoValues.push_back(isolator.getIsolationPhoton());
132  nhIsoValues.push_back(isolator.getIsolationNeutral());
133  }
134 
135  chFiller.insert(phoCollection, chIsoValues.begin(), chIsoValues.end());
136  chFiller.fill();
137 
138  phFiller.insert(phoCollection, phIsoValues.begin(), phIsoValues.end());
139  phFiller.fill();
140 
141  nhFiller.insert(phoCollection, nhIsoValues.begin(), nhIsoValues.end());
142  nhFiller.fill();
143 
144  iEvent.put(std::move(chIsoMap), nameIsoCh_);
145  iEvent.put(std::move(phIsoMap), nameIsoPh_);
146  iEvent.put(std::move(nhIsoMap), nameIsoNh_);
147 
148  return true;
149 }
T const * product() const
Definition: Handle.h:70
edm::EDGetTokenT< reco::PhotonCollection > photonToken_
int iEvent
Definition: GenABIO.cc:224
PFIsolationEstimator isolator
Log< level::Warning, true > LogPrint
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
edm::EDGetTokenT< reco::PFCandidateCollection > particleFlowToken_
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
float fGetIsolation(const reco::PFCandidate *pfCandidate, const reco::PFCandidateCollection *pfParticlesColl, reco::VertexRef vtx, edm::Handle< reco::VertexCollection > vertices)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ isolator

PFIsolationEstimator PhotonIsoProducer::isolator
private

Definition at line 42 of file PhotonIsoProducer.cc.

Referenced by filter(), and PhotonIsoProducer().

◆ nameIsoCh_

std::string PhotonIsoProducer::nameIsoCh_
private

Definition at line 38 of file PhotonIsoProducer.cc.

Referenced by filter(), and PhotonIsoProducer().

◆ nameIsoNh_

std::string PhotonIsoProducer::nameIsoNh_
private

Definition at line 40 of file PhotonIsoProducer.cc.

Referenced by filter(), and PhotonIsoProducer().

◆ nameIsoPh_

std::string PhotonIsoProducer::nameIsoPh_
private

Definition at line 39 of file PhotonIsoProducer.cc.

Referenced by filter(), and PhotonIsoProducer().

◆ particleFlowToken_

edm::EDGetTokenT<reco::PFCandidateCollection> PhotonIsoProducer::particleFlowToken_
private

Definition at line 37 of file PhotonIsoProducer.cc.

Referenced by filter(), and PhotonIsoProducer().

◆ photonToken_

edm::EDGetTokenT<reco::PhotonCollection> PhotonIsoProducer::photonToken_
private

Definition at line 36 of file PhotonIsoProducer.cc.

Referenced by filter(), and PhotonIsoProducer().

◆ verbose_

bool PhotonIsoProducer::verbose_
private

Definition at line 34 of file PhotonIsoProducer.cc.

Referenced by filter(), and PhotonIsoProducer().

◆ vertexToken_

edm::EDGetTokenT<reco::VertexCollection> PhotonIsoProducer::vertexToken_
private

Definition at line 35 of file PhotonIsoProducer.cc.

Referenced by filter(), and PhotonIsoProducer().