CMS 3D CMS Logo

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 } // namespace dummy
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 *getXMLNode() const;
45 #endif
46 
47  private:
48  mutable XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *xmlDoc;
49  };
50 
51  const HEPRUP *getHEPRUP() const { return &heprup; }
52 
53  bool operator==(const LHERunInfo &other) const;
54  inline bool operator!=(const LHERunInfo &other) const { return !(*this == other); }
55 
56  const std::vector<Header> &getHeaders() const { return headers; }
57  const std::vector<std::string> &getComments() const { return comments; }
58 
59  std::vector<std::string> findHeader(const std::string &tag) const;
60 
61  void addHeader(const Header &header) { headers.push_back(header); }
62  void addComment(const std::string &line) { comments.push_back(line); }
63 
65 
66  struct XSec {
67  public:
68  XSec() : value_(0.0), error_(0.0) {}
69  XSec(double v, double e) : value_(v), error_(e) {}
70  double value() { return value_; }
71  double error() { return error_; }
72 
73  private:
74  double value_;
75  double error_;
76  };
77 
78  void count(int process, CountMode count, double eventWeight = 1.0, double brWeight = 1.0, double matchWeight = 1.0);
79  XSec xsec() const;
80  void statistics() const;
81 
82  std::pair<int, int> pdfSetTranslation() const;
83 
84  struct Counter {
85  public:
86  Counter() : n_(0), sum_(0.0), sum2_(0.0) {}
87  Counter(unsigned int n1, double sum1, double sum21) : n_(n1), sum_(sum1), sum2_(sum21) {}
88  inline void add(double weight) {
89  n_++;
90  sum_ += weight;
91  sum2_ += weight * weight;
92  }
93  unsigned int n() const { return n_; }
94  double sum() const { return sum_; }
95  double sum2() const { return sum2_; }
96 
97  private:
98  unsigned int n_;
99  double sum_;
100  double sum2_;
101  };
102 
103  struct Process {
104  public:
107  // accessors
108  int process() const { return process_; }
109  unsigned int heprupIndex() const { return heprupIndex_; }
110  XSec getLHEXSec() const { return lheXSec_; }
111 
112  unsigned int nPassPos() const { return nPassPos_; }
113  unsigned int nPassNeg() const { return nPassNeg_; }
114  unsigned int nTotalPos() const { return nTotalPos_; }
115  unsigned int nTotalNeg() const { return nTotalNeg_; }
116 
117  Counter tried() const { return tried_; }
118  Counter selected() const { return selected_; }
119  Counter killed() const { return killed_; }
120  Counter accepted() const { return accepted_; }
121  Counter acceptedBr() const { return acceptedBr_; }
122 
123  // setters
124  void setProcess(int id) { process_ = id; }
125  void setHepRupIndex(int id) { heprupIndex_ = id; }
126  void setLHEXSec(double value, double error) { lheXSec_ = XSec(value, error); }
127 
128  void addNPassPos(unsigned int n = 1) { nPassPos_ += n; }
129  void addNPassNeg(unsigned int n = 1) { nPassNeg_ += n; }
130  void addNTotalPos(unsigned int n = 1) { nTotalPos_ += n; }
131  void addNTotalNeg(unsigned int n = 1) { nTotalNeg_ += n; }
132 
133  void addTried(double w) { tried_.add(w); }
134  void addSelected(double w) { selected_.add(w); }
135  void addKilled(double w) { killed_.add(w); }
136  void addAccepted(double w) { accepted_.add(w); }
137  void addAcceptedBr(double w) { acceptedBr_.add(w); }
138 
139  private:
140  int process_;
142  unsigned int heprupIndex_;
143  unsigned int nPassPos_;
144  unsigned int nPassNeg_;
145  unsigned int nTotalPos_;
146  unsigned int nTotalNeg_;
152  };
153 
154  private:
155  void init();
156 
158  std::vector<Process> processes;
159  std::vector<Header> headers;
160  std::vector<std::string> comments;
161 
162  public:
163  const std::vector<Process> &getLumiProcesses() const { return processesLumi; }
164  const int getHEPIDWTUP() const { return heprup.IDWTUP; }
165  void initLumi();
166 
167  private:
168  std::vector<Process> processesLumi;
169  };
170 
171 } // namespace lhef
172 
173 #ifdef UNDEF_XERCES_CPP_NAMESPACE_QUALIFIER
174 #undef XERCES_CPP_NAMESPACE_QUALIFIER
175 #endif
176 
177 #endif // GeneratorRunInfo_LHEInterface_LHERunInfo_h
void setLHEXSec(double value, double error)
Definition: LHERunInfo.h:126
const std::vector< std::string > & getComments() const
Definition: LHERunInfo.h:57
T w() const
void addNPassPos(unsigned int n=1)
Definition: LHERunInfo.h:128
void addNTotalNeg(unsigned int n=1)
Definition: LHERunInfo.h:131
Counter selected() const
Definition: LHERunInfo.h:118
const int getHEPIDWTUP() const
Definition: LHERunInfo.h:164
Definition: weight.py:1
#define XERCES_CPP_NAMESPACE_QUALIFIER
Definition: LHERunInfo.h:16
void addSelected(double w)
Definition: LHERunInfo.h:134
std::vector< Process > processes
Definition: LHERunInfo.h:158
unsigned int nPassNeg() const
Definition: LHERunInfo.h:113
void addNTotalPos(unsigned int n=1)
Definition: LHERunInfo.h:130
void addComment(const std::string &line)
Definition: LHERunInfo.h:62
std::pair< int, int > pdfSetTranslation() const
Definition: LHERunInfo.cc:524
const HEPRUP * getHEPRUP() const
Definition: LHERunInfo.h:51
Counter tried() const
Definition: LHERunInfo.h:117
dummy::DOMDocument * xmlDoc
Definition: LHERunInfo.h:48
void addHeader(const Header &header)
Definition: LHERunInfo.h:61
Counter(unsigned int n1, double sum1, double sum21)
Definition: LHERunInfo.h:87
unsigned int heprupIndex() const
Definition: LHERunInfo.h:109
const std::vector< Header > & getHeaders() const
Definition: LHERunInfo.h:56
std::vector< std::string > findHeader(const std::string &tag) const
Definition: LHERunInfo.cc:431
unsigned int heprupIndex_
Definition: LHERunInfo.h:142
Definition: value.py:1
LHERunInfo(std::istream &in)
Definition: LHERunInfo.cc:45
void statistics() const
Definition: LHERunInfo.cc:252
double sum() const
Definition: LHERunInfo.h:94
void addKilled(double w)
Definition: LHERunInfo.h:135
bool operator==(const LHERunInfo &other) const
Definition: LHERunInfo.cc:124
void addNPassNeg(unsigned int n=1)
Definition: LHERunInfo.h:129
void setHepRupIndex(int id)
Definition: LHERunInfo.h:125
double sum2() const
Definition: LHERunInfo.h:95
void addTried(double w)
Definition: LHERunInfo.h:133
std::vector< Process > processesLumi
Definition: LHERunInfo.h:168
const std::vector< Process > & getLumiProcesses() const
Definition: LHERunInfo.h:163
void addAcceptedBr(double w)
Definition: LHERunInfo.h:137
XSec(double v, double e)
Definition: LHERunInfo.h:69
Counter killed() const
Definition: LHERunInfo.h:119
std::vector< std::string > comments
Definition: LHERunInfo.h:160
unsigned int nPassPos() const
Definition: LHERunInfo.h:112
unsigned int nTotalPos() const
Definition: LHERunInfo.h:114
void add(double weight)
Definition: LHERunInfo.h:88
void addAccepted(double w)
Definition: LHERunInfo.h:136
const std::string & tag() const
Counter accepted() const
Definition: LHERunInfo.h:120
bool operator!=(const LHERunInfo &other) const
Definition: LHERunInfo.h:54
Counter acceptedBr() const
Definition: LHERunInfo.h:121
std::vector< Header > headers
Definition: LHERunInfo.h:159
void count(int process, CountMode count, double eventWeight=1.0, double brWeight=1.0, double matchWeight=1.0)
Definition: LHERunInfo.cc:126
XSec xsec() const
Definition: LHERunInfo.cc:170
unsigned int n() const
Definition: LHERunInfo.h:93
unsigned int nTotalNeg() const
Definition: LHERunInfo.h:115