[CMSSW] / CMSSW / SimDataFormats / GeneratorProducts / interface / LHERunInfoProduct.h Repository:
ViewVC logotype

Annotation of /CMSSW/SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (view) (download)

1 : saout 1.1 #ifndef SimDataFormats_GeneratorProducts_LHERunInfoProduct_h
2 :     #define SimDataFormats_GeneratorProducts_LHERunInfoProduct_h
3 :    
4 :     #include <iterator>
5 :     #include <memory>
6 :     #include <vector>
7 :     #include <string>
8 :    
9 :     //#include <hepml.hpp>
10 :    
11 :     #include "SimDataFormats/GeneratorProducts/interface/LesHouches.h"
12 :    
13 :     class LHERunInfoProduct {
14 :     public:
15 :     class Header {
16 :     public:
17 :     typedef std::vector<std::string>::const_iterator const_iterator;
18 :     typedef std::vector<std::string>::size_type size_type;
19 :    
20 :     Header() {}
21 :     Header(const std::string &tag) : tag_(tag) {}
22 :     ~Header() {}
23 :    
24 :     void addLine(const std::string &line) { lines_.push_back(line); }
25 :    
26 :     const std::string &tag() const { return tag_; }
27 :    
28 :     size_type size() const { return lines_.size(); }
29 :     const_iterator begin() const { return lines_.begin(); }
30 :     const_iterator end() const { return lines_.end(); }
31 :    
32 : saout 1.3 bool operator == (const Header &other) const
33 :     { return tag_ == other.tag_ && lines_ == other.lines_; }
34 :     inline bool operator != (const Header &other) const
35 :     { return !(*this == other); }
36 :    
37 : saout 1.1 private:
38 :     std::string tag_;
39 :     std::vector<std::string> lines_;
40 :     };
41 :    
42 :     typedef std::vector<Header>::size_type size_type;
43 :     typedef std::vector<Header>::const_iterator headers_const_iterator;
44 :     typedef std::vector<std::string>::const_iterator
45 :     comments_const_iterator;
46 :    
47 :     LHERunInfoProduct() {}
48 :     LHERunInfoProduct(const lhef::HEPRUP &heprup) : heprup_(heprup) {}
49 :     ~LHERunInfoProduct() {}
50 :    
51 :     void addHeader(const Header &header) { headers_.push_back(header); }
52 :     void addComment(const std::string &line) { comments_.push_back(line); }
53 :    
54 :     const lhef::HEPRUP &heprup() const { return heprup_; }
55 :    
56 :     size_type headers_size() const { return headers_.size(); }
57 :     headers_const_iterator headers_begin() const { return headers_.begin(); }
58 :     headers_const_iterator headers_end() const { return headers_.end(); }
59 :    
60 :     size_type comments_size() const { return comments_.size(); }
61 :     comments_const_iterator comments_begin() const { return comments_.begin(); }
62 :     comments_const_iterator comments_end() const { return comments_.end(); }
63 :    
64 :     class const_iterator {
65 :     public:
66 :     typedef std::forward_iterator_tag iterator_category;
67 :     typedef std::string value_type;
68 :     typedef std::ptrdiff_t difference_type;
69 :     typedef std::string *pointer;
70 :     typedef std::string &reference;
71 :    
72 :     const_iterator() : mode(kDone) {}
73 :     ~const_iterator() {}
74 :    
75 :     bool operator == (const const_iterator &other) const;
76 :     inline bool operator != (const const_iterator &other) const
77 :     { return !operator == (other); }
78 :    
79 :     inline const_iterator &operator ++ ()
80 :     { next(); return *this; }
81 :     inline const_iterator operator ++ (int dummy)
82 :     { const_iterator orig = *this; next(); return orig; }
83 :    
84 :     const std::string &operator * () const { return tmp; }
85 :     const std::string *operator -> () const { return &tmp; }
86 :    
87 :     private:
88 :     friend class LHERunInfoProduct;
89 :    
90 :     void next();
91 :    
92 :     enum Mode {
93 : saout 1.2 kHeader,
94 :     kBody,
95 : saout 1.1 kInit,
96 :     kDone,
97 :     kFooter
98 :     };
99 :    
100 :     const LHERunInfoProduct *runInfo;
101 :     headers_const_iterator header;
102 :     Header::const_iterator iter;
103 :     Mode mode;
104 :     unsigned int line;
105 :     std::string tmp;
106 :     };
107 :    
108 :     const_iterator begin() const;
109 : saout 1.2 const_iterator init() const;
110 : saout 1.1 inline const_iterator end() const { return const_iterator(); }
111 :    
112 :     static const std::string &endOfFile();
113 :    
114 : saout 1.3 bool operator == (const LHERunInfoProduct &other) const
115 :     { return heprup_ == other.heprup_ && headers_ == other.headers_ && comments_ == other.comments_; }
116 :     inline bool operator != (const LHERunInfoProduct &other) const
117 :     { return !(*this == other); }
118 :    
119 :     bool mergeProduct(const LHERunInfoProduct &other);
120 :     bool isProductEqual(const LHERunInfoProduct &other)
121 :     { return *this == other; }
122 :    
123 : saout 1.1 private:
124 :     lhef::HEPRUP heprup_;
125 :     std::vector<Header> headers_;
126 :     std::vector<std::string> comments_;
127 :     };
128 :    
129 :     #endif // GeneratorRunInfo_LHEInterface_LHERunInfoProduct_h

CERN LCG CVS service
ViewVC Help
Powered by ViewVC 1.0.9