Rev 2 | Rev 69 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 65 | ||
|---|---|---|---|
| Line 14... | Line 14... | ||
| 14 | {} |
14 | {} |
| 15 | 15 | ||
| 16 | Flow::Flow( const Flow& inflow ) : |
16 | Flow::Flow( const Flow& inflow ) : |
| 17 | m_particle_owner(inflow.m_particle_owner) |
17 | m_particle_owner(inflow.m_particle_owner) |
| 18 | {
|
18 | {
|
| 19 | // copies both the m_icode AND t;he m_particle_owner
|
- | |
| - | 19 | /// copies both the m_icode AND the m_particle_owner
|
|
| 20 | *this = inflow; |
20 | *this = inflow; |
| 21 | }
|
21 | }
|
| 22 | 22 | ||
| 23 | Flow::~Flow() { |
23 | Flow::~Flow() { |
| 24 | m_icode.clear(); |
24 | m_icode.clear(); |
| Line 28... | Line 28... | ||
| 28 | ostr << "Flow(" << m_particle_owner << "): " << *this << std::endl; |
28 | ostr << "Flow(" << m_particle_owner << "): " << *this << std::endl; |
| 29 | }
|
29 | }
|
| 30 | 30 | ||
| 31 | std::set<GenParticle*> Flow::connected_partners( int code, int code_index, |
31 | std::set<GenParticle*> Flow::connected_partners( int code, int code_index, |
| 32 | int num_indices ) const { |
32 | int num_indices ) const { |
| 33 | // Returns all flow partners which have "code" in any of the
|
- | |
| 34 | // num_indices beginning with index code_index.
|
- | |
| 35 | // m_particle_owner is included in the result.
|
- | |
| 36 | // Return is by value since the set should never be very big.
|
- | |
| 37 | // EXAMPLE: if you want to find all flow partners that have the same
|
- | |
| 38 | // code in indices 2,3,4 as particle p has in index 2, you would use:
|
- | |
| 39 | // set<GenParticle*> result =
|
- | |
| 40 | // p->flow().connected_partners(p->flow().icode(2),2,3);
|
- | |
| - | 33 | /// Returns all flow partners which have "code" in any of the
|
|
| - | 34 | /// num_indices beginning with index code_index.
|
|
| - | 35 | /// m_particle_owner is included in the result.
|
|
| - | 36 | /// Return is by value since the set should never be very big.
|
|
| - | 37 | /// EXAMPLE: if you want to find all flow partners that have the same
|
|
| - | 38 | /// code in indices 2,3,4 as particle p has in index 2, you would use:
|
|
| - | 39 | /// set<GenParticle*> result =
|
|
| - | 40 | /// p->flow().connected_partners(p->flow().icode(2),2,3);
|
|
| 41 | //
|
41 | //
|
| 42 | std::set<GenParticle*> output; |
42 | std::set<GenParticle*> output; |
| 43 | for ( int i = code_index; i!=code_index+num_indices; ++i ) { |
43 | for ( int i = code_index; i!=code_index+num_indices; ++i ) { |
| 44 | if ( icode(i)==code ) { |
44 | if ( icode(i)==code ) { |
| 45 | output.insert(m_particle_owner); |
45 | output.insert(m_particle_owner); |
| Line 51... | Line 51... | ||
| 51 | }
|
51 | }
|
| 52 | 52 | ||
| 53 | void Flow::connected_partners( std::set<GenParticle*>* output, int code, |
53 | void Flow::connected_partners( std::set<GenParticle*>* output, int code, |
| 54 | int code_index, int num_indices ) const |
54 | int code_index, int num_indices ) const |
| 55 | {
|
55 | {
|
| 56 | // protected: for recursive use by Flow::connected_partners()
|
- | |
| - | 56 | /// protected: for recursive use by Flow::connected_partners()
|
|
| 57 | //
|
57 | //
|
| 58 | if ( !m_particle_owner ) return; // nothing to do |
58 | if ( !m_particle_owner ) return; // nothing to do |
| 59 | // look for connected partners joined to this m_particle_owner
|
59 | // look for connected partners joined to this m_particle_owner
|
| 60 | // through its end_vertex
|
60 | // through its end_vertex
|
| 61 | if ( m_particle_owner->end_vertex() ) { |
61 | if ( m_particle_owner->end_vertex() ) { |
| Line 117... | Line 117... | ||
| 117 | std::set<GenParticle*>* |
117 | std::set<GenParticle*>* |
| 118 | visited_particles, |
118 | visited_particles, |
| 119 | int code, int code_index, |
119 | int code, int code_index, |
| 120 | int num_indices ) const |
120 | int num_indices ) const |
| 121 | {
|
121 | {
|
| 122 | // protected: for recursive use by Flow::dangling_connected_partners
|
- | |
| - | 122 | /// protected: for recursive use by Flow::dangling_connected_partners
|
|
| 123 | //
|
123 | //
|
| 124 | if ( !m_particle_owner ) return; // nothing to do |
124 | if ( !m_particle_owner ) return; // nothing to do |
| 125 | int count_partners = 0; |
125 | int count_partners = 0; |
| 126 | // look for connected partners joined to this m_particle_owner
|
126 | // look for connected partners joined to this m_particle_owner
|
| 127 | // through its end_vertex
|
127 | // through its end_vertex
|
| Line 176... | Line 176... | ||
| 176 | /////////////
|
176 | /////////////
|
| 177 | // Friends //
|
177 | // Friends //
|
| 178 | /////////////
|
178 | /////////////
|
| 179 | 179 | ||
| 180 | std::ostream& operator<<( std::ostream& ostr, const Flow& f ) { |
180 | std::ostream& operator<<( std::ostream& ostr, const Flow& f ) { |
| - | 181 | /// send Flow informatin to ostr for printing
|
|
| 181 | ostr << f.m_icode.size(); |
182 | ostr << f.m_icode.size(); |
| 182 | for ( std::map<int,int>::const_iterator i = f.m_icode.begin(); |
183 | for ( std::map<int,int>::const_iterator i = f.m_icode.begin(); |
| 183 | i != f.m_icode.end(); ++i ) { |
184 | i != f.m_icode.end(); ++i ) { |
| 184 | ostr << " " << (*i).first << " " << (*i).second; |
185 | ostr << " " << (*i).first << " " << (*i).second; |
| 185 | }
|
186 | }
|