Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of weights in generator interfaces (53x backport) #7361

Merged
merged 1 commit into from
Feb 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions GeneratorInterface/Core/interface/HadronizerFilter.h
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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