CMS 3D CMS Logo

GenEventInfoProduct3.cc
Go to the documentation of this file.
1 #include <functional>
2 #include <numeric>
3 using std::ptrdiff_t;
4 
5 #include <HepMC3/GenEvent.h>
6 // #include <HepMC3/WeightContainer.h>
7 #include <HepMC3/GenPdfInfo.h>
8 
10 
12 
13 using namespace edm;
14 using namespace std;
15 
17  : signalProcessID_(0), qScale_(-1.), alphaQCD_(-1.), alphaQED_(-1.), nMEPartons_(-1), nMEPartonsFiltered_(-1) {}
18 
19 GenEventInfoProduct3::GenEventInfoProduct3(const HepMC3::GenEvent *evt)
20  : weights_(evt->weights().begin(), evt->weights().end()), nMEPartons_(-1), nMEPartonsFiltered_(-1) {
21  std::shared_ptr<HepMC3::IntAttribute> A_signal_process_id = evt->attribute<HepMC3::IntAttribute>("signal_process_id");
22  std::shared_ptr<HepMC3::DoubleAttribute> A_event_scale = evt->attribute<HepMC3::DoubleAttribute>("event_scale");
23  std::shared_ptr<HepMC3::DoubleAttribute> A_alphaQCD = evt->attribute<HepMC3::DoubleAttribute>("alphaQCD");
24  std::shared_ptr<HepMC3::DoubleAttribute> A_alphaQED = evt->attribute<HepMC3::DoubleAttribute>("alphaQED");
25  //std::shared_ptr<HepMC3::IntAttribute> A_mpi = evt->attribute<HepMC3::IntAttribute>("mpi");
26 
27  signalProcessID_ = A_signal_process_id ? (A_signal_process_id->value()) : 0;
28  qScale_ = A_event_scale ? (A_event_scale->value()) : 0.0;
29  alphaQCD_ = A_alphaQCD ? (A_alphaQCD->value()) : 0.0;
30  alphaQED_ = A_alphaQED ? (A_alphaQED->value()) : 0.0;
31 
32  std::shared_ptr<HepMC3::GenPdfInfo> A_pdf = evt->attribute<HepMC3::GenPdfInfo>("GenPdfInfo");
33  if (A_pdf) {
34  PDF pdf;
35  pdf.id = std::make_pair(A_pdf->parton_id[0], A_pdf->parton_id[1]);
36  pdf.x = std::make_pair(A_pdf->x[0], A_pdf->x[1]);
37  pdf.xPDF = std::make_pair(A_pdf->xf[0], A_pdf->xf[1]);
38  pdf.scalePDF = A_pdf->scale;
39  setPDF(&pdf);
40  }
41 }
42 
44  : weights_(other.weights_),
45  signalProcessID_(other.signalProcessID_),
46  qScale_(other.qScale_),
47  alphaQCD_(other.alphaQCD_),
48  alphaQED_(other.alphaQED_),
49  binningValues_(other.binningValues_),
50  DJRValues_(other.DJRValues_),
51  nMEPartons_(other.nMEPartons_),
52  nMEPartonsFiltered_(other.nMEPartons_) {
53  setPDF(other.pdf());
54 }
55 
57  : weights_(std::move(other.weights_)),
58  signalProcessID_(other.signalProcessID_),
59  qScale_(other.qScale_),
60  alphaQCD_(other.alphaQCD_),
61  alphaQED_(other.alphaQED_),
62  pdf_(other.pdf_.release()),
63  binningValues_(std::move(other.binningValues_)),
64  DJRValues_(std::move(other.DJRValues_)),
65  nMEPartons_(other.nMEPartons_),
66  nMEPartonsFiltered_(other.nMEPartons_) {}
67 
69 
71  weights_ = other.weights_;
72  signalProcessID_ = other.signalProcessID_;
73  qScale_ = other.qScale_;
74  alphaQCD_ = other.alphaQCD_;
75  alphaQED_ = other.alphaQED_;
76  binningValues_ = other.binningValues_;
77  DJRValues_ = other.DJRValues_;
78  nMEPartons_ = other.nMEPartons_;
79  nMEPartonsFiltered_ = other.nMEPartonsFiltered_;
80 
81  setPDF(other.pdf());
82 
83  return *this;
84 }
85 
87  weights_ = std::move(other.weights_);
88  signalProcessID_ = other.signalProcessID_;
89  qScale_ = other.qScale_;
90  alphaQCD_ = other.alphaQCD_;
91  alphaQED_ = other.alphaQED_;
92  binningValues_ = std::move(other.binningValues_);
93  DJRValues_ = std::move(other.DJRValues_);
94  nMEPartons_ = other.nMEPartons_;
95  nMEPartonsFiltered_ = other.nMEPartonsFiltered_;
96  pdf_ = std::move(other.pdf_);
97 
98  return *this;
99 }
100 
102  return std::accumulate(weights_.begin(), weights_.end(), 1., std::multiplies<double>());
103 }
void setPDF(const PDF *pdf)
std::pair< double, double > x
Definition: PdfInfo.h:13
const PDF * pdf() const
GenEventInfoProduct3 & operator=(const GenEventInfoProduct3 &other)
std::pair< double, double > xPDF
Definition: PdfInfo.h:14
std::vector< double > weights_
std::vector< float > DJRValues_
std::pair< int, int > id
Definition: PdfInfo.h:12
HLT enums.
std::vector< double > binningValues_
double scalePDF
Definition: PdfInfo.h:15
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< PDF > pdf_