File indexing completed on 2025-01-18 10:01:09
0001 #ifndef HEPMC_GEN_EVENT_ITERATORS_H
0002 #define HEPMC_GEN_EVENT_ITERATORS_H
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <stdexcept>
0012
0013 #include "HepMC/GenEvent.h"
0014 #include "HepMC/GenVertex.h"
0015
0016 namespace HepMC {
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 class GenEventVertexRange {
0027
0028 public:
0029
0030
0031 GenEventVertexRange( GenEvent & e ) : m_event(e) {}
0032
0033 GenEvent::vertex_iterator begin() { return m_event.vertices_begin(); }
0034 GenEvent::vertex_iterator end() { return m_event.vertices_end(); }
0035
0036 private:
0037
0038
0039 GenEventVertexRange& operator=( GenEventVertexRange & );
0040
0041 private:
0042 GenEvent & m_event;
0043
0044 };
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 class ConstGenEventVertexRange {
0056
0057 public:
0058
0059
0060 ConstGenEventVertexRange( GenEvent const & e ) : m_event(e) {}
0061
0062 GenEvent::vertex_const_iterator begin() const { return m_event.vertices_begin(); }
0063 GenEvent::vertex_const_iterator end() const { return m_event.vertices_end(); }
0064
0065 private:
0066
0067
0068 ConstGenEventVertexRange& operator=( ConstGenEventVertexRange & );
0069
0070 private:
0071 GenEvent const & m_event;
0072
0073 };
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 class GenEventParticleRange {
0084
0085 public:
0086
0087
0088 GenEventParticleRange( GenEvent & e ) : m_event(e) {}
0089
0090 GenEvent::particle_iterator begin() { return m_event.particles_begin(); }
0091 GenEvent::particle_iterator end() { return m_event.particles_end(); }
0092
0093 private:
0094
0095
0096 GenEventParticleRange& operator=( GenEventParticleRange & );
0097
0098 private:
0099 GenEvent & m_event;
0100
0101 };
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112 class ConstGenEventParticleRange {
0113
0114 public:
0115
0116
0117 ConstGenEventParticleRange( GenEvent const & e ) : m_event(e) {}
0118
0119 GenEvent::particle_const_iterator begin() const { return m_event.particles_begin(); }
0120 GenEvent::particle_const_iterator end() const { return m_event.particles_end(); }
0121
0122 private:
0123
0124
0125 ConstGenEventParticleRange& operator=( ConstGenEventParticleRange & );
0126
0127 private:
0128 GenEvent const & m_event;
0129
0130 };
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140 class GenVertexParticleRange {
0141
0142 public:
0143
0144
0145 GenVertexParticleRange( GenVertex & v, IteratorRange range = relatives )
0146 : m_vertex(v),m_range(range) {}
0147
0148 GenVertex::particle_iterator begin() { return m_vertex.particles_begin(m_range); }
0149 GenVertex::particle_iterator end() { return m_vertex.particles_end(m_range); }
0150
0151 private:
0152
0153
0154 GenVertexParticleRange& operator=( GenVertexParticleRange & );
0155
0156 private:
0157 GenVertex & m_vertex;
0158 IteratorRange m_range;
0159
0160 };
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170 class GenParticleProductionRange {
0171
0172 public:
0173
0174
0175 GenParticleProductionRange( GenParticle const & p, IteratorRange range = relatives )
0176 : m_particle(p),m_range(range) {}
0177
0178 GenVertex::particle_iterator begin();
0179
0180 GenVertex::particle_iterator end();
0181
0182 private:
0183
0184
0185 GenParticleProductionRange& operator=( GenParticleProductionRange & );
0186
0187 private:
0188 GenParticle const & m_particle;
0189 IteratorRange m_range;
0190
0191 };
0192
0193 class ConstGenParticleProductionRange {
0194
0195 public:
0196
0197
0198 ConstGenParticleProductionRange( GenParticle const & p, IteratorRange range = relatives )
0199 : m_particle(p),m_range(range) {}
0200
0201 GenVertex::particle_iterator begin();
0202
0203 GenVertex::particle_iterator end();
0204
0205 private:
0206
0207
0208 ConstGenParticleProductionRange& operator=( ConstGenParticleProductionRange & );
0209
0210 private:
0211 GenParticle const & m_particle;
0212 IteratorRange m_range;
0213
0214 };
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224 class GenParticleEndRange {
0225
0226 public:
0227
0228
0229 GenParticleEndRange( GenParticle const & p, IteratorRange range = relatives )
0230 : m_particle(p),m_range(range) {}
0231
0232 GenVertex::particle_iterator begin();
0233
0234 GenVertex::particle_iterator end();
0235
0236 private:
0237
0238
0239 GenParticleEndRange& operator=( GenParticleEndRange & );
0240
0241 private:
0242 GenParticle const & m_particle;
0243 IteratorRange m_range;
0244
0245 };
0246
0247 class ConstGenParticleEndRange {
0248
0249 public:
0250
0251
0252 ConstGenParticleEndRange( GenParticle const & p, IteratorRange range = relatives )
0253 : m_particle(p),m_range(range) {}
0254
0255 GenVertex::particle_iterator begin();
0256
0257 GenVertex::particle_iterator end();
0258
0259 private:
0260
0261
0262 ConstGenParticleEndRange& operator=( ConstGenParticleEndRange & );
0263
0264 private:
0265 GenParticle const & m_particle;
0266 IteratorRange m_range;
0267
0268 };
0269
0270
0271 inline GenVertex::particle_iterator GenParticleProductionRange::begin()
0272 {
0273 if ( ! m_particle.production_vertex() )
0274 throw(std::range_error("GenParticleProductionRange: GenParticle has no production_vertex"));
0275 return m_particle.production_vertex()->particles_begin(m_range);
0276 }
0277
0278 inline GenVertex::particle_iterator GenParticleProductionRange::end()
0279 {
0280 if ( ! m_particle.production_vertex() )
0281 throw(std::range_error("GenParticleProductionRange: GenParticle has no production_vertex"));
0282 return m_particle.production_vertex()->particles_end(m_range);
0283 }
0284
0285
0286 inline GenVertex::particle_iterator ConstGenParticleProductionRange::begin()
0287 {
0288 if ( ! m_particle.production_vertex() )
0289 throw(std::range_error("ConstGenParticleProductionRange: GenParticle has no production_vertex"));
0290 return m_particle.production_vertex()->particles_begin(m_range);
0291 }
0292
0293 inline GenVertex::particle_iterator ConstGenParticleProductionRange::end()
0294 {
0295 if ( ! m_particle.production_vertex() )
0296 throw(std::range_error("ConstGenParticleProductionRange: GenParticle has no production_vertex"));
0297 return m_particle.production_vertex()->particles_end(m_range);
0298 }
0299
0300 inline GenVertex::particle_iterator GenParticleEndRange::begin()
0301 {
0302 if ( ! m_particle.end_vertex() )
0303 throw(std::range_error("GenParticleEndRange: GenParticle has no end_vertex"));
0304 return m_particle.end_vertex()->particles_begin(m_range);
0305 }
0306 inline GenVertex::particle_iterator GenParticleEndRange::end()
0307 {
0308 if ( ! m_particle.end_vertex() )
0309 throw(std::range_error("GenParticleEndRange: GenParticle has no end_vertex"));
0310 return m_particle.end_vertex()->particles_end(m_range);
0311 }
0312
0313 inline GenVertex::particle_iterator ConstGenParticleEndRange::begin()
0314 {
0315 if ( ! m_particle.end_vertex() )
0316 throw(std::range_error("ConstGenParticleEndRange: GenParticle has no end_vertex"));
0317 return m_particle.end_vertex()->particles_begin(m_range);
0318 }
0319 inline GenVertex::particle_iterator ConstGenParticleEndRange::end()
0320 {
0321 if ( ! m_particle.end_vertex() )
0322 throw(std::range_error("ConstGenParticleEndRange: GenParticle has no end_vertex"));
0323 return m_particle.end_vertex()->particles_end(m_range);
0324 }
0325
0326 }
0327
0328 #endif