ATLAS Offline Software
GenVertex.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_GENVERTEX_H
7 #define ATLASHEPMC_GENVERTEX_H
8 #ifdef HEPMC3
9 #include "HepMC3/GenVertex.h"
10 #include "HepMC3/PrintStreams.h"
11 #include "AtlasHepMC/Barcode.h"
12 namespace HepMC3 {
13 inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenVertex& v) { return v.particles_out().begin(); }
14 inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenVertex& v) { return v.particles_out().end(); }
15 inline std::vector<HepMC3::GenParticlePtr>::const_iterator begin(HepMC3::GenVertex& v) { return v.particles_out().begin(); }
16 inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenVertex& v) { return v.particles_out().end(); }
17 
20 inline std::ostream& operator<<(std::ostream& os, GenVertexPtr v) { ConstGenVertexPtr cv = v; Print::line(os,cv); return os; }
21 }
22 namespace HepMC {
25 inline GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos = HepMC3::FourVector::ZERO_VECTOR(),const int i=0) {
26  GenVertexPtr v=std::make_shared<HepMC3::GenVertex>(pos);
27  v->set_status(i);
28  return v;
29 }
30 
31 inline int barcode(const GenVertexPtr& p) {
32  if (!p) return 0;
33  auto e = p->parent_event();
34  if (!e) return 0;
35  std::shared_ptr<HepMC3::IntAttribute> barcode=e->attribute<HepMC3::IntAttribute>("barcode",p->id());
36  return barcode?(barcode->value()):p->id();
37 }
38 inline int barcode_or_id(const ConstGenVertexPtr& p) { return p->id();}
39 inline int barcode(const ConstGenVertexPtr& p) {
40  if (!p) return 0;
41  auto e = p->parent_event();
42  if (!e) return 0;
43  std::shared_ptr<HepMC3::IntAttribute> barcode=e->attribute<HepMC3::IntAttribute>("barcode",p->id());
44  return barcode?(barcode->value()):p->id();
45 }
46 inline int barcode(const HepMC3::GenVertex& p) {
47  auto e = p.parent_event();
48  if (!e) return 0;
49  std::shared_ptr<HepMC3::IntAttribute> barcode=e->attribute<HepMC3::IntAttribute>("barcode",p.id());
50  return barcode?(barcode->value()):p.id();
51 }
52 
53 using HepMC3::GenVertex;
54 }
55 #else
56 #include "HepMC/GenVertex.h"
57 #include "AtlasHepMC/Barcode.h"
58 namespace HepMC {
59 typedef HepMC::GenVertex* GenVertexPtr;
60 typedef const HepMC::GenVertex* ConstGenVertexPtr;
61 inline GenVertex::particles_out_const_iterator begin(const HepMC::GenVertex& v) { return v.particles_out_const_begin(); }
62 inline GenVertex::particles_out_const_iterator end(const HepMC::GenVertex& v) { return v.particles_out_const_end(); }
63 
64 inline GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos = HepMC::FourVector(0.0,0.0,0.0,0.0), const int i=0) {
65  return new HepMC::GenVertex(pos,i);
66 }
67 namespace Print {
68 inline void line(std::ostream& os,const GenVertex& v) {v.print(os);}
69 inline void line(std::ostream& os,const GenVertex* v) {v->print(os);}
70 }
71 inline int barcode_or_id(const ConstGenVertexPtr& p) { return p->barcode();}
72 inline std::ostream& operator<<( std::ostream& os, const GenVertex* v ) { if (v) return os<<(*v); else return os;}
73 }
74 #endif
75 #endif
HepMC::GenVertexPtr
HepMC::GenVertex * GenVertexPtr
Definition: GenVertex.h:59
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Barcode.h
GenVertex.h
HepMC::Print::line
void line(std::ostream &os, const GenEvent &e)
Definition: GenEvent.h:676
HepMC::end
GenVertex::particles_out_const_iterator end(const HepMC::GenVertex &v)
Definition: GenVertex.h:62
HepMC::operator<<
std::ostream & operator<<(std::ostream &os, const GenParticle *p)
Definition: GenParticle.h:47
HepMC::end
GenEvent::particle_iterator end(HepMC::GenEvent &e)
Definition: GenEvent.h:621
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
HepMC::newGenVertexPtr
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition: GenVertex.h:64
lumiFormat.i
int i
Definition: lumiFormat.py:85
HepMC::barcode_or_id
int barcode_or_id(const ConstGenParticlePtr &p)
Definition: GenParticle.h:42
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
HepMC::operator<<
std::ostream & operator<<(std::ostream &os, const GenVertex *v)
Definition: GenVertex.h:72
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
python.PyAthena.v
v
Definition: PyAthena.py:154
HepMC
Definition: Barcode.h:14
dqm_persistency::Print
void Print(const PParameter *param, TDirectory *topdir, Option_t *opt="")
Definition: dqm_persistency_impl.cxx:161
HepMC::begin
GenEvent::particle_iterator begin(HepMC::GenEvent &e)
Definition: GenEvent.h:620
HepMC::ConstGenVertexPtr
const HepMC::GenVertex * ConstGenVertexPtr
Definition: GenVertex.h:60
HepMC::begin
GenVertex::particles_out_const_iterator begin(const HepMC::GenVertex &v)
Definition: GenVertex.h:61
HepMC::Print::line
void line(std::ostream &os, const GenVertex *v)
Definition: GenVertex.h:69