Fork me on GitHub

source: svn/trunk/Utilities/HepMC/interface/GenRanges.h@ 606

Last change on this file since 606 was 572, checked in by cp3-support, 13 years ago

upgrade HepMC to version 2.06.05

File size: 10.7 KB
RevLine 
[572]1#ifndef HEPMC_GEN_EVENT_ITERATORS_H
2#define HEPMC_GEN_EVENT_ITERATORS_H
3
4//--------------------------------------------------------------------------
5//////////////////////////////////////////////////////////////////////////
6// garren@fnal.gov, May 2009
7//
8//////////////////////////////////////////////////////////////////////////
9//--------------------------------------------------------------------------
10
11#include <stdexcept>
12
13#include "GenEvent.h"
14#include "GenVertex.h"
15
16namespace HepMC {
17
18//! GenEventVertexRange acts like a collection of vertices
19
20///
21/// \class GenEventVertexRange
22/// HepMC::GenEventVertexRange is used to mimic a collection of
23/// vertices for ease of use - especially with utilities such as
24/// the Boost foreach funtion
25///
26class GenEventVertexRange {
27
28public:
29
30 /// the constructor requires a GenEvent
31 GenEventVertexRange( GenEvent & e ) : m_event(e) {}
32 ///
33 GenEvent::vertex_iterator begin() { return m_event.vertices_begin(); }
34 GenEvent::vertex_iterator end() { return m_event.vertices_end(); }
35
36private:
37 /// Because the class contains a reference, assignments are not allowed.
38 /// However, we need the copy constructor for GenEvent::vertex_range().
39 GenEventVertexRange& operator=( GenEventVertexRange & );
40
41private:
42 GenEvent & m_event;
43
44};
45
46//! ConstGenEventVertexRange acts like a collection of vertices
47
48///
49/// \class ConstGenEventVertexRange
50/// HepMC::ConstGenEventVertexRange is used to mimic a collection of
51/// vertices for ease of use - especially with utilities such as
52/// the Boost foreach funtion
53/// This is the const partner of GenEventVertexRange
54///
55class ConstGenEventVertexRange {
56
57public:
58
59 /// the constructor requires a const GenEvent
60 ConstGenEventVertexRange( GenEvent const & e ) : m_event(e) {}
61 ///
62 GenEvent::vertex_const_iterator begin() const { return m_event.vertices_begin(); }
63 GenEvent::vertex_const_iterator end() const { return m_event.vertices_end(); }
64
65private:
66 /// Because the class contains a reference, assignments are not allowed.
67 /// However, we need the copy constructor for GenEvent::vertex_range().
68 ConstGenEventVertexRange& operator=( ConstGenEventVertexRange & );
69
70private:
71 GenEvent const & m_event;
72
73};
74
75//! GenEventParticleRange acts like a collection of particles
76
77///
78/// \class GenEventParticleRange
79/// HepMC::GenEventParticleRange is used to mimic a collection of
80/// particles for ease of use - especially with utilities such as
81/// the Boost foreach funtion
82///
83class GenEventParticleRange {
84
85public:
86
87 /// the constructor requires a GenEvent
88 GenEventParticleRange( GenEvent & e ) : m_event(e) {}
89 ///
90 GenEvent::particle_iterator begin() { return m_event.particles_begin(); }
91 GenEvent::particle_iterator end() { return m_event.particles_end(); }
92
93private:
94 /// Because the class contains a reference, assignments are not allowed.
95 /// However, we need the copy constructor for GenEvent::particle_range().
96 GenEventParticleRange& operator=( GenEventParticleRange & );
97
98private:
99 GenEvent & m_event;
100
101};
102
103//! ConstGenEventParticleRange acts like a collection of particles
104
105///
106/// \class ConstGenEventParticleRange
107/// HepMC::ConstGenEventParticleRange is used to mimic a collection of
108/// particles for ease of use - especially with utilities such as
109/// the Boost foreach funtion
110/// This is the const partner of GenEventParticleRange
111///
112class ConstGenEventParticleRange {
113
114public:
115
116 /// the constructor requires a const GenEvent
117 ConstGenEventParticleRange( GenEvent const & e ) : m_event(e) {}
118 ///
119 GenEvent::particle_const_iterator begin() const { return m_event.particles_begin(); }
120 GenEvent::particle_const_iterator end() const { return m_event.particles_end(); }
121
122private:
123 /// Because the class contains a reference, assignments are not allowed.
124 /// However, we need the copy constructor for GenEvent::particle_range().
125 ConstGenEventParticleRange& operator=( ConstGenEventParticleRange & );
126
127private:
128 GenEvent const & m_event;
129
130};
131
132//! GenVertexParticleRange acts like a collection of particles
133
134///
135/// \class GenVertexParticleRange
136/// HepMC::GenVertexParticleRange is used to mimic a collection of
137/// particles for ease of use - especially with utilities such as
138/// the Boost foreach funtion
139///
140class GenVertexParticleRange {
141
142public:
143
144 /// the constructor requires a GenVertex
145 GenVertexParticleRange( GenVertex & v, IteratorRange range = relatives )
146 : m_vertex(v),m_range(range) {}
147 ///
148 GenVertex::particle_iterator begin() { return m_vertex.particles_begin(m_range); }
149 GenVertex::particle_iterator end() { return m_vertex.particles_end(m_range); }
150
151private:
152 /// Because the class contains a reference, assignments are not allowed.
153 /// However, we need the copy constructor for GenVertex::particles().
154 GenVertexParticleRange& operator=( GenVertexParticleRange & );
155
156private:
157 GenVertex & m_vertex;
158 IteratorRange m_range;
159
160};
161
162//! GenParticleProductionRange acts like a collection of particles
163
164///
165/// \class GenParticleProductionRange
166/// HepMC::GenParticleProductionRange is used to mimic a collection of
167/// particles associated with the particle's production vertex for ease of use
168/// Utilities such as the Boost foreach funtion will want to use this class.
169///
170class GenParticleProductionRange {
171
172public:
173
174 /// the constructor requires a GenParticle
175 GenParticleProductionRange( GenParticle const & p, IteratorRange range = relatives )
176 : m_particle(p),m_range(range) {}
177 /// begin iterator throws an error if the particle production_vertex is undefined
178 GenVertex::particle_iterator begin();
179 /// end iterator throws an error if the particle production_vertex is undefined
180 GenVertex::particle_iterator end();
181
182private:
183 /// Because the class contains a reference, assignments are not allowed.
184 /// However, we need the copy constructor for GenVertex::particles_in().
185 GenParticleProductionRange& operator=( GenParticleProductionRange & );
186
187private:
188 GenParticle const & m_particle;
189 IteratorRange m_range;
190
191};
192
193class ConstGenParticleProductionRange {
194
195public:
196
197 /// the constructor requires a GenParticle
198 ConstGenParticleProductionRange( GenParticle const & p, IteratorRange range = relatives )
199 : m_particle(p),m_range(range) {}
200 /// begin iterator throws an error if the particle production_vertex is undefined
201 GenVertex::particle_iterator begin();
202 /// end iterator throws an error if the particle production_vertex is undefined
203 GenVertex::particle_iterator end();
204
205private:
206 /// Because the class contains a reference, assignments are not allowed.
207 /// However, we need the copy constructor for GenVertex::particles_in().
208 ConstGenParticleProductionRange& operator=( ConstGenParticleProductionRange & );
209
210private:
211 GenParticle const & m_particle;
212 IteratorRange m_range;
213
214};
215
216//! GenParticleEndRange acts like a collection of particles
217
218///
219/// \class GenParticleEndRange
220/// HepMC::GenParticleEndRange is used to mimic a collection of
221/// particles associated with the particle's end vertex for ease of use
222/// Utilities such as the Boost foreach funtion will want to use this class.
223///
224class GenParticleEndRange {
225
226public:
227
228 /// the constructor requires a GenParticle
229 GenParticleEndRange( GenParticle const & p, IteratorRange range = relatives )
230 : m_particle(p),m_range(range) {}
231 /// begin iterator throws an error if the particle end_vertex is undefined
232 GenVertex::particle_iterator begin();
233 /// end iterator throws an error if the particle end_vertex is undefined
234 GenVertex::particle_iterator end();
235
236private:
237 /// Because the class contains a reference, assignments are not allowed.
238 /// However, we need the copy constructor for GenVertex::particles_out().
239 GenParticleEndRange& operator=( GenParticleEndRange & );
240
241private:
242 GenParticle const & m_particle;
243 IteratorRange m_range;
244
245};
246
247class ConstGenParticleEndRange {
248
249public:
250
251 /// the constructor requires a GenParticle
252 ConstGenParticleEndRange( GenParticle const & p, IteratorRange range = relatives )
253 : m_particle(p),m_range(range) {}
254 /// begin iterator throws an error if the particle end_vertex is undefined
255 GenVertex::particle_iterator begin();
256 /// end iterator throws an error if the particle end_vertex is undefined
257 GenVertex::particle_iterator end();
258
259private:
260 /// Because the class contains a reference, assignments are not allowed.
261 /// However, we need the copy constructor for GenVertex::particles_out().
262 ConstGenParticleEndRange& operator=( ConstGenParticleEndRange & );
263
264private:
265 GenParticle const & m_particle;
266 IteratorRange m_range;
267
268};
269
270
271inline GenVertex::particle_iterator GenParticleProductionRange::begin()
272{
273 if ( ! m_particle.production_vertex() )
274 throw(std::range_error("GenParticleProductionRange: GenParticle has no production_vertex"));
275 return m_particle.production_vertex()->particles_begin(m_range);
276}
277
278inline GenVertex::particle_iterator GenParticleProductionRange::end()
279{
280 if ( ! m_particle.production_vertex() )
281 throw(std::range_error("GenParticleProductionRange: GenParticle has no production_vertex"));
282 return m_particle.production_vertex()->particles_end(m_range);
283}
284
285
286inline GenVertex::particle_iterator ConstGenParticleProductionRange::begin()
287{
288 if ( ! m_particle.production_vertex() )
289 throw(std::range_error("ConstGenParticleProductionRange: GenParticle has no production_vertex"));
290 return m_particle.production_vertex()->particles_begin(m_range);
291}
292
293inline GenVertex::particle_iterator ConstGenParticleProductionRange::end()
294{
295 if ( ! m_particle.production_vertex() )
296 throw(std::range_error("ConstGenParticleProductionRange: GenParticle has no production_vertex"));
297 return m_particle.production_vertex()->particles_end(m_range);
298}
299
300inline GenVertex::particle_iterator GenParticleEndRange::begin()
301{
302 if ( ! m_particle.end_vertex() )
303 throw(std::range_error("GenParticleEndRange: GenParticle has no end_vertex"));
304 return m_particle.end_vertex()->particles_begin(m_range);
305}
306inline GenVertex::particle_iterator GenParticleEndRange::end()
307{
308 if ( ! m_particle.end_vertex() )
309 throw(std::range_error("GenParticleEndRange: GenParticle has no end_vertex"));
310 return m_particle.end_vertex()->particles_end(m_range);
311}
312
313inline GenVertex::particle_iterator ConstGenParticleEndRange::begin()
314{
315 if ( ! m_particle.end_vertex() )
316 throw(std::range_error("ConstGenParticleEndRange: GenParticle has no end_vertex"));
317 return m_particle.end_vertex()->particles_begin(m_range);
318}
319inline GenVertex::particle_iterator ConstGenParticleEndRange::end()
320{
321 if ( ! m_particle.end_vertex() )
322 throw(std::range_error("ConstGenParticleEndRange: GenParticle has no end_vertex"));
323 return m_particle.end_vertex()->particles_end(m_range);
324}
325
326} // HepMC
327
328#endif // HEPMC_GEN_EVENT_ITERATORS_H
Note: See TracBrowser for help on using the repository browser.