CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::HepMCProduct
hepmcCollectionToken_
 

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.

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

Definition at line 23 of file WeightManager.h.

23 {};

Member Function Documentation

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

Definition at line 24 of file WeightManager.cc.

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

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

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

Member Data Documentation

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

Definition at line 29 of file WeightManager.h.

Referenced by WeightManager().

edm::InputTag WeightManager::_hepmcCollection
private

Definition at line 30 of file WeightManager.h.

Referenced by WeightManager().

bool WeightManager::_useHepMC
private

Definition at line 28 of file WeightManager.h.

Referenced by weight(), and WeightManager().

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

Definition at line 33 of file WeightManager.h.

Referenced by weight(), and WeightManager().

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

Definition at line 32 of file WeightManager.h.

Referenced by weight(), and WeightManager().