00001
00002 #ifndef HEPMC_FLOW_H
00003 #define HEPMC_FLOW_H
00004
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include "CLHEP/config/CLHEP.h"
00050 #include "CLHEP/config/iostream.h"
00051 #include <map>
00052 #include <set>
00053
00054 namespace HepMC {
00055
00056 class GenParticle;
00057
00058 class Flow {
00059
00060 friend std::ostream& operator<<( std::ostream& ostr, const Flow& f );
00061
00062 public:
00063 Flow( GenParticle* particle_owner = 0 );
00064 Flow( const Flow& );
00065 virtual ~Flow();
00066 Flow& operator=( const Flow& );
00067 bool operator==( const Flow& a ) const;
00068 bool operator!=( const Flow& a ) const;
00069
00070 void print( std::ostream& ostr = std::cout ) const;
00071
00072
00073
00074 std::set<GenParticle*> connected_partners( int code, int code_index =1,
00075 int num_indices = 2 ) const;
00076
00077
00078
00079 std::set<GenParticle*> dangling_connected_partners( int code,
00080 int code_index = 1, int num_indices = 2 ) const;
00081
00083
00085 const GenParticle* particle_owner() const;
00086 int icode( int code_index = 1 ) const;
00087 Flow set_icode( int code_index, int code );
00088
00090
00092
00093 bool empty() const;
00094 int size() const;
00095 void clear();
00096 bool erase( int code_index );
00097
00098 typedef std::map<int,int>::iterator iterator;
00099 typedef std::map<int,int>::const_iterator const_iterator;
00100 iterator begin();
00101 iterator end();
00102 const_iterator begin() const;
00103 const_iterator end() const;
00104
00105 protected:
00106 void connected_partners( std::set<GenParticle*>* output,
00107 int code,
00108 int code_index,
00109 int num_indices ) const;
00110 void dangling_connected_partners( std::set<GenParticle*>*
00111 output,
00112 std::set<GenParticle*>*
00113 visited_particles,
00114 int code, int code_index,
00115 int num_indices ) const;
00116 private:
00117 GenParticle* m_particle_owner;
00118 std::map<int,int> m_icode;
00119 };
00120
00122
00124
00125 inline const GenParticle* Flow::particle_owner() const {
00126 return m_particle_owner;
00127 }
00128 inline int Flow::icode( int code_index ) const {
00129 std::map<int,int>::const_iterator a = m_icode.find(code_index);
00130 return a==m_icode.end() ? 0 : (*a).second;
00131 }
00132 inline Flow Flow::set_icode( int code_index, int code ) {
00133 m_icode[code_index] = code;
00134 return *this;
00135 }
00136 inline bool Flow::empty() const { return (bool)m_icode.empty(); }
00137 inline int Flow::size() const { return (int)m_icode.size(); }
00138 inline void Flow::clear() { m_icode.clear(); }
00139 inline bool Flow::erase( int code_index ) {
00140 return (bool)m_icode.erase( code_index );
00141 }
00142 inline Flow::iterator Flow::begin() { return m_icode.begin(); }
00143 inline Flow::iterator Flow::end() { return m_icode.end(); }
00144 inline Flow::const_iterator Flow::begin() const { return m_icode.begin(); }
00145 inline Flow::const_iterator Flow::end() const { return m_icode.end(); }
00146
00148
00150
00151 inline bool Flow::operator==( const Flow& a ) const {
00152
00153
00154
00155 return (m_icode == a.m_icode);
00156 }
00157 inline bool Flow::operator!=( const Flow& a ) const {
00158 return !( *this == a );
00159 }
00160 inline Flow& Flow::operator=( const Flow& inflow ) {
00161
00162
00163
00164
00165 m_icode = inflow.m_icode;
00166 return *this;
00167 }
00168
00169 }
00170
00171 #endif // HEPMC_FLOW_H
00172
00173