StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IO_HERWIG.h
1 //--------------------------------------------------------------------------
2 #ifndef HEPMC_IO_HERWIG_H
3 #define HEPMC_IO_HERWIG_H
4 
6 // Matt.Dobbs@Cern.CH, October 2002, refer to:
7 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for
8 // High Energy Physics", Computer Physics Communications (to be published).
9 //
10 // IO class for reading the (non-standard) HEPEVT common block from
11 // the Herwig monte carlo program.
12 // Notes:
13 // - The HERWIG HEPEVT common block is non-standard, primarily because it
14 // contains some color flow information. When you call IO_HERWIG, the
15 // HEPEVT common block is transformed to the standard. THIS CHANGES THE
16 // CONTENT of HEPEVT!.
17 // - The HERWIG HEPEVT common block has some EXTRA non-physical ENTRIES
18 // (such as CMS frame, HARD subprocess, and CONE).
19 // These are removed by IO_HERWIG. Thus the HepMC event will APPEAR
20 // to have fewer particles in it that herwig did.
21 // There is a switch m_no_gaps_in_barcodes. For
22 // true - then the extra particles are removed from HEPEVT, with
23 // the result that the HepMC barcodes will be sequential, with
24 // no gaps.
25 // false - the barcodes will correspond directly to the HEPEVT index, but
26 // there will be gaps ... ie some barcodes will be unassigned.
27 // this switch requested by I Hinchliffe, October 31, 2002
28 // - some of the Herwig GLUON SPLITTING products are not properly documented
29 // in hepevt. I was unable to repair this in a simple and robust way.
30 // Therefore some of the gluon splitting products will be orphans
31 // in the HepMC output.
32 // - Herwig uses HEPEVT_Wrapper::set_max_number_entries(4000);
33 // HEPEVT_Wrapper::set_sizeof_real(8);
34 // which are the defaults for HEPEVT_Wrapper.
36 //
37 
38 #include <set>
39 #include <vector>
40 #include "HepMC/IO_BaseClass.h"
41 #include "HepMC/HEPEVT_Wrapper.h"
42 
43 namespace HepMC {
44 
45  class GenEvent;
46  class GenVertex;
47  class GenParticle;
48 
50 
56  class IO_HERWIG : public IO_BaseClass {
57  public:
58  IO_HERWIG();
59  virtual ~IO_HERWIG();
61  bool fill_next_event( GenEvent* );
63  void print( std::ostream& ostr = std::cout ) const;
65  double interfaces_to_version_number() const {return 6.400;}
66 
67  // see comments below for these switches.
69  bool print_inconsistency_errors() const;
71  void set_print_inconsistency_errors( bool b = true );
72 
74  bool no_gaps_in_barcodes() const
75  { return m_no_gaps_in_barcodes; }
87  void set_no_gaps_in_barcodes( bool a )
88  { m_no_gaps_in_barcodes=a; }
89 
90  protected: // for internal use only
94  bool trust_mothers_before_daughters() const;
96  void set_trust_mothers_before_daughters( bool b = true );
98  void set_trust_both_mothers_and_daughters( bool b = false );
99 
101  GenParticle* build_particle( int index );
104  int i,std::vector<GenParticle*>& hepevt_particle, GenEvent* evt );
106  void build_end_vertex(
107  int i, std::vector<GenParticle*>& hepevt_particle, GenEvent* evt );
109  int find_in_map(
110  const std::map<GenParticle*,int>& m, GenParticle* p) const;
111 
113  void repair_hepevt() const;
115  void remove_gaps_in_hepevt() const;
117  void zero_hepevt_entry( int i ) const;
119  int translate_herwig_to_pdg_id( int i ) const;
120 
121  private: // following are not implemented for Herwig
122  virtual void write_event( const GenEvent* ){}
123 
124  private: // use of copy constructor is not allowed
125  IO_HERWIG( const IO_HERWIG& ) : IO_BaseClass() {}
126 
127  private: // data members
128  bool m_trust_mothers_before_daughters;
129  bool m_trust_both_mothers_and_daughters;
130  bool m_print_inconsistency_errors;
131  bool m_no_gaps_in_barcodes;
132  std::vector<int> m_herwig_to_pdg_id;
133  std::set<int> m_no_antiparticles;
134  };
135 
137  // INLINES access methods //
140  { return m_trust_both_mothers_and_daughters; }
141 
143  { return m_trust_mothers_before_daughters; }
144 
146  { return m_print_inconsistency_errors; }
147 
149  { m_trust_both_mothers_and_daughters = b; }
150 
152  { m_trust_mothers_before_daughters = b; }
153 
155  { m_print_inconsistency_errors = b; }
156 
157 } // HepMC
158 
159 #endif // HEPMC_IO_HERWIG_H
160 //--------------------------------------------------------------------------
int translate_herwig_to_pdg_id(int i) const
translate particle ID
Definition: IO_HERWIG.cc:753
int find_in_map(const std::map< GenParticle *, int > &m, GenParticle *p) const
find this particle in the map
Definition: IO_HERWIG.cc:387
void set_trust_both_mothers_and_daughters(bool b=false)
define mother daughter trust rules
Definition: IO_HERWIG.h:148
bool fill_next_event(GenEvent *)
get the next event
Definition: IO_HERWIG.cc:96
void repair_hepevt() const
make the HERWIG HEPEVT common block look like the standard
Definition: IO_HERWIG.cc:394
void print(std::ostream &ostr=std::cout) const
write to ostr
Definition: IO_HERWIG.cc:85
IO_HERWIG is used to get Herwig information.
Definition: IO_HERWIG.h:56
bool no_gaps_in_barcodes() const
ask how to deal with extra non-physical pseudo particles
Definition: IO_HERWIG.h:74
GenParticle * build_particle(int index)
make a particle
Definition: IO_HERWIG.cc:372
The GenEvent class is the core of HepMC.
Definition: GenEvent.h:155
all input/output classes inherit from IO_BaseClass
Definition: IO_BaseClass.h:34
void remove_gaps_in_hepevt() const
deal with artifacts of repairing HEPEVT
Definition: IO_HERWIG.cc:682
void set_trust_mothers_before_daughters(bool b=true)
define mother daughter trust rules
Definition: IO_HERWIG.h:151
void build_end_vertex(int i, std::vector< GenParticle * > &hepevt_particle, GenEvent *evt)
make a decay vertex
Definition: IO_HERWIG.cc:304
bool print_inconsistency_errors() const
default is true
Definition: IO_HERWIG.h:145
double interfaces_to_version_number() const
this information is dubious
Definition: IO_HERWIG.h:65
void set_print_inconsistency_errors(bool b=true)
decide whether or not to print inconsistency errors
Definition: IO_HERWIG.h:154
bool trust_both_mothers_and_daughters() const
default is true
Definition: IO_HERWIG.h:139
void set_no_gaps_in_barcodes(bool a)
Definition: IO_HERWIG.h:87
bool trust_mothers_before_daughters() const
default is false
Definition: IO_HERWIG.h:142
void build_production_vertex(int i, std::vector< GenParticle * > &hepevt_particle, GenEvent *evt)
make a production vertex
Definition: IO_HERWIG.cc:231
void zero_hepevt_entry(int i) const
zero out a HEPEVT pseudo particle
Definition: IO_HERWIG.cc:742
The GenParticle class contains information about generated particles.
Definition: GenParticle.h:60