CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenFilterInfo.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 
5 
7 
8 using namespace edm;
9 using namespace std;
10 
12  numPassPositiveEvents_(0),
13  numPassNegativeEvents_(0),
14  numTotalPositiveEvents_(0),
15  numTotalNegativeEvents_(0),
16  sumPassWeights_(0.),
17  sumPassWeights2_(0.),
18  sumTotalWeights_(0.),
19  sumTotalWeights2_(0.)
20 {
21 }
22 
23 GenFilterInfo::GenFilterInfo(unsigned int tried, unsigned int pass) :
24  numPassPositiveEvents_(pass),
25  numPassNegativeEvents_(0),
26  numTotalPositiveEvents_(tried),
27  numTotalNegativeEvents_(0),
28  sumPassWeights_(pass),
29  sumPassWeights2_(pass),
30  sumTotalWeights_(tried),
31  sumTotalWeights2_(tried)
32 {
33 }
34 
35 GenFilterInfo::GenFilterInfo(unsigned int passp, unsigned int passn, unsigned int totalp, unsigned int totaln,
36  double passw, double passw2, double totalw, double totalw2) :
37  numPassPositiveEvents_(passp),
38  numPassNegativeEvents_(passn),
39  numTotalPositiveEvents_(totalp),
40  numTotalNegativeEvents_(totaln),
41  sumPassWeights_(passw),
42  sumPassWeights2_(passw2),
43  sumTotalWeights_(totalw),
44  sumTotalWeights2_(totalw2)
45 {
46 }
47 
49  numPassPositiveEvents_(other.numPassPositiveEvents_),
50  numPassNegativeEvents_(other.numPassNegativeEvents_),
51  numTotalPositiveEvents_(other.numTotalPositiveEvents_),
52  numTotalNegativeEvents_(other.numTotalNegativeEvents_),
53  sumPassWeights_(other.sumPassWeights_),
54  sumPassWeights2_(other.sumPassWeights2_),
55  sumTotalWeights_(other.sumTotalWeights_),
56  sumTotalWeights2_(other.sumTotalWeights2_)
57 {
58 }
59 
61 {
62 }
63 
65 {
66  // merging two GenFilterInfos means that the numerator and
67  // denominator from the original product need to besummed with
68  // those in the product we are going to merge
69 
78 
79  return true;
80 }
81 
82 double GenFilterInfo::filterEfficiency(int idwtup) const {
83  double eff = -1;
84  switch(idwtup) {
85  case 3: case -3:
86  eff = numEventsTotal() > 0 ? (double) numEventsPassed() / (double) numEventsTotal(): -1;
87  break;
88  default:
89  eff = sumWeights() > 1e-6? sumPassWeights()/sumWeights(): -1;
90  break;
91  }
92  return eff;
93 
94 }
95 
96 double GenFilterInfo::filterEfficiencyError(int idwtup) const {
97 
98  double efferr = -1;
99  switch(idwtup) {
100  case 3: case -3:
101  {
102  double effp = numTotalPositiveEvents() > 1e-6?
103  (double)numPassPositiveEvents()/(double)numTotalPositiveEvents():0;
104  double effp_err2 = numTotalPositiveEvents() > 1e-6?
105  (1-effp)*effp/(double)numTotalPositiveEvents(): 0;
106 
107  double effn = numTotalNegativeEvents() > 1e-6?
108  (double)numPassNegativeEvents()/(double)numTotalNegativeEvents():0;
109  double effn_err2 = numTotalNegativeEvents() > 1e-6?
110  (1-effn)*effn/(double)numTotalNegativeEvents(): 0;
111 
112  efferr = numEventsTotal() > 0 ? sqrt (
113  ((double)numTotalPositiveEvents()*(double)numTotalPositiveEvents()*effp_err2 +
114  (double)numTotalNegativeEvents()*(double)numTotalNegativeEvents()*effn_err2)
115  /(double)numEventsTotal()/(double)numEventsTotal()
116  ) : -1;
117  break;
118  }
119  default:
120  {
122  double numerator =
125  efferr = denominator>1e-6?
126  sqrt(numerator/denominator):-1;
127  break;
128  }
129  }
130 
131  return efferr;
132 }
double sumTotalWeights_
Definition: GenFilterInfo.h:57
unsigned int numTotalPositiveEvents() const
Definition: GenFilterInfo.h:28
double filterEfficiency(int idwtup=+3) const
virtual ~GenFilterInfo()
double sumFailWeights2() const
Definition: GenFilterInfo.h:38
bool mergeProduct(GenFilterInfo const &other)
double sumPassWeights() const
Definition: GenFilterInfo.h:34
unsigned int numEventsPassed() const
Definition: GenFilterInfo.h:24
unsigned int numTotalNegativeEvents_
Definition: GenFilterInfo.h:53
T sqrt(T t)
Definition: SSEVec.h:46
unsigned int numPassNegativeEvents_
Definition: GenFilterInfo.h:51
double sumPassWeights_
Definition: GenFilterInfo.h:55
unsigned int numPassPositiveEvents_
Definition: GenFilterInfo.h:50
unsigned int numTotalNegativeEvents() const
Definition: GenFilterInfo.h:31
unsigned int numTotalPositiveEvents_
Definition: GenFilterInfo.h:52
unsigned int numEventsTotal() const
Definition: GenFilterInfo.h:25
double sumFailWeights() const
Definition: GenFilterInfo.h:37
double filterEfficiencyError(int idwtup=+3) const
double sumTotalWeights2_
Definition: GenFilterInfo.h:58
unsigned int numPassPositiveEvents() const
Definition: GenFilterInfo.h:27
double sumPassWeights2_
Definition: GenFilterInfo.h:56
double sumPassWeights2() const
Definition: GenFilterInfo.h:35
double sumWeights() const
Definition: GenFilterInfo.h:40
unsigned int numPassNegativeEvents() const
Definition: GenFilterInfo.h:30