CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
WeightManager Class Reference

#include <WeightManager.h>

Public Member Functions

double weight (const edm::Event &)
 
 WeightManager (const edm::ParameterSet &, edm::ConsumesCollector iC)
 
 ~WeightManager ()
 

Private Attributes

std::vector< edm::InputTag_genEventInfos
 
edm::InputTag _hepmcCollection
 
bool _useHepMC
 
std::vector< edm::EDGetTokenT< std::vector< edm::InputTag > > > genEventInfosTokens_
 
edm::EDGetTokenT< edm::HepMCProducthepmcCollectionToken_
 

Detailed Description

Definition at line 20 of file WeightManager.h.

Constructor & Destructor Documentation

WeightManager::WeightManager ( const edm::ParameterSet iConfig,
edm::ConsumesCollector  iC 
)

Definition at line 12 of file WeightManager.cc.

References _genEventInfos, _hepmcCollection, _useHepMC, edm::ConsumesCollector::consumes(), genEventInfosTokens_, edm::ParameterSet::getParameter(), hepmcCollectionToken_, and mps_fire::i.

12  :
13 _useHepMC(iConfig.getParameter<bool>("UseWeightFromHepMC"))
14 {
15  if (_useHepMC){
16  _hepmcCollection = iConfig.getParameter<InputTag>("hepmcCollection");
18  }
19  else{
20  _genEventInfos = iConfig.getParameter<std::vector<InputTag> >("genEventInfos");
21  for(unsigned int i=0; i<_genEventInfos.size();i++) genEventInfosTokens_.push_back(iC.consumes<std::vector<InputTag> >(_genEventInfos[i]));
22  }
23 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< edm::InputTag > _genEventInfos
Definition: WeightManager.h:31
edm::InputTag _hepmcCollection
Definition: WeightManager.h:32
std::vector< edm::EDGetTokenT< std::vector< edm::InputTag > > > genEventInfosTokens_
Definition: WeightManager.h:35
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
Definition: WeightManager.h:34
WeightManager::~WeightManager ( )
inline

Definition at line 25 of file WeightManager.h.

References mps_merge::weight.

25 {};

Member Function Documentation

double WeightManager::weight ( const edm::Event iEvent)

Definition at line 25 of file WeightManager.cc.

References _useHepMC, genEventInfosTokens_, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), hepmcCollectionToken_, mps_fire::i, info(), and GenEventInfoProduct::weight().

Referenced by WValidation::analyze(), BasicHepMCHeavyIonValidation::analyze(), DrellYanValidation::analyze(), BasicGenParticleValidation::analyze(), BasicHepMCValidation::analyze(), MBUEandQCDValidation::analyze(), HiggsValidation::analyze(), and DuplicationChecker::analyze().

25  {
26  if (_useHepMC){
28  iEvent.getByToken(hepmcCollectionToken_, evt);
29  const HepMC::GenEvent *myGenEvent = evt->GetEvent();
30 
31  double weight = 1.;
32  if (!myGenEvent->weights().empty())
33  weight = myGenEvent->weights()[0];
34  return weight;
35  } else {
36  double weight = 1.;
37  for (unsigned int i = 0; i < genEventInfosTokens_.size(); ++i){
39  iEvent.getByToken(genEventInfosTokens_[i], info);
40  weight *= info->weight();
41  }
42  return weight;
43  }
44 }
static const TGPicture * info(bool iBackgroundIsBlack)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Definition: weight.py:1
std::vector< edm::EDGetTokenT< std::vector< edm::InputTag > > > genEventInfosTokens_
Definition: WeightManager.h:35
double weight() const
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
Definition: WeightManager.h:34
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
double weight(const edm::Event &)

Member Data Documentation

std::vector<edm::InputTag> WeightManager::_genEventInfos
private

Definition at line 31 of file WeightManager.h.

Referenced by WeightManager().

edm::InputTag WeightManager::_hepmcCollection
private

Definition at line 32 of file WeightManager.h.

Referenced by WeightManager().

bool WeightManager::_useHepMC
private

Definition at line 30 of file WeightManager.h.

Referenced by weight(), and WeightManager().

std::vector<edm::EDGetTokenT<std::vector<edm::InputTag> > > WeightManager::genEventInfosTokens_
private

Definition at line 35 of file WeightManager.h.

Referenced by weight(), and WeightManager().

edm::EDGetTokenT<edm::HepMCProduct> WeightManager::hepmcCollectionToken_
private

Definition at line 34 of file WeightManager.h.

Referenced by weight(), and WeightManager().