File indexing completed on 2024-04-06 12:29:42
0001 #include <functional>
0002 #include <numeric>
0003 using std::ptrdiff_t;
0004
0005 #include <HepMC/GenEvent.h>
0006 #include <HepMC/WeightContainer.h>
0007 #include <HepMC/PdfInfo.h>
0008
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
0012
0013 using namespace edm;
0014 using namespace std;
0015
0016 GenEventInfoProduct::GenEventInfoProduct()
0017 : signalProcessID_(0), qScale_(-1.), alphaQCD_(-1.), alphaQED_(-1.), nMEPartons_(-1), nMEPartonsFiltered_(-1) {}
0018
0019 GenEventInfoProduct::GenEventInfoProduct(const HepMC::GenEvent *evt)
0020 : weights_(evt->weights().begin(), evt->weights().end()),
0021 signalProcessID_(evt->signal_process_id()),
0022 qScale_(evt->event_scale()),
0023 alphaQCD_(evt->alphaQCD()),
0024 alphaQED_(evt->alphaQED()),
0025 nMEPartons_(-1),
0026 nMEPartonsFiltered_(-1) {
0027 const HepMC::PdfInfo *hepPDF = evt->pdf_info();
0028 if (hepPDF) {
0029 PDF pdf;
0030
0031 pdf.id = std::make_pair(hepPDF->id1(), hepPDF->id2());
0032 pdf.x = std::make_pair(hepPDF->x1(), hepPDF->x2());
0033 pdf.xPDF = std::make_pair(hepPDF->pdf1(), hepPDF->pdf2());
0034 pdf.scalePDF = hepPDF->scalePDF();
0035
0036 setPDF(&pdf);
0037 }
0038 }
0039
0040 GenEventInfoProduct::GenEventInfoProduct(GenEventInfoProduct const &other)
0041 : weights_(other.weights_),
0042 signalProcessID_(other.signalProcessID_),
0043 qScale_(other.qScale_),
0044 alphaQCD_(other.alphaQCD_),
0045 alphaQED_(other.alphaQED_),
0046 binningValues_(other.binningValues_),
0047 DJRValues_(other.DJRValues_),
0048 nMEPartons_(other.nMEPartons_),
0049 nMEPartonsFiltered_(other.nMEPartons_) {
0050 setPDF(other.pdf());
0051 }
0052
0053 GenEventInfoProduct::GenEventInfoProduct(GenEventInfoProduct &&other)
0054 : weights_(std::move(other.weights_)),
0055 signalProcessID_(other.signalProcessID_),
0056 qScale_(other.qScale_),
0057 alphaQCD_(other.alphaQCD_),
0058 alphaQED_(other.alphaQED_),
0059 pdf_(other.pdf_.release()),
0060 binningValues_(std::move(other.binningValues_)),
0061 DJRValues_(std::move(other.DJRValues_)),
0062 nMEPartons_(other.nMEPartons_),
0063 nMEPartonsFiltered_(other.nMEPartons_) {}
0064
0065 GenEventInfoProduct::~GenEventInfoProduct() {}
0066
0067 GenEventInfoProduct &GenEventInfoProduct::operator=(GenEventInfoProduct const &other) {
0068 weights_ = other.weights_;
0069 signalProcessID_ = other.signalProcessID_;
0070 qScale_ = other.qScale_;
0071 alphaQCD_ = other.alphaQCD_;
0072 alphaQED_ = other.alphaQED_;
0073 binningValues_ = other.binningValues_;
0074 DJRValues_ = other.DJRValues_;
0075 nMEPartons_ = other.nMEPartons_;
0076 nMEPartonsFiltered_ = other.nMEPartonsFiltered_;
0077
0078 setPDF(other.pdf());
0079
0080 return *this;
0081 }
0082
0083 GenEventInfoProduct &GenEventInfoProduct::operator=(GenEventInfoProduct &&other) {
0084 weights_ = std::move(other.weights_);
0085 signalProcessID_ = other.signalProcessID_;
0086 qScale_ = other.qScale_;
0087 alphaQCD_ = other.alphaQCD_;
0088 alphaQED_ = other.alphaQED_;
0089 binningValues_ = std::move(other.binningValues_);
0090 DJRValues_ = std::move(other.DJRValues_);
0091 nMEPartons_ = other.nMEPartons_;
0092 nMEPartonsFiltered_ = other.nMEPartonsFiltered_;
0093 pdf_ = std::move(other.pdf_);
0094
0095 return *this;
0096 }
0097
0098 double GenEventInfoProduct::weightProduct() const {
0099 return std::accumulate(weights_.begin(), weights_.end(), 1., std::multiplies<double>());
0100 }