From 05a597ae7e074569e0fc74b6b053b819f7ca6136 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <averbyts@cern.ch> Date: Fri, 4 Dec 2020 17:29:43 +0100 Subject: [PATCH 01/11] Make suggest_barcode return bool --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index 0faf0b32fe73..bf9344e348ee 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -35,7 +35,7 @@ inline int barcode(const HepMC3::GenParticle* p){ std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); return barcode?(barcode->value()):p->id(); } -template <class T> void suggest_barcode(T p, int i){p->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(i));} +template <class T> bool suggest_barcode(T p, int i){return p->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(i));} using HepMC3::GenParticle; } #else @@ -48,9 +48,9 @@ inline GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom = HepMC::Fo } inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } -template <class T> void suggest_barcode(T p, int i){p->suggest_barcode(i);} -inline void suggest_barcode(GenParticle p, int i){p.suggest_barcode(i);} -template <class T> void suggest_barcode(T* p, int i){p->suggest_barcode(i);} +template <class T> bool suggest_barcode(T p, int i){return p->suggest_barcode(i);} +inline bool suggest_barcode(GenParticle p, int i){return p.suggest_barcode(i);} +template <class T> bool suggest_barcode(T* p, int i){return p->suggest_barcode(i);} namespace Print { inline void line(std::ostream& os,const GenParticle& p){p.print(os);} inline void line(std::ostream& os,const GenParticle* p){p->print(os);} -- GitLab From 2129c5e66a441c3099fd84743c4da3e30b680c90 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <averbyts@cern.ch> Date: Fri, 4 Dec 2020 17:44:30 +0100 Subject: [PATCH 02/11] Run astyle on AtlasHepMC headers --- Generators/AtlasHepMC/AtlasHepMC/Flow.h | 66 +++++---- Generators/AtlasHepMC/AtlasHepMC/GenEvent.h | 130 +++++++++--------- .../AtlasHepMC/AtlasHepMC/GenParticle.h | 46 +++---- Generators/AtlasHepMC/AtlasHepMC/GenVertex.h | 55 ++++---- .../AtlasHepMC/AtlasHepMC/HEPEVT_Wrapper.h | 3 +- .../AtlasHepMC/AtlasHepMC/IO_GenEvent.h | 3 +- Generators/AtlasHepMC/AtlasHepMC/PdfInfo.h | 6 +- .../AtlasHepMC/AtlasHepMC/Polarization.h | 45 +++--- .../AtlasHepMC/AtlasHepMC/SimpleVector.h | 3 +- 9 files changed, 173 insertions(+), 184 deletions(-) diff --git a/Generators/AtlasHepMC/AtlasHepMC/Flow.h b/Generators/AtlasHepMC/AtlasHepMC/Flow.h index 1aee5c176b48..f54e9acdf9cc 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/Flow.h +++ b/Generators/AtlasHepMC/AtlasHepMC/Flow.h @@ -8,48 +8,44 @@ #ifdef HEPMC3 #include "HepMC3/Attribute.h" #include "HepMC3/GenParticle.h" -namespace HepMC -{ +namespace HepMC { typedef std::shared_ptr<HepMC3::VectorIntAttribute> Flow; -inline int flow(HepMC3::GenParticlePtr p, int i){ -std::shared_ptr<HepMC3::IntAttribute> f=p->attribute<HepMC3::IntAttribute>("flow"+std::to_string(i)); if (f) return f->value(); -std::shared_ptr<HepMC3::VectorIntAttribute> vf=p->attribute<HepMC3::VectorIntAttribute>("flow"); if (vf) if (0<i&&i<(int)(vf->value().size())) return vf->value().at(i); -return 0; -} -inline int flow(HepMC3::ConstGenParticlePtr p, int i){ -std::shared_ptr<HepMC3::IntAttribute> f=p->attribute<HepMC3::IntAttribute>("flow"+std::to_string(i)); if (f) return f->value(); -std::shared_ptr<HepMC3::VectorIntAttribute> vf=p->attribute<HepMC3::VectorIntAttribute>("flow"); if (vf) if (0<i&&i<(int)(vf->value().size())) return vf->value().at(i); -return 0; -} -inline Flow flow(HepMC3::GenParticlePtr p){ -std::shared_ptr<HepMC3::VectorIntAttribute> vf=p->attribute<HepMC3::VectorIntAttribute>("flow"); -if (vf) return vf; +inline int flow(HepMC3::GenParticlePtr p, int i) { + std::shared_ptr<HepMC3::IntAttribute> f=p->attribute<HepMC3::IntAttribute>("flow"+std::to_string(i)); if (f) return f->value(); + std::shared_ptr<HepMC3::VectorIntAttribute> vf=p->attribute<HepMC3::VectorIntAttribute>("flow"); if (vf) if (0<i&&i<(int)(vf->value().size())) return vf->value().at(i); + return 0; +} +inline int flow(HepMC3::ConstGenParticlePtr p, int i) { + std::shared_ptr<HepMC3::IntAttribute> f=p->attribute<HepMC3::IntAttribute>("flow"+std::to_string(i)); if (f) return f->value(); + std::shared_ptr<HepMC3::VectorIntAttribute> vf=p->attribute<HepMC3::VectorIntAttribute>("flow"); if (vf) if (0<i&&i<(int)(vf->value().size())) return vf->value().at(i); + return 0; +} +inline Flow flow(HepMC3::GenParticlePtr p) { + std::shared_ptr<HepMC3::VectorIntAttribute> vf=p->attribute<HepMC3::VectorIntAttribute>("flow"); + if (vf) return vf; -std::vector<int> fl; -for (int i=1;i<=10;i++) -{ -std::shared_ptr<HepMC3::IntAttribute> f=p->attribute<HepMC3::IntAttribute>("flow"+std::to_string(i)); if (f) fl.push_back(i); else break; -} -return std::make_shared<HepMC3::VectorIntAttribute>(fl); -} -inline Flow flow(HepMC3::ConstGenParticlePtr p){ -std::shared_ptr<HepMC3::VectorIntAttribute> vf=p->attribute<HepMC3::VectorIntAttribute>("flow"); -if (vf) return vf; + std::vector<int> fl; + for (int i=1; i<=10; i++) { + std::shared_ptr<HepMC3::IntAttribute> f=p->attribute<HepMC3::IntAttribute>("flow"+std::to_string(i)); if (f) fl.push_back(i); else break; + } + return std::make_shared<HepMC3::VectorIntAttribute>(fl); +} +inline Flow flow(HepMC3::ConstGenParticlePtr p) { + std::shared_ptr<HepMC3::VectorIntAttribute> vf=p->attribute<HepMC3::VectorIntAttribute>("flow"); + if (vf) return vf; -std::vector<int> fl; -for (int i=1;i<=10;i++) -{ -std::shared_ptr<HepMC3::IntAttribute> f=p->attribute<HepMC3::IntAttribute>("flow"+std::to_string(i)); if (f) fl.push_back(i); else break; -} -return std::make_shared<HepMC3::VectorIntAttribute>(fl); + std::vector<int> fl; + for (int i=1; i<=10; i++) { + std::shared_ptr<HepMC3::IntAttribute> f=p->attribute<HepMC3::IntAttribute>("flow"+std::to_string(i)); if (f) fl.push_back(i); else break; + } + return std::make_shared<HepMC3::VectorIntAttribute>(fl); } } #else #include "HepMC/Flow.h" -namespace HepMC -{ -template <class T> int flow(T a,int i){return a->flow(i);} -template <class T> Flow flow(T a){return a->flow();} +namespace HepMC { +template <class T> int flow(T a,int i) {return a->flow(i);} +template <class T> Flow flow(T a) {return a->flow();} } #endif #endif diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenEvent.h b/Generators/AtlasHepMC/AtlasHepMC/GenEvent.h index 20259b2fd1d4..f3e4753ab542 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenEvent.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenEvent.h @@ -14,12 +14,11 @@ #include "AtlasHepMC/GenVertex.h" #include "AtlasHepMC/GenParticle.h" #include "AtlasHepMC/SimpleVector.h" -namespace HepMC3 -{ -inline std::vector<HepMC3::GenParticlePtr>::const_iterator begin(HepMC3::GenEvent& e){ return e.particles().begin(); } -inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenEvent& e){ return e.particles().end(); } -inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenEvent& e){ return e.particles().begin(); } -inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenEvent& e){ return e.particles().end(); } +namespace HepMC3 { +inline std::vector<HepMC3::GenParticlePtr>::const_iterator begin(HepMC3::GenEvent& e) { return e.particles().begin(); } +inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenEvent& e) { return e.particles().end(); } +inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenEvent& e) { return e.particles().begin(); } +inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenEvent& e) { return e.particles().end(); } } namespace HepMC { @@ -27,88 +26,91 @@ using Print=HepMC3::Print; using GenHeavyIon=HepMC3::GenHeavyIon; using GenEvent=HepMC3::GenEvent; -inline std::vector<HepMC3::GenParticlePtr>::const_iterator begin(HepMC3::GenEvent& e){ return e.particles().begin(); } -inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenEvent& e){ return e.particles().end(); } -inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenEvent& e){ return e.particles().begin(); } -inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenEvent& e){ return e.particles().end(); } +inline std::vector<HepMC3::GenParticlePtr>::const_iterator begin(HepMC3::GenEvent& e) { return e.particles().begin(); } +inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenEvent& e) { return e.particles().end(); } +inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenEvent& e) { return e.particles().begin(); } +inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenEvent& e) { return e.particles().end(); } -inline GenEvent* newGenEvent(const int signal_process_id, const int event_number ){ GenEvent* e= new GenEvent(); -std::shared_ptr<HepMC3::IntAttribute> signal_process_id_A = std::make_shared<HepMC3::IntAttribute>(signal_process_id); -e->add_attribute("signal_process_id",signal_process_id_A); -e->set_event_number(event_number); -return e; +inline GenEvent* newGenEvent(const int signal_process_id, const int event_number ) { + GenEvent* e= new GenEvent(); + std::shared_ptr<HepMC3::IntAttribute> signal_process_id_A = std::make_shared<HepMC3::IntAttribute>(signal_process_id); + e->add_attribute("signal_process_id",signal_process_id_A); + e->set_event_number(event_number); + return e; } -inline GenVertexPtr barcode_to_vertex(const GenEvent* e, int id ){ -auto vertices=((GenEvent*)e)->vertices(); -for (auto v: vertices) -{ -auto barcode_attr=e->attribute<HepMC3::IntAttribute>("barcode"); -if (!barcode_attr) continue; -if (barcode_attr->value()==id) return v; -} -if (-id>0&&-id<=(int)vertices.size()) return vertices[-id-1]; -return HepMC3::GenVertexPtr(); +inline GenVertexPtr barcode_to_vertex(const GenEvent* e, int id ) { + auto vertices=((GenEvent*)e)->vertices(); + for (auto v: vertices) { + auto barcode_attr=e->attribute<HepMC3::IntAttribute>("barcode"); + if (!barcode_attr) continue; + if (barcode_attr->value()==id) return v; + } + if (-id>0&&-id<=(int)vertices.size()) return vertices[-id-1]; + return HepMC3::GenVertexPtr(); } -inline GenParticlePtr barcode_to_particle(const GenEvent* e, int id ){ -auto particles=((GenEvent*)e)->particles(); -for (auto p: particles) -{ -auto barcode_attr=p->attribute<HepMC3::IntAttribute>("barcode"); -if (!barcode_attr) continue; -if (barcode_attr->value()==id) return p; -} -if (id>0&&id<=(int)particles.size()) return particles[id-1]; -return HepMC3::GenParticlePtr(); +inline GenParticlePtr barcode_to_particle(const GenEvent* e, int id ) { + auto particles=((GenEvent*)e)->particles(); + for (auto p: particles) { + auto barcode_attr=p->attribute<HepMC3::IntAttribute>("barcode"); + if (!barcode_attr) continue; + if (barcode_attr->value()==id) return p; + } + if (id>0&&id<=(int)particles.size()) return particles[id-1]; + return HepMC3::GenParticlePtr(); } inline int mpi(const GenEvent evt) { -std::shared_ptr<HepMC3::IntAttribute> A_mpi=evt.attribute<HepMC3::IntAttribute>("mpi"); - return A_mpi?(A_mpi->value()):0; + std::shared_ptr<HepMC3::IntAttribute> A_mpi=evt.attribute<HepMC3::IntAttribute>("mpi"); + return A_mpi?(A_mpi->value()):0; } inline int mpi(const GenEvent* evt) { -std::shared_ptr<HepMC3::IntAttribute> A_mpi=evt->attribute<HepMC3::IntAttribute>("mpi"); - return A_mpi?(A_mpi->value()):0; + std::shared_ptr<HepMC3::IntAttribute> A_mpi=evt->attribute<HepMC3::IntAttribute>("mpi"); + return A_mpi?(A_mpi->value()):0; } inline int signal_process_id(const GenEvent evt) { -std::shared_ptr<HepMC3::IntAttribute> A_signal_process_id=evt.attribute<HepMC3::IntAttribute>("signal_process_id"); - return A_signal_process_id?(A_signal_process_id->value()):0; + std::shared_ptr<HepMC3::IntAttribute> A_signal_process_id=evt.attribute<HepMC3::IntAttribute>("signal_process_id"); + return A_signal_process_id?(A_signal_process_id->value()):0; } inline int signal_process_id(const GenEvent* evt) { -std::shared_ptr<HepMC3::IntAttribute> A_signal_process_id=evt->attribute<HepMC3::IntAttribute>("signal_process_id"); - return A_signal_process_id?(A_signal_process_id->value()):0; + std::shared_ptr<HepMC3::IntAttribute> A_signal_process_id=evt->attribute<HepMC3::IntAttribute>("signal_process_id"); + return A_signal_process_id?(A_signal_process_id->value()):0; +} +inline void set_signal_process_id(GenEvent* e, const int i=0) { + std::shared_ptr<HepMC3::IntAttribute> signal_process_id = std::make_shared<HepMC3::IntAttribute>(i); + e->add_attribute("signal_process_id",signal_process_id); } -inline void set_signal_process_id(GenEvent* e, const int i=0) { std::shared_ptr<HepMC3::IntAttribute> signal_process_id = std::make_shared<HepMC3::IntAttribute>(i); - e->add_attribute("signal_process_id",signal_process_id); } -inline void set_mpi(GenEvent* e, const int i=0) { std::shared_ptr<HepMC3::IntAttribute> mpi = std::make_shared<HepMC3::IntAttribute>(i); - e->add_attribute("mpi",mpi); } -inline void set_random_states(GenEvent* e, std::vector<long int>& a) { - e->add_attribute("random_states",std::make_shared<HepMC3::VectorLongIntAttribute>(a)); +inline void set_mpi(GenEvent* e, const int i=0) { + std::shared_ptr<HepMC3::IntAttribute> mpi = std::make_shared<HepMC3::IntAttribute>(i); + e->add_attribute("mpi",mpi); } -template <class T> void set_signal_process_vertex(GenEvent* e, T v){ -if (!v) return; -if (v->parent_event()!=e) return; -v->add_attribute("signal_process_vertex",std::make_shared<HepMC3::IntAttribute>(1)); +inline void set_random_states(GenEvent* e, std::vector<long int>& a) { + e->add_attribute("random_states",std::make_shared<HepMC3::VectorLongIntAttribute>(a)); +} +template <class T> void set_signal_process_vertex(GenEvent* e, T v) { + if (!v) return; + if (v->parent_event()!=e) return; + v->add_attribute("signal_process_vertex",std::make_shared<HepMC3::IntAttribute>(1)); } 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; } inline GenVertexPtr signal_process_vertex(GenEvent* e) { for (auto v: e->vertices()) if (v->attribute<HepMC3::IntAttribute>("signal_process_vertex")) return v; return nullptr; } -inline bool valid_beam_particles(const GenEvent* e){ if (!e) return false; if (e->beams().size()!=2) return false; return true;} +inline bool valid_beam_particles(const GenEvent* e) { if (!e) return false; if (e->beams().size()!=2) return false; return true;} } #else #include "HepMC/GenEvent.h" #include "HepMC/GenVertex.h" #include "AtlasHepMC/GenVertex.h" namespace HepMC { -inline GenEvent::particle_iterator begin(HepMC::GenEvent& e){ return e.particles_begin(); } -inline GenEvent::particle_iterator end(HepMC::GenEvent& e){ return e.particles_end(); } -inline GenEvent::particle_const_iterator begin(const HepMC::GenEvent& e){ return e.particles_begin(); } -inline GenEvent::particle_const_iterator end(const HepMC::GenEvent& e){ return e.particles_end(); } -inline GenEvent* newGenEvent(const int a, const int b ){ return new GenEvent(a,b); } +inline GenEvent::particle_iterator begin(HepMC::GenEvent& e) { return e.particles_begin(); } +inline GenEvent::particle_iterator end(HepMC::GenEvent& e) { return e.particles_end(); } +inline GenEvent::particle_const_iterator begin(const HepMC::GenEvent& e) { return e.particles_begin(); } +inline GenEvent::particle_const_iterator end(const HepMC::GenEvent& e) { return e.particles_end(); } +inline GenEvent* newGenEvent(const int a, const int b ) { return new GenEvent(a,b); } inline GenVertex* signal_process_vertex(const GenEvent* e) { return e->signal_process_vertex(); } -inline GenVertex* barcode_to_vertex(const GenEvent* e, int id ){return e->barcode_to_vertex(id);} -inline GenParticle* barcode_to_particle(const GenEvent* e, int id ){return e->barcode_to_particle(id);} +inline GenVertex* barcode_to_vertex(const GenEvent* e, int id ) {return e->barcode_to_vertex(id);} +inline GenParticle* barcode_to_particle(const GenEvent* e, int id ) {return e->barcode_to_particle(id);} inline int mpi(const GenEvent e) { return e.mpi(); } @@ -134,10 +136,10 @@ template <class T> void set_signal_process_vertex(GenEvent* e, T v) { e->set_signal_process_vertex(v); } namespace Print { -inline void line(std::ostream& os,const GenEvent& e){e.print(os);} -inline void line(std::ostream& os,const GenEvent* e){e->print(os);} +inline void line(std::ostream& os,const GenEvent& e) {e.print(os);} +inline void line(std::ostream& os,const GenEvent* e) {e->print(os);} } -inline bool valid_beam_particles(const GenEvent* e){return e->valid_beam_particles();} +inline bool valid_beam_particles(const GenEvent* e) {return e->valid_beam_particles();} } #include "AtlasHepMC/SimpleVector.h" #endif diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index bf9344e348ee..54d6e4268946 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -14,28 +14,28 @@ namespace HepMC { typedef HepMC3::GenParticlePtr GenParticlePtr; typedef HepMC3::ConstGenParticlePtr ConstGenParticlePtr; inline GenParticlePtr newGenParticlePtr(const HepMC3::FourVector &mom = HepMC3::FourVector::ZERO_VECTOR(), int pid = 0, int status = 0) { - return std::make_shared<HepMC3::GenParticle>(mom,pid,status); + return std::make_shared<HepMC3::GenParticle>(mom,pid,status); } -inline int barcode(GenParticlePtr p){ - if (!p) return 0; - std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); - return barcode?(barcode->value()):p->id(); +inline int barcode(GenParticlePtr p) { + if (!p) return 0; + std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); + return barcode?(barcode->value()):p->id(); } -inline int barcode(ConstGenParticlePtr p){ - if (!p) return 0; - std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); - return barcode?(barcode->value()):p->id(); +inline int barcode(ConstGenParticlePtr p) { + if (!p) return 0; + std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); + return barcode?(barcode->value()):p->id(); } -inline int barcode(const HepMC3::GenParticle p){ - std::shared_ptr<HepMC3::IntAttribute> barcode=p.attribute<HepMC3::IntAttribute>("barcode"); - return barcode?(barcode->value()):p.id(); +inline int barcode(const HepMC3::GenParticle p) { + std::shared_ptr<HepMC3::IntAttribute> barcode=p.attribute<HepMC3::IntAttribute>("barcode"); + return barcode?(barcode->value()):p.id(); } -inline int barcode(const HepMC3::GenParticle* p){ - if (!p) return 0; - std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); - return barcode?(barcode->value()):p->id(); +inline int barcode(const HepMC3::GenParticle* p) { + if (!p) return 0; + std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); + return barcode?(barcode->value()):p->id(); } -template <class T> bool suggest_barcode(T p, int i){return p->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(i));} +template <class T> bool suggest_barcode(T p, int i) {return p->add_attribute("barcode",std::make_shared<HepMC3::IntAttribute>(i));} using HepMC3::GenParticle; } #else @@ -48,14 +48,14 @@ inline GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom = HepMC::Fo } inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } -template <class T> bool suggest_barcode(T p, int i){return p->suggest_barcode(i);} -inline bool suggest_barcode(GenParticle p, int i){return p.suggest_barcode(i);} -template <class T> bool suggest_barcode(T* p, int i){return p->suggest_barcode(i);} +template <class T> bool suggest_barcode(T p, int i) {return p->suggest_barcode(i);} +inline bool suggest_barcode(GenParticle p, int i) {return p.suggest_barcode(i);} +template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);} namespace Print { -inline void line(std::ostream& os,const GenParticle& p){p.print(os);} -inline void line(std::ostream& os,const GenParticle* p){p->print(os);} +inline void line(std::ostream& os,const GenParticle& p) {p.print(os);} +inline void line(std::ostream& os,const GenParticle* p) {p->print(os);} } -inline std::ostream& operator<<( std::ostream& os, const GenParticle* p ) { if (p) return os<<(*p); else return os;} +inline std::ostream& operator<<( std::ostream& os, const GenParticle* p ) { if (p) return os<<(*p); else return os;} } #endif #endif diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenVertex.h b/Generators/AtlasHepMC/AtlasHepMC/GenVertex.h index 80bad06fc507..02220ccc846d 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenVertex.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenVertex.h @@ -8,36 +8,35 @@ #ifdef HEPMC3 #include "HepMC3/GenVertex.h" #include "HepMC3/PrintStreams.h" -namespace HepMC3 -{ -inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenVertex& v){ return v.particles_out().begin(); } -inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenVertex& v){ return v.particles_out().end(); } +namespace HepMC3 { +inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator begin(const HepMC3::GenVertex& v) { return v.particles_out().begin(); } +inline std::vector<HepMC3::ConstGenParticlePtr>::const_iterator end(const HepMC3::GenVertex& v) { return v.particles_out().end(); } } namespace HepMC { typedef HepMC3::GenVertexPtr GenVertexPtr; typedef HepMC3::ConstGenVertexPtr ConstGenVertexPtr; inline GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos = HepMC3::FourVector::ZERO_VECTOR(),const int i=0) { - GenVertexPtr v=std::make_shared<HepMC3::GenVertex>(pos); - v->set_status(i); - return v; + GenVertexPtr v=std::make_shared<HepMC3::GenVertex>(pos); + v->set_status(i); + return v; } -inline int barcode(GenVertexPtr p){ - if (!p) return 0; - std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); - return barcode?(barcode->value()):p->id(); +inline int barcode(GenVertexPtr p) { + if (!p) return 0; + std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); + return barcode?(barcode->value()):p->id(); } -inline int barcode(ConstGenVertexPtr p){ - if (!p) return 0; - std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); - return barcode?(barcode->value()):p->id(); +inline int barcode(ConstGenVertexPtr p) { + if (!p) return 0; + std::shared_ptr<HepMC3::IntAttribute> barcode=p->attribute<HepMC3::IntAttribute>("barcode"); + return barcode?(barcode->value()):p->id(); } -inline int barcode(HepMC3::GenVertex p){ - std::shared_ptr<HepMC3::IntAttribute> barcode=p.attribute<HepMC3::IntAttribute>("barcode"); - return barcode?(barcode->value()):p.id(); +inline int barcode(HepMC3::GenVertex p) { + std::shared_ptr<HepMC3::IntAttribute> barcode=p.attribute<HepMC3::IntAttribute>("barcode"); + return barcode?(barcode->value()):p.id(); } -inline void* raw_pointer(GenVertexPtr p){ return p.get();} -inline const void* raw_pointer(ConstGenVertexPtr p){ return p.get();} +inline void* raw_pointer(GenVertexPtr p) { return p.get();} +inline const void* raw_pointer(ConstGenVertexPtr p) { return p.get();} using HepMC3::GenVertex; } #else @@ -45,20 +44,20 @@ using HepMC3::GenVertex; namespace HepMC { typedef HepMC::GenVertex* GenVertexPtr; typedef const HepMC::GenVertex* ConstGenVertexPtr; -inline GenVertex::particles_out_const_iterator begin(const HepMC::GenVertex& v){ return v.particles_out_const_begin(); } -inline GenVertex::particles_out_const_iterator end(const HepMC::GenVertex& v){ return v.particles_out_const_end(); } +inline GenVertex::particles_out_const_iterator begin(const HepMC::GenVertex& v) { return v.particles_out_const_begin(); } +inline GenVertex::particles_out_const_iterator end(const HepMC::GenVertex& v) { return v.particles_out_const_end(); } inline GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos = HepMC::FourVector(0.0,0.0,0.0,0.0), const int i=0) { return new HepMC::GenVertex(pos,i); } namespace Print { -inline void line(std::ostream& os,const GenVertex& v){v.print(os);} -inline void line(std::ostream& os,const GenVertex* v){v->print(os);} +inline void line(std::ostream& os,const GenVertex& v) {v.print(os);} +inline void line(std::ostream& os,const GenVertex* v) {v->print(os);} } -inline int barcode(ConstGenVertexPtr p){ return p->barcode();} -inline void* raw_pointer(GenVertexPtr p){ return p;} -inline const void* raw_pointer(ConstGenVertexPtr p){ return p;} -inline std::ostream& operator<<( std::ostream& os, const GenVertex* v ) { if (v) return os<<(*v); else return os;} +inline int barcode(ConstGenVertexPtr p) { return p->barcode();} +inline void* raw_pointer(GenVertexPtr p) { return p;} +inline const void* raw_pointer(ConstGenVertexPtr p) { return p;} +inline std::ostream& operator<<( std::ostream& os, const GenVertex* v ) { if (v) return os<<(*v); else return os;} } #endif #endif diff --git a/Generators/AtlasHepMC/AtlasHepMC/HEPEVT_Wrapper.h b/Generators/AtlasHepMC/AtlasHepMC/HEPEVT_Wrapper.h index eb5d60c177a9..7eee5e1fea52 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/HEPEVT_Wrapper.h +++ b/Generators/AtlasHepMC/AtlasHepMC/HEPEVT_Wrapper.h @@ -7,8 +7,7 @@ #define ATLASHEPMC_HEPEVTWRAPPER_H #ifdef HEPMC3 #include "HepMC3/HEPEVT_Wrapper.h" -namespace HepMC -{ +namespace HepMC { typedef HepMC3::HEPEVT_Wrapper HEPEVT_Wrapper; } #else diff --git a/Generators/AtlasHepMC/AtlasHepMC/IO_GenEvent.h b/Generators/AtlasHepMC/AtlasHepMC/IO_GenEvent.h index 04dd2c9f6b91..ce3247278fbd 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/IO_GenEvent.h +++ b/Generators/AtlasHepMC/AtlasHepMC/IO_GenEvent.h @@ -11,8 +11,7 @@ #include "HepMC3/Writer.h" #include "HepMC3/ReaderAsciiHepMC2.h" #include "HepMC3/WriterAsciiHepMC2.h" -namespace HepMC -{ +namespace HepMC { typedef HepMC3::WriterAsciiHepMC2 WriterAsciiHepMC2; typedef HepMC3::ReaderAsciiHepMC2 ReaderAsciiHepMC2; class IO_GenEvent { diff --git a/Generators/AtlasHepMC/AtlasHepMC/PdfInfo.h b/Generators/AtlasHepMC/AtlasHepMC/PdfInfo.h index d2db82006295..6ae4c64aec0a 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/PdfInfo.h +++ b/Generators/AtlasHepMC/AtlasHepMC/PdfInfo.h @@ -8,14 +8,12 @@ #ifdef HEPMC3 #include "HepMC3/GenEvent.h" #include "HepMC3/PrintStreams.h" -namespace HepMC -{ +namespace HepMC { typedef std::shared_ptr<HepMC3::GenPdfInfo> GenPdfInfoPtr; } #else #include "HepMC/PdfInfo.h" -namespace HepMC -{ +namespace HepMC { typedef HepMC::PdfInfo* GenPdfInfoPtr; } #endif diff --git a/Generators/AtlasHepMC/AtlasHepMC/Polarization.h b/Generators/AtlasHepMC/AtlasHepMC/Polarization.h index e954879347bc..78c16cc52d9f 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/Polarization.h +++ b/Generators/AtlasHepMC/AtlasHepMC/Polarization.h @@ -8,43 +8,40 @@ #ifdef HEPMC3 #include "HepMC3/GenParticle.h" #include "HepMC3/Attribute.h" -namespace HepMC -{ -class Polarization { +namespace HepMC { +class Polarization { public: -Polarization( const double a=0.0, const double b=0.0): m_theta(a), m_phi(b) {}; -~Polarization(){}; -double theta() const { return m_theta;} -double phi() const { return m_phi;} -bool is_defined() const { if (std::abs(m_theta)<0.00001&&std::abs(m_phi)<0.00001) return false; return true; } + Polarization( const double a=0.0, const double b=0.0): m_theta(a), m_phi(b) {}; + ~Polarization() {}; + double theta() const { return m_theta;} + double phi() const { return m_phi;} + bool is_defined() const { if (std::abs(m_theta)<0.00001&&std::abs(m_phi)<0.00001) return false; return true; } private: -double m_theta; -double m_phi; + double m_theta; + double m_phi; }; -inline Polarization polarization(HepMC3::GenParticlePtr a){ - std::shared_ptr<HepMC3::DoubleAttribute> phi_A =a->attribute<HepMC3::DoubleAttribute>("phi"); - std::shared_ptr<HepMC3::DoubleAttribute> theta_A=a->attribute<HepMC3::DoubleAttribute>("theta"); +inline Polarization polarization(HepMC3::GenParticlePtr a) { + std::shared_ptr<HepMC3::DoubleAttribute> phi_A =a->attribute<HepMC3::DoubleAttribute>("phi"); + std::shared_ptr<HepMC3::DoubleAttribute> theta_A=a->attribute<HepMC3::DoubleAttribute>("theta"); double phi=(phi_A?phi_A->value():0.0); double theta=(theta_A?theta_A->value():0.0); - return Polarization(theta,phi); + return Polarization(theta,phi); } -inline Polarization polarization(HepMC3::ConstGenParticlePtr a){ - std::shared_ptr<HepMC3::DoubleAttribute> phi_A =a->attribute<HepMC3::DoubleAttribute>("phi"); - std::shared_ptr<HepMC3::DoubleAttribute> theta_A=a->attribute<HepMC3::DoubleAttribute>("theta"); +inline Polarization polarization(HepMC3::ConstGenParticlePtr a) { + std::shared_ptr<HepMC3::DoubleAttribute> phi_A =a->attribute<HepMC3::DoubleAttribute>("phi"); + std::shared_ptr<HepMC3::DoubleAttribute> theta_A=a->attribute<HepMC3::DoubleAttribute>("theta"); double phi=(phi_A?phi_A->value():0.0); double theta=(theta_A?theta_A->value():0.0); - return Polarization(theta,phi); + return Polarization(theta,phi); } -template<class T> void set_polarization( T a, Polarization b) -{ -a->add_attribute("phi",std::make_shared<HepMC3::DoubleAttribute>(b.phi())); -a->add_attribute("theta",std::make_shared<HepMC3::DoubleAttribute>(b.theta())); +template<class T> void set_polarization( T a, Polarization b) { + a->add_attribute("phi",std::make_shared<HepMC3::DoubleAttribute>(b.phi())); + a->add_attribute("theta",std::make_shared<HepMC3::DoubleAttribute>(b.theta())); } } #else #include "HepMC/Polarization.h" -namespace HepMC -{ +namespace HepMC { template<class T> void set_polarization( T a, Polarization b) { a->set_polarization(b); } diff --git a/Generators/AtlasHepMC/AtlasHepMC/SimpleVector.h b/Generators/AtlasHepMC/AtlasHepMC/SimpleVector.h index 8a578130b0e0..41bef08e206d 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/SimpleVector.h +++ b/Generators/AtlasHepMC/AtlasHepMC/SimpleVector.h @@ -8,8 +8,7 @@ #ifdef HEPMC3 #include "HepMC3/FourVector.h" #include "HepMC3/PrintStreams.h" -namespace HepMC -{ +namespace HepMC { typedef HepMC3::FourVector FourVector; } #else -- GitLab From 738e3f512a2b2817934ef835e0202a8ca6552ee5 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <averbyts@cern.ch> Date: Fri, 4 Dec 2020 18:10:10 +0100 Subject: [PATCH 03/11] Make xAODHepMCtool compatible with HePMC3 --- .../GenInterfaces/IxAODtoHepMCTool.h | 10 ++-- .../TruthConverters/Root/xAODtoHepMCTool.cxx | 46 ++++++++++++------- .../TruthConverters/xAODtoHepMCTool.h | 6 +-- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h b/Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h index 2045eee2f551..4727bb1c806a 100644 --- a/Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h +++ b/Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h @@ -25,13 +25,9 @@ #include "xAODEventInfo/EventInfo.h" #include "xAODTruth/TruthEventContainer.h" -#include "HepMC/GenEvent.h" - -namespace HepMC { - class GenEvent; - class GenParticle; - class GenVertex; -} +#include "AtlasHepMC/GenEvent.h" +#include "AtlasHepMC/GenParticle.h" +#include "AtlasHepMC/GenVertex.h" class IxAODtoHepMCTool : public virtual asg::IAsgTool { public: diff --git a/Generators/TruthConverters/Root/xAODtoHepMCTool.cxx b/Generators/TruthConverters/Root/xAODtoHepMCTool.cxx index 29972fe36750..63764b8d0e07 100644 --- a/Generators/TruthConverters/Root/xAODtoHepMCTool.cxx +++ b/Generators/TruthConverters/Root/xAODtoHepMCTool.cxx @@ -74,7 +74,7 @@ std::vector<HepMC::GenEvent> xAODtoHepMCTool :: getHepMCEvents(const xAOD::Truth // Insert into McEventCollection mcEventCollection.push_back(hepmcEvent); if( doPrint ) ATH_MSG_DEBUG("XXX Printing HepMC Event"); - if( doPrint ) hepmcEvent.print(); + if( doPrint ) HepMC::Print::line(std::cout,hepmcEvent); // Quit if signal only if( m_signalOnly ) break; } @@ -93,7 +93,7 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt, // PARTICLES AND VERTICES // Map of existing vertices - needed for the tree linking - std::map<const xAOD::TruthVertex*,HepMC::GenVertex*> vertexMap; + std::map<const xAOD::TruthVertex*,HepMC::GenVertexPtr> vertexMap; // Loop over all of the particles in the event, call particle builder // Call suggest_barcode only after insertion! @@ -117,7 +117,11 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt, // Create GenParticle //presumably the GenEvent takes ownership of this, but creating a unique_ptr here as that will only happen if there's an associated vertex +#ifdef HEPMC3 + auto hepmcParticle=createHepMCParticle(xPart) ; +#else std::unique_ptr<HepMC::GenParticle> hepmcParticle( createHepMCParticle(xPart) ); +#endif int bcpart = xPart->barcode(); // status 10902 should be treated just as status 2 @@ -129,18 +133,22 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt, // skip production vertices with barcode > 200000 --> Geant4 secondaries if ( std::abs(xAODProdVtx->barcode()) > 200000 ) continue; bool prodVtxSeenBefore(false); // is this new? - HepMC::GenVertex* hepmcProdVtx = vertexHelper(xAODProdVtx,vertexMap,prodVtxSeenBefore); + auto hepmcProdVtx = vertexHelper(xAODProdVtx,vertexMap,prodVtxSeenBefore); // Set the decay/production links +#ifdef HEPMC3 + hepmcProdVtx->add_particle_out(hepmcParticle); +#else hepmcProdVtx->add_particle_out(hepmcParticle.release()); +#endif // Insert into Event if (!prodVtxSeenBefore){ genEvt.add_vertex(hepmcProdVtx); - if( !hepmcProdVtx->suggest_barcode(xAODProdVtx->barcode()) ){ + if( !HepMC::suggest_barcode(hepmcProdVtx,xAODProdVtx->barcode()) ){ ATH_MSG_WARNING("suggest_barcode failed for vertex "<<xAODProdVtx->barcode()); ++m_badSuggest; } } - if( !hepmcParticle->suggest_barcode(bcpart) ){ + if( !HepMC::suggest_barcode(hepmcParticle,bcpart) ){ ATH_MSG_DEBUG("suggest_barcode failed for particle " <<bcpart); ++m_badSuggest; } @@ -152,22 +160,26 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt, if( xPart->hasDecayVtx() ){ const xAOD::TruthVertex* xAODDecayVtx = xPart->decayVtx(); // skip decay vertices with barcode > 200000 --> Geant4 secondaries - if ( fabs(xAODDecayVtx->barcode()) > 200000 ) continue; + if ( std::abs(xAODDecayVtx->barcode()) > 200000 ) continue; bool decayVtxSeenBefore(false); // is this new? - HepMC::GenVertex* hepmcDecayVtx = vertexHelper(xAODDecayVtx,vertexMap,decayVtxSeenBefore); + auto hepmcDecayVtx = vertexHelper(xAODDecayVtx,vertexMap,decayVtxSeenBefore); // Set the decay/production links +#ifdef HEPMC3 + hepmcDecayVtx->add_particle_in(hepmcParticle); +#else hepmcDecayVtx->add_particle_in(hepmcParticle.release()); +#endif // Insert into Event if (!decayVtxSeenBefore){ genEvt.add_vertex(hepmcDecayVtx); - if( !hepmcDecayVtx->suggest_barcode(xAODDecayVtx->barcode()) ){ + if( !HepMC::suggest_barcode(hepmcDecayVtx,xAODDecayVtx->barcode()) ){ ATH_MSG_WARNING("suggest_barcode failed for vertex " <<xAODDecayVtx->barcode()); ++m_badSuggest; } } if( bcpart != 0 ){ - if( !hepmcParticle->suggest_barcode(bcpart) ){ + if( !HepMC::suggest_barcode(hepmcParticle,bcpart) ){ ATH_MSG_DEBUG("suggest_barcode failed for particle " <<bcpart); ++m_badSuggest; } @@ -185,12 +197,12 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt, // Helper to check whether a vertex exists or not using a map; // calls createHepMCVertex if not -HepMC::GenVertex* xAODtoHepMCTool::vertexHelper(const xAOD::TruthVertex* xaodVertex, - std::map<const xAOD::TruthVertex*,HepMC::GenVertex*> &vertexMap, +HepMC::GenVertexPtr xAODtoHepMCTool::vertexHelper(const xAOD::TruthVertex* xaodVertex, + std::map<const xAOD::TruthVertex*,HepMC::GenVertexPtr> &vertexMap, bool &seenBefore) const { - HepMC::GenVertex* hepmcVertex; - std::map<const xAOD::TruthVertex*,HepMC::GenVertex*>::iterator vMapItr; + HepMC::GenVertexPtr hepmcVertex; + std::map<const xAOD::TruthVertex*,HepMC::GenVertexPtr>::iterator vMapItr; vMapItr=vertexMap.find(xaodVertex); // Vertex seen before? if (vMapItr!=vertexMap.end()) { @@ -209,20 +221,20 @@ HepMC::GenVertex* xAODtoHepMCTool::vertexHelper(const xAOD::TruthVertex* xaodVer // Create the HepMC GenParticle // Call suggest_barcode after insertion! -HepMC::GenParticle* xAODtoHepMCTool::createHepMCParticle(const xAOD::TruthParticle* particle) const { +HepMC::GenParticlePtr xAODtoHepMCTool::createHepMCParticle(const xAOD::TruthParticle* particle) const { ATH_MSG_VERBOSE("Creating GenParticle for barcode " <<particle->barcode()); const HepMC::FourVector fourVec( m_momFac * particle->px(), m_momFac * particle->py(), m_momFac * particle->pz(), m_momFac * particle->e() ); - HepMC::GenParticle* hepmcParticle=new HepMC::GenParticle(fourVec, particle->pdgId(), particle->status()); + auto hepmcParticle=HepMC::newGenParticlePtr(fourVec, particle->pdgId(), particle->status()); hepmcParticle->set_generated_mass( m_momFac * particle->m()); return hepmcParticle; } // Create the HepMC GenVertex // Call suggest_barcode after insertion! -HepMC::GenVertex* xAODtoHepMCTool::createHepMCVertex(const xAOD::TruthVertex* vertex) const { +HepMC::GenVertexPtr xAODtoHepMCTool::createHepMCVertex(const xAOD::TruthVertex* vertex) const { ATH_MSG_VERBOSE("Creating GenVertex for barcode " <<vertex->barcode()); HepMC::FourVector prod_pos( m_lenFac * vertex->x(), m_lenFac * vertex->y(),m_lenFac * vertex->z(), m_lenFac * vertex->t() ); - HepMC::GenVertex* genVertex=new HepMC::GenVertex(prod_pos); + auto genVertex=HepMC::newGenVertexPtr(prod_pos); return genVertex; } diff --git a/Generators/TruthConverters/TruthConverters/xAODtoHepMCTool.h b/Generators/TruthConverters/TruthConverters/xAODtoHepMCTool.h index 15aa09edbef4..c81acb12dcb8 100644 --- a/Generators/TruthConverters/TruthConverters/xAODtoHepMCTool.h +++ b/Generators/TruthConverters/TruthConverters/xAODtoHepMCTool.h @@ -33,9 +33,9 @@ class xAODtoHepMCTool: public asg::AsgTool, public virtual IxAODtoHepMCTool { private: HepMC::GenEvent createHepMCEvent(const xAOD::TruthEvent* xEvt, const xAOD::EventInfo* eventInfo) const; - HepMC::GenVertex* vertexHelper(const xAOD::TruthVertex*,std::map<const xAOD::TruthVertex*,HepMC::GenVertex*>&,bool&) const; - HepMC::GenParticle* createHepMCParticle(const xAOD::TruthParticle*) const; - HepMC::GenVertex* createHepMCVertex(const xAOD::TruthVertex*) const; + HepMC::GenVertexPtr vertexHelper(const xAOD::TruthVertex*,std::map<const xAOD::TruthVertex*,HepMC::GenVertexPtr>&,bool&) const; + HepMC::GenParticlePtr createHepMCParticle(const xAOD::TruthParticle*) const; + HepMC::GenVertexPtr createHepMCVertex(const xAOD::TruthVertex*) const; void printxAODEvent(const xAOD::TruthEvent* event, const xAOD::EventInfo* eventInfo) const; private: -- GitLab From b7339ead5e0d8a4c279d1fccd23b7f9315d5e95b Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Sat, 5 Dec 2020 02:15:54 +0000 Subject: [PATCH 04/11] Update GenParticle.h --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index 54d6e4268946..36017f60c1c8 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -49,7 +49,7 @@ inline GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom = HepMC::Fo inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } template <class T> bool suggest_barcode(T p, int i) {return p->suggest_barcode(i);} -inline bool suggest_barcode(GenParticle p, int i) {return p.suggest_barcode(i);} +inline bool suggest_barcode(GenParticle& p, int i) {return p.suggest_barcode(i);} template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);} namespace Print { inline void line(std::ostream& os,const GenParticle& p) {p.print(os);} -- GitLab From 93e4f82dc8d5bf9c282b5dce2f63d1246a8ac4ff Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <averbyts@cern.ch> Date: Mon, 7 Dec 2020 12:05:08 +0100 Subject: [PATCH 05/11] Added smart pointer case for the suggest_barcode --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index 36017f60c1c8..f15c4b2eeaf0 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -49,6 +49,8 @@ inline GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom = HepMC::Fo inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } template <class T> bool suggest_barcode(T p, int i) {return p->suggest_barcode(i);} +//Smart pointersh should not be used with HepMC2. But it happens. +template <class T> bool suggest_barcode(std::unique_ptr<T>& p, int i) {return p->suggest_barcode(i);} inline bool suggest_barcode(GenParticle& p, int i) {return p.suggest_barcode(i);} template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);} namespace Print { -- GitLab From 4d71e70a60aaef9b7aa93572a3270ca79c7cc4ef Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <averbyts@cern.ch> Date: Mon, 7 Dec 2020 12:07:53 +0100 Subject: [PATCH 06/11] Added smart pointer case for the suggest_barcode --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index f15c4b2eeaf0..aa3ae9fac39a 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -49,7 +49,7 @@ inline GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom = HepMC::Fo inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } template <class T> bool suggest_barcode(T p, int i) {return p->suggest_barcode(i);} -//Smart pointersh should not be used with HepMC2. But it happens. +//Smart pointers should not be used with HepMC2. But it happens. template <class T> bool suggest_barcode(std::unique_ptr<T>& p, int i) {return p->suggest_barcode(i);} inline bool suggest_barcode(GenParticle& p, int i) {return p.suggest_barcode(i);} template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);} -- GitLab From 3087e9dd949bf70e92bcf41bd2d009a6b6ffdbbc Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@mpp.mpg.de> Date: Mon, 7 Dec 2020 14:21:01 +0100 Subject: [PATCH 07/11] Fix compilation --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index aa3ae9fac39a..de9a9ae44a21 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -50,7 +50,7 @@ inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } template <class T> bool suggest_barcode(T p, int i) {return p->suggest_barcode(i);} //Smart pointers should not be used with HepMC2. But it happens. -template <class T> bool suggest_barcode(std::unique_ptr<T>& p, int i) {return p->suggest_barcode(i);} +inline bool suggest_barcode(std::unique_ptr<HepMC::GenParticle>& p, int i) {return p->suggest_barcode(i);} inline bool suggest_barcode(GenParticle& p, int i) {return p.suggest_barcode(i);} template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);} namespace Print { -- GitLab From 2226a8bc2fb528ccf2d1e353099b2a90019cecbd Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Mon, 7 Dec 2020 17:10:13 +0000 Subject: [PATCH 08/11] Update GenParticle.h --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index de9a9ae44a21..4229f54446d7 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -40,6 +40,7 @@ using HepMC3::GenParticle; } #else #include "HepMC/GenParticle.h" +#include <memory> namespace HepMC { typedef GenParticle* GenParticlePtr; typedef const GenParticle* ConstGenParticlePtr; @@ -48,10 +49,9 @@ inline GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom = HepMC::Fo } inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } -template <class T> bool suggest_barcode(T p, int i) {return p->suggest_barcode(i);} +template <class T> bool suggest_barcode(T& p, int i) {return p.suggest_barcode(i);} //Smart pointers should not be used with HepMC2. But it happens. -inline bool suggest_barcode(std::unique_ptr<HepMC::GenParticle>& p, int i) {return p->suggest_barcode(i);} -inline bool suggest_barcode(GenParticle& p, int i) {return p.suggest_barcode(i);} +inline bool suggest_barcode<std::unique_ptr<HepMC::GenParticle> >(std::unique_ptr<HepMC::GenParticle>& p, int i) {return p->suggest_barcode(i);} template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);} namespace Print { inline void line(std::ostream& os,const GenParticle& p) {p.print(os);} -- GitLab From 100f37acf94bf6f7fb48e44db93299cc7b790744 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Tue, 8 Dec 2020 10:34:07 +0000 Subject: [PATCH 09/11] Update GenParticle.h --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index 4229f54446d7..ace71d2f1775 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -51,7 +51,7 @@ inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } template <class T> bool suggest_barcode(T& p, int i) {return p.suggest_barcode(i);} //Smart pointers should not be used with HepMC2. But it happens. -inline bool suggest_barcode<std::unique_ptr<HepMC::GenParticle> >(std::unique_ptr<HepMC::GenParticle>& p, int i) {return p->suggest_barcode(i);} +inline template <> bool suggest_barcode<std::unique_ptr<HepMC::GenParticle> >(std::unique_ptr<HepMC::GenParticle>& p, int i) {return p->suggest_barcode(i);} template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);} namespace Print { inline void line(std::ostream& os,const GenParticle& p) {p.print(os);} -- GitLab From 59ade11102a4524388fccce7aa371e1209d5db2d Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Tue, 8 Dec 2020 11:43:21 +0000 Subject: [PATCH 10/11] Update GenParticle.h --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index ace71d2f1775..ca59ea1d9ec4 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -51,7 +51,7 @@ inline int barcode(GenParticle p) { return p.barcode(); } template <class T> inline int barcode(T p) { return p->barcode(); } template <class T> bool suggest_barcode(T& p, int i) {return p.suggest_barcode(i);} //Smart pointers should not be used with HepMC2. But it happens. -inline template <> bool suggest_barcode<std::unique_ptr<HepMC::GenParticle> >(std::unique_ptr<HepMC::GenParticle>& p, int i) {return p->suggest_barcode(i);} +template <> inline bool suggest_barcode<std::unique_ptr<HepMC::GenParticle> >(std::unique_ptr<HepMC::GenParticle>& p, int i) {return p->suggest_barcode(i);} template <class T> bool suggest_barcode(T* p, int i) {return p->suggest_barcode(i);} namespace Print { inline void line(std::ostream& os,const GenParticle& p) {p.print(os);} -- GitLab From fdc26048c202134af4080d9a602b91d4155ec694 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Tue, 8 Dec 2020 13:18:36 +0000 Subject: [PATCH 11/11] Update IxAODtoHepMCTool.h --- Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h b/Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h index 3e7d11ee22fe..c673f6da67ae 100644 --- a/Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h +++ b/Generators/GenInterfaces/GenInterfaces/IxAODtoHepMCTool.h @@ -30,7 +30,6 @@ #include "AtlasHepMC/GenVertex.h" - class IxAODtoHepMCTool : public virtual asg::IAsgTool { public: ASG_TOOL_INTERFACE( IxAODtoHepMCTool ) -- GitLab