00001 //-------------------------------------------------------------------------- 00002 #ifndef HEPMC_IO_HERWIG_H 00003 #define HEPMC_IO_HERWIG_H 00004 00006 // Matt.Dobbs@Cern.CH, October 2002, refer to: 00007 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for 00008 // High Energy Physics", Computer Physics Communications (to be published). 00009 // 00010 // IO class for reading the (non-standard) HEPEVT common block from 00011 // the Herwig monte carlo program. 00012 // Notes: 00013 // - The HERWIG HEPEVT common block is non-standard, primarily because it 00014 // contains some color flow information. When you call IO_HERWIG, the 00015 // HEPEVT common block is transformed to the standard. THIS CHANGES THE 00016 // CONTENT of HEPEVT!. 00017 // - The HERWIG HEPEVT common block has some EXTRA non-physical ENTRIES 00018 // (such as CMS frame, HARD subprocess, and CONE). 00019 // These are removed by IO_HERWIG. Thus the HepMC event will APPEAR 00020 // to have fewer particles in it that herwig did. 00021 // There is a switch m_no_gaps_in_barcodes. For 00022 // true - then the extra particles are removed from HEPEVT, with 00023 // the result that the HepMC barcodes will be sequential, with 00024 // no gaps. 00025 // false - the barcodes will correspond directly to the HEPEVT index, but 00026 // there will be gaps ... ie some barcodes will be unassigned. 00027 // this switch requested by I Hinchliffe, October 31, 2002 00028 // - some of the Herwig GLUON SPLITTING products are not properly documented 00029 // in hepevt. I was unable to repair this in a simple and robust way. 00030 // Therefore some of the gluon splitting products will be orphans 00031 // in the HepMC output. 00032 // - Herwig uses HEPEVT_Wrapper::set_max_number_entries(4000); 00033 // HEPEVT_Wrapper::set_sizeof_real(8); 00034 // which are the defaults for HEPEVT_Wrapper. 00036 // 00037 00038 #include <set> 00039 #include <vector> 00040 #include "HepMC/IO_BaseClass.h" 00041 #include "HepMC/HEPEVT_Wrapper.h" 00042 00043 namespace HepMC { 00044 00045 class GenEvent; 00046 class GenVertex; 00047 class GenParticle; 00048 class ParticleDataTable; 00049 00051 00057 class IO_HERWIG : public IO_BaseClass { 00058 public: 00059 IO_HERWIG(); 00060 virtual ~IO_HERWIG(); 00062 bool fill_next_event( GenEvent* ); 00064 void print( std::ostream& ostr = std::cout ) const; 00066 double interfaces_to_version_number() const {return 6.400;} 00067 00068 // see comments below for these switches. 00070 bool print_inconsistency_errors() const; 00072 void set_print_inconsistency_errors( bool b = 1 ); 00073 00075 bool no_gaps_in_barcodes() const 00076 { return m_no_gaps_in_barcodes; } 00088 void set_no_gaps_in_barcodes( bool a ) 00089 { m_no_gaps_in_barcodes=a; } 00090 00091 protected: // for internal use only 00093 bool trust_both_mothers_and_daughters() const; 00095 bool trust_mothers_before_daughters() const; 00097 void set_trust_mothers_before_daughters( bool b = 1 ); 00099 void set_trust_both_mothers_and_daughters( bool b = 0 ); 00100 00102 GenParticle* build_particle( int index ); 00104 void build_production_vertex( 00105 int i,std::vector<GenParticle*>& hepevt_particle, GenEvent* evt ); 00107 void build_end_vertex( 00108 int i, std::vector<GenParticle*>& hepevt_particle, GenEvent* evt ); 00110 int find_in_map( 00111 const std::map<GenParticle*,int>& m, GenParticle* p) const; 00112 00114 void repair_hepevt() const; 00116 void remove_gaps_in_hepevt() const; 00118 void zero_hepevt_entry( int i ) const; 00120 int translate_herwig_to_pdg_id( int i ) const; 00121 00122 private: // following are not implemented for Herwig 00123 virtual void write_event( const GenEvent* ){} 00124 virtual void write_particle_data_table( const ParticleDataTable* ){} 00125 virtual bool fill_particle_data_table( ParticleDataTable* ) 00126 { return 0; } 00127 00128 private: // use of copy constructor is not allowed 00129 IO_HERWIG( const IO_HERWIG& ) : IO_BaseClass() {} 00130 00131 private: // data members 00132 bool m_trust_mothers_before_daughters; 00133 bool m_trust_both_mothers_and_daughters; 00134 bool m_print_inconsistency_errors; 00135 bool m_no_gaps_in_barcodes; 00136 std::vector<int> m_herwig_to_pdg_id; 00137 std::set<int> m_no_antiparticles; 00138 }; 00139 00141 // INLINES access methods // 00143 inline bool IO_HERWIG::trust_both_mothers_and_daughters() const 00144 { return m_trust_both_mothers_and_daughters; } 00145 00146 inline bool IO_HERWIG::trust_mothers_before_daughters() const 00147 { return m_trust_mothers_before_daughters; } 00148 00149 inline bool IO_HERWIG::print_inconsistency_errors() const 00150 { return m_print_inconsistency_errors; } 00151 00152 inline void IO_HERWIG::set_trust_both_mothers_and_daughters( bool b ) 00153 { m_trust_both_mothers_and_daughters = b; } 00154 00155 inline void IO_HERWIG::set_trust_mothers_before_daughters( bool b ) 00156 { m_trust_mothers_before_daughters = b; } 00157 00158 inline void IO_HERWIG::set_print_inconsistency_errors( bool b ) 00159 { m_print_inconsistency_errors = b; } 00160 00161 } // HepMC 00162 00163 #endif // HEPMC_IO_HERWIG_H 00164 //--------------------------------------------------------------------------