Fork me on GitHub

Ignore:
Timestamp:
Nov 2, 2011, 5:39:26 PM (13 years ago)
Author:
cp3-support
Message:

upgrade HepMC to version 2.06.05

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/HepMC/interface/GenEvent.h

    r349 r572  
    119119//   parent_event() return value will return a pointer to the event which owns
    120120//   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.
    121125//
    122126
     
    124128#include "GenParticle.h"
    125129#include "WeightContainer.h"
     130#include "GenCrossSection.h"
    126131#include "HeavyIon.h"
    127132#include "PdfInfo.h"
    128133#include "Units.h"
     134#include "HepMCDefs.h"
    129135#include <map>
    130136#include <string>
     
    134140
    135141namespace HepMC {
     142
     143    class GenEventVertexRange;
     144    class ConstGenEventVertexRange;
     145    class GenEventParticleRange;
     146    class ConstGenEventParticleRange;
    136147
    137148    //! The GenEvent class is the core of HepMC
     
    146157        friend class GenVertex; 
    147158    public:
    148         /// default constructor creates null pointers to HeavyIon and PdfInfo
     159        /// default constructor creates null pointers to HeavyIon, PdfInfo, and GenCrossSection
    149160        GenEvent( int signal_process_id = 0, int event_number = 0,
    150161                  GenVertex* signal_vertex = 0,
     
    202213        /// pair of pointers to the two incoming beam particles
    203214        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;
    204218
    205219        /// direct access to the weights container is allowed.
     
    211225        const WeightContainer&  weights() const; //!< direct access to WeightContainer
    212226
     227        /// access the GenCrossSection container if it exists
     228        GenCrossSection const *     cross_section() const;
     229        GenCrossSection*            cross_section();
    213230        /// access the HeavyIon container if it exists
    214         HeavyIon const *          heavy_ion() const;
     231        HeavyIon const *         heavy_ion() const;
    215232        HeavyIon*                heavy_ion();
    216233        /// access the PdfInfo container if it exists
    217         PdfInfo const *           pdf_info() const;
     234        PdfInfo const *          pdf_info() const;
    218235        PdfInfo*                 pdf_info();
    219236
     
    230247        bool    vertices_empty() const;
    231248
     249        /// Write the unit information to an output stream. 
     250        /// If the output stream is not defined, use std::cout.
    232251        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;
    233256
    234257        /// Units used by the GenParticle momentum FourVector.
     
    236259        /// Units used by the GenVertex position FourVector.
    237260        Units::LengthUnit   length_unit()   const;
     261       
     262        std::ostream& write(std::ostream&);
     263        std::istream& read(std::istream&);
    238264
    239265        /////////////////////
     
    261287        void set_random_states( const std::vector<long>& randomstates );
    262288
     289        /// provide a pointer to the GenCrossSection container
     290        void set_cross_section( const GenCrossSection& );
    263291        /// provide a pointer to the HeavyIon container
    264292        void set_heavy_ion( const HeavyIon& ion );
     
    271299        /// the string must match the enum exactly
    272300        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;
    273310
    274311    public:
     
    320357            std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator
    321358                                                                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);
    322364        };
    323365        friend class vertex_const_iterator;
     
    377419            std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator
    378420                                                               m_map_iterator;
     421        private:
     422            /// Pre-fix increment
     423            vertex_iterator&  operator--(void);
     424            /// Post-fix increment
     425            vertex_iterator   operator--(int);
     426
    379427        };
    380428        friend class vertex_iterator;
     
    439487            /// const iterator to the GenParticle map
    440488            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);
    441494        };     
    442495        friend class particle_const_iterator;
     
    492545            /// iterator for GenParticle map
    493546            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);
    494552        };
    495553        friend class particle_iterator;
     
    526584        bool use_length_unit( Units::LengthUnit );
    527585        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 & );
    528606
    529607    private: // data members
     
    544622        std::map< int,HepMC::GenVertex*,std::greater<int> >   m_vertex_barcodes;
    545623        std::map< int,HepMC::GenParticle*,std::less<int> >    m_particle_barcodes;
     624        GenCrossSection*         m_cross_section;             // undefined by default
    546625        HeavyIon*             m_heavy_ion;            // undefined by default
    547626        PdfInfo*              m_pdf_info;             // undefined by default
     
    549628        Units::LengthUnit     m_position_unit;    // default value set by configure switch
    550629
    551         //static unsigned int   s_counter;
    552630    };
     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 & );
    553648
    554649
     
    596691    inline const WeightContainer& GenEvent::weights() const
    597692    { 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; }
    598699
    599700    inline HeavyIon const * GenEvent::heavy_ion() const
     
    639740    }
    640741
     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
    641748    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    }
    643753
    644754    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    }
    646759
    647760    inline void GenEvent::set_random_states( const std::vector<long>&
     
    649762    { m_random_states = randomstates; }
    650763
    651     inline void GenEvent::remove_barcode( HepMC::GenParticle* p )
     764    inline void GenEvent::remove_barcode( GenParticle* p )
    652765    { m_particle_barcodes.erase( p->barcode() ); }
    653766
     
    668781    /// The barcodes are chosen and set automatically when a vertex or particle
    669782    /// 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.
    670788    inline GenParticle* GenEvent::barcode_to_particle( int barCode ) const
    671789    {
     
    688806    /// The barcodes are chosen and set automatically when a vertex or particle
    689807    /// 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.
    690813    inline GenVertex* GenEvent::barcode_to_vertex( int barCode ) const
    691814    {
     
    709832   
    710833    // 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);
    713836    }
    714837
Note: See TracChangeset for help on using the changeset viewer.