Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:10

0001 //--------------------------------------------------------------------------
0002 #ifndef HEPMC_IO_HEPEVT_H
0003 #define HEPMC_IO_HEPEVT_H
0004 
0005 //////////////////////////////////////////////////////////////////////////
0006 // Matt.Dobbs@Cern.CH, January 2000, refer to:
0007 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for
0008 // High Energy Physics", Computer Physics Communications (to be published).
0009 //
0010 // HEPEVT IO class
0011 //////////////////////////////////////////////////////////////////////////
0012 //
0013 // Important note: This class uses HepMC::HEPEVT_Wrapper which is an
0014 //                 interface to the fortran77 HEPEVT common block.
0015 //                 The precision and number of entries in the F77 common 
0016 //                 block can be specified. See HepMC/HEPEVT_Wrapper.h.
0017 //                 You will very likely have to specify these values for your
0018 //                 application.
0019 //
0020 //
0021 
0022 #include <map>
0023 #include <vector>
0024 #include "HepMC/IO_BaseClass.h"
0025 #include "HepMC/HEPEVT_Wrapper.h"
0026 
0027 namespace HepMC {
0028 
0029     class GenEvent;
0030     class GenVertex;
0031     class GenParticle;
0032 
0033     //! HEPEVT IO class
0034 
0035     ///
0036     /// \class  IO_HEPEVT
0037     /// IO class for reading the standard HEPEVT common block.
0038     ///
0039     class IO_HEPEVT : public IO_BaseClass {
0040     public:
0041     IO_HEPEVT();
0042     virtual           ~IO_HEPEVT();
0043     bool              fill_next_event( GenEvent* );
0044     void              write_event( const GenEvent* );
0045     void              print( std::ostream& ostr = std::cout ) const;
0046     
0047     // see comments below for these switches.
0048     /// default is false
0049     bool              trust_both_mothers_and_daughters() const;
0050     /// default is true
0051     bool              trust_mothers_before_daughters() const;
0052     /// default is true
0053     bool              print_inconsistency_errors() const;
0054     /// default is true
0055     bool              trust_beam_particles() const;
0056         /// define mother daughter trust rules
0057     void              set_trust_mothers_before_daughters( bool b = true );
0058         /// define mother daughter trust rules
0059     void              set_trust_both_mothers_and_daughters( bool b = false );
0060     /// Since HEPEVT has bi-directional pointers, it is possible that
0061     /// the mother/daughter pointers are inconsistent (though physically
0062     /// speaking this should never happen). In practise it happens often.
0063     /// When a conflict occurs (i.e. when mother/daughter pointers are in 
0064     /// disagreement, where an empty (0) pointer is not considered a 
0065     /// disagreement) an error is printed. These errors can be turned off 
0066     /// with:            myio_hepevt.set_print_inconsistency_errors(0);
0067     /// but it is STRONGLY recommended that you print the HEPEVT 
0068     /// common and understand the inconsistency BEFORE you turn off the
0069     /// errors. The messages are there for a reason [remember, there is
0070     /// no message printed when the information is missing, ... only when
0071     /// is it inconsistent. User beware.]
0072     /// You can inspect the HEPEVT common block for inconsistencies with
0073     ///   HEPEVT_Wrapper::check_hepevt_consistency()
0074     ///
0075     /// There is a switch controlling whether the mother pointers or
0076     /// the daughters are to be trusted.
0077     /// For example, in Pythia the mother information is always correctly
0078     /// included, but the daughter information is often left unfilled: in
0079     /// this case we want to trust the mother pointers and not necessarily
0080     /// the daughters. [THIS IS THE DEFAULT]. Unfortunately the reverse
0081     /// happens for the stdhep(2001) translation of Isajet, so we need
0082     /// an option to toggle the choices.
0083     void              set_print_inconsistency_errors( bool b = true );
0084         /// declare whether or not beam particles exist
0085     void              set_trust_beam_particles( bool b = true );
0086 
0087     protected: // for internal use only
0088         /// create a GenParticle
0089     GenParticle* build_particle( int index );
0090         /// create a production vertex
0091     void build_production_vertex( 
0092         int i,std::vector<HepMC::GenParticle*>& hepevt_particle, GenEvent* evt );
0093         /// create an end vertex
0094     void build_end_vertex( 
0095         int i, std::vector<HepMC::GenParticle*>& hepevt_particle, GenEvent* evt );
0096         /// find this particle in the particle map
0097     int  find_in_map( 
0098         const std::map<HepMC::GenParticle*,int>& m, GenParticle* p) const;
0099 
0100     private: // use of copy constructor is not allowed
0101     IO_HEPEVT( const IO_HEPEVT& ) : IO_BaseClass() {}
0102 
0103     private: // data members
0104 
0105     bool m_trust_mothers_before_daughters;
0106     bool m_trust_both_mothers_and_daughters;
0107     bool m_print_inconsistency_errors; 
0108     bool m_trust_beam_particles;
0109     };
0110 
0111     ////////////////////////////
0112     // INLINES access methods //
0113     ////////////////////////////
0114     inline bool IO_HEPEVT::trust_both_mothers_and_daughters() const 
0115     { return m_trust_both_mothers_and_daughters; }
0116     
0117     inline bool IO_HEPEVT::trust_mothers_before_daughters() const 
0118     { return m_trust_mothers_before_daughters; }
0119 
0120     inline bool IO_HEPEVT::print_inconsistency_errors() const
0121     { return m_print_inconsistency_errors; }
0122 
0123     inline void IO_HEPEVT::set_trust_both_mothers_and_daughters( bool b )
0124     { m_trust_both_mothers_and_daughters = b; }
0125 
0126     inline void IO_HEPEVT::set_trust_mothers_before_daughters( bool b )
0127     { m_trust_mothers_before_daughters = b; }
0128 
0129     inline void IO_HEPEVT::set_print_inconsistency_errors( bool b  )
0130     { m_print_inconsistency_errors = b; }
0131 
0132     inline bool IO_HEPEVT::trust_beam_particles() const
0133     { return m_trust_beam_particles; }
0134 
0135     inline void IO_HEPEVT::set_trust_beam_particles( bool b )
0136     { m_trust_beam_particles = b; }
0137 
0138 } // HepMC
0139 
0140 #endif  // HEPMC_IO_HEPEVT_H
0141 //--------------------------------------------------------------------------