CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenLumiInfoProduct.h
Go to the documentation of this file.
1 #ifndef SimDataFormats_GeneratorProducts_GenLumiInfoProduct_h
2 #define SimDataFormats_GeneratorProducts_GenLumiInfoProduct_h
3 
9  public:
10  // a few forward declarations
11  struct XSec;
12  struct ProcessInfo;
13 
14  // constructors, destructors
16  GenLumiInfoProduct(const int id);
18  virtual ~GenLumiInfoProduct();
19 
20  // getters
21 
22  const int getHEPIDWTUP() const {return hepidwtup_;}
23  const std::vector<ProcessInfo>& getProcessInfos() const {return internalProcesses_;}
24 
25  // setters
26 
27  void setHEPIDWTUP(const int id) { hepidwtup_ = id;}
28  void setProcessInfo(const std::vector<ProcessInfo> & processes) {internalProcesses_ = processes;}
29 
30  // Struct- definitions
31  struct XSec {
32  public:
33  XSec() : value_(-1.), error_(-1.) {}
34  XSec(double v, double e = -1.) :
35  value_(v), error_(e) {}
36  XSec(const XSec &other) :
37  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
49  { return value_ == other.value_ && error_ == other.error_; }
50  bool operator != (const XSec &other) const { return !(*this == other); }
51 
52  private:
53  double value_, error_;
54  };
55 
56 
57  struct FinalStat {
58  public:
59  FinalStat() : n_(0), sum_(0.0), sum2_(0.0) {}
60  FinalStat(unsigned int n1, double sum1, double sum21) :
61  n_(n1), sum_(sum1), sum2_(sum21) {}
62  FinalStat(const FinalStat &other) :
63  n_(other.n_), sum_(other.sum_), sum2_(other.sum2_) {}
64 
65  unsigned int n() const { return n_; }
66  double sum() const { return sum_; }
67  double sum2() const{ return sum2_; }
68 
69  void add(const FinalStat& other)
70  {
71  n_ += other.n();
72  sum_ += other.sum();
73  sum2_ += other.sum2();
74  }
75 
76  bool operator == (const FinalStat &other) const
77  { return n_ == other.n_ && sum_ == other.sum_ && sum2_ == other.sum2_; }
78  bool operator != (const FinalStat &other) const { return !(*this == other); }
79  private:
80  unsigned int n_;
81  double sum_;
82  double sum2_;
83  };
84 
85 
86  struct ProcessInfo {
87  public:
90 
91  // accessors
92  int process() const {return process_;}
93  XSec lheXSec() const {return lheXSec_;}
94 
95  unsigned int nPassPos() const {return nPassPos_;}
96  unsigned int nPassNeg() const {return nPassNeg_;}
97  unsigned int nTotalPos() const {return nTotalPos_;}
98  unsigned int nTotalNeg() const {return nTotalNeg_;}
99 
100  FinalStat tried() const {return tried_;}
101  FinalStat selected() const {return selected_;}
102  FinalStat killed() const {return killed_;}
103  FinalStat accepted() const {return accepted_;}
104  FinalStat acceptedBr() const {return acceptedBr_;}
105 
106  // setters
107  void addOthers(const ProcessInfo& other){
108  nPassPos_ += other.nPassPos();
109  nPassNeg_ += other.nPassNeg();
110  nTotalPos_ += other.nTotalPos();
111  nTotalNeg_ += other.nTotalNeg();
112  tried_.add(other.tried());
113  selected_.add(other.selected());
114  killed_.add(other.killed());
115  accepted_.add(other.accepted());
116  acceptedBr_.add(other.acceptedBr());
117  }
118  void setProcess(int id) { process_ = id; }
119  void setLheXSec(double value, double err) { lheXSec_ = XSec(value,err); }
120  void setNPassPos(unsigned int n) { nPassPos_ = n; }
121  void setNPassNeg(unsigned int n) { nPassNeg_ = n; }
122  void setNTotalPos(unsigned int n) { nTotalPos_ = n; }
123  void setNTotalNeg(unsigned int n) { nTotalNeg_ = n; }
124  void setTried(unsigned int n, double sum, double sum2) { tried_ = FinalStat(n,sum,sum2); }
125  void setSelected(unsigned int n, double sum, double sum2) { selected_ = FinalStat(n,sum,sum2); }
126  void setKilled(unsigned int n, double sum, double sum2) { killed_ = FinalStat(n,sum,sum2); }
127  void setAccepted(unsigned int n, double sum, double sum2) { accepted_ = FinalStat(n,sum,sum2); }
128  void setAcceptedBr(unsigned int n, double sum, double sum2) { acceptedBr_ = FinalStat(n,sum,sum2); }
129 
130  private:
131  int process_;
133  unsigned int nPassPos_;
134  unsigned int nPassNeg_;
135  unsigned int nTotalPos_;
136  unsigned int nTotalNeg_;
142 
143  };
144 
145 
146 
147  // methods used by EDM
148  virtual bool mergeProduct(const GenLumiInfoProduct &other);
149  virtual bool isProductEqual(const GenLumiInfoProduct &other) const;
150  private:
151  // cross sections
153  std::vector<ProcessInfo> internalProcesses_;
154 
155 
156 };
157 
158 #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
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.)
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