Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //--------------------------------------------------------------------------
0002 #ifndef HEPMC_IO_HERWIG_H
0003 #define HEPMC_IO_HERWIG_H
0004 
0005 //////////////////////////////////////////////////////////////////////////
0006 // Matt.Dobbs@Cern.CH, October 2002, 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 // IO class for reading the (non-standard) HEPEVT common block from 
0011 //  the Herwig monte carlo program.
0012 // Notes:
0013 //   - The HERWIG HEPEVT common block is non-standard, primarily because it 
0014 //     contains some color flow information. When you call IO_HERWIG, the 
0015 //     HEPEVT common block is transformed to the standard. THIS CHANGES THE
0016 //     CONTENT of HEPEVT!.
0017 //   - The HERWIG HEPEVT common block has some EXTRA non-physical ENTRIES 
0018 //     (such as CMS frame, HARD subprocess, and CONE).
0019 //     These are removed by IO_HERWIG. Thus the HepMC event will APPEAR
0020 //     to have fewer particles in it that herwig did.
0021 //     There is a switch m_no_gaps_in_barcodes. For
0022 //       true  - then the extra particles are removed from HEPEVT, with 
0023 //               the result that the HepMC barcodes will be sequential, with 
0024 //               no gaps.
0025 //       false - the barcodes will correspond directly to the HEPEVT index, but
0026 //               there will be gaps ... ie some barcodes will be unassigned.
0027 //       this switch requested by I Hinchliffe, October 31, 2002
0028 //   - some of the Herwig GLUON SPLITTING products are not properly documented
0029 //     in hepevt. I was unable to repair this in a simple and robust way. 
0030 //     Therefore some of the gluon splitting products will be orphans 
0031 //     in the HepMC output. 
0032 //   - Herwig uses      HEPEVT_Wrapper::set_max_number_entries(4000);
0033 //                      HEPEVT_Wrapper::set_sizeof_real(8);
0034 //     which are the defaults for HEPEVT_Wrapper.
0035 //////////////////////////////////////////////////////////////////////////
0036 //
0037 
0038 #include <set>
0039 #include <vector>
0040 #include "HepMC/IO_BaseClass.h"
0041 #include "HepMC/HEPEVT_Wrapper.h"
0042 
0043 namespace HepMC {
0044 
0045     class GenEvent;
0046     class GenVertex;
0047     class GenParticle;
0048 
0049     //! IO_HERWIG is used to get Herwig information
0050 
0051     ///
0052     /// \class  IO_HERWIG
0053     /// IO class for reading the HEPEVT common block from 
0054     ///  the Herwig monte carlo program.
0055     ///
0056     class IO_HERWIG : public IO_BaseClass {
0057     public:
0058     IO_HERWIG();
0059     virtual           ~IO_HERWIG();
0060         /// get the next event
0061     bool              fill_next_event( GenEvent* );
0062         /// write to ostr
0063     void              print( std::ostream& ostr = std::cout ) const;
0064         /// this information is dubious
0065     double            interfaces_to_version_number() const {return 6.400;}
0066         
0067     // see comments below for these switches.
0068     /// default is true
0069     bool              print_inconsistency_errors() const;
0070     /// decide whether or not to print inconsistency errors
0071     void              set_print_inconsistency_errors( bool b = true );
0072 
0073         /// ask how to deal with extra non-physical pseudo particles
0074     bool              no_gaps_in_barcodes() const 
0075                          { return m_no_gaps_in_barcodes; }
0076     /// The HERWIG HEPEVT common block has some EXTRA non-physical ENTRIES 
0077     /// (such as CMS frame, HARD subprocess, and CONE).
0078     /// These are removed by IO_HERWIG. Thus the HepMC event will APPEAR
0079     /// to have fewer particles in it that herwig did.
0080     /// There is a switch m_no_gaps_in_barcodes. For
0081     ///   true  - then the extra particles are removed from HEPEVT, with 
0082     ///             the result that the HepMC barcodes will be sequential, with 
0083     ///             no gaps.
0084     ///   false - the barcodes will correspond directly to the HEPEVT index, but
0085     ///             there will be gaps ... ie some barcodes will be unassigned.
0086     ///   this switch requested by I Hinchliffe, October 31, 2002
0087     void              set_no_gaps_in_barcodes( bool a ) 
0088                          { m_no_gaps_in_barcodes=a; }
0089 
0090     protected: // for internal use only
0091         /// default is true
0092     bool              trust_both_mothers_and_daughters() const;
0093         /// default is false
0094     bool              trust_mothers_before_daughters() const;
0095         /// define mother daughter trust rules
0096     void              set_trust_mothers_before_daughters( bool b = true );
0097         /// define mother daughter trust rules
0098     void              set_trust_both_mothers_and_daughters( bool b = false );
0099 
0100         /// make a particle
0101     GenParticle* build_particle( int index );
0102     /// make a production vertex
0103     void         build_production_vertex( 
0104         int i,std::vector<GenParticle*>& hepevt_particle, GenEvent* evt );
0105     /// make a decay vertex
0106     void         build_end_vertex( 
0107         int i, std::vector<GenParticle*>& hepevt_particle, GenEvent* evt );
0108         /// find this particle in the map
0109     int          find_in_map( 
0110         const std::map<GenParticle*,int>& m, GenParticle* p) const;
0111 
0112         /// make the HERWIG HEPEVT common block look like the standard
0113     void repair_hepevt() const;
0114     /// deal with artifacts of repairing HEPEVT
0115     void remove_gaps_in_hepevt() const;
0116     /// zero out a HEPEVT pseudo particle
0117     void zero_hepevt_entry( int i ) const;
0118     /// translate particle ID
0119     int  translate_herwig_to_pdg_id( int i ) const;
0120 
0121     private: // following are not implemented for Herwig
0122     virtual void write_event( const GenEvent* ){}
0123 
0124     private: // use of copy constructor is not allowed
0125     IO_HERWIG( const IO_HERWIG& ) : IO_BaseClass() {}
0126 
0127     private: // data members
0128     bool              m_trust_mothers_before_daughters;
0129     bool              m_trust_both_mothers_and_daughters;
0130     bool              m_print_inconsistency_errors; 
0131     bool              m_no_gaps_in_barcodes;
0132     std::vector<int>  m_herwig_to_pdg_id;
0133     std::set<int>     m_no_antiparticles;
0134     };
0135 
0136     ////////////////////////////
0137     // INLINES access methods //
0138     ////////////////////////////
0139     inline bool IO_HERWIG::trust_both_mothers_and_daughters() const 
0140     { return m_trust_both_mothers_and_daughters; }
0141     
0142     inline bool IO_HERWIG::trust_mothers_before_daughters() const 
0143     { return m_trust_mothers_before_daughters; }
0144 
0145     inline bool IO_HERWIG::print_inconsistency_errors() const
0146     { return m_print_inconsistency_errors; }
0147 
0148     inline void IO_HERWIG::set_trust_both_mothers_and_daughters( bool b )
0149     { m_trust_both_mothers_and_daughters = b; }
0150 
0151     inline void IO_HERWIG::set_trust_mothers_before_daughters( bool b )
0152     { m_trust_mothers_before_daughters = b; }
0153 
0154     inline void IO_HERWIG::set_print_inconsistency_errors( bool b  )
0155     { m_print_inconsistency_errors = b; }
0156 
0157 } // HepMC
0158 
0159 #endif  // HEPMC_IO_HERWIG_H
0160 //--------------------------------------------------------------------------