File indexing completed on 2025-01-18 10:01:11
0001
0002
0003
0004
0005
0006 #ifndef HEPMC3_AssociatedParticle_H
0007 #define HEPMC3_AssociatedParticle_H
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include "HepMC3/Attribute.h"
0021 #include "HepMC3/GenParticle.h"
0022
0023 namespace HepMC3 {
0024
0025
0026
0027
0028
0029
0030
0031 class AssociatedParticle : public IntAttribute {
0032 public:
0033
0034
0035 AssociatedParticle() {}
0036
0037
0038 AssociatedParticle(ConstGenParticlePtr p)
0039 : IntAttribute(p->id()), m_associated(p) {}
0040
0041
0042 bool from_string(const std::string &att) {
0043 IntAttribute::from_string(att);
0044 if ( associatedId() > int(event()->particles().size()) ||
0045 associatedId() <= 0 ) return false;
0046 m_associated = event()->particles()[associatedId() -1];
0047 return true;
0048 }
0049
0050
0051 int associatedId() const {
0052 return value();
0053 }
0054
0055
0056 ConstGenParticlePtr associated() const {
0057 return m_associated;
0058 }
0059
0060
0061 void set_associated(ConstGenParticlePtr p) {
0062 IntAttribute::set_value(p->id());
0063 m_associated = p;
0064 }
0065
0066 private:
0067
0068 ConstGenParticlePtr m_associated;
0069
0070 };
0071
0072 }
0073
0074 #endif