Skip to content

Commit

Permalink
Merge pull request #7348 from bendavid/hepmcweightfix
Browse files Browse the repository at this point in the history
Fix handling of weights in generator interfaces
  • Loading branch information
cmsbuild authored and bendavid committed Jan 25, 2015
1 parent 202e45c commit 2f457f0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 2 additions & 4 deletions GeneratorInterface/Core/interface/HadronizerFilter.h
Expand Up @@ -224,12 +224,10 @@ namespace edm
double multihadweight = double(naccept)/double(nAttempts_);

//adjust weight for GenEventInfoProduct
std::vector<double> genEventInfoWeights = finalGenEventInfo->weights();
genEventInfoWeights.push_back(multihadweight);
finalGenEventInfo->setWeights(genEventInfoWeights);
finalGenEventInfo->weights()[0] *= multihadweight;

//adjust weight for HepMC GenEvent (used e.g for RIVET)
finalEvent->weights().push_back(multihadweight);
finalEvent->weights()[0] *= multihadweight;
}


Expand Down
10 changes: 7 additions & 3 deletions GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc
Expand Up @@ -484,7 +484,11 @@ bool Pythia8Hadronizer::hadronize()

bool py8next = fMasterGen->next();

double mergeweight = fMasterGen.get()->info.mergingWeight();
double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
if (fMergingHook) {
mergeweight *= fMergingHook->getNormFactor();
}


//protect against 0-weight from ckkw or similar
if (!py8next || std::abs(mergeweight)==0.)
Expand Down Expand Up @@ -516,9 +520,9 @@ bool Pythia8Hadronizer::hadronize()
return false;
}

//add ckkw merging weight
//add ckkw/umeps/unlops merging weight
if (mergeweight!=1.) {
event()->weights().push_back(mergeweight);
event()->weights()[0] *= mergeweight;
}

if (fEmissionVetoHook) {
Expand Down
Expand Up @@ -25,8 +25,12 @@ class GenEventInfoProduct {

// getters

std::vector<double> &weights() { return weights_; }
const std::vector<double> &weights() const { return weights_; }
double weight() const;

double weight() const { return weights_.empty() ? 1.0 : weights_[0]; }

double weightProduct() const;

unsigned int signalProcessID() const { return signalProcessID_; }

Expand Down
Expand Up @@ -74,7 +74,7 @@ GenEventInfoProduct &GenEventInfoProduct::operator = (GenEventInfoProduct const
return *this;
}

double GenEventInfoProduct::weight() const
double GenEventInfoProduct::weightProduct() const
{
return std::accumulate(weights_.begin(), weights_.end(),
1., std::multiplies<double>());
Expand Down

0 comments on commit 2f457f0

Please sign in to comment.