File indexing completed on 2023-10-25 10:03:49
0001 #include <functional>
0002 #include <numeric>
0003 using std::ptrdiff_t;
0004
0005 #include <HepMC3/GenEvent.h>
0006
0007 #include <HepMC3/GenPdfInfo.h>
0008
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct3.h"
0012
0013 using namespace edm;
0014 using namespace std;
0015
0016 GenEventInfoProduct3::GenEventInfoProduct3()
0017 : signalProcessID_(0), qScale_(-1.), alphaQCD_(-1.), alphaQED_(-1.), nMEPartons_(-1), nMEPartonsFiltered_(-1) {}
0018
0019 GenEventInfoProduct3::GenEventInfoProduct3(const HepMC3::GenEvent *evt)
0020 : weights_(evt->weights().begin(), evt->weights().end()), nMEPartons_(-1), nMEPartonsFiltered_(-1) {
0021 std::shared_ptr<HepMC3::IntAttribute> A_signal_process_id = evt->attribute<HepMC3::IntAttribute>("signal_process_id");
0022 std::shared_ptr<HepMC3::DoubleAttribute> A_event_scale = evt->attribute<HepMC3::DoubleAttribute>("event_scale");
0023 std::shared_ptr<HepMC3::DoubleAttribute> A_alphaQCD = evt->attribute<HepMC3::DoubleAttribute>("alphaQCD");
0024 std::shared_ptr<HepMC3::DoubleAttribute> A_alphaQED = evt->attribute<HepMC3::DoubleAttribute>("alphaQED");
0025
0026
0027 signalProcessID_ = A_signal_process_id ? (A_signal_process_id->value()) : 0;
0028 qScale_ = A_event_scale ? (A_event_scale->value()) : 0.0;
0029 alphaQCD_ = A_alphaQCD ? (A_alphaQCD->value()) : 0.0;
0030 alphaQED_ = A_alphaQED ? (A_alphaQED->value()) : 0.0;
0031
0032 std::shared_ptr<HepMC3::GenPdfInfo> A_pdf = evt->attribute<HepMC3::GenPdfInfo>("GenPdfInfo");
0033 if (A_pdf) {
0034 PDF pdf;
0035 pdf.id = std::make_pair(A_pdf->parton_id[0], A_pdf->parton_id[1]);
0036 pdf.x = std::make_pair(A_pdf->x[0], A_pdf->x[1]);
0037 pdf.xPDF = std::make_pair(A_pdf->xf[0], A_pdf->xf[1]);
0038 pdf.scalePDF = A_pdf->scale;
0039 setPDF(&pdf);
0040 }
0041 }
0042
0043 GenEventInfoProduct3::GenEventInfoProduct3(GenEventInfoProduct3 const &other)
0044 : weights_(other.weights_),
0045 signalProcessID_(other.signalProcessID_),
0046 qScale_(other.qScale_),
0047 alphaQCD_(other.alphaQCD_),
0048 alphaQED_(other.alphaQED_),
0049 binningValues_(other.binningValues_),
0050 DJRValues_(other.DJRValues_),
0051 nMEPartons_(other.nMEPartons_),
0052 nMEPartonsFiltered_(other.nMEPartons_) {
0053 setPDF(other.pdf());
0054 }
0055
0056 GenEventInfoProduct3::GenEventInfoProduct3(GenEventInfoProduct3 &&other)
0057 : weights_(std::move(other.weights_)),
0058 signalProcessID_(other.signalProcessID_),
0059 qScale_(other.qScale_),
0060 alphaQCD_(other.alphaQCD_),
0061 alphaQED_(other.alphaQED_),
0062 pdf_(other.pdf_.release()),
0063 binningValues_(std::move(other.binningValues_)),
0064 DJRValues_(std::move(other.DJRValues_)),
0065 nMEPartons_(other.nMEPartons_),
0066 nMEPartonsFiltered_(other.nMEPartons_) {}
0067
0068 GenEventInfoProduct3::~GenEventInfoProduct3() {}
0069
0070 GenEventInfoProduct3 &GenEventInfoProduct3::operator=(GenEventInfoProduct3 const &other) {
0071 weights_ = other.weights_;
0072 signalProcessID_ = other.signalProcessID_;
0073 qScale_ = other.qScale_;
0074 alphaQCD_ = other.alphaQCD_;
0075 alphaQED_ = other.alphaQED_;
0076 binningValues_ = other.binningValues_;
0077 DJRValues_ = other.DJRValues_;
0078 nMEPartons_ = other.nMEPartons_;
0079 nMEPartonsFiltered_ = other.nMEPartonsFiltered_;
0080
0081 setPDF(other.pdf());
0082
0083 return *this;
0084 }
0085
0086 GenEventInfoProduct3 &GenEventInfoProduct3::operator=(GenEventInfoProduct3 &&other) {
0087 weights_ = std::move(other.weights_);
0088 signalProcessID_ = other.signalProcessID_;
0089 qScale_ = other.qScale_;
0090 alphaQCD_ = other.alphaQCD_;
0091 alphaQED_ = other.alphaQED_;
0092 binningValues_ = std::move(other.binningValues_);
0093 DJRValues_ = std::move(other.DJRValues_);
0094 nMEPartons_ = other.nMEPartons_;
0095 nMEPartonsFiltered_ = other.nMEPartonsFiltered_;
0096 pdf_ = std::move(other.pdf_);
0097
0098 return *this;
0099 }
0100
0101 double GenEventInfoProduct3::weightProduct() const {
0102 return std::accumulate(weights_.begin(), weights_.end(), 1., std::multiplies<double>());
0103 }