diff --git a/Generators/AtlasHepMC/AtlasHepMC/Flow.h b/Generators/AtlasHepMC/AtlasHepMC/Flow.h index 1aee5c176b48c6264f8f21e8a7f756c4c4262624..f54e9acdf9cc8b00d425f55b860f6c91f073e4c2 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 20259b2fd1d4dee5d7b2f7558956b452697f97dd..f3e4753ab542745576e66c9a94a0b6c3462b7903 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 0faf0b32fe7381857ae45e7a1d3169721b68c9dd..54d6e42689467f790ea23339684518348d20fa7b 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> 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,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> 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);} +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 80bad06fc50716512d7b69890fa58dac60bbadee..02220ccc846d15399c614494c4d16961ad631aa2 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 eb5d60c177a994dea41fe518ffe1df8a7e8aeb97..7eee5e1fea52931698b1f258f3281392c343ce2a 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 04dd2c9f6b91111edaaa491f080268a419c50173..ce3247278fbd0aadfd3e6ba5639c14a51a68fbd0 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 d2db820062956da96e26ca9680c005a8e6b00e8b..6ae4c64aec0ad01c273613b720e021e4f25473d5 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 e954879347bcd8f6209a169f81947f2e2c08e139..78c16cc52d9ff9d5a40182338a6e7d01635578fa 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 8a578130b0e01c915b1f5a5569619edb65d2fb10..41bef08e206d3742a71ac01d31e0ec184591d3d9 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