CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ISRWeightProducer Class Reference
Inheritance diagram for ISRWeightProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ISRWeightProducer (const edm::ParameterSet &)
 
 ~ISRWeightProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
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 beginJob () override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< reco::GenParticleCollectiongenToken_
 
std::vector< double > isrBinEdges_
 
std::vector< double > ptWeights_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 20 of file ISRWeightProducer.cc.

Constructor & Destructor Documentation

◆ ISRWeightProducer()

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

Definition at line 36 of file ISRWeightProducer.cc.

36  {
37  genToken_ = consumes<reco::GenParticleCollection>(
38  pset.getUntrackedParameter<edm::InputTag>("GenTag", edm::InputTag("genParticles")));
39 
40  // Pt bin edges
41  std::vector<double> defPtEdges;
42  defPtEdges.push_back(0.);
43  defPtEdges.push_back(999999.);
44  isrBinEdges_ = pset.getUntrackedParameter<std::vector<double> >("ISRBinEdges", defPtEdges);
45  unsigned int ninputs_expected = isrBinEdges_.size() - 1;
46 
47  // Distortions in muon momentum
48  std::vector<double> defWeights;
49  defWeights.push_back(1.);
50  ptWeights_ = pset.getUntrackedParameter<std::vector<double> >("PtWeights", defWeights);
51  if (ptWeights_.size() == 1 && ninputs_expected > 1) {
52  for (unsigned int i = 1; i < ninputs_expected; i++) {
53  ptWeights_.push_back(ptWeights_[0]);
54  }
55  }
56 
57  produces<double>();
58 }

References genToken_, mps_fire::i, isrBinEdges_, muonDTDigis_cfi::pset, and ptWeights_.

◆ ~ISRWeightProducer()

ISRWeightProducer::~ISRWeightProducer ( )
override

Definition at line 61 of file ISRWeightProducer.cc.

61 {}

Member Function Documentation

◆ beginJob()

void ISRWeightProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 64 of file ISRWeightProducer.cc.

64 {}

◆ endJob()

void ISRWeightProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 67 of file ISRWeightProducer.cc.

67 {}

◆ produce()

void ISRWeightProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 70 of file ISRWeightProducer.cc.

70  {
71  if (iEvent.isRealData())
72  return;
73 
75  iEvent.getByToken(genToken_, genParticles);
76  unsigned int gensize = genParticles->size();
77 
78  std::unique_ptr<double> weight(new double);
79 
80  // Set as default weight the asymptotic value at high pt (i.e. value of last bin)
81  (*weight) = ptWeights_[ptWeights_.size() - 1];
82 
83  unsigned int nbins = isrBinEdges_.size() - 1;
84  for (unsigned int i = 0; i < gensize; ++i) {
85  const reco::GenParticle& part = (*genParticles)[i];
86  int id = part.pdgId();
87  if (id != 23 && abs(id) != 24)
88  continue;
89  int status = part.status();
90  if (status != 3)
91  continue;
92  double pt = part.pt();
93  if (pt > isrBinEdges_[0] && pt < isrBinEdges_[nbins]) {
94  for (unsigned int j = 1; j <= nbins; ++j) {
95  if (pt > isrBinEdges_[j])
96  continue;
97  (*weight) = ptWeights_[j - 1];
98  break;
99  }
100  }
101  break;
102  }
103 
104  iEvent.put(std::move(weight));
105 }

References funct::abs(), genParticles2HepMC_cfi::genParticles, genToken_, mps_fire::i, iEvent, isrBinEdges_, dqmiolumiharvest::j, eostools::move(), LaserClient_cfi::nbins, reco::LeafCandidate::pdgId(), DiDispStaMuonMonitor_cfi::pt, ptWeights_, mps_update::status, and mps_merge::weight.

Member Data Documentation

◆ genToken_

edm::EDGetTokenT<reco::GenParticleCollection> ISRWeightProducer::genToken_
private

Definition at line 30 of file ISRWeightProducer.cc.

Referenced by ISRWeightProducer(), and produce().

◆ isrBinEdges_

std::vector<double> ISRWeightProducer::isrBinEdges_
private

Definition at line 31 of file ISRWeightProducer.cc.

Referenced by ISRWeightProducer(), and produce().

◆ ptWeights_

std::vector<double> ISRWeightProducer::ptWeights_
private

Definition at line 32 of file ISRWeightProducer.cc.

Referenced by ISRWeightProducer(), and produce().

mps_fire.i
i
Definition: mps_fire.py:428
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
reco::GenParticle
Definition: GenParticle.h:21
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
mps_update.status
status
Definition: mps_update.py:69
mps_merge.weight
weight
Definition: mps_merge.py:88
ISRWeightProducer::isrBinEdges_
std::vector< double > isrBinEdges_
Definition: ISRWeightProducer.cc:31
edm::Handle< reco::GenParticleCollection >
part
part
Definition: HCALResponse.h:20
ISRWeightProducer::genToken_
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
Definition: ISRWeightProducer.cc:30
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
reco::LeafCandidate::pdgId
int pdgId() const final
PDG identifier.
Definition: LeafCandidate.h:176
iEvent
int iEvent
Definition: GenABIO.cc:224
eostools.move
def move(src, dest)
Definition: eostools.py:511
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ISRWeightProducer::ptWeights_
std::vector< double > ptWeights_
Definition: ISRWeightProducer.cc:32
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27