ATLAS Offline Software
Loading...
Searching...
No Matches
GenVertex.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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"
12namespace HepMC3 {
13inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenVertex& v) { return v.particles_out().begin(); }
14inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenVertex& v) { return v.particles_out().end(); }
15inline std::vector<HepMC3::GenParticlePtr>::const_iterator begin(HepMC3::GenVertex& v) { return v.particles_out().begin(); }
16inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenVertex& v) { return v.particles_out().end(); }
17
20inline std::ostream& operator<<(std::ostream& os, GenVertexPtr v) { ConstGenVertexPtr cv = v; Print::line(os,std::move(cv)); return os; }
21}
22namespace HepMC {
23typedef HepMC3::GenVertexPtr GenVertexPtr;
24typedef HepMC3::ConstGenVertexPtr ConstGenVertexPtr;
25inline 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
31inline 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}
38inline int barcode_or_id(const ConstGenVertexPtr& p) { return p->id();}
39inline 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}
46inline 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
53using HepMC3::GenVertex;
54}
55#else
56#include "HepMC/GenVertex.h"
57#include "AtlasHepMC/Barcode.h"
58namespace HepMC {
59typedef HepMC::GenVertex* GenVertexPtr;
60typedef const HepMC::GenVertex* ConstGenVertexPtr;
61inline GenVertex::particles_out_const_iterator begin(const HepMC::GenVertex& v) { return v.particles_out_const_begin(); }
62inline GenVertex::particles_out_const_iterator end(const HepMC::GenVertex& v) { return v.particles_out_const_end(); }
63
64inline 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}
67namespace Print {
68inline void line(std::ostream& os,const GenVertex& v) {v.print(os);}
69inline void line(std::ostream& os,const GenVertex* v) {v->print(os);}
70}
71inline int barcode_or_id(const ConstGenVertexPtr& p) { return p->barcode();}
72inline std::ostream& operator<<( std::ostream& os, const GenVertex* v ) { if (v) return os<<(*v); else return os;}
73}
74#endif
75#endif
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
void line(std::ostream &os, const GenEvent &e)
Definition GenEvent.h:677
int barcode(const T *p)
Definition Barcode.h:16
GenEvent::particle_iterator begin(HepMC::GenEvent &e)
Definition GenEvent.h:621
GenEvent::particle_iterator end(HepMC::GenEvent &e)
Definition GenEvent.h:622
std::ostream & operator<<(std::ostream &os, const GenParticle *p)
Definition GenParticle.h:47
int barcode_or_id(const ConstGenParticlePtr &p)
Definition GenParticle.h:42
HepMC::GenVertex * GenVertexPtr
Definition GenVertex.h:59
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition GenVertex.h:64
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60