CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WeightManager.cc
Go to the documentation of this file.
4 
8 
9 
10 using namespace edm;
11 
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 }
20 
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 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< edm::InputTag > _genEventInfos
Definition: WeightManager.h:28
edm::InputTag _hepmcCollection
Definition: WeightManager.h:29
WeightManager(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double weight(const edm::Event &)