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 }
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,
70  kAccepted
71  };
72 
73  struct XSec {
74  public:
75  XSec() : value_(0.0), error_(0.0) {}
76  XSec(double v, double e): value_(v), error_(e){}
77  double value(){return value_;}
78  double error(){return error_;}
79  private:
80  double value_;
81  double error_;
82  };
83 
84  void count(int process, CountMode count, double eventWeight = 1.0,
85  double brWeight = 1.0, double matchWeight = 1.0);
86  XSec xsec() const;
87  void statistics() const;
88 
89  std::pair<int, int> pdfSetTranslation() const;
90 
91  struct Counter {
92  public:
93  Counter() : n_(0), sum_(0.0), sum2_(0.0) {}
94  Counter(unsigned int n1, double sum1, double sum21)
95  :n_(n1), sum_(sum1), sum2_(sum21) {}
96  inline void add(double weight)
97  {
98  n_++;
99  sum_ += weight;
100  sum2_ += weight * weight;
101  }
102  unsigned int n() const {return n_;}
103  double sum() const {return sum_;}
104  double sum2() const {return sum2_;}
105  private:
106  unsigned int n_;
107  double sum_;
108  double sum2_;
109  };
110 
111  struct Process {
112  public:
113  Process(): process_(-1), heprupIndex_(-1), nPassPos_(0), nPassNeg_(0), nTotalPos_(0), nTotalNeg_(0){}
114  Process(int id): process_(id), heprupIndex_(-1), nPassPos_(0), nPassNeg_(0), nTotalPos_(0), nTotalNeg_(0){}
115  // accessors
116  int process() const {return process_;}
117  unsigned int heprupIndex() const {return heprupIndex_;}
118  XSec getLHEXSec() const {return lheXSec_;}
119 
120  unsigned int nPassPos() const {return nPassPos_;}
121  unsigned int nPassNeg() const {return nPassNeg_;}
122  unsigned int nTotalPos() const {return nTotalPos_;}
123  unsigned int nTotalNeg() const {return nTotalNeg_;}
124 
125  Counter tried() const {return tried_;}
126  Counter selected() const {return selected_;}
127  Counter killed() const {return killed_;}
128  Counter accepted() const {return accepted_;}
129  Counter acceptedBr() const {return acceptedBr_;}
130 
131  // setters
132  void setProcess(int id) {process_ = id;}
133  void setHepRupIndex(int id) {heprupIndex_ = id;}
134  void setLHEXSec(double value, double error) {lheXSec_ = XSec(value,error);}
135 
136  void addNPassPos(unsigned int n=1) { nPassPos_ += n; }
137  void addNPassNeg(unsigned int n=1) { nPassNeg_ += n; }
138  void addNTotalPos(unsigned int n=1) { nTotalPos_ += n; }
139  void addNTotalNeg(unsigned int n=1) { nTotalNeg_ += n; }
140 
141  void addTried(double w) {tried_.add(w);}
142  void addSelected(double w) {selected_.add(w);}
143  void addKilled(double w) {killed_.add(w);}
144  void addAccepted(double w) {accepted_.add(w);}
145  void addAcceptedBr(double w) {acceptedBr_.add(w);}
146 
147  private:
148  int process_;
150  unsigned int heprupIndex_;
151  unsigned int nPassPos_;
152  unsigned int nPassNeg_;
153  unsigned int nTotalPos_;
154  unsigned int nTotalNeg_;
160  };
161 
162  private:
163  void init();
164 
166  std::vector<Process> processes;
167  std::vector<Header> headers;
168  std::vector<std::string> comments;
169 
170  public:
171  const std::vector<Process>& getLumiProcesses() const {return processesLumi;}
172  const int getHEPIDWTUP() const {return heprup.IDWTUP;}
173  void initLumi();
174  private:
175  std::vector<Process> processesLumi;
176 };
177 
178 } // namespace lhef
179 
180 #ifdef UNDEF_XERCES_CPP_NAMESPACE_QUALIFIER
181 # undef XERCES_CPP_NAMESPACE_QUALIFIER
182 #endif
183 
184 #endif // GeneratorRunInfo_LHEInterface_LHERunInfo_h
unsigned int nTotalPos() const
Definition: LHERunInfo.h:122
const std::vector< std::string > & getComments() const
Definition: LHERunInfo.h:59
unsigned int n() const
Definition: LHERunInfo.h:102
const int getHEPIDWTUP() const
Definition: LHERunInfo.h:172
unsigned int heprupIndex() const
Definition: LHERunInfo.h:117
const double w
Definition: UKUtility.cc:23
void setLHEXSec(double value, double error)
Definition: LHERunInfo.h:134
void addNPassPos(unsigned int n=1)
Definition: LHERunInfo.h:136
void addNTotalNeg(unsigned int n=1)
Definition: LHERunInfo.h:139
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
Definition: weight.py:1
#define XERCES_CPP_NAMESPACE_QUALIFIER
Definition: LHERunInfo.h:16
void addSelected(double w)
Definition: LHERunInfo.h:142
std::vector< Process > processes
Definition: LHERunInfo.h:166
void addNTotalPos(unsigned int n=1)
Definition: LHERunInfo.h:138
void addComment(const std::string &line)
Definition: LHERunInfo.h:64
const std::vector< Process > & getLumiProcesses() const
Definition: LHERunInfo.h:171
XSec getLHEXSec() const
Definition: LHERunInfo.h:118
dummy::DOMDocument * xmlDoc
Definition: LHERunInfo.h:49
void addHeader(const Header &header)
Definition: LHERunInfo.h:63
Counter(unsigned int n1, double sum1, double sum21)
Definition: LHERunInfo.h:94
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
unsigned int heprupIndex_
Definition: LHERunInfo.h:150
const std::vector< Header > & getHeaders() const
Definition: LHERunInfo.h:58
Definition: value.py:1
unsigned int nTotalNeg() const
Definition: LHERunInfo.h:123
void addKilled(double w)
Definition: LHERunInfo.h:143
void addNPassNeg(unsigned int n=1)
Definition: LHERunInfo.h:137
void setHepRupIndex(int id)
Definition: LHERunInfo.h:133
double sum2() const
Definition: LHERunInfo.h:104
unsigned int nPassPos() const
Definition: LHERunInfo.h:120
const HEPRUP * getHEPRUP() const
Definition: LHERunInfo.h:52
void addTried(double w)
Definition: LHERunInfo.h:141
std::vector< Process > processesLumi
Definition: LHERunInfo.h:175
Counter killed() const
Definition: LHERunInfo.h:127
void addAcceptedBr(double w)
Definition: LHERunInfo.h:145
XSec(double v, double e)
Definition: LHERunInfo.h:76
std::vector< std::string > comments
Definition: LHERunInfo.h:168
double sum() const
Definition: LHERunInfo.h:103
void add(double weight)
Definition: LHERunInfo.h:96
void addAccepted(double w)
Definition: LHERunInfo.h:144
std::vector< Header > headers
Definition: LHERunInfo.h:167
Counter acceptedBr() const
Definition: LHERunInfo.h:129
Counter accepted() const
Definition: LHERunInfo.h:128
Counter selected() const
Definition: LHERunInfo.h:126
Counter tried() const
Definition: LHERunInfo.h:125
unsigned int nPassNeg() const
Definition: LHERunInfo.h:121