ATLAS Offline Software
GenEvent.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 /* Author: Andrii Verbytskyi andrii.verbytskyi@mpp.mpg.de */
5 
6 #ifndef ATLASHEPMC_GENEVENT_H
7 #define ATLASHEPMC_GENEVENT_H
8 #ifdef HEPMC3
9 #undef private
10 #undef protected
11 #include "HepMC3/GenEvent.h"
12 #include "HepMC3/GenHeavyIon.h"
13 #include "HepMC3/GenPdfInfo.h"
14 #include "HepMC3/PrintStreams.h"
15 #include "AtlasHepMC/Barcode.h"
16 #include "AtlasHepMC/GenVertex.h"
17 #include "AtlasHepMC/GenParticle.h"
19 
20 #include <unordered_map>
21 
22 namespace HepMC3 {
23 inline std::vector<HepMC3::GenParticlePtr>::const_iterator begin(HepMC3::GenEvent& e) { return e.particles().begin(); }
24 inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenEvent& e) { return e.particles().end(); }
25 inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenEvent& e) { return e.particles().begin(); }
26 inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenEvent& e) { return e.particles().end(); }
27 }
28 
29 namespace HepMC {
30 using Print=HepMC3::Print;
31 using GenHeavyIon=HepMC3::GenHeavyIon;
32 using GenEvent=HepMC3::GenEvent;
33 
34 class GenEventBarcodes : public HepMC3::Attribute
35 {
36 public:
37  virtual bool from_string(const std::string & /*att*/) override { return false; }
38  virtual bool to_string(std::string &att) const override
39  {
40  att = "GenEventBarcodes";
41  return true;
42  }
43  ConstGenVertexPtr barcode_to_vertex (int id) const {
44  auto it = m_vertexBC.find (id);
45  if (it != m_vertexBC.end()) return it->second;
46  return nullptr;
47  }
49  auto it = m_vertexBC.find (id);
50  if (it != m_vertexBC.end()) return it->second;
51  return nullptr;
52  }
54  auto it = m_particleBC.find (id);
55  if (it != m_particleBC.end()) return it->second;
56  return nullptr;
57  }
59  auto it = m_particleBC.find (id);
60  if (it != m_particleBC.end()) return it->second;
61  return nullptr;
62  }
63 
64  void add (GenVertexPtr p) {
65  if (!p) return;
66  auto barcode = p->attribute<HepMC3::IntAttribute>("barcode");
67  if (barcode) {
68  m_vertexBC[barcode->value()] = p;
69  }
70  }
71 
72  void remove (GenVertexPtr p) {
73  if (!p) return;
74  auto barcode = p->attribute<HepMC3::IntAttribute>("barcode");
75  if (barcode) {
76  auto it = m_vertexBC.find (barcode->value());
77  if (it != m_vertexBC.end()) {
78  m_vertexBC.erase (it);
79  }
80  }
81  }
82 
83  void add (GenParticlePtr p) {
84  if (!p) return;
85  auto barcode = p->attribute<HepMC3::IntAttribute>("barcode");
86  if (barcode) {
87  m_particleBC[barcode->value()] = p;
88  }
89  }
90 
91  void remove (GenParticlePtr p) {
92  if (!p) return;
93  auto barcode = p->attribute<HepMC3::IntAttribute>("barcode");
94  if (barcode) {
95  auto it = m_particleBC.find (barcode->value());
96  if (it != m_particleBC.end()) {
97  m_particleBC.erase (it);
98  }
99  }
100  }
101 
102  std::map<int, ConstGenVertexPtr> barcode_to_vertex_map() const {
103  std::map<int, ConstGenVertexPtr> ret;
104  for (const auto &bcvertpair: m_vertexBC)
105  ret.insert({bcvertpair.first,std::const_pointer_cast<const HepMC3::GenVertex>(bcvertpair.second)});
106  return ret;
107  }
108  std::map<int, ConstGenParticlePtr> barcode_to_particle_map() const {
109  std::map<int, ConstGenParticlePtr> ret;
110  for (const auto &bcpartpair: m_particleBC)
111  ret.insert({bcpartpair.first,std::const_pointer_cast<const HepMC3::GenParticle>(bcpartpair.second)});
112  return ret;
113  }
114  std::map<int,int> id_to_barcode_map() const {
115  std::map<int, int> ret;
116  for (const auto &bcvertpair: m_vertexBC) ret.insert({bcvertpair.second->id(),bcvertpair.first});
117  for (const auto &bcpartpair: m_particleBC) ret.insert({bcpartpair.second->id(),bcpartpair.first});
118  return ret;
119  }
120 
121 
122  void fillAttribute(GenEvent* e) {
123  const auto eventAttributes = e->attributes(); // this makes a copy
124  const auto barcodeAttributeIt = eventAttributes.find("barcode");
125  const bool hasBarcodeAttribute = barcodeAttributeIt != eventAttributes.end();
126 
127  const auto &particles = e->particles();
128  for (size_t i = 1; i <= particles.size(); i++) {
129  if (hasBarcodeAttribute && barcodeAttributeIt->second.count(i) > 0) {
130  const auto &ptr = barcodeAttributeIt->second.at(i);
131  if (ptr->is_parsed()) {
132  m_particleBC[std::dynamic_pointer_cast<HepMC3::IntAttribute>(ptr)->value()] = ptr->particle();
133  }
134  else {
135  m_particleBC[std::atoi(ptr->unparsed_string().c_str())] = ptr->particle();
136  }
137  } else {
138  m_particleBC[i] = particles[i-1];
139  }
140  }
141  const auto &vertices = e->vertices();
142  for (size_t i = 1; i <= vertices.size(); i++) {
143  if (hasBarcodeAttribute && barcodeAttributeIt->second.count(-i) > 0) {
144  const auto &ptr = barcodeAttributeIt->second.at(-i);
145  if (ptr->is_parsed()) {
146  m_vertexBC[std::dynamic_pointer_cast<HepMC3::IntAttribute>(ptr)->value()] = ptr->vertex();
147  }
148  else {
149  m_vertexBC[std::atoi(ptr->unparsed_string().c_str())] = ptr->vertex();
150  }
151  } else {
152  m_vertexBC[-i] = vertices[i-1];
153  }
154  }
155  set_is_parsed(true);
156  }
157 
158 private:
159  std::unordered_map<int, GenVertexPtr> m_vertexBC;
160  std::unordered_map<int, GenParticlePtr> m_particleBC;
161 };
162 
168 class ShadowParticle : public HepMC3::Attribute {
169 public:
170 
172  ShadowParticle() {}
173 
175  ShadowParticle(ConstGenParticlePtr p)
176  : Attribute(), m_shadow(p) {}
177 
179  virtual bool from_string(const std::string &) override { return false; }
180 
182  virtual bool to_string(std::string &att) const override
183  {
184  att = "ShadowParticle";
185  return true;
186  }
188  ConstGenParticlePtr value() const {
189  return m_shadow;
190  }
191 
192 private:
193 
194  ConstGenParticlePtr m_shadow;
195 };
196 
197 inline bool set_ll_event_number(HepMC3::GenEvent* e, long long int num){
198  e->add_attribute("long_long_event_number", std::make_shared<HepMC3::LongLongAttribute>(num));
199  return true;
200 }
201 inline long long int get_ll_event_number(const HepMC3::GenEvent* e){
202  auto at = e->attribute<HepMC3::LongLongAttribute>("long_long_event_number");
203  return at?at->value():e->event_number();
204 }
205 
206 inline std::map<std::string, std::size_t> weights_map(const HepMC3::GenEvent* e) {
207  std::map<std::string, std::size_t> ret;
208  auto run = e->run_info();
209  if (!run) return ret;
210  std::vector<std::string> names = run->weight_names();
211  for (const auto& name: names) ret[name] = run->weight_index(name);
212  return ret;
213 }
214 
215 inline std::vector<HepMC3::GenParticlePtr>::const_iterator begin(HepMC3::GenEvent& e) { return e.particles().begin(); }
216 inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenEvent& e) { return e.particles().end(); }
217 inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenEvent& e) { return e.particles().begin(); }
218 inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenEvent& e) { return e.particles().end(); }
219 
220 inline GenEvent* newGenEvent(const int signal_process_id, const int event_number ) { // TODO Update event_number to long long int?
221  GenEvent* e= new GenEvent();
222  std::shared_ptr<HepMC3::IntAttribute> signal_process_id_A = std::make_shared<HepMC3::IntAttribute>(signal_process_id);
223  e->add_attribute("signal_process_id",signal_process_id_A);
224  e->add_attribute("barcodes", std::make_shared<GenEventBarcodes>());
225  e->set_event_number(event_number);
226  return e;
227 }
228 
229 inline GenEvent* copyemptyGenEvent(const GenEvent* inEvt) {
230  GenEvent* e= new GenEvent();
231  e->set_event_number(inEvt->event_number());
232  e->weights()=inEvt->weights();
233  auto a_mpi = inEvt->attribute<HepMC3::IntAttribute>("mpi");
234  if (a_mpi) e->add_attribute("mpi",std::make_shared<HepMC3::IntAttribute>(*a_mpi));
235  auto a_signal_process_id = inEvt->attribute<HepMC3::IntAttribute>("signal_process_id");
236  if (a_signal_process_id) e->add_attribute("signal_process_id",std::make_shared<HepMC3::IntAttribute>(*a_signal_process_id));
237  auto a_event_scale = inEvt->attribute<HepMC3::DoubleAttribute>("event_scale");
238  if (a_event_scale) e->add_attribute("event_scale",std::make_shared<HepMC3::DoubleAttribute>(*a_event_scale));
239  auto a_alphaQCD = inEvt->attribute<HepMC3::DoubleAttribute>("alphaQCD");
240  if (a_alphaQCD) e->add_attribute("alphaQCD",std::make_shared<HepMC3::DoubleAttribute>(*a_alphaQCD));
241  auto a_alphaQED = inEvt->attribute<HepMC3::DoubleAttribute>("alphaQED");
242  if (a_alphaQED) e->add_attribute("alphaQED",std::make_shared<HepMC3::DoubleAttribute>(*a_alphaQED));
243  auto a_pi = inEvt->pdf_info();
244  if (a_pi) e->set_pdf_info(std::make_shared<HepMC3::GenPdfInfo>(*a_pi));
245  auto a_hi = inEvt->heavy_ion();
246  if (a_hi) e->set_heavy_ion(std::make_shared<HepMC3::GenHeavyIon>(*a_hi));
247  auto a_random_states = inEvt->attribute<HepMC3::VectorLongIntAttribute>("random_states");
248  if (a_random_states) e->add_attribute("random_states",std::make_shared<HepMC3::VectorLongIntAttribute>(*a_random_states));
249  e->add_attribute("barcodes", std::make_shared<GenEventBarcodes>());
250  return e;
251 }
252 
253 inline void fillBarcodesAttribute(GenEvent* e) {
254  auto barcodes = e->attribute<GenEventBarcodes> ("barcodes");
255  if (!barcodes) {
256  barcodes = std::make_shared<GenEventBarcodes>();
257  e->add_attribute("barcodes", barcodes);
258  }
259  // force re-parsing as calling barcodes->is_parsed() returns true here
260  barcodes->fillAttribute(e);
261 }
262 
263 inline ConstGenVertexPtr barcode_to_vertex(const GenEvent* e, int id ) {
264  // Prefer to use optimized GenEvent barcodes attribute
265  const auto &barcodes = e->attribute<GenEventBarcodes> ("barcodes");
266  if (barcodes) {
267  ConstGenVertexPtr ptr = barcodes->barcode_to_vertex (id);
268  if (ptr) return ptr;
269  }
270  // Fallback to unoptimized GenVertex barcode attribute
271  const auto eventAttributes = e->attributes(); // this makes a copy
272  const auto barcodeAttributeIt = eventAttributes.find("barcode");
273  const bool hasBarcodeAttribute = barcodeAttributeIt != eventAttributes.end();
274 
275  const auto &vertices = e->vertices();
276  if (hasBarcodeAttribute) {
277  for (size_t i = 1; i <= vertices.size(); i++) {
278  const auto &ptrIt = barcodeAttributeIt->second.find(-i);
279  if (ptrIt != barcodeAttributeIt->second.end()) {
280  const auto &ptr = ptrIt->second;
281  if (ptr->is_parsed()) {
282  if (id == std::dynamic_pointer_cast<HepMC3::IntAttribute>(ptr)->value()) {
283  return ptr->vertex();
284  }
285  }
286  else {
287  if (id == std::atoi(ptr->unparsed_string().c_str())) {
288  return ptr->vertex();
289  }
290  }
291  }
292  }
293  }
294  // No barcodes attribute, so assume that we are passing the id member variable instead of a barcode
295  if (-id > 0 && -id <= static_cast<int>(vertices.size())) {
296  if (!vertices[-id-1]->attribute<HepMC3::IntAttribute>("barcode")) {
297  return vertices[-id-1];
298  }
299  }
300  return HepMC3::ConstGenVertexPtr();
301 }
302 
303 inline ConstGenParticlePtr barcode_to_particle(const GenEvent* e, int id ) {
304  // Prefer to use optimized GenEvent barcodes attribute
305  const auto &barcodes = e->attribute<GenEventBarcodes> ("barcodes");
306  if (barcodes) {
307  ConstGenParticlePtr ptr = barcodes->barcode_to_particle (id);
308  if (ptr) return ptr;
309  }
310  // Fallback to unoptimized GenParticle barcode attribute
311  const auto eventAttributes = e->attributes(); // this makes a copy
312  const auto barcodeAttributeIt = eventAttributes.find("barcode");
313  const bool hasBarcodeAttribute = barcodeAttributeIt != eventAttributes.end();
314 
315  const auto &particles = e->particles();
316  if (hasBarcodeAttribute) {
317  for (size_t i = 1; i <= particles.size(); i++) {
318  const auto &ptrIt = barcodeAttributeIt->second.find(i);
319  if (ptrIt != barcodeAttributeIt->second.end()) {
320  const auto &ptr = ptrIt->second;
321  if (ptr->is_parsed()) {
322  if (id == std::dynamic_pointer_cast<HepMC3::IntAttribute>(ptr)->value()) {
323  return ptr->particle();
324  }
325  }
326  else {
327  if (id == std::atoi(ptr->unparsed_string().c_str())) {
328  return ptr->particle();
329  }
330  }
331  }
332  }
333  }
334  // No barcodes attribute, so assume that we are passing the id member variable instead of a barcode
335  if (id > 0 && id <= static_cast<int>(particles.size())) {
336  if (!particles[id-1]->attribute<HepMC3::IntAttribute>("barcode")) {
337  return particles[id-1];
338  }
339  }
341 }
342 
343 inline GenVertexPtr barcode_to_vertex(GenEvent* e, int id ) {
344  // Prefer to use optimized GenEvent barcodes attribute
345  const auto &barcodes = e->attribute<GenEventBarcodes> ("barcodes");
346  if (barcodes) {
347  GenVertexPtr ptr = barcodes->barcode_to_vertex (id);
348  if (ptr) return ptr;
349  }
350  // Fallback to unoptimized GenVertex barcode attribute
351  const auto eventAttributes = e->attributes(); // this makes a copy
352  const auto barcodeAttributeIt = eventAttributes.find("barcode");
353  const bool hasBarcodeAttribute = barcodeAttributeIt != eventAttributes.end();
354 
355  const auto &vertices = e->vertices();
356  if (hasBarcodeAttribute) {
357  for (size_t i = 1; i <= vertices.size(); i++) {
358  const auto &ptrIt = barcodeAttributeIt->second.find(-i);
359  if (ptrIt != barcodeAttributeIt->second.end()) {
360  const auto &ptr = ptrIt->second;
361  if (ptr->is_parsed()) {
362  if (id == std::dynamic_pointer_cast<HepMC3::IntAttribute>(ptr)->value()) {
363  return ptr->vertex();
364  }
365  }
366  else {
367  if (id == std::atoi(ptr->unparsed_string().c_str())) {
368  return ptr->vertex();
369  }
370  }
371  }
372  }
373  }
374  // No barcodes attribute, so assume that we are passing the id member variable instead of a barcode
375  if (-id > 0 && -id <= static_cast<int>(vertices.size())) {
376  if (!vertices[-id-1]->attribute<HepMC3::IntAttribute>("barcode")) {
377  return vertices[-id-1];
378  }
379  }
380  return HepMC3::GenVertexPtr();
381 }
382 
383 inline GenParticlePtr barcode_to_particle(GenEvent* e, int id ) {
384  // Prefer to use optimized GenEvent barcodes attribute
385  const auto &barcodes = e->attribute<GenEventBarcodes> ("barcodes");
386  if (barcodes) {
387  GenParticlePtr ptr = barcodes->barcode_to_particle (id);
388  if (ptr) return ptr;
389  }
390  // Fallback to unoptimized GenParticle barcode attribute
391  const auto eventAttributes = e->attributes(); // this makes a copy
392  const auto barcodeAttributeIt = eventAttributes.find("barcode");
393  const bool hasBarcodeAttribute = barcodeAttributeIt != eventAttributes.end();
394 
395  const auto &particles = e->particles();
396  if (hasBarcodeAttribute) {
397  for (size_t i = 1; i <= particles.size(); i++) {
398  const auto &ptrIt = barcodeAttributeIt->second.find(i);
399  if (ptrIt != barcodeAttributeIt->second.end()) {
400  const auto &ptr = ptrIt->second;
401  if (ptr->is_parsed()) {
402  if (id == std::dynamic_pointer_cast<HepMC3::IntAttribute>(ptr)->value()) {
403  return ptr->particle();
404  }
405  }
406  else {
407  if (id == std::atoi(ptr->unparsed_string().c_str())) {
408  return ptr->particle();
409  }
410  }
411  }
412  }
413  }
414  // No barcodes attribute, so assume that we are passing the id member variable instead of a barcode
415  if (id > 0 && id <= static_cast<int>(particles.size())) {
416  if (!particles[id-1]->attribute<HepMC3::IntAttribute>("barcode")) {
417  return particles[id-1];
418  }
419  }
420  return HepMC3::GenParticlePtr();
421 }
422 
423 inline int mpi(const GenEvent& evt) {
424  std::shared_ptr<HepMC3::IntAttribute> A_mpi=evt.attribute<HepMC3::IntAttribute>("mpi");
425  return A_mpi?(A_mpi->value()):0;
426 }
427 inline int mpi(const GenEvent* evt) {
428  std::shared_ptr<HepMC3::IntAttribute> A_mpi=evt->attribute<HepMC3::IntAttribute>("mpi");
429  return A_mpi?(A_mpi->value()):0;
430 }
431 
432 inline int signal_process_id(const GenEvent& evt) {
433  std::shared_ptr<HepMC3::IntAttribute> A_signal_process_id=evt.attribute<HepMC3::IntAttribute>("signal_process_id");
434  return A_signal_process_id?(A_signal_process_id->value()):0;
435 }
436 inline int signal_process_id(const GenEvent* evt) {
437  std::shared_ptr<HepMC3::IntAttribute> A_signal_process_id=evt->attribute<HepMC3::IntAttribute>("signal_process_id");
438  return A_signal_process_id?(A_signal_process_id->value()):0;
439 }
440 inline void set_signal_process_id(GenEvent* e, const int i=0) {
441  std::shared_ptr<HepMC3::IntAttribute> signal_process_id = std::make_shared<HepMC3::IntAttribute>(i);
442  e->add_attribute("signal_process_id",signal_process_id);
443 }
444 inline void set_mpi(GenEvent* e, const int i=0) {
445  std::shared_ptr<HepMC3::IntAttribute> mpi = std::make_shared<HepMC3::IntAttribute>(i);
446  e->add_attribute("mpi",mpi);
447 }
448 inline void set_random_states(GenEvent* e, std::vector<long int>& a) {
449  e->add_attribute("random_states",std::make_shared<HepMC3::VectorLongIntAttribute>(a));
450 }
451 template <class T> void set_signal_process_vertex(GenEvent* e, T& v) {
452  if (!v || !e) return;
453 /* AV: HepMC2 adds the vertex to event */
454  e->add_vertex(v);
455  v->add_attribute("signal_process_vertex",std::make_shared<HepMC3::IntAttribute>(1));
456 }
457 inline ConstGenVertexPtr signal_process_vertex(const GenEvent* e) { for (auto v: e->vertices()) if (v->attribute<HepMC3::IntAttribute>("signal_process_vertex")) return v; return nullptr; }
458 inline GenVertexPtr signal_process_vertex(GenEvent* e) { for (auto v: e->vertices()) if (v->attribute<HepMC3::IntAttribute>("signal_process_vertex")) return v; return nullptr; }
459 inline bool valid_beam_particles(const GenEvent* e) {
460  if (!e) return false;
461  size_t nBeams = 0;
462  for (const auto& p : e->beams()) { if (p->status() == 4) ++nBeams; }
463  if (nBeams != 2) return false;
464  return true;
465 }
466 
467 template <class T> bool suggest_barcode(T& p, int i) {
468  if (!p->parent_event()) return false;
469  auto barcodes = p->parent_event()->template attribute<GenEventBarcodes> ("barcodes");
470  if (!barcodes) {
471  barcodes = std::make_shared<GenEventBarcodes>();
472  p->parent_event()->add_attribute("barcodes", barcodes);
473  }
474  barcodes->remove(p);
475  bool ret = p->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(i));
476  if (barcodes && ret) barcodes->add(p);
477  return ret;
478 }
479 
480 }
481 
482 #else
483 
484 #include "HepMC/GenEvent.h"
485 #include "HepMC/GenVertex.h"
486 #include "AtlasHepMC/GenVertex.h"
487 #include "AtlasHepMC/Barcode.h"
488 #include <memory>
489 namespace HepMC {
490 inline bool set_ll_event_number(HepMC::GenEvent* e, long long int num){
491  if (num > std::numeric_limits<int>::max()) return false;
492  e->set_event_number((int)num);
493  return true;
494 }
495 inline long long int get_ll_event_number(const HepMC::GenEvent* e){
496  return e->event_number();
497 }
498 inline GenEvent::particle_iterator begin(HepMC::GenEvent& e) { return e.particles_begin(); }
499 inline GenEvent::particle_iterator end(HepMC::GenEvent& e) { return e.particles_end(); }
500 inline GenEvent::particle_const_iterator begin(const HepMC::GenEvent& e) { return e.particles_begin(); }
501 inline GenEvent::particle_const_iterator end(const HepMC::GenEvent& e) { return e.particles_end(); }
502 inline GenEvent* newGenEvent(const int a, const int b ) { return new GenEvent(a,b); }
503 inline GenVertex* signal_process_vertex(const GenEvent* e) { return e->signal_process_vertex(); }
504 inline void fillBarcodesAttribute(GenEvent* ) { }
505 inline GenVertex* barcode_to_vertex(const GenEvent* e, int id ) {return e->barcode_to_vertex(id);}
506 inline GenParticle* barcode_to_particle(const GenEvent* e, int id ) {return e->barcode_to_particle(id);}
507 inline int mpi(const GenEvent& e) {
508  return e.mpi();
509 }
510 inline int mpi(const GenEvent* e) {
511  return e->mpi();
512 }
513 inline int signal_process_id(const GenEvent& e) {
514  return e.signal_process_id();
515 }
516 inline int signal_process_id(const GenEvent* e) {
517  return e->signal_process_id();
518 }
519 inline void set_signal_process_id(GenEvent* e, const int i) {
520  e->set_signal_process_id(i);
521 }
522 inline void set_mpi(GenEvent* e, const int i) {
523  e->set_mpi(i);
524 }
525 template <class T> void set_random_states(GenEvent* e, std::vector<T> a) {
526  e->set_random_states(a);
527 }
528 template <class T> void set_signal_process_vertex(GenEvent* e, T v) {
529  e->set_signal_process_vertex(v);
530 }
531 inline GenEvent* copyemptyGenEvent(const GenEvent* inEvt) {
532  HepMC::GenEvent* outEvt = new HepMC::GenEvent( inEvt->signal_process_id(), inEvt->event_number() );
533  outEvt->set_mpi ( inEvt->mpi() );
534  outEvt->set_event_scale ( inEvt->event_scale() );
535  outEvt->set_alphaQCD ( inEvt->alphaQCD() );
536  outEvt->set_alphaQED ( inEvt->alphaQED() );
537  outEvt->weights() = inEvt->weights();
538  outEvt->set_random_states( inEvt->random_states() );
539  if ( nullptr != inEvt->heavy_ion() ) {
540  outEvt->set_heavy_ion ( *inEvt->heavy_ion() );
541  }
542  if ( nullptr != inEvt->pdf_info() ) {
543  outEvt->set_pdf_info ( *inEvt->pdf_info() );
544  }
545  return outEvt;
546 }
547 
548 template <class T> bool suggest_barcode(T& p, int i) {return p.suggest_barcode(i);}
549 template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);}
550 //Smart pointers should not be used with HepMC2. But it happens.
551 template <> inline bool suggest_barcode<std::unique_ptr<HepMC::GenParticle> >(std::unique_ptr<HepMC::GenParticle>& p, int i) {return p->suggest_barcode(i);}
552 
553 namespace Print {
554 inline void line(std::ostream& os,const GenEvent& e) {e.print(os);}
555 inline void line(std::ostream& os,const GenEvent* e) {e->print(os);}
556 inline void content(std::ostream& os,const GenEvent& e) {e.print(os);}
557 inline void content(std::ostream& os,const GenEvent* e) {e->print(os);}
558 }
559 inline bool valid_beam_particles(const GenEvent* e) {return e->valid_beam_particles();}
560 }
561 #include "AtlasHepMC/SimpleVector.h"
562 #endif
563 #endif
HepMC::GenVertexPtr
HepMC::GenVertex * GenVertexPtr
Definition: GenVertex.h:59
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
HepMC::suggest_barcode
bool suggest_barcode(T &p, int i)
Definition: GenEvent.h:548
HepMC::set_ll_event_number
bool set_ll_event_number(HepMC::GenEvent *e, long long int num)
Definition: GenEvent.h:490
GenEvent.h
HepMC::Print::content
void content(std::ostream &os, const GenEvent &e)
Definition: GenEvent.h:556
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
Barcode.h
HepMC::signal_process_id
int signal_process_id(const GenEvent &e)
Definition: GenEvent.h:513
HepMC::get_ll_event_number
long long int get_ll_event_number(const HepMC::GenEvent *e)
Definition: GenEvent.h:495
GenVertex.h
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
skel.it
it
Definition: skel.GENtoEVGEN.py:423
HepMC::newGenEvent
GenEvent * newGenEvent(const int a, const int b)
Definition: GenEvent.h:502
athena.value
value
Definition: athena.py:124
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
HepMC::Print::line
void line(std::ostream &os, const GenEvent &e)
Definition: GenEvent.h:554
HepMC::fillBarcodesAttribute
void fillBarcodesAttribute(GenEvent *)
Definition: GenEvent.h:504
GenParticle.h
HepMC::end
GenEvent::particle_iterator end(HepMC::GenEvent &e)
Definition: GenEvent.h:499
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
HepMC::begin
GenEvent::particle_const_iterator begin(const HepMC::GenEvent &e)
Definition: GenEvent.h:500
HepMC::set_signal_process_vertex
void set_signal_process_vertex(GenEvent *e, T v)
Definition: GenEvent.h:528
SimpleVector.h
HepMC::barcode_to_particle
GenParticle * barcode_to_particle(const GenEvent *e, int id)
Definition: GenEvent.h:506
python.Dumpers.barcodes
def barcodes(beg, end, sz)
Definition: Dumpers.py:2800
lumiFormat.i
int i
Definition: lumiFormat.py:85
ret
T ret(T t)
Definition: rootspy.cxx:260
python.subdetectors.mmg.names
names
Definition: mmg.py:8
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
run
Definition: run.py:1
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
python.PyAthena.v
v
Definition: PyAthena.py:154
a
TList * a
Definition: liststreamerinfos.cxx:10
HepMC
Definition: Barcode.h:14
HepMC::valid_beam_particles
bool valid_beam_particles(const GenEvent *e)
Definition: GenEvent.h:559
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
dqm_persistency::Print
void Print(const PParameter *param, TDirectory *topdir, Option_t *opt="")
Definition: dqm_persistency_impl.cxx:161
HepMC::barcode_to_vertex
GenVertex * barcode_to_vertex(const GenEvent *e, int id)
Definition: GenEvent.h:505
HepMC::begin
GenEvent::particle_iterator begin(HepMC::GenEvent &e)
Definition: GenEvent.h:498
HepMC::mpi
int mpi(const GenEvent &e)
Definition: GenEvent.h:507
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
HepMC::ConstGenVertexPtr
const HepMC::GenVertex * ConstGenVertexPtr
Definition: GenVertex.h:60
HepMC::copyemptyGenEvent
GenEvent * copyemptyGenEvent(const GenEvent *inEvt)
Definition: GenEvent.h:531
HepMC::end
GenEvent::particle_const_iterator end(const HepMC::GenEvent &e)
Definition: GenEvent.h:501
HepMC::set_signal_process_id
void set_signal_process_id(GenEvent *e, const int i)
Definition: GenEvent.h:519
HepMC::set_mpi
void set_mpi(GenEvent *e, const int i)
Definition: GenEvent.h:522
GenParticle
@ GenParticle
Definition: TruthClasses.h:30
HepMC::set_random_states
void set_random_states(GenEvent *e, std::vector< T > a)
Definition: GenEvent.h:525
HepMC::signal_process_vertex
GenVertex * signal_process_vertex(const GenEvent *e)
Definition: GenEvent.h:503