Changeset 572 in svn for trunk/Utilities/HepMC/interface/GenEvent.h
- Timestamp:
- Nov 2, 2011, 5:39:26 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/HepMC/interface/GenEvent.h
r349 r572 119 119 // parent_event() return value will return a pointer to the event which owns 120 120 // it (or null if its an orphan). 121 // - Please note that the barcodes are intended for internal use within HepMC 122 // as a unique identifier for the particles and vertices. 123 // Using the barcode to encode extra information is an abuse of 124 // the barcode data member and causes confusion among users. 121 125 // 122 126 … … 124 128 #include "GenParticle.h" 125 129 #include "WeightContainer.h" 130 #include "GenCrossSection.h" 126 131 #include "HeavyIon.h" 127 132 #include "PdfInfo.h" 128 133 #include "Units.h" 134 #include "HepMCDefs.h" 129 135 #include <map> 130 136 #include <string> … … 134 140 135 141 namespace HepMC { 142 143 class GenEventVertexRange; 144 class ConstGenEventVertexRange; 145 class GenEventParticleRange; 146 class ConstGenEventParticleRange; 136 147 137 148 //! The GenEvent class is the core of HepMC … … 146 157 friend class GenVertex; 147 158 public: 148 /// default constructor creates null pointers to HeavyIon and PdfInfo159 /// default constructor creates null pointers to HeavyIon, PdfInfo, and GenCrossSection 149 160 GenEvent( int signal_process_id = 0, int event_number = 0, 150 161 GenVertex* signal_vertex = 0, … … 202 213 /// pair of pointers to the two incoming beam particles 203 214 std::pair<HepMC::GenParticle*,HepMC::GenParticle*> beam_particles() const; 215 /// check GenEvent for validity 216 /// A GenEvent is presumed valid if it has particles and/or vertices. 217 bool is_valid() const; 204 218 205 219 /// direct access to the weights container is allowed. … … 211 225 const WeightContainer& weights() const; //!< direct access to WeightContainer 212 226 227 /// access the GenCrossSection container if it exists 228 GenCrossSection const * cross_section() const; 229 GenCrossSection* cross_section(); 213 230 /// access the HeavyIon container if it exists 214 HeavyIon const * 231 HeavyIon const * heavy_ion() const; 215 232 HeavyIon* heavy_ion(); 216 233 /// access the PdfInfo container if it exists 217 PdfInfo const * 234 PdfInfo const * pdf_info() const; 218 235 PdfInfo* pdf_info(); 219 236 … … 230 247 bool vertices_empty() const; 231 248 249 /// Write the unit information to an output stream. 250 /// If the output stream is not defined, use std::cout. 232 251 void write_units( std::ostream & os = std::cout ) const; 252 /// If the cross section is defined, 253 /// write the cross section information to an output stream. 254 /// If the output stream is not defined, use std::cout. 255 void write_cross_section( std::ostream& ostr = std::cout ) const; 233 256 234 257 /// Units used by the GenParticle momentum FourVector. … … 236 259 /// Units used by the GenVertex position FourVector. 237 260 Units::LengthUnit length_unit() const; 261 262 std::ostream& write(std::ostream&); 263 std::istream& read(std::istream&); 238 264 239 265 ///////////////////// … … 261 287 void set_random_states( const std::vector<long>& randomstates ); 262 288 289 /// provide a pointer to the GenCrossSection container 290 void set_cross_section( const GenCrossSection& ); 263 291 /// provide a pointer to the HeavyIon container 264 292 void set_heavy_ion( const HeavyIon& ion ); … … 271 299 /// the string must match the enum exactly 272 300 void use_units( std::string&, std::string& ); 301 302 /// vertex range 303 GenEventVertexRange vertex_range(); 304 /// vertex range 305 ConstGenEventVertexRange vertex_range() const; 306 /// particle range 307 GenEventParticleRange particle_range(); 308 /// particle range 309 ConstGenEventParticleRange particle_range() const; 273 310 274 311 public: … … 320 357 std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator 321 358 m_map_iterator; 359 private: 360 /// Pre-fix increment -- is not allowed 361 vertex_const_iterator& operator--(void); 362 /// Post-fix increment -- is not allowed 363 vertex_const_iterator operator--(int); 322 364 }; 323 365 friend class vertex_const_iterator; … … 377 419 std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator 378 420 m_map_iterator; 421 private: 422 /// Pre-fix increment 423 vertex_iterator& operator--(void); 424 /// Post-fix increment 425 vertex_iterator operator--(int); 426 379 427 }; 380 428 friend class vertex_iterator; … … 439 487 /// const iterator to the GenParticle map 440 488 std::map<int,HepMC::GenParticle*>::const_iterator m_map_iterator; 489 private: 490 /// Pre-fix increment 491 particle_const_iterator& operator--(void); 492 /// Post-fix increment 493 particle_const_iterator operator--(int); 441 494 }; 442 495 friend class particle_const_iterator; … … 492 545 /// iterator for GenParticle map 493 546 std::map<int,HepMC::GenParticle*>::iterator m_map_iterator; 547 private: 548 /// Pre-fix increment 549 particle_iterator& operator--(void); 550 /// Post-fix increment 551 particle_iterator operator--(int); 494 552 }; 495 553 friend class particle_iterator; … … 526 584 bool use_length_unit( Units::LengthUnit ); 527 585 bool use_length_unit( std::string& ); 586 587 // the following internal methods are used by read() and write() 588 589 /// send the beam particles to ASCII output 590 std::ostream & write_beam_particles( std::ostream &, 591 std::pair<HepMC::GenParticle *,HepMC::GenParticle *> ); 592 /// send a GenVertex to ASCII output 593 std::ostream & write_vertex( std::ostream &, GenVertex const * ); 594 /// send a GenParticle to ASCII output 595 std::ostream & write_particle( std::ostream&, GenParticle const * ); 596 /// find the file type 597 std::istream & find_file_type( std::istream & ); 598 /// find the key at the end of the block 599 std::istream & find_end_key( std::istream &, int & ); 600 /// get unit information from ASCII input 601 std::istream & read_units( std::istream & ); 602 /// get weight names from ASCII input 603 std::istream & read_weight_names( std::istream & ); 604 /// read the event header line 605 std::istream & process_event_line( std::istream &, int &, int &, int &, int & ); 528 606 529 607 private: // data members … … 544 622 std::map< int,HepMC::GenVertex*,std::greater<int> > m_vertex_barcodes; 545 623 std::map< int,HepMC::GenParticle*,std::less<int> > m_particle_barcodes; 624 GenCrossSection* m_cross_section; // undefined by default 546 625 HeavyIon* m_heavy_ion; // undefined by default 547 626 PdfInfo* m_pdf_info; // undefined by default … … 549 628 Units::LengthUnit m_position_unit; // default value set by configure switch 550 629 551 //static unsigned int s_counter;552 630 }; 631 632 633 /////////////////////////// 634 // IO Free Functions // 635 /////////////////////////// 636 637 /// standard streaming IO output operator 638 std::ostream & operator << (std::ostream &, GenEvent &); 639 /// standard streaming IO input operator 640 std::istream & operator >> (std::istream &, GenEvent &); 641 /// set the units for this input stream 642 std::istream & set_input_units(std::istream &, 643 Units::MomentumUnit, Units::LengthUnit); 644 /// Explicitly write the begin block lines that IO_GenEvent uses 645 std::ostream & write_HepMC_IO_block_begin(std::ostream & ); 646 /// Explicitly write the end block line that IO_GenEvent uses 647 std::ostream & write_HepMC_IO_block_end(std::ostream & ); 553 648 554 649 … … 596 691 inline const WeightContainer& GenEvent::weights() const 597 692 { return m_weights; } 693 694 inline GenCrossSection const * GenEvent::cross_section() const 695 { return m_cross_section; } 696 697 inline GenCrossSection* GenEvent::cross_section() 698 { return m_cross_section; } 598 699 599 700 inline HeavyIon const * GenEvent::heavy_ion() const … … 639 740 } 640 741 742 inline void GenEvent::set_cross_section( const GenCrossSection& xs ) 743 { 744 delete m_cross_section; 745 m_cross_section = new GenCrossSection(xs); 746 } 747 641 748 inline void GenEvent::set_heavy_ion( const HeavyIon& ion ) 642 { m_heavy_ion = new HeavyIon(ion); } 749 { 750 delete m_heavy_ion; 751 m_heavy_ion = new HeavyIon(ion); 752 } 643 753 644 754 inline void GenEvent::set_pdf_info( const PdfInfo& p ) 645 { m_pdf_info = new PdfInfo(p); } 755 { 756 delete m_pdf_info; 757 m_pdf_info = new PdfInfo(p); 758 } 646 759 647 760 inline void GenEvent::set_random_states( const std::vector<long>& … … 649 762 { m_random_states = randomstates; } 650 763 651 inline void GenEvent::remove_barcode( HepMC::GenParticle* p )764 inline void GenEvent::remove_barcode( GenParticle* p ) 652 765 { m_particle_barcodes.erase( p->barcode() ); } 653 766 … … 668 781 /// The barcodes are chosen and set automatically when a vertex or particle 669 782 /// comes under the ownership of an event (i.e. it is contained in an event). 783 /// 784 /// Please note that the barcodes are intended for internal use within 785 /// HepMC as a unique identifier for the particles and vertices. 786 /// Using the barcode to encode extra information is an abuse of 787 /// the barcode data member and causes confusion among users. 670 788 inline GenParticle* GenEvent::barcode_to_particle( int barCode ) const 671 789 { … … 688 806 /// The barcodes are chosen and set automatically when a vertex or particle 689 807 /// comes under the ownership of an event (i.e. it is contained in an event). 808 /// 809 /// Please note that the barcodes are intended for internal use within 810 /// HepMC as a unique identifier for the particles and vertices. 811 /// Using the barcode to encode extra information is an abuse of 812 /// the barcode data member and causes confusion among users. 690 813 inline GenVertex* GenEvent::barcode_to_vertex( int barCode ) const 691 814 { … … 709 832 710 833 // beam particles 711 inline std::pair<HepMC::GenParticle *,HepMC::GenParticle*> GenEvent::beam_particles() const {712 return std::pair<GenParticle *,GenParticle*> (m_beam_particle_1, m_beam_particle_2);834 inline std::pair<HepMC::GenParticle *,HepMC::GenParticle *> GenEvent::beam_particles() const { 835 return std::pair<GenParticle *,GenParticle *> (m_beam_particle_1, m_beam_particle_2); 713 836 } 714 837
Note:
See TracChangeset
for help on using the changeset viewer.