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 Attributes
WeightManager Class Reference

#include <WeightManager.h>

Public Member Functions

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

Private Attributes

std::vector< edm::InputTag_genEventInfos
 
edm::InputTag _hepmcCollection
 
bool _useHepMC
 

Detailed Description

Definition at line 17 of file WeightManager.h.

Constructor & Destructor Documentation

WeightManager::WeightManager ( const edm::ParameterSet iConfig)

Definition at line 12 of file WeightManager.cc.

References _genEventInfos, _hepmcCollection, _useHepMC, and edm::ParameterSet::getParameter().

12  :
13 _useHepMC(iConfig.getParameter<bool>("UseWeightFromHepMC"))
14 {
15  if (_useHepMC)
16  _hepmcCollection = iConfig.getParameter<InputTag>("hepmcCollection");
17  else
18  _genEventInfos = iConfig.getParameter<std::vector<InputTag> >("genEventInfos");
19 }
T getParameter(std::string const &) const
std::vector< edm::InputTag > _genEventInfos
Definition: WeightManager.h:28
edm::InputTag _hepmcCollection
Definition: WeightManager.h:29
WeightManager::~WeightManager ( )
inline

Definition at line 22 of file WeightManager.h.

22 {};

Member Function Documentation

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

Definition at line 21 of file WeightManager.cc.

References _genEventInfos, _hepmcCollection, _useHepMC, edm::Event::getByLabel(), i, and info.

Referenced by cuy.ValElement::__init__(), cuy.additionElement::__init__(), cuy.superimposeElement::__init__(), cuy.graphElement::__init__(), VVVValidation::analyze(), BasicHepMCHeavyIonValidation::analyze(), DrellYanValidation::analyze(), BasicHepMCValidation::analyze(), WValidation::analyze(), HiggsValidation::analyze(), BasicGenParticleValidation::analyze(), MBUEandQCDValidation::analyze(), DuplicationChecker::analyze(), and TauValidation::analyze().

21  {
22  if (_useHepMC){
24  iEvent.getByLabel(_hepmcCollection, evt);
25  const HepMC::GenEvent *myGenEvent = evt->GetEvent();
26 
27  double weight = 1.;
28  if (myGenEvent->weights().size() > 0)
29  weight = myGenEvent->weights()[0];
30  return weight;
31  } else {
32  double weight = 1.;
33  for (unsigned int i = 0; i < _genEventInfos.size(); ++i){
35  iEvent.getByLabel(_genEventInfos[i], info);
36  weight *= info->weight();
37  }
38  return weight;
39  }
40 }
int i
Definition: DBlmapReader.cc:9
std::vector< edm::InputTag > _genEventInfos
Definition: WeightManager.h:28
edm::InputTag _hepmcCollection
Definition: WeightManager.h:29
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
double weight(const edm::Event &)

Member Data Documentation

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

Definition at line 28 of file WeightManager.h.

Referenced by weight(), and WeightManager().

edm::InputTag WeightManager::_hepmcCollection
private

Definition at line 29 of file WeightManager.h.

Referenced by weight(), and WeightManager().

bool WeightManager::_useHepMC
private

Definition at line 27 of file WeightManager.h.

Referenced by weight(), and WeightManager().