CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LHERunInfo.h
Go to the documentation of this file.
1 #ifndef GeneratorInterface_LHEInterface_LHERunInfo_h
2 #define GeneratorInterface_LHEInterface_LHERunInfo_h
3 
4 #include <iostream>
5 #include <memory>
6 #include <vector>
7 #include <string>
8 
10 
13 
14 #ifndef XERCES_CPP_NAMESPACE_QUALIFIER
15 # define UNDEF_XERCES_CPP_NAMESPACE_QUALIFIER
16 # define XERCES_CPP_NAMESPACE_QUALIFIER dummy::
17 namespace dummy {
18  class DOMNode;
19  class DOMDocument;
20 }
21 #endif
22 
23 namespace lhef {
24 
25 class LHERunInfo {
26  public:
27  LHERunInfo(std::istream &in);
28  LHERunInfo(const HEPRUP &heprup);
29  LHERunInfo(const HEPRUP &heprup,
30  const std::vector<LHERunInfoProduct::Header> &headers,
31  const std::vector<std::string> &comments);
32  LHERunInfo(const LHERunInfoProduct &product);
33  ~LHERunInfo();
34 
36  public:
37  Header();
38  Header(const std::string &tag);
39  Header(const Header &orig);
40  Header(const LHERunInfoProduct::Header &orig);
41  ~Header();
42 
43 #ifndef UNDEF_XERCES_CPP_NAMESPACE_QUALIFIER
44  const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
45  *getXMLNode() const;
46 #endif
47 
48  private:
49  mutable XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *xmlDoc;
50  };
51 
52  const HEPRUP *getHEPRUP() const { return &heprup; }
53 
54  bool operator == (const LHERunInfo &other) const;
55  inline bool operator != (const LHERunInfo &other) const
56  { return !(*this == other); }
57 
58  const std::vector<Header> &getHeaders() const { return headers; }
59  const std::vector<std::string> &getComments() const { return comments; }
60 
61  std::vector<std::string> findHeader(const std::string &tag) const;
62 
63  void addHeader(const Header &header) { headers.push_back(header); }
64  void addComment(const std::string &line) { comments.push_back(line); }
65 
66  enum CountMode {
67  kTried = 0,
71  };
72 
73  struct XSec {
74  XSec() : value(0.0), error(0.0) {}
75 
76  double value;
77  double error;
78  };
79 
80  void count(int process, CountMode count, double eventWeight = 1.0,
81  double brWeight = 1.0, double matchWeight = 1.0);
82  XSec xsec() const;
83  void statistics() const;
84 
85  std::pair<int, int> pdfSetTranslation() const;
86 
87  private:
88  struct Counter {
89  Counter() : n(0), sum(0.0), sum2(0.0) {}
90 
91  inline void add(double weight)
92  {
93  n++;
94  sum += weight;
95  sum2 += weight * weight;
96  }
97 
98  unsigned int n;
99  double sum;
100  double sum2;
101  };
102 
103  struct Process {
104  int process;
105  unsigned int heprupIndex;
111 
112  inline bool operator < (const Process &other) const
113  { return process < other.process; }
114  inline bool operator < (int process) const
115  { return this->process < process; }
116  inline bool operator == (int process) const
117  { return this->process == process; }
118  };
119 
120  void init();
121 
123  std::vector<Process> processes;
124  std::vector<Header> headers;
125  std::vector<std::string> comments;
126 };
127 
128 } // namespace lhef
129 
130 #ifdef UNDEF_XERCES_CPP_NAMESPACE_QUALIFIER
131 # undef XERCES_CPP_NAMESPACE_QUALIFIER
132 #endif
133 
134 #endif // GeneratorRunInfo_LHEInterface_LHERunInfo_h
const std::vector< std::string > & getComments() const
Definition: LHERunInfo.h:59
XSec xsec() const
Definition: LHERunInfo.cc:153
#define XERCES_CPP_NAMESPACE_QUALIFIER
Definition: LHERunInfo.h:16
std::vector< Process > processes
Definition: LHERunInfo.h:123
void addComment(const std::string &line)
Definition: LHERunInfo.h:64
unsigned int heprupIndex
Definition: LHERunInfo.h:105
bool operator<(const Process &other) const
Definition: LHERunInfo.h:112
void addHeader(const Header &header)
Definition: LHERunInfo.h:63
bool operator!=(const LHERunInfo &other) const
Definition: LHERunInfo.h:55
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * xmlDoc
Definition: LHERunInfo.h:49
const std::string & tag() const
const std::vector< Header > & getHeaders() const
Definition: LHERunInfo.h:58
LHERunInfo(std::istream &in)
Definition: LHERunInfo.cc:41
const HEPRUP * getHEPRUP() const
Definition: LHERunInfo.h:52
bool operator==(int process) const
Definition: LHERunInfo.h:116
std::pair< int, int > pdfSetTranslation() const
Definition: LHERunInfo.cc:502
std::vector< std::string > comments
Definition: LHERunInfo.h:125
void add(double weight)
Definition: LHERunInfo.h:91
std::vector< Header > headers
Definition: LHERunInfo.h:124
void count(int process, CountMode count, double eventWeight=1.0, double brWeight=1.0, double matchWeight=1.0)
Definition: LHERunInfo.cc:132
std::vector< std::string > findHeader(const std::string &tag) const
Definition: LHERunInfo.cc:390
bool operator==(const LHERunInfo &other) const
Definition: LHERunInfo.cc:127
int weight
Definition: histoStyle.py:50
tuple process
Definition: LaserDQM_cfg.py:3
void statistics() const
Definition: LHERunInfo.cc:228