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 ()
 
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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

Detailed Description

Definition at line 20 of file ISRWeightProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 37 of file ISRWeightProducer.cc.

References genToken_, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, isrBinEdges_, and ptWeights_.

37  {
38  genToken_ = consumes<reco::GenParticleCollection>(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++){ ptWeights_.push_back(ptWeights_[0]);}
53  }
54 
55  produces<double>();
56 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > isrBinEdges_
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
std::vector< double > ptWeights_
ISRWeightProducer::~ISRWeightProducer ( )
override

Definition at line 59 of file ISRWeightProducer.cc.

59 {}

Member Function Documentation

void ISRWeightProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 62 of file ISRWeightProducer.cc.

62 {}
void ISRWeightProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 65 of file ISRWeightProducer.cc.

65 {}
void ISRWeightProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprivate

Definition at line 68 of file ISRWeightProducer.cc.

References funct::abs(), DEFINE_FWK_MODULE, GenHFHadronMatcher_cfi::genParticles, genToken_, edm::Event::getByToken(), mps_fire::i, isrBinEdges_, edm::EventBase::isRealData(), eostools::move(), pileupCalc::nbins, reco::LeafCandidate::pdgId(), EnergyCorrector::pt, reco::LeafCandidate::pt(), ptWeights_, edm::Event::put(), mps_update::status, reco::LeafCandidate::status(), and mps_merge::weight.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

68  {
69 
70  if (iEvent.isRealData()) return;
71 
73  iEvent.getByToken(genToken_, genParticles);
74  unsigned int gensize = genParticles->size();
75 
76  std::unique_ptr<double> weight (new double);
77 
78  // Set as default weight the asymptotic value at high pt (i.e. value of last bin)
79  (*weight) = ptWeights_[ptWeights_.size()-1];
80 
81  unsigned int nbins = isrBinEdges_.size()-1;
82  for(unsigned int i = 0; i<gensize; ++i) {
83  const reco::GenParticle& part = (*genParticles)[i];
84  int id = part.pdgId();
85  if (id!=23 && abs(id)!=24) continue;
86  int status = part.status();
87  if (status!=3) continue;
88  double pt = part.pt();
89  if (pt>isrBinEdges_[0] && pt<isrBinEdges_[nbins]) {
90  for (unsigned int j=1; j<=nbins; ++j) {
91  if (pt>isrBinEdges_[j]) continue;
92  (*weight) = ptWeights_[j-1];
93  break;
94  }
95  }
96  break;
97  }
98 
99  iEvent.put(std::move(weight));
100 }
int pdgId() const final
PDG identifier.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
double pt() const final
transverse momentum
Definition: weight.py:1
bool isRealData() const
Definition: EventBase.h:64
std::vector< double > isrBinEdges_
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
part
Definition: HCALResponse.h:20
std::vector< double > ptWeights_
int status() const final
status word
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

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

Definition at line 30 of file ISRWeightProducer.cc.

Referenced by ISRWeightProducer(), and produce().

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

Definition at line 31 of file ISRWeightProducer.cc.

Referenced by ISRWeightProducer(), and produce().

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

Definition at line 32 of file ISRWeightProducer.cc.

Referenced by ISRWeightProducer(), and produce().