CMS 3D CMS Logo

GenLumiInfoProduct.h
Go to the documentation of this file.
1 #ifndef SimDataFormats_GeneratorProducts_GenLumiInfoProduct_h
2 #define SimDataFormats_GeneratorProducts_GenLumiInfoProduct_h
3 
4 #include <vector>
5 
11 public:
12  // a few forward declarations
13  struct XSec;
14  struct ProcessInfo;
15 
16  // constructors, destructors
18  GenLumiInfoProduct(const int id);
20  virtual ~GenLumiInfoProduct();
21 
22  // getters
23 
24  const int getHEPIDWTUP() const { return hepidwtup_; }
25  const std::vector<ProcessInfo> &getProcessInfos() const { return internalProcesses_; }
26 
27  // setters
28 
29  void setHEPIDWTUP(const int id) { hepidwtup_ = id; }
30  void setProcessInfo(const std::vector<ProcessInfo> &processes) { internalProcesses_ = processes; }
31 
32  // Struct- definitions
33  struct XSec {
34  public:
35  XSec() : value_(-1.), error_(-1.) {}
36  XSec(double v, double e = -1.) : value_(v), error_(e) {}
37  XSec(const XSec &other) : value_(other.value_), error_(other.error_) {}
38 
39  double value() const { return value_; }
40  double error() const { return error_; }
41 
42  bool isSet() const { return value_ >= 0.; }
43  bool hasError() const { return error_ >= 0.; }
44 
45  operator double() const { return value_; }
46  operator bool() const { return isSet(); }
47 
48  bool operator==(const XSec &other) const { return value_ == other.value_ && error_ == other.error_; }
49  bool operator!=(const XSec &other) const { return !(*this == other); }
50 
51  private:
52  double value_, error_;
53  };
54 
55  struct FinalStat {
56  public:
57  FinalStat() : n_(0), sum_(0.0), sum2_(0.0) {}
58  FinalStat(unsigned int n1, double sum1, double sum21) : n_(n1), sum_(sum1), sum2_(sum21) {}
59  FinalStat(const FinalStat &other) : n_(other.n_), sum_(other.sum_), sum2_(other.sum2_) {}
60 
61  unsigned int n() const { return n_; }
62  double sum() const { return sum_; }
63  double sum2() const { return sum2_; }
64 
65  void add(const FinalStat &other) {
66  n_ += other.n();
67  sum_ += other.sum();
68  sum2_ += other.sum2();
69  }
70 
71  bool operator==(const FinalStat &other) const {
72  return n_ == other.n_ && sum_ == other.sum_ && sum2_ == other.sum2_;
73  }
74  bool operator!=(const FinalStat &other) const { return !(*this == other); }
75 
76  private:
77  unsigned int n_;
78  double sum_;
79  double sum2_;
80  };
81 
82  struct ProcessInfo {
83  public:
84  ProcessInfo() : process_(-1), nPassPos_(0), nPassNeg_(0), nTotalPos_(0), nTotalNeg_(0) {}
85  ProcessInfo(int id) : process_(id), nPassPos_(0), nPassNeg_(0), nTotalPos_(0), nTotalNeg_(0) {}
86 
87  // accessors
88  int process() const { return process_; }
89  XSec lheXSec() const { return lheXSec_; }
90 
91  unsigned int nPassPos() const { return nPassPos_; }
92  unsigned int nPassNeg() const { return nPassNeg_; }
93  unsigned int nTotalPos() const { return nTotalPos_; }
94  unsigned int nTotalNeg() const { return nTotalNeg_; }
95 
96  FinalStat tried() const { return tried_; }
97  FinalStat selected() const { return selected_; }
98  FinalStat killed() const { return killed_; }
99  FinalStat accepted() const { return accepted_; }
100  FinalStat acceptedBr() const { return acceptedBr_; }
101 
102  // setters
103  void addOthers(const ProcessInfo &other) {
104  nPassPos_ += other.nPassPos();
105  nPassNeg_ += other.nPassNeg();
106  nTotalPos_ += other.nTotalPos();
107  nTotalNeg_ += other.nTotalNeg();
108  tried_.add(other.tried());
109  selected_.add(other.selected());
110  killed_.add(other.killed());
111  accepted_.add(other.accepted());
112  acceptedBr_.add(other.acceptedBr());
113  }
114  void setProcess(int id) { process_ = id; }
115  void setLheXSec(double value, double err) { lheXSec_ = XSec(value, err); }
116  void setNPassPos(unsigned int n) { nPassPos_ = n; }
117  void setNPassNeg(unsigned int n) { nPassNeg_ = n; }
118  void setNTotalPos(unsigned int n) { nTotalPos_ = n; }
119  void setNTotalNeg(unsigned int n) { nTotalNeg_ = n; }
120  void setTried(unsigned int n, double sum, double sum2) { tried_ = FinalStat(n, sum, sum2); }
121  void setSelected(unsigned int n, double sum, double sum2) { selected_ = FinalStat(n, sum, sum2); }
122  void setKilled(unsigned int n, double sum, double sum2) { killed_ = FinalStat(n, sum, sum2); }
123  void setAccepted(unsigned int n, double sum, double sum2) { accepted_ = FinalStat(n, sum, sum2); }
124  void setAcceptedBr(unsigned int n, double sum, double sum2) { acceptedBr_ = FinalStat(n, sum, sum2); }
125 
126  private:
127  int process_;
129  unsigned int nPassPos_;
130  unsigned int nPassNeg_;
131  unsigned int nTotalPos_;
132  unsigned int nTotalNeg_;
138  };
139 
140  // methods used by EDM
141  virtual bool mergeProduct(const GenLumiInfoProduct &other);
142  void swap(GenLumiInfoProduct &other);
143  virtual bool isProductEqual(const GenLumiInfoProduct &other) const;
144 
145 private:
146  // cross sections
148  std::vector<ProcessInfo> internalProcesses_;
149 };
150 
151 #endif // SimDataFormats_GeneratorProducts_GenLumiInfoProduct_h
const std::vector< ProcessInfo > & getProcessInfos() const
void add(const FinalStat &other)
void setTried(unsigned int n, double sum, double sum2)
bool operator!=(const XSec &other) const
void setSelected(unsigned int n, double sum, double sum2)
void setKilled(unsigned int n, double sum, double sum2)
bool operator!=(const FinalStat &other) const
void swap(GenLumiInfoProduct &other)
bool operator==(const FinalStat &other) const
void setAccepted(unsigned int n, double sum, double sum2)
FinalStat(unsigned int n1, double sum1, double sum21)
void setAcceptedBr(unsigned int n, double sum, double sum2)
XSec(double v, double e=-1.)
Definition: value.py:1
virtual bool isProductEqual(const GenLumiInfoProduct &other) const
virtual bool mergeProduct(const GenLumiInfoProduct &other)
void setLheXSec(double value, double err)
void setHEPIDWTUP(const int id)
bool operator==(const XSec &other) const
void addOthers(const ProcessInfo &other)
FinalStat(const FinalStat &other)
void setProcessInfo(const std::vector< ProcessInfo > &processes)
std::vector< ProcessInfo > internalProcesses_
const int getHEPIDWTUP() const