Public Member Functions | |
ISRWeightProducer (const edm::ParameterSet &) | |
~ISRWeightProducer () | |
Private Member Functions | |
virtual void | beginJob () |
virtual void | endJob () |
virtual void | produce (edm::Event &, const edm::EventSetup &) override |
Private Attributes | |
edm::InputTag | genTag_ |
std::vector< double > | isrBinEdges_ |
std::vector< double > | ptWeights_ |
Definition at line 20 of file ISRWeightProducer.cc.
ISRWeightProducer::ISRWeightProducer | ( | const edm::ParameterSet & | pset | ) | [explicit] |
Definition at line 38 of file ISRWeightProducer.cc.
References genTag_, edm::ParameterSet::getUntrackedParameter(), i, isrBinEdges_, and ptWeights_.
{ genTag_ = pset.getUntrackedParameter<edm::InputTag> ("GenTag", edm::InputTag("genPArticles")); // Pt bin edges std::vector<double> defPtEdges; defPtEdges.push_back(0.); defPtEdges.push_back(999999.); isrBinEdges_ = pset.getUntrackedParameter<std::vector<double> > ("ISRBinEdges",defPtEdges); unsigned int ninputs_expected = isrBinEdges_.size()-1; // Distortions in muon momentum std::vector<double> defWeights; defWeights.push_back(1.); ptWeights_ = pset.getUntrackedParameter<std::vector<double> > ("PtWeights",defWeights); if (ptWeights_.size()==1 && ninputs_expected>1) { for (unsigned int i=1; i<ninputs_expected; i++){ ptWeights_.push_back(ptWeights_[0]);} } produces<double>(); }
ISRWeightProducer::~ISRWeightProducer | ( | ) |
Definition at line 60 of file ISRWeightProducer.cc.
{}
void ISRWeightProducer::beginJob | ( | void | ) | [private, virtual] |
void ISRWeightProducer::endJob | ( | void | ) | [private, virtual] |
void ISRWeightProducer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | |||
) | [override, private, virtual] |
Implements edm::EDProducer.
Definition at line 69 of file ISRWeightProducer.cc.
References abs, genParticleCandidates2GenParticles_cfi::genParticles, genTag_, edm::Event::getByLabel(), i, isrBinEdges_, edm::EventBase::isRealData(), j, pileupCalc::nbins, reco::LeafCandidate::pdgId(), reco::LeafCandidate::pt(), ptWeights_, edm::Event::put(), ntuplemaker::status, reco::LeafCandidate::status(), and histoStyle::weight.
{ if (iEvent.isRealData()) return; edm::Handle<reco::GenParticleCollection> genParticles; iEvent.getByLabel(genTag_, genParticles); unsigned int gensize = genParticles->size(); std::auto_ptr<double> weight (new double); // Set as default weight the asymptotic value at high pt (i.e. value of last bin) (*weight) = ptWeights_[ptWeights_.size()-1]; unsigned int nbins = isrBinEdges_.size()-1; for(unsigned int i = 0; i<gensize; ++i) { const reco::GenParticle& part = (*genParticles)[i]; int id = part.pdgId(); if (id!=23 && abs(id)!=24) continue; int status = part.status(); if (status!=3) continue; double pt = part.pt(); if (pt>isrBinEdges_[0] && pt<isrBinEdges_[nbins]) { for (unsigned int j=1; j<=nbins; ++j) { if (pt>isrBinEdges_[j]) continue; (*weight) = ptWeights_[j-1]; break; } } break; } iEvent.put(weight); }
edm::InputTag ISRWeightProducer::genTag_ [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().