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 #include <cmath>
6 
12 public:
13  // a few forward declarations
14  struct XSec;
15  struct ProcessInfo;
16 
17  // constructors, destructors
19  GenLumiInfoProduct(const int id);
21  virtual ~GenLumiInfoProduct();
22 
23  // getters
24 
25  const int getHEPIDWTUP() const { return hepidwtup_; }
26  const std::vector<ProcessInfo> &getProcessInfos() const { return internalProcesses_; }
27 
28  // setters
29 
30  void setHEPIDWTUP(const int id) { hepidwtup_ = id; }
31  void setProcessInfo(const std::vector<ProcessInfo> &processes) { internalProcesses_ = processes; }
32 
33  // Struct- definitions
34  struct XSec {
35  public:
36  XSec() : value_(-1.), error_(-1.) {}
37  XSec(double v, double e = -1.) : value_(v), error_(e) {}
39 
40  double value() const { return value_; }
41  double error() const { return error_; }
42 
43  bool isSet() const { return value_ >= 0.; }
44  bool hasError() const { return error_ >= 0.; }
45 
46  operator double() const { return value_; }
47  operator bool() const { return isSet(); }
48 
49  bool operator==(const XSec &other) const { 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  struct FinalStat {
57  public:
58  FinalStat() : n_(0), sum_(0.0), sum2_(0.0) {}
59  FinalStat(unsigned int n1, double sum1, double sum21) : n_(n1), sum_(sum1), sum2_(sum21) {}
61 
62  unsigned int n() const { return n_; }
63  double sum() const { return sum_; }
64  double sum2() const { return sum2_; }
65 
66  void add(const FinalStat &other) {
67  //Hadronizers treat 0, -1., -1. to mean the value is not present
68  if (other.n() != 0 and other.sum_ != -1. and other.sum2() != -1.) {
69  n_ += other.n();
70  sum_ += other.sum();
71  sum2_ += other.sum2();
72  }
73  }
74 
75  bool operator==(const FinalStat &other) const {
76  return n_ == other.n_ && sum_ == other.sum_ && sum2_ == other.sum2_;
77  }
78  bool operator!=(const FinalStat &other) const { return !(*this == other); }
79 
80  private:
81  unsigned int n_;
82  double sum_;
83  double sum2_;
84  };
85 
86  struct ProcessInfo {
87  public:
90 
91  // accessors
92  int process() const { return process_; }
93  XSec const &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 const &tried() const { return tried_; }
101  FinalStat const &selected() const { return selected_; }
102  FinalStat const &killed() const { return killed_; }
103  FinalStat const &accepted() const { return accepted_; }
104  FinalStat const &acceptedBr() const { return acceptedBr_; }
105 
106  // setters
107  void addOthers(const ProcessInfo &other) {
108  mergeXSec(other.lheXSec(), other.selected().sum());
109  nPassPos_ += other.nPassPos();
110  nPassNeg_ += other.nPassNeg();
111  nTotalPos_ += other.nTotalPos();
112  nTotalNeg_ += other.nTotalNeg();
113  tried_.add(other.tried());
114  selected_.add(other.selected());
115  killed_.add(other.killed());
116  accepted_.add(other.accepted());
117  acceptedBr_.add(other.acceptedBr());
118  }
119  void setProcess(int id) { process_ = id; }
120  void setLheXSec(double value, double err) { lheXSec_ = XSec(value, err); }
121  void setNPassPos(unsigned int n) { nPassPos_ = n; }
122  void setNPassNeg(unsigned int n) { nPassNeg_ = n; }
123  void setNTotalPos(unsigned int n) { nTotalPos_ = n; }
124  void setNTotalNeg(unsigned int n) { nTotalNeg_ = n; }
125  void setTried(unsigned int n, double sum, double sum2) { tried_ = FinalStat(n, sum, sum2); }
126  void setSelected(unsigned int n, double sum, double sum2) { selected_ = FinalStat(n, sum, sum2); }
127  void setKilled(unsigned int n, double sum, double sum2) { killed_ = FinalStat(n, sum, sum2); }
128  void setAccepted(unsigned int n, double sum, double sum2) { accepted_ = FinalStat(n, sum, sum2); }
129  void setAcceptedBr(unsigned int n, double sum, double sum2) { acceptedBr_ = FinalStat(n, sum, sum2); }
130 
131  private:
132  void mergeXSec(XSec const &iXSec, double iWeight) {
133  if (iWeight <= 0.) {
134  return;
135  }
136  if (lheXSec_.value() <= 0.) {
137  lheXSec_ = iXSec;
138  } else {
139  bool useWeights = (lheXSec_.error() <= 0. || iXSec.error() <= 0.);
140  double wgt1 = useWeights ? selected().sum() : 1. / (lheXSec_.error() * lheXSec_.error());
141  double wgt2 = useWeights ? iWeight : 1. / (iXSec.error() * iXSec.error());
142  double xsec = (wgt1 * lheXSec_.value() + wgt2 * iXSec.value()) / (wgt1 + wgt2);
143  double err = useWeights ? 0. : 1.0 / std::sqrt(wgt1 + wgt2);
144  lheXSec_ = XSec(xsec, err);
145  }
146  }
147  int process_;
149  unsigned int nPassPos_;
150  unsigned int nPassNeg_;
151  unsigned int nTotalPos_;
152  unsigned int nTotalNeg_;
158  };
159 
160  // methods used by EDM
161  virtual bool mergeProduct(const GenLumiInfoProduct &other);
163  virtual bool isProductEqual(const GenLumiInfoProduct &other) const;
164 
165 private:
166  // cross sections
168  std::vector<ProcessInfo> internalProcesses_;
169 };
170 
171 #endif // SimDataFormats_GeneratorProducts_GenLumiInfoProduct_h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
GenLumiInfoProduct::ProcessInfo::setNPassNeg
void setNPassNeg(unsigned int n)
Definition: GenLumiInfoProduct.h:122
GenLumiInfoProduct::FinalStat::FinalStat
FinalStat(const FinalStat &other)
Definition: GenLumiInfoProduct.h:60
GenLumiInfoProduct::ProcessInfo::setNTotalNeg
void setNTotalNeg(unsigned int n)
Definition: GenLumiInfoProduct.h:124
GenLumiInfoProduct::ProcessInfo::setTried
void setTried(unsigned int n, double sum, double sum2)
Definition: GenLumiInfoProduct.h:125
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
GenLumiInfoProduct::ProcessInfo::ProcessInfo
ProcessInfo()
Definition: GenLumiInfoProduct.h:88
GenLumiInfoProduct::ProcessInfo::mergeXSec
void mergeXSec(XSec const &iXSec, double iWeight)
Definition: GenLumiInfoProduct.h:132
GenLumiInfoProduct::GenLumiInfoProduct
GenLumiInfoProduct()
Definition: GenLumiInfoProduct.cc:70
GenLumiInfoProduct::ProcessInfo::killed
const FinalStat & killed() const
Definition: GenLumiInfoProduct.h:102
GenLumiInfoProduct::ProcessInfo::setKilled
void setKilled(unsigned int n, double sum, double sum2)
Definition: GenLumiInfoProduct.h:127
GenLumiInfoProduct::XSec::error
double error() const
Definition: GenLumiInfoProduct.h:41
GenLumiInfoProduct::ProcessInfo::setSelected
void setSelected(unsigned int n, double sum, double sum2)
Definition: GenLumiInfoProduct.h:126
GenLumiInfoProduct::FinalStat::sum2_
double sum2_
Definition: GenLumiInfoProduct.h:83
GenLumiInfoProduct::ProcessInfo::process_
int process_
Definition: GenLumiInfoProduct.h:147
GenLumiInfoProduct::FinalStat::n_
unsigned int n_
Definition: GenLumiInfoProduct.h:81
GenLumiInfoProduct::~GenLumiInfoProduct
virtual ~GenLumiInfoProduct()
Definition: GenLumiInfoProduct.cc:77
GenLumiInfoProduct::ProcessInfo::setProcess
void setProcess(int id)
Definition: GenLumiInfoProduct.h:119
GenLumiInfoProduct::ProcessInfo::lheXSec
const XSec & lheXSec() const
Definition: GenLumiInfoProduct.h:93
GenLumiInfoProduct::ProcessInfo::tried_
FinalStat tried_
Definition: GenLumiInfoProduct.h:153
GenLumiInfoProduct::FinalStat::operator!=
bool operator!=(const FinalStat &other) const
Definition: GenLumiInfoProduct.h:78
findQualityFiles.v
v
Definition: findQualityFiles.py:179
GenLumiInfoProduct::FinalStat::n
unsigned int n() const
Definition: GenLumiInfoProduct.h:62
GenLumiInfoProduct::XSec::isSet
bool isSet() const
Definition: GenLumiInfoProduct.h:43
GenLumiInfoProduct::ProcessInfo::acceptedBr
const FinalStat & acceptedBr() const
Definition: GenLumiInfoProduct.h:104
GenLumiInfoProduct::setProcessInfo
void setProcessInfo(const std::vector< ProcessInfo > &processes)
Definition: GenLumiInfoProduct.h:31
GenLumiInfoProduct::XSec::value_
double value_
Definition: GenLumiInfoProduct.h:53
GenLumiInfoProduct::XSec::operator!=
bool operator!=(const XSec &other) const
Definition: GenLumiInfoProduct.h:50
GenLumiInfoProduct::XSec
Definition: GenLumiInfoProduct.h:34
GenLumiInfoProduct::XSec::value
double value() const
Definition: GenLumiInfoProduct.h:40
GenLumiInfoProduct::ProcessInfo::setAccepted
void setAccepted(unsigned int n, double sum, double sum2)
Definition: GenLumiInfoProduct.h:128
GenLumiInfoProduct::ProcessInfo::nPassPos
unsigned int nPassPos() const
Definition: GenLumiInfoProduct.h:95
GenLumiInfoProduct::XSec::operator==
bool operator==(const XSec &other) const
Definition: GenLumiInfoProduct.h:49
GenLumiInfoProduct::ProcessInfo::nTotalPos
unsigned int nTotalPos() const
Definition: GenLumiInfoProduct.h:97
GenLumiInfoProduct::ProcessInfo
Definition: GenLumiInfoProduct.h:86
GenLumiInfoProduct::isProductEqual
virtual bool isProductEqual(const GenLumiInfoProduct &other) const
Definition: GenLumiInfoProduct.cc:111
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
GenLumiInfoProduct::ProcessInfo::setNTotalPos
void setNTotalPos(unsigned int n)
Definition: GenLumiInfoProduct.h:123
GenLumiInfoProduct::getProcessInfos
const std::vector< ProcessInfo > & getProcessInfos() const
Definition: GenLumiInfoProduct.h:26
GenLumiInfoProduct::FinalStat::FinalStat
FinalStat(unsigned int n1, double sum1, double sum21)
Definition: GenLumiInfoProduct.h:59
trackingPlots.other
other
Definition: trackingPlots.py:1465
GenLumiInfoProduct::ProcessInfo::setLheXSec
void setLheXSec(double value, double err)
Definition: GenLumiInfoProduct.h:120
GenLumiInfoProduct::ProcessInfo::tried
const FinalStat & tried() const
Definition: GenLumiInfoProduct.h:100
GenLumiInfoProduct::XSec::XSec
XSec(double v, double e=-1.)
Definition: GenLumiInfoProduct.h:37
GenLumiInfoProduct::XSec::XSec
XSec(const XSec &other)
Definition: GenLumiInfoProduct.h:38
GenLumiInfoProduct::XSec::hasError
bool hasError() const
Definition: GenLumiInfoProduct.h:44
GenLumiInfoProduct::hepidwtup_
int hepidwtup_
Definition: GenLumiInfoProduct.h:167
GenLumiInfoProduct::mergeProduct
virtual bool mergeProduct(const GenLumiInfoProduct &other)
Definition: GenLumiInfoProduct.cc:79
runTheMatrix.err
err
Definition: runTheMatrix.py:288
GenLumiInfoProduct::XSec::error_
double error_
Definition: GenLumiInfoProduct.h:53
GenLumiInfoProduct::ProcessInfo::accepted_
FinalStat accepted_
Definition: GenLumiInfoProduct.h:156
GenLumiInfoProduct::ProcessInfo::setAcceptedBr
void setAcceptedBr(unsigned int n, double sum, double sum2)
Definition: GenLumiInfoProduct.h:129
GenLumiInfoProduct::ProcessInfo::nPassPos_
unsigned int nPassPos_
Definition: GenLumiInfoProduct.h:149
GenLumiInfoProduct::ProcessInfo::selected
const FinalStat & selected() const
Definition: GenLumiInfoProduct.h:101
GenLumiInfoProduct::ProcessInfo::addOthers
void addOthers(const ProcessInfo &other)
Definition: GenLumiInfoProduct.h:107
value
Definition: value.py:1
GenLumiInfoProduct::swap
void swap(GenLumiInfoProduct &other)
Definition: GenLumiInfoProduct.cc:106
GenLumiInfoProduct
Definition: GenLumiInfoProduct.h:11
GenLumiInfoProduct::FinalStat::operator==
bool operator==(const FinalStat &other) const
Definition: GenLumiInfoProduct.h:75
combinedConstraintHelpers::sum2
void sum2(T &x, T y)
Definition: CombinedKinematicConstraintT.h:74
GenLumiInfoProduct::ProcessInfo::accepted
const FinalStat & accepted() const
Definition: GenLumiInfoProduct.h:103
GenLumiInfoProduct::ProcessInfo::ProcessInfo
ProcessInfo(int id)
Definition: GenLumiInfoProduct.h:89
GenLumiInfoProduct::ProcessInfo::nPassNeg
unsigned int nPassNeg() const
Definition: GenLumiInfoProduct.h:96
GenLumiInfoProduct::ProcessInfo::selected_
FinalStat selected_
Definition: GenLumiInfoProduct.h:154
GenLumiInfoProduct::FinalStat::sum
double sum() const
Definition: GenLumiInfoProduct.h:63
GenLumiInfoProduct::ProcessInfo::nTotalNeg
unsigned int nTotalNeg() const
Definition: GenLumiInfoProduct.h:98
GenLumiInfoProduct::ProcessInfo::nTotalNeg_
unsigned int nTotalNeg_
Definition: GenLumiInfoProduct.h:152
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
GenLumiInfoProduct::getHEPIDWTUP
const int getHEPIDWTUP() const
Definition: GenLumiInfoProduct.h:25
GenLumiInfoProduct::FinalStat
Definition: GenLumiInfoProduct.h:56
GenLumiInfoProduct::ProcessInfo::killed_
FinalStat killed_
Definition: GenLumiInfoProduct.h:155
dqmiodatasetharvest.processes
processes
Definition: dqmiodatasetharvest.py:190
GenLumiInfoProduct::XSec::XSec
XSec()
Definition: GenLumiInfoProduct.h:36
GenLumiInfoProduct::FinalStat::sum_
double sum_
Definition: GenLumiInfoProduct.h:82
GenLumiInfoProduct::ProcessInfo::nTotalPos_
unsigned int nTotalPos_
Definition: GenLumiInfoProduct.h:151
GenLumiInfoProduct::setHEPIDWTUP
void setHEPIDWTUP(const int id)
Definition: GenLumiInfoProduct.h:30
GenLumiInfoProduct::ProcessInfo::acceptedBr_
FinalStat acceptedBr_
Definition: GenLumiInfoProduct.h:157
GenLumiInfoProduct::FinalStat::add
void add(const FinalStat &other)
Definition: GenLumiInfoProduct.h:66
GenLumiInfoProduct::ProcessInfo::setNPassPos
void setNPassPos(unsigned int n)
Definition: GenLumiInfoProduct.h:121
GenLumiInfoProduct::FinalStat::sum2
double sum2() const
Definition: GenLumiInfoProduct.h:64
GenLumiInfoProduct::ProcessInfo::process
int process() const
Definition: GenLumiInfoProduct.h:92
GenLumiInfoProduct::ProcessInfo::nPassNeg_
unsigned int nPassNeg_
Definition: GenLumiInfoProduct.h:150
GenLumiInfoProduct::ProcessInfo::lheXSec_
XSec lheXSec_
Definition: GenLumiInfoProduct.h:148
GenLumiInfoProduct::FinalStat::FinalStat
FinalStat()
Definition: GenLumiInfoProduct.h:58
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
GenLumiInfoProduct::internalProcesses_
std::vector< ProcessInfo > internalProcesses_
Definition: GenLumiInfoProduct.h:168