![]() |
![]() |
00001 #ifndef SimDataFormats_GeneratorProducts_LHERunInfoProduct_h 00002 #define SimDataFormats_GeneratorProducts_LHERunInfoProduct_h 00003 00004 #include <iterator> 00005 #include <memory> 00006 #include <vector> 00007 #include <string> 00008 00009 //#include <hepml.hpp> 00010 00011 #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h" 00012 00013 class LHERunInfoProduct { 00014 public: 00015 class Header { 00016 public: 00017 typedef std::vector<std::string>::const_iterator const_iterator; 00018 typedef std::vector<std::string>::size_type size_type; 00019 00020 Header() {} 00021 Header(const std::string &tag) : tag_(tag) {} 00022 ~Header() {} 00023 00024 void addLine(const std::string &line) { lines_.push_back(line); } 00025 00026 const std::string &tag() const { return tag_; } 00027 00028 size_type size() const { return lines_.size(); } 00029 const_iterator begin() const { return lines_.begin(); } 00030 const_iterator end() const { return lines_.end(); } 00031 00032 bool operator == (const Header &other) const 00033 { return tag_ == other.tag_ && lines_ == other.lines_; } 00034 inline bool operator != (const Header &other) const 00035 { return !(*this == other); } 00036 00037 private: 00038 std::string tag_; 00039 std::vector<std::string> lines_; 00040 }; 00041 00042 typedef std::vector<Header>::size_type size_type; 00043 typedef std::vector<Header>::const_iterator headers_const_iterator; 00044 typedef std::vector<std::string>::const_iterator 00045 comments_const_iterator; 00046 00047 LHERunInfoProduct() {} 00048 LHERunInfoProduct(const lhef::HEPRUP &heprup) : heprup_(heprup) {} 00049 ~LHERunInfoProduct() {} 00050 00051 void addHeader(const Header &header) { headers_.push_back(header); } 00052 void addComment(const std::string &line) { comments_.push_back(line); } 00053 00054 const lhef::HEPRUP &heprup() const { return heprup_; } 00055 00056 size_type headers_size() const { return headers_.size(); } 00057 headers_const_iterator headers_begin() const { return headers_.begin(); } 00058 headers_const_iterator headers_end() const { return headers_.end(); } 00059 00060 size_type comments_size() const { return comments_.size(); } 00061 comments_const_iterator comments_begin() const { return comments_.begin(); } 00062 comments_const_iterator comments_end() const { return comments_.end(); } 00063 00064 class const_iterator { 00065 public: 00066 typedef std::forward_iterator_tag iterator_category; 00067 typedef std::string value_type; 00068 typedef std::ptrdiff_t difference_type; 00069 typedef std::string *pointer; 00070 typedef std::string &reference; 00071 00072 const_iterator() : mode(kDone) {} 00073 ~const_iterator() {} 00074 00075 bool operator == (const const_iterator &other) const; 00076 inline bool operator != (const const_iterator &other) const 00077 { return !operator == (other); } 00078 00079 inline const_iterator &operator ++ () 00080 { next(); return *this; } 00081 inline const_iterator operator ++ (int dummy) 00082 { const_iterator orig = *this; next(); return orig; } 00083 00084 const std::string &operator * () const { return tmp; } 00085 const std::string *operator -> () const { return &tmp; } 00086 00087 private: 00088 friend class LHERunInfoProduct; 00089 00090 void next(); 00091 00092 enum Mode { 00093 kHeader, 00094 kBody, 00095 kInit, 00096 kDone, 00097 kFooter 00098 }; 00099 00100 const LHERunInfoProduct *runInfo; 00101 headers_const_iterator header; 00102 Header::const_iterator iter; 00103 Mode mode; 00104 unsigned int line; 00105 std::string tmp; 00106 }; 00107 00108 const_iterator begin() const; 00109 const_iterator init() const; 00110 inline const_iterator end() const { return const_iterator(); } 00111 00112 static const std::string &endOfFile(); 00113 00114 bool operator == (const LHERunInfoProduct &other) const 00115 { return heprup_ == other.heprup_ && headers_ == other.headers_ && comments_ == other.comments_; } 00116 inline bool operator != (const LHERunInfoProduct &other) const 00117 { return !(*this == other); } 00118 00119 bool mergeProduct(const LHERunInfoProduct &other); 00120 bool isProductEqual(const LHERunInfoProduct &other) const 00121 { return *this == other; } 00122 00123 private: 00124 lhef::HEPRUP heprup_; 00125 std::vector<Header> headers_; 00126 std::vector<std::string> comments_; 00127 }; 00128 00129 #endif // GeneratorRunInfo_LHEInterface_LHERunInfoProduct_h