CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ISRWeightProducer Class Reference
Inheritance diagram for ISRWeightProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 ISRWeightProducer (const edm::ParameterSet &)
 
 ~ISRWeightProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag genTag_
 
std::vector< double > isrBinEdges_
 
std::vector< double > ptWeights_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 20 of file ISRWeightProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 38 of file ISRWeightProducer.cc.

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

38  {
39  genTag_ = pset.getUntrackedParameter<edm::InputTag> ("GenTag", edm::InputTag("genPArticles"));
40 
41  // Pt bin edges
42  std::vector<double> defPtEdges;
43  defPtEdges.push_back(0.);
44  defPtEdges.push_back(999999.);
45  isrBinEdges_ = pset.getUntrackedParameter<std::vector<double> > ("ISRBinEdges",defPtEdges);
46  unsigned int ninputs_expected = isrBinEdges_.size()-1;
47 
48  // Distortions in muon momentum
49  std::vector<double> defWeights;
50  defWeights.push_back(1.);
51  ptWeights_ = pset.getUntrackedParameter<std::vector<double> > ("PtWeights",defWeights);
52  if (ptWeights_.size()==1 && ninputs_expected>1) {
53  for (unsigned int i=1; i<ninputs_expected; i++){ ptWeights_.push_back(ptWeights_[0]);}
54  }
55 
56  produces<double>();
57 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< double > isrBinEdges_
std::vector< double > ptWeights_
edm::InputTag genTag_
ISRWeightProducer::~ISRWeightProducer ( )

Definition at line 60 of file ISRWeightProducer.cc.

60 {}

Member Function Documentation

void ISRWeightProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 63 of file ISRWeightProducer.cc.

63 {}
void ISRWeightProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 66 of file ISRWeightProducer.cc.

66 {}
void ISRWeightProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
privatevirtual

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(), reco::LeafCandidate::status(), ntuplemaker::status, and CommonMethods::weight().

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

69  {
70 
71  if (iEvent.isRealData()) return;
72 
74  iEvent.getByLabel(genTag_, genParticles);
75  unsigned int gensize = genParticles->size();
76 
77  std::auto_ptr<double> weight (new double);
78 
79  // Set as default weight the asymptotic value at high pt (i.e. value of last bin)
80  (*weight) = ptWeights_[ptWeights_.size()-1];
81 
82  unsigned int nbins = isrBinEdges_.size()-1;
83  for(unsigned int i = 0; i<gensize; ++i) {
84  const reco::GenParticle& part = (*genParticles)[i];
85  int id = part.pdgId();
86  if (id!=23 && abs(id)!=24) continue;
87  int status = part.status();
88  if (status!=3) continue;
89  double pt = part.pt();
90  if (pt>isrBinEdges_[0] && pt<isrBinEdges_[nbins]) {
91  for (unsigned int j=1; j<=nbins; ++j) {
92  if (pt>isrBinEdges_[j]) continue;
93  (*weight) = ptWeights_[j-1];
94  break;
95  }
96  }
97  break;
98  }
99 
100  iEvent.put(weight);
101 }
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const
PDG identifier.
virtual int status() const
status word
#define abs(x)
Definition: mlp_lapack.h:159
bool isRealData() const
Definition: EventBase.h:60
std::vector< double > isrBinEdges_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual double pt() const
transverse momentum
part
Definition: HCALResponse.h:21
std::vector< double > ptWeights_
edm::InputTag genTag_
tuple status
Definition: ntuplemaker.py:245

Member Data Documentation

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().