CMS 3D CMS Logo

Public Member Functions | Private Attributes

WeightManager Class Reference

#include <WeightManager.h>

List of all members.

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

                                                       :
_useHepMC(iConfig.getParameter<bool>("UseWeightFromHepMC"))
{
  if (_useHepMC)
    _hepmcCollection = iConfig.getParameter<InputTag>("hepmcCollection");
  else  
    _genEventInfos = iConfig.getParameter<std::vector<InputTag> >("genEventInfos");
}
WeightManager::~WeightManager ( ) [inline]

Definition at line 22 of file WeightManager.h.

{};

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 WValidation::analyze(), MBUEandQCDValidation::analyze(), BasicGenParticleValidation::analyze(), DuplicationChecker::analyze(), TauValidation::analyze(), DrellYanValidation::analyze(), BasicHepMCValidation::analyze(), and HiggsValidation::analyze().

                                               {
  if (_useHepMC){
    edm::Handle<HepMCProduct> evt;
    iEvent.getByLabel(_hepmcCollection, evt);
    const HepMC::GenEvent *myGenEvent = evt->GetEvent();

    double weight = 1.;
    if (myGenEvent->weights().size() > 0)
      weight = myGenEvent->weights()[0];
    return weight;
  } else {
    double weight = 1.;
    for (unsigned int i = 0; i < _genEventInfos.size(); ++i){
      edm::Handle<GenEventInfoProduct> info;
      iEvent.getByLabel(_genEventInfos[i], info);
      weight *= info->weight();
    }
    return weight;
  }
}

Member Data Documentation

Definition at line 28 of file WeightManager.h.

Referenced by weight(), and WeightManager().

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