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.) :
37  value_(v), error_(e) {}
38  XSec(const XSec &other) :
39  value_(other.value_), error_(other.error_) {}
40 
41  double value() const { return value_; }
42  double error() const { return error_; }
43 
44  bool isSet() const { return value_ >= 0.; }
45  bool hasError() const { return error_ >= 0.; }
46 
47  operator double() const { return value_; }
48  operator bool() const { return isSet(); }
49 
50  bool operator == (const XSec &other) const
51  { return value_ == other.value_ && error_ == other.error_; }
52  bool operator != (const XSec &other) const { return !(*this == other); }
53 
54  private:
55  double value_, error_;
56  };
57 
58 
59  struct FinalStat {
60  public:
61  FinalStat() : n_(0), sum_(0.0), sum2_(0.0) {}
62  FinalStat(unsigned int n1, double sum1, double sum21) :
63  n_(n1), sum_(sum1), sum2_(sum21) {}
64  FinalStat(const FinalStat &other) :
65  n_(other.n_), sum_(other.sum_), sum2_(other.sum2_) {}
66 
67  unsigned int n() const { return n_; }
68  double sum() const { return sum_; }
69  double sum2() const{ return sum2_; }
70 
71  void add(const FinalStat& other)
72  {
73  n_ += other.n();
74  sum_ += other.sum();
75  sum2_ += other.sum2();
76  }
77 
78  bool operator == (const FinalStat &other) const
79  { return n_ == other.n_ && sum_ == other.sum_ && sum2_ == other.sum2_; }
80  bool operator != (const FinalStat &other) const { return !(*this == other); }
81  private:
82  unsigned int n_;
83  double sum_;
84  double sum2_;
85  };
86 
87 
88  struct ProcessInfo {
89  public:
90  ProcessInfo():process_(-1),nPassPos_(0),nPassNeg_(0),nTotalPos_(0),nTotalNeg_(0){}
91  ProcessInfo(int id):process_(id),nPassPos_(0),nPassNeg_(0),nTotalPos_(0),nTotalNeg_(0){}
92 
93  // accessors
94  int process() const {return process_;}
95  XSec lheXSec() const {return lheXSec_;}
96 
97  unsigned int nPassPos() const {return nPassPos_;}
98  unsigned int nPassNeg() const {return nPassNeg_;}
99  unsigned int nTotalPos() const {return nTotalPos_;}
100  unsigned int nTotalNeg() const {return nTotalNeg_;}
101 
102  FinalStat tried() const {return tried_;}
103  FinalStat selected() const {return selected_;}
104  FinalStat killed() const {return killed_;}
105  FinalStat accepted() const {return accepted_;}
106  FinalStat acceptedBr() const {return acceptedBr_;}
107 
108  // setters
109  void addOthers(const ProcessInfo& other){
110  nPassPos_ += other.nPassPos();
111  nPassNeg_ += other.nPassNeg();
112  nTotalPos_ += other.nTotalPos();
113  nTotalNeg_ += other.nTotalNeg();
114  tried_.add(other.tried());
115  selected_.add(other.selected());
116  killed_.add(other.killed());
117  accepted_.add(other.accepted());
118  acceptedBr_.add(other.acceptedBr());
119  }
120  void setProcess(int id) { process_ = id; }
121  void setLheXSec(double value, double err) { lheXSec_ = XSec(value,err); }
122  void setNPassPos(unsigned int n) { nPassPos_ = n; }
123  void setNPassNeg(unsigned int n) { nPassNeg_ = n; }
124  void setNTotalPos(unsigned int n) { nTotalPos_ = n; }
125  void setNTotalNeg(unsigned int n) { nTotalNeg_ = n; }
126  void setTried(unsigned int n, double sum, double sum2) { tried_ = FinalStat(n,sum,sum2); }
127  void setSelected(unsigned int n, double sum, double sum2) { selected_ = FinalStat(n,sum,sum2); }
128  void setKilled(unsigned int n, double sum, double sum2) { killed_ = FinalStat(n,sum,sum2); }
129  void setAccepted(unsigned int n, double sum, double sum2) { accepted_ = FinalStat(n,sum,sum2); }
130  void setAcceptedBr(unsigned int n, double sum, double sum2) { acceptedBr_ = FinalStat(n,sum,sum2); }
131 
132  private:
133  int process_;
135  unsigned int nPassPos_;
136  unsigned int nPassNeg_;
137  unsigned int nTotalPos_;
138  unsigned int nTotalNeg_;
144 
145  };
146 
147 
148 
149  // methods used by EDM
150  virtual bool mergeProduct(const GenLumiInfoProduct &other);
151  virtual bool isProductEqual(const GenLumiInfoProduct &other) const;
152  private:
153  // cross sections
155  std::vector<ProcessInfo> internalProcesses_;
156 
157 
158 };
159 
160 #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)
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