File indexing completed on 2024-07-03 04:18:17
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() {}
0057
0058 GenEventInfoProduct3 &GenEventInfoProduct3::operator=(GenEventInfoProduct3 const &other) {
0059 weights_ = other.weights_;
0060 signalProcessID_ = other.signalProcessID_;
0061 qScale_ = other.qScale_;
0062 alphaQCD_ = other.alphaQCD_;
0063 alphaQED_ = other.alphaQED_;
0064 binningValues_ = other.binningValues_;
0065 DJRValues_ = other.DJRValues_;
0066 nMEPartons_ = other.nMEPartons_;
0067 nMEPartonsFiltered_ = other.nMEPartonsFiltered_;
0068
0069 setPDF(other.pdf());
0070
0071 return *this;
0072 }
0073
0074 double GenEventInfoProduct3::weightProduct() const {
0075 return std::accumulate(weights_.begin(), weights_.end(), 1., std::multiplies<double>());
0076 }