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
00050 #include <iostream>
00051 #include <map>
00052 #include <vector>
00053
00054 namespace HepMC {
00055
00056 class GenParticle;
00057
00059
00066 class Flow {
00067
00069 friend std::ostream& operator<<( std::ostream& ostr, const Flow& f );
00070
00071 public:
00073 Flow( GenParticle* particle_owner = 0 );
00075 Flow( const Flow& );
00076 virtual ~Flow();
00078 void swap( Flow & other);
00080 Flow& operator=( const Flow& );
00082 bool operator==( const Flow& a ) const;
00084 bool operator!=( const Flow& a ) const;
00085
00087 void print( std::ostream& ostr = std::cout ) const;
00088
00091 std::vector<HepMC::GenParticle*> connected_partners( int code, int code_index =1,
00092 int num_indices = 2 ) const;
00096 std::vector<HepMC::GenParticle*> dangling_connected_partners( int code,
00097 int code_index = 1, int num_indices = 2 ) const;
00098
00100
00102
00104 const GenParticle* particle_owner() const;
00106 int icode( int code_index = 1 ) const;
00108 Flow set_icode( int code_index, int code );
00110 Flow set_unique_icode( int code_index = 1 );
00111
00113
00115
00117 bool empty() const;
00119 int size() const;
00121 void clear();
00123 bool erase( int code_index );
00124
00126 typedef std::map<int,int>::iterator iterator;
00128 typedef std::map<int,int>::const_iterator const_iterator;
00130 iterator begin();
00132 iterator end();
00134 const_iterator begin() const;
00136 const_iterator end() const;
00137
00138 protected:
00140 void connected_partners( std::vector<HepMC::GenParticle*>* output,
00141 int code,
00142 int code_index,
00143 int num_indices ) const;
00145 void dangling_connected_partners( std::vector<HepMC::GenParticle*>*
00146 output,
00147 std::vector<HepMC::GenParticle*>*
00148 visited_particles,
00149 int code, int code_index,
00150 int num_indices ) const;
00151 private:
00152 GenParticle* m_particle_owner;
00153 std::map<int,int> m_icode;
00154 };
00155
00157
00159
00160 inline const GenParticle* Flow::particle_owner() const {
00161 return m_particle_owner;
00162 }
00163 inline int Flow::icode( int code_index ) const {
00164 std::map<int,int>::const_iterator a = m_icode.find(code_index);
00165 return a==m_icode.end() ? 0 : (*a).second;
00166 }
00167 inline Flow Flow::set_icode( int code_index, int code ) {
00168 m_icode[code_index] = code;
00169 return *this;
00170 }
00171 inline Flow Flow::set_unique_icode( int flow_num ) {
00174 m_icode[flow_num] = size_t(this);
00175 return *this;
00176 }
00177 inline bool Flow::empty() const { return (bool)m_icode.empty(); }
00178 inline int Flow::size() const { return (int)m_icode.size(); }
00179 inline void Flow::clear() { m_icode.clear(); }
00180 inline bool Flow::erase( int code_index ) {
00181 return (bool)m_icode.erase( code_index );
00182 }
00183 inline Flow::iterator Flow::begin() { return m_icode.begin(); }
00184 inline Flow::iterator Flow::end() { return m_icode.end(); }
00185 inline Flow::const_iterator Flow::begin() const { return m_icode.begin(); }
00186 inline Flow::const_iterator Flow::end() const { return m_icode.end(); }
00187
00189
00191
00192 inline bool Flow::operator==( const Flow& a ) const {
00196 return (m_icode == a.m_icode);
00197 }
00198 inline bool Flow::operator!=( const Flow& a ) const {
00199 return !( *this == a );
00200 }
00201 inline Flow& Flow::operator=( const Flow& inflow ) {
00205
00206 m_icode = inflow.m_icode;
00207 return *this;
00208 }
00209
00210 }
00211
00212 #endif // HEPMC_FLOW_H
00213
00214