CMS 3D CMS Logo

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

Public Member Functions

 DeltaBetaWeights (const edm::ParameterSet &)
 
- 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)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

edm::InputTag pfCharged_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCharged_token
 
edm::InputTag pfPU_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > pfPU_token
 
edm::InputTag src_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > src_token
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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::global::EDProducerBase
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 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 19 of file DeltaBetaWeights.cc.

Constructor & Destructor Documentation

◆ DeltaBetaWeights()

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

Definition at line 35 of file DeltaBetaWeights.cc.

References pfCharged_, pfCharged_token, pfPU_, pfPU_token, src_, and src_token.

36  : src_(iConfig.getParameter<edm::InputTag>("src")),
37  pfCharged_(iConfig.getParameter<edm::InputTag>("chargedFromPV")),
38  pfPU_(iConfig.getParameter<edm::InputTag>("chargedFromPU")) {
39  produces<reco::PFCandidateCollection>();
40 
41  pfCharged_token = consumes<edm::View<reco::Candidate> >(pfCharged_);
42  pfPU_token = consumes<edm::View<reco::Candidate> >(pfPU_);
43  src_token = consumes<edm::View<reco::Candidate> >(src_);
44 
45  // pfCharged_token = consumes<reco::PFCandidateCollection>(pfCharged_);
46  // pfPU_token = consumes<reco::PFCandidateCollection>(pfPU_);
47  // src_token = consumes<reco::PFCandidateCollection>(src_);
48 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::View< reco::Candidate > > pfPU_token
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCharged_token
edm::InputTag pfCharged_
edm::InputTag pfPU_
edm::EDGetTokenT< edm::View< reco::Candidate > > src_token
edm::InputTag src_

Member Function Documentation

◆ produce()

void DeltaBetaWeights::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 54 of file DeltaBetaWeights.cc.

References HLTMuonOfflineAnalyzer_cfi::deltaR2, PVValHelper::eta, iEvent, dqm-mbProfile::log, eostools::move(), MillePedeFileConverter_cfg::out, reco::LeafCandidate::p4(), pfElectronTranslator_cfi::PFCandidate, pfCharged_token, pfPU_token, phi, reco::LeafCandidate::setP4(), reco::PFCandidate::setParticleType(), TrackRefitter_38T_cff::src, src_token, reco::PFCandidate::translatePdgIdToType(), and X.

54  {
55  using namespace edm;
56 
57  edm::View<reco::Candidate> const pfCharged = iEvent.get(pfCharged_token);
58  edm::View<reco::Candidate> const& pfPU = iEvent.get(pfPU_token);
60 
61  double sumNPU = .0;
62  double sumPU = .0;
63 
64  std::unique_ptr<reco::PFCandidateCollection> out(new reco::PFCandidateCollection);
65 
66  out->reserve(src.size());
67  for (const reco::Candidate& cand : src) {
68  if (cand.charge() != 0) {
69  // this part of code should be executed only if input collection is not entirely composed of neutral candidates, i.e. never by default
70  edm::LogWarning("DeltaBetaWeights")
71  << "Trying to reweight charged particle... saving it to output collection without any change";
72  out->emplace_back(cand.charge(), cand.p4(), reco::PFCandidate::ParticleType::X);
73  (out->back()).setParticleType((out->back()).translatePdgIdToType(cand.pdgId()));
74  continue;
75  }
76 
77  sumNPU = 1.0;
78  sumPU = 1.0;
79  double eta = cand.eta();
80  double phi = cand.phi();
81  for (const reco::Candidate& chCand : pfCharged) {
82  double sum = (chCand.pt() * chCand.pt()) / (deltaR2(eta, phi, chCand.eta(), chCand.phi()));
83  if (sum > 1.0)
84  sumNPU *= sum;
85  }
86  sumNPU = 0.5 * log(sumNPU);
87 
88  for (const reco::Candidate& puCand : pfPU) {
89  double sum = (puCand.pt() * puCand.pt()) / (deltaR2(eta, phi, puCand.eta(), puCand.phi()));
90  if (sum > 1.0)
91  sumPU *= sum;
92  }
93  sumPU = 0.5 * log(sumPU);
94 
96  neutral.setParticleType(neutral.translatePdgIdToType(cand.pdgId()));
97  if (sumNPU + sumPU > 0)
98  neutral.setP4(((sumNPU) / (sumNPU + sumPU)) * neutral.p4());
99  out->push_back(neutral);
100  }
101 
102  iEvent.put(std::move(out));
103 }
edm::EDGetTokenT< edm::View< reco::Candidate > > pfPU_token
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCharged_token
#define X(str)
Definition: MuonsGrabber.cc:38
const LorentzVector & p4() const final
four-momentum Lorentz vector
int iEvent
Definition: GenABIO.cc:224
void setParticleType(ParticleType type)
set Particle Type
Definition: PFCandidate.cc:278
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
edm::EDGetTokenT< edm::View< reco::Candidate > > src_token
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:231
HLT enums.
Log< level::Warning, false > LogWarning
void setP4(const LorentzVector &p4) final
set 4-momentum
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ pfCharged_

edm::InputTag DeltaBetaWeights::pfCharged_
private

Definition at line 27 of file DeltaBetaWeights.cc.

Referenced by DeltaBetaWeights().

◆ pfCharged_token

edm::EDGetTokenT<edm::View<reco::Candidate> > DeltaBetaWeights::pfCharged_token
private

Definition at line 30 of file DeltaBetaWeights.cc.

Referenced by DeltaBetaWeights(), and produce().

◆ pfPU_

edm::InputTag DeltaBetaWeights::pfPU_
private

Definition at line 28 of file DeltaBetaWeights.cc.

Referenced by DeltaBetaWeights().

◆ pfPU_token

edm::EDGetTokenT<edm::View<reco::Candidate> > DeltaBetaWeights::pfPU_token
private

Definition at line 31 of file DeltaBetaWeights.cc.

Referenced by DeltaBetaWeights(), and produce().

◆ src_

edm::InputTag DeltaBetaWeights::src_
private

Definition at line 26 of file DeltaBetaWeights.cc.

Referenced by DeltaBetaWeights().

◆ src_token

edm::EDGetTokenT<edm::View<reco::Candidate> > DeltaBetaWeights::src_token
private

Definition at line 32 of file DeltaBetaWeights.cc.

Referenced by DeltaBetaWeights(), and produce().