ATLAS Offline Software
APEvtWeight.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #define APEvtWeight_cxx
8 #include <cmath>
9 #include <iostream>
10 
11 using namespace std;
12 
14  : m_current_evt_weights(vector< vector< APWeightEntry* > >(12)),
15  m_n_entries(0),
16  m_k_evt_weight(0),
17  m_variance(0),
18  m_variance_sys(0),
19  m_isComputed (type > APEvtWeight::kDiJet),
20  m_type(type)
21 {
22 }
23 
25  m_current_evt_weights.clear();
26 }
27 
29  if (weight->IsTrig()) {
30  if (m_type <= APEvtWeight::kDiJet ) {
32  ++m_n_entries;
33  m_isComputed = false;
34  } else {
35  cout << "ERROR in APEvtWeight::AddWeightToEvt: Trying to add a weight entry to a combined event weight. Ignoring command (not adding weight entry)." << endl;
36  }
37  } else {
38  cout << "ERROR in APEvtWeight::AddWeightToEvt: Trying to add a non-trigger weight entry to trigger event weight. Ignoring command (not adding weight entry)." << endl;
39  }
40 }
41 
42 const APEvtWeight operator&&(const APEvtWeight& a_in, const APEvtWeight& b_in) {
43  APEvtWeight a = a_in;
44  APEvtWeight b = b_in;
45  APEvtWeight::ObjType a_type = a.GetType();
46  APEvtWeight::ObjType b_type = b.GetType();
47 
48  if ( (a_type >= APEvtWeight::kDiMuon && a_type <= APEvtWeight::kDiJet) || (b_type >= APEvtWeight::kDiMuon && b_type <= APEvtWeight::kDiJet) ) cout << "WARNING in APEvtWeight::operator&&: Trying to logically AND diobject weights. You shouldn't do this. Uncertainties will be incorrect." << endl;
49  if ( ((a_type >= APEvtWeight::kMuon && a_type <= APEvtWeight::kJet) || (b_type >= APEvtWeight::kMuon && b_type <= APEvtWeight::kJet)) && (a_type != b_type) ) cout << "WARNING in APEvtWeight::operator&&: Trying to logically AND weights for single component triggers in multiobject configuration. You shouldn't do this, but use kXxxMO types instead. Uncertainties will be incorrect." << endl;
50 
51  if ( a_type != b_type ) {
53  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuon].push_back(a.m_current_evt_weights[APEvtWeight::kMuon][i]);
54  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuon].push_back(b.m_current_evt_weights[APEvtWeight::kMuon][i]);
55  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTau].push_back(a.m_current_evt_weights[APEvtWeight::kTau][i]);
56  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTau].push_back(b.m_current_evt_weights[APEvtWeight::kTau][i]);
57  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectron].push_back(a.m_current_evt_weights[APEvtWeight::kElectron][i]);
58  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectron].push_back(b.m_current_evt_weights[APEvtWeight::kElectron][i]);
59  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJet].push_back(a.m_current_evt_weights[APEvtWeight::kJet][i]);
60  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJet].push_back(b.m_current_evt_weights[APEvtWeight::kJet][i]);
61  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kMuonMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuonMO].push_back(a.m_current_evt_weights[APEvtWeight::kMuonMO][i]);
62  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kMuonMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuonMO].push_back(b.m_current_evt_weights[APEvtWeight::kMuonMO][i]);
63  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kTauMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTauMO].push_back(a.m_current_evt_weights[APEvtWeight::kTauMO][i]);
64  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kTauMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTauMO].push_back(b.m_current_evt_weights[APEvtWeight::kTauMO][i]);
65  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kElectronMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectronMO].push_back(a.m_current_evt_weights[APEvtWeight::kElectronMO][i]);
66  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kElectronMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectronMO].push_back(b.m_current_evt_weights[APEvtWeight::kElectronMO][i]);
67  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kJetMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJetMO].push_back(a.m_current_evt_weights[APEvtWeight::kJetMO][i]);
68  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kJetMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJetMO].push_back(b.m_current_evt_weights[APEvtWeight::kJetMO][i]);
69  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiMuon].push_back(a.m_current_evt_weights[APEvtWeight::kDiMuon][i]);
70  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiMuon].push_back(b.m_current_evt_weights[APEvtWeight::kDiMuon][i]);
71  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiTau].push_back(a.m_current_evt_weights[APEvtWeight::kDiTau][i]);
72  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiTau].push_back(b.m_current_evt_weights[APEvtWeight::kDiTau][i]);
73  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiElectron].push_back(a.m_current_evt_weights[APEvtWeight::kDiElectron][i]);
74  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiElectron].push_back(b.m_current_evt_weights[APEvtWeight::kDiElectron][i]);
75  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiJet].push_back(a.m_current_evt_weights[APEvtWeight::kDiJet][i]);
76  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiJet].push_back(b.m_current_evt_weights[APEvtWeight::kDiJet][i]);
77 
78  if (!b.m_isComputed) b.Compute();
79  if (!a.m_isComputed) a.Compute();
80  ret.m_n_entries = a.m_n_entries + b.m_n_entries;
81  ret.m_k_evt_weight = a.m_k_evt_weight * b.m_k_evt_weight;
82  ret.m_variance = a.m_variance * b.m_k_evt_weight * b.m_k_evt_weight + b.m_variance * a.m_k_evt_weight * a.m_k_evt_weight;
83  ret.m_variance_sys = a.m_variance_sys * b.m_k_evt_weight * b.m_k_evt_weight + b.m_variance_sys * a.m_k_evt_weight * a.m_k_evt_weight;
84  return ret;
85 
86  }
87  else {
89  if (a_type > APEvtWeight::kJetMO || b_type > APEvtWeight::kJetMO) {
90  if ((a.m_current_evt_weights[APEvtWeight::kMuon].size() > 0 && b.m_current_evt_weights[APEvtWeight::kMuon].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kTau].size() > 0 && b.m_current_evt_weights[APEvtWeight::kTau].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kElectron].size() > 0 && b.m_current_evt_weights[APEvtWeight::kElectron].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kJet].size() > 0 && b.m_current_evt_weights[APEvtWeight::kJet].size() > 0) ||(a.m_current_evt_weights[APEvtWeight::kMuonMO].size() > 0 && b.m_current_evt_weights[APEvtWeight::kMuonMO].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kTauMO].size() > 0 && b.m_current_evt_weights[APEvtWeight::kTauMO].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kElectronMO].size() > 0 && b.m_current_evt_weights[APEvtWeight::kElectronMO].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kJetMO].size() > 0 && b.m_current_evt_weights[APEvtWeight::kJetMO].size() > 0) )
91  cout << "WARNING in APEvtWeight::operator&&: Trying to combine already combined event weights with overlapping objects. Uncertainties will be incorrect." << endl;
92  }
93  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuon].push_back(a.m_current_evt_weights[APEvtWeight::kMuon][i]);
94  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuon].push_back(b.m_current_evt_weights[APEvtWeight::kMuon][i]);
95  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTau].push_back(a.m_current_evt_weights[APEvtWeight::kTau][i]);
96  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTau].push_back(b.m_current_evt_weights[APEvtWeight::kTau][i]);
97  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectron].push_back(a.m_current_evt_weights[APEvtWeight::kElectron][i]);
98  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectron].push_back(b.m_current_evt_weights[APEvtWeight::kElectron][i]);
99  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJet].push_back(a.m_current_evt_weights[APEvtWeight::kJet][i]);
100  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJet].push_back(b.m_current_evt_weights[APEvtWeight::kJet][i]);
101  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kMuonMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuonMO].push_back(a.m_current_evt_weights[APEvtWeight::kMuonMO][i]);
102  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kMuonMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuonMO].push_back(b.m_current_evt_weights[APEvtWeight::kMuonMO][i]);
103  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kTauMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTauMO].push_back(a.m_current_evt_weights[APEvtWeight::kTauMO][i]);
104  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kTauMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTauMO].push_back(b.m_current_evt_weights[APEvtWeight::kTauMO][i]);
105  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kElectronMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectronMO].push_back(a.m_current_evt_weights[APEvtWeight::kElectronMO][i]);
106  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kElectronMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectronMO].push_back(b.m_current_evt_weights[APEvtWeight::kElectronMO][i]);
107  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kJetMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJetMO].push_back(a.m_current_evt_weights[APEvtWeight::kJetMO][i]);
108  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kJetMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJetMO].push_back(b.m_current_evt_weights[APEvtWeight::kJetMO][i]);
109  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiMuon].push_back(a.m_current_evt_weights[APEvtWeight::kDiMuon][i]);
110  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiMuon].push_back(b.m_current_evt_weights[APEvtWeight::kDiMuon][i]);
111  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiTau].push_back(a.m_current_evt_weights[APEvtWeight::kDiTau][i]);
112  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiTau].push_back(b.m_current_evt_weights[APEvtWeight::kDiTau][i]);
113  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiElectron].push_back(a.m_current_evt_weights[APEvtWeight::kDiElectron][i]);
114  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiElectron].push_back(b.m_current_evt_weights[APEvtWeight::kDiElectron][i]);
115  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiJet].push_back(a.m_current_evt_weights[APEvtWeight::kDiJet][i]);
116  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiJet].push_back(b.m_current_evt_weights[APEvtWeight::kDiJet][i]);
117 
118  if (!b.m_isComputed) b.Compute();
119  if (!a.m_isComputed) a.Compute();
120  ret.m_n_entries = a.m_n_entries + b.m_n_entries;
121  ret.m_k_evt_weight = a.m_k_evt_weight * b.m_k_evt_weight;
122  ret.m_variance = a.m_variance * b.m_k_evt_weight * b.m_k_evt_weight + b.m_variance * a.m_k_evt_weight * a.m_k_evt_weight;
123  ret.m_variance_sys = a.m_variance_sys * b.m_k_evt_weight * b.m_k_evt_weight + b.m_variance_sys * a.m_k_evt_weight * a.m_k_evt_weight;
124  return ret;
125  }
126 }
127 
128 const APEvtWeight operator||(const APEvtWeight& a_in, const APEvtWeight& b_in) {
129  APEvtWeight a = a_in;
130  APEvtWeight b = b_in;
131  APEvtWeight::ObjType a_type = a.GetType();
132  APEvtWeight::ObjType b_type = b.GetType();
133 
134  if ( (a_type != b_type) || (a_type == APEvtWeight::kElectron && b_type == APEvtWeight::kDiElectron ) || (a_type == APEvtWeight::kDiElectron && b_type == APEvtWeight::kElectron ) || (a_type == APEvtWeight::kMuon && b_type == APEvtWeight::kDiMuon ) || (a_type == APEvtWeight::kDiMuon && b_type == APEvtWeight::kMuon ) || (a_type == APEvtWeight::kTau && b_type == APEvtWeight::kDiTau ) || ( a_type == APEvtWeight::kDiTau && b_type == APEvtWeight::kTau ) || (a_type == APEvtWeight::kJet && b_type == APEvtWeight::kDiJet ) || (a_type == APEvtWeight::kDiJet && b_type == APEvtWeight::kJet ) ) { // for what reason were all the extra conditions included?!
136  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuon].push_back(a.m_current_evt_weights[APEvtWeight::kMuon][i]);
137  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuon].push_back(b.m_current_evt_weights[APEvtWeight::kMuon][i]);
138  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTau].push_back(a.m_current_evt_weights[APEvtWeight::kTau][i]);
139  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTau].push_back(b.m_current_evt_weights[APEvtWeight::kTau][i]);
140  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectron].push_back(a.m_current_evt_weights[APEvtWeight::kElectron][i]);
141  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectron].push_back(b.m_current_evt_weights[APEvtWeight::kElectron][i]);
142  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJet].push_back(a.m_current_evt_weights[APEvtWeight::kJet][i]);
143  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJet].push_back(b.m_current_evt_weights[APEvtWeight::kJet][i]);
144  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kMuonMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuonMO].push_back(a.m_current_evt_weights[APEvtWeight::kMuonMO][i]);
145  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kMuonMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuonMO].push_back(b.m_current_evt_weights[APEvtWeight::kMuonMO][i]);
146  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kTauMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTauMO].push_back(a.m_current_evt_weights[APEvtWeight::kTauMO][i]);
147  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kTauMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTauMO].push_back(b.m_current_evt_weights[APEvtWeight::kTauMO][i]);
148  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kElectronMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectronMO].push_back(a.m_current_evt_weights[APEvtWeight::kElectronMO][i]);
149  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kElectronMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectronMO].push_back(b.m_current_evt_weights[APEvtWeight::kElectronMO][i]);
150  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kJetMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJetMO].push_back(a.m_current_evt_weights[APEvtWeight::kJetMO][i]);
151  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kJetMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJetMO].push_back(b.m_current_evt_weights[APEvtWeight::kJetMO][i]);
152  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiMuon].push_back(a.m_current_evt_weights[APEvtWeight::kDiMuon][i]);
153  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiMuon].push_back(b.m_current_evt_weights[APEvtWeight::kDiMuon][i]);
154  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiTau].push_back(a.m_current_evt_weights[APEvtWeight::kDiTau][i]);
155  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiTau].push_back(b.m_current_evt_weights[APEvtWeight::kDiTau][i]);
156  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiElectron].push_back(a.m_current_evt_weights[APEvtWeight::kDiElectron][i]);
157  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiElectron].push_back(b.m_current_evt_weights[APEvtWeight::kDiElectron][i]);
158  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiJet].push_back(a.m_current_evt_weights[APEvtWeight::kDiJet][i]);
159  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiJet].push_back(b.m_current_evt_weights[APEvtWeight::kDiJet][i]);
160 
161  if (!b.m_isComputed) b.Compute();
162  if (!a.m_isComputed) a.Compute();
163 
164  ret.m_n_entries = a.m_n_entries + b.m_n_entries;
165  ret.m_k_evt_weight = a.m_k_evt_weight + b.m_k_evt_weight * ( 1.0 - a.m_k_evt_weight );
166  ret.m_variance = a.m_variance * ( 1.0 - b.m_k_evt_weight ) * ( 1.0 - b.m_k_evt_weight ) + b.m_variance * ( 1.0 - a.m_k_evt_weight ) * ( 1.0 - a.m_k_evt_weight );
167  ret.m_variance_sys = a.m_variance_sys * ( 1.0 - b.m_k_evt_weight ) * ( 1.0 - b.m_k_evt_weight ) + b.m_variance_sys * ( 1.0 - a.m_k_evt_weight ) * ( 1.0 - a.m_k_evt_weight );
168  return ret;
169  }
170  else if (a_type > APEvtWeight::kJetMO || b_type > APEvtWeight::kJetMO) {
171  if ((a.m_current_evt_weights[APEvtWeight::kMuon].size() > 0 && b.m_current_evt_weights[APEvtWeight::kMuon].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kTau].size() > 0 && b.m_current_evt_weights[APEvtWeight::kTau].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kElectron].size() > 0 && b.m_current_evt_weights[APEvtWeight::kElectron].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kJet].size() > 0 && b.m_current_evt_weights[APEvtWeight::kJet].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kMuonMO].size() > 0 && b.m_current_evt_weights[APEvtWeight::kMuonMO].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kTauMO].size() > 0 && b.m_current_evt_weights[APEvtWeight::kTauMO].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kElectronMO].size() > 0 && b.m_current_evt_weights[APEvtWeight::kElectronMO].size() > 0) || (a.m_current_evt_weights[APEvtWeight::kJetMO].size() > 0 && b.m_current_evt_weights[APEvtWeight::kJetMO].size() > 0) )
172  cout << "WARNING in APEvtWeight::operator||: Trying to combine already combined event weights with overlapping objects. Uncertainties will be incorrect." << endl;
173  }
174 
176 
177  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuon].push_back(a.m_current_evt_weights[APEvtWeight::kMuon][i]);
178  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuon].push_back(b.m_current_evt_weights[APEvtWeight::kMuon][i]);
179  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTau].push_back(a.m_current_evt_weights[APEvtWeight::kTau][i]);
180  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTau].push_back(b.m_current_evt_weights[APEvtWeight::kTau][i]);
181  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectron].push_back(a.m_current_evt_weights[APEvtWeight::kElectron][i]);
182  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectron].push_back(b.m_current_evt_weights[APEvtWeight::kElectron][i]);
183  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJet].push_back(a.m_current_evt_weights[APEvtWeight::kJet][i]);
184  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJet].push_back(b.m_current_evt_weights[APEvtWeight::kJet][i]);
185  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kMuonMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuonMO].push_back(a.m_current_evt_weights[APEvtWeight::kMuonMO][i]);
186  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kMuonMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kMuonMO].push_back(b.m_current_evt_weights[APEvtWeight::kMuonMO][i]);
187  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kTauMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTauMO].push_back(a.m_current_evt_weights[APEvtWeight::kTauMO][i]);
188  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kTauMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kTauMO].push_back(b.m_current_evt_weights[APEvtWeight::kTauMO][i]);
189  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kElectronMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectronMO].push_back(a.m_current_evt_weights[APEvtWeight::kElectronMO][i]);
190  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kElectronMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kElectronMO].push_back(b.m_current_evt_weights[APEvtWeight::kElectronMO][i]);
191  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kJetMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJetMO].push_back(a.m_current_evt_weights[APEvtWeight::kJetMO][i]);
192  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kJetMO].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kJetMO].push_back(b.m_current_evt_weights[APEvtWeight::kJetMO][i]);
193  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiMuon].push_back(a.m_current_evt_weights[APEvtWeight::kDiMuon][i]);
194  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiMuon].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiMuon].push_back(b.m_current_evt_weights[APEvtWeight::kDiMuon][i]);
195  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiTau].push_back(a.m_current_evt_weights[APEvtWeight::kDiTau][i]);
196  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiTau].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiTau].push_back(b.m_current_evt_weights[APEvtWeight::kDiTau][i]);
197  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiElectron].push_back(a.m_current_evt_weights[APEvtWeight::kDiElectron][i]);
198  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiElectron].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiElectron].push_back(b.m_current_evt_weights[APEvtWeight::kDiElectron][i]);
199  for (unsigned int i = 0, I = a.m_current_evt_weights[APEvtWeight::kDiJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiJet].push_back(a.m_current_evt_weights[APEvtWeight::kDiJet][i]);
200  for (unsigned int i = 0, I = b.m_current_evt_weights[APEvtWeight::kDiJet].size(); i < I; ++i) ret.m_current_evt_weights[APEvtWeight::kDiJet].push_back(b.m_current_evt_weights[APEvtWeight::kDiJet][i]);
201 
202  if (!b.m_isComputed) b.Compute();
203  if (!a.m_isComputed) a.Compute();
204 
205  ret.m_n_entries = a.m_n_entries + b.m_n_entries;
206  ret.m_k_evt_weight = 1.0 - (1.0 - a.m_k_evt_weight) * (1.0 - b.m_k_evt_weight);
207  ret.m_variance = a.m_variance * (1.0 - b.m_k_evt_weight) * (1.0 - b.m_k_evt_weight) + b.m_variance * (1.0 - a.m_k_evt_weight) * (1.0 - a.m_k_evt_weight);
208  ret.m_variance_sys = a.m_variance_sys * (1.0 - b.m_k_evt_weight) * (1.0 - b.m_k_evt_weight) + b.m_variance_sys * (1.0 - a.m_k_evt_weight) * (1.0 - a.m_k_evt_weight);
209  return ret;
210 }
211 
212 const APEvtWeight operator!(const APEvtWeight& a_in ) {
213 
214  APEvtWeight a = a_in;
215  APEvtWeight ret = a;
216  if(!a.m_isComputed && a.GetType() <= APEvtWeight::kDiJet ) a.Compute();
217  if(ret.GetType() <= APEvtWeight::kDiJet) ret.Compute();
218  ret.m_k_evt_weight = 1.0 - a.m_k_evt_weight;
219  return ret;
220 
221 }
222 
224  if (!m_isComputed) Compute();
225  //if ( m_type >= APEvtWeight::kMuonMO && m_type <= APEvtWeight::kJetMO ) cout << "WARNING in APEvtWeight::GetWeight: Trying to access weight for single component of multiobject trigger. You shouldn't do this!" << endl;
226  return m_k_evt_weight;
227 }
228 
230  if (!m_isComputed) Compute();
231  //if ( m_type >= APEvtWeight::kMuonMO && m_type <= APEvtWeight::kJetMO ) cout << "WARNING in APEvtWeight::GetStdDev: Trying to access StdDev for single component of multiobject trigger. You shouldn't do this!" << endl;
232  return sqrt(m_variance);
233 }
234 
236  if (!m_isComputed) Compute();
237  //if ( m_type >= APEvtWeight::kMuonMO && m_type <= APEvtWeight::kJetMO ) cout << "WARNING in APEvtWeight::GetVariance: Trying to access variance for single component of multiobject trigger. You shouldn't do this!" << endl;
238  return m_variance;
239 }
240 
242  if (!m_isComputed) Compute();
243  return sqrt(m_variance_sys);
244 }
245 
247  if (!m_isComputed) Compute();
248  return m_variance_sys;
249 }
250 
251 vector< APWeightEntry* > APEvtWeight::GetWeightObjects(ObjType type) {
252  if (type > APEvtWeight::kDiJet) {
253  cout << "WARNING in APEvtWeight::GetWeightObjects: Trying to get non-defined object type. Returning empty vector." << endl;
254  return vector< APWeightEntry* >();
255  }
256  return m_current_evt_weights[type];
257 }
258 
259 unsigned long APEvtWeight::NEntries() {
260  return m_n_entries;
261 }
262 
264  return m_type;
265 }
266 
267 void APEvtWeight::Compute() {
268  if (m_type > APEvtWeight::kDiJet ) {
269  cout << "ERROR in APEvtWeight::Compute: Trying to compute combined event weight. Ignoring command." << endl;
270  } else {
271  double evt_weight = 1.0;
272  double variance = 0.0;
273  double variance_sys = 0.0;
274  if ( m_type <= APEvtWeight::kJetMO ) {
275  for (unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; ++i) {
276  double variance_summand = 1.0;
277  evt_weight *= (1. - m_current_evt_weights[m_type][i]->GetExpectancy());
278  for (unsigned int k = 0; k < I; ++k) {
279  if (i != k) variance_summand *= (1. - m_current_evt_weights[m_type][k]->GetExpectancy());
280  }
281  variance += (variance_summand * variance_summand * m_current_evt_weights[m_type][i]->GetVariance());
282  variance_sys += (variance_summand * variance_summand * m_current_evt_weights[m_type][i]->GetSysUncert2());
283  }
284  }
285  else if ( m_type <= APEvtWeight::kDiJet ) {
286  if ( m_current_evt_weights[m_type].size() >= 2 ) {
287 
288  /* preliminary code to implement asymmetric triggers */
289  bool isAsymTrig = false;
290  vector<unsigned int> temp_vec_IDs;
291  temp_vec_IDs.push_back( m_current_evt_weights[m_type][0]->GetID() );
292  for( unsigned int i = 1, I = m_current_evt_weights[m_type].size(); i < I; ++i ) {
293  bool knownID = false;
294  for( unsigned int j = 0, J = temp_vec_IDs.size(); j < J; ++j ) {
295  if( m_current_evt_weights[m_type][i]->GetID() == temp_vec_IDs[j] ) { knownID = true; break; }
296  }
297  if( !knownID ) temp_vec_IDs.push_back( m_current_evt_weights[m_type][i]->GetID() );
298  }
299  if( temp_vec_IDs.size() != 1 ) isAsymTrig = true;
300 
301  if( !isAsymTrig ) {
302  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; ++i ) {
303  evt_weight *= (1. - m_current_evt_weights[m_type][i]->GetExpectancy());
304  }
305  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; ++i ) {
306  double variance_summand = 0.0;
307  double temp_weight = m_current_evt_weights[m_type][i]->GetExpectancy();
308  for( unsigned int k = 0; k < I; ++k ) {
309  double temp_variance_summand = 0.0;
310  if ( i != k ) {
311  temp_weight *= (1.-m_current_evt_weights[m_type][k]->GetExpectancy());
312  temp_variance_summand = m_current_evt_weights[m_type][k]->GetExpectancy();
313  }
314  for( unsigned int j = 0; j < I; ++j ) {
315  if ( j != i && j != k ) temp_variance_summand *= (1.-m_current_evt_weights[m_type][j]->GetExpectancy());
316  }
317  variance_summand += temp_variance_summand;
318  }
319  variance += (variance_summand * variance_summand * m_current_evt_weights[m_type][i]->GetVariance());
320  variance_sys += (variance_summand * variance_summand * m_current_evt_weights[m_type][i]->GetSysUncert2());
321  evt_weight += temp_weight;
322  }
323  }
324  else {
325  /* preliminary code to implement asymmetric triggers */
326  /* needs to be implemented */
327  /* this trigger will need : */
328  /* - absolute efficiency of first leg */
329  /* - absolute efficiency of second leg */
330  /* - conditional efficiency: efficiency of second leg under the condition the first leg fired */
331  /* - conditional efficiecny: efficiecny of second leg under the condition the first leg did not fire */
332  //std::cout << "this is an asymmetric trigger" << std::endl;
333  if( temp_vec_IDs.size() != 4 ) { std::cout << "WARNING! Required exactly 4 different efficiencies, while " << temp_vec_IDs.size() << " efficiencies are provided! Please check your implementation! Weight is set to 0! " << std::endl; }
334  else if( m_current_evt_weights[m_type].size() < 2*temp_vec_IDs.size() ) { std::cout << "less than 2 leptons added. Weight is 0." << std::endl; }
335  else {
336  // first the weight //
337  double evt_weight_leg1 = 1.;
338  double evt_weight_leg2 = 1.;
339  double evt_weight_leg2_cond = 1.;
340  double evt_weight_singleHit = 0.;
341  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
342  evt_weight_leg1 *= (1. - m_current_evt_weights[m_type][i]->GetExpectancy());
343  evt_weight_leg2 *= (1. - m_current_evt_weights[m_type][i+1]->GetExpectancy());
344  evt_weight_leg2_cond *= (1. - m_current_evt_weights[m_type][i]->GetExpectancy())*(1. - m_current_evt_weights[m_type][i+2]->GetExpectancy());
345  }
346  for( unsigned int j = 0, J = m_current_evt_weights[m_type].size(); j < J; j += 4 ) {
347  double temp_weight = 0.;
348  temp_weight += m_current_evt_weights[m_type][j]->GetExpectancy()*m_current_evt_weights[m_type][j+3]->GetExpectancy();
349  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
350  if( i == j ) continue;
351  temp_weight *= (1. - m_current_evt_weights[m_type][i]->GetExpectancy() )*(1. - m_current_evt_weights[m_type][i+2]->GetExpectancy() );
352  }
353  evt_weight_singleHit += temp_weight;
354  }
355  //std::cout << "got " << evt_weight_leg1 << " and " << evt_weight_leg2 << " and " << evt_weight_leg2_cond << " and " << evt_weight_singleHit << std::endl;
356  evt_weight = evt_weight_leg1 + evt_weight_leg2 - evt_weight_leg2_cond + evt_weight_singleHit;
357  // done; now the uncertainty //
358  double variance_leg1 = 0.;
359  double variance_leg2 = 0.;
360  double variance_leg2_cond = 0.;
361  double variance_singleHit = 0.;
362  // first leg of the trigger
363  for( unsigned int k = 0, K = m_current_evt_weights[m_type].size(); k < K; k += 4 ) {
364  double variance_k = 0.;
365  double variance_temp = 1.;
366  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
367  if( i == k ) continue;
368  variance_temp *= (1. - m_current_evt_weights[m_type][i]->GetExpectancy());
369  }
370  variance_k += variance_temp;
371  variance_temp = -1.;
372  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
373  variance_temp *= (1.0 - m_current_evt_weights[m_type][i+2]->GetExpectancy());
374  if( i == k ) continue;
375  variance_temp *= (1.0 - m_current_evt_weights[m_type][i]->GetExpectancy());
376  }
377  variance_k += variance_temp;
378  variance_temp = -m_current_evt_weights[m_type][k+3]->GetExpectancy();
379  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
380  if( i == k ) continue;
381  variance_temp *= (1.0 - m_current_evt_weights[m_type][i]->GetExpectancy())*(1.0 - m_current_evt_weights[m_type][i+2]->GetExpectancy());
382  }
383  variance_k += variance_temp;
384  variance_temp = 0.;
385  for( unsigned int j = 0, J = m_current_evt_weights[m_type].size(); j < J; j+= 4 ) {
386  if( j == k ) continue;
387  double variance_ijk_temp = m_current_evt_weights[m_type][j]->GetExpectancy()*m_current_evt_weights[m_type][j+3]->GetExpectancy();
388  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
389  if( i == j ) continue;
390  variance_ijk_temp *= (1.0 - m_current_evt_weights[m_type][i+2]->GetExpectancy());
391  if( i == k ) continue;
392  variance_ijk_temp *= (1.0 - m_current_evt_weights[m_type][i]->GetExpectancy());
393  }
394  variance_temp += variance_ijk_temp;
395  }
396  variance_k += variance_temp;
397  variance_leg1 += variance_k*variance_k*m_current_evt_weights[m_type][k]->GetVariance();
398  }
399 
400  // second leg of the trigger; standalone
401  for( unsigned int k = 0, K = m_current_evt_weights[m_type].size(); k < K; k += 4 ) {
402  double variance_temp = 1.;
403  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
404  if( i == k ) continue;
405  variance_temp *= (1. - m_current_evt_weights[m_type][i+1]->GetExpectancy());
406  }
407  variance_leg2 += variance_temp*variance_temp*m_current_evt_weights[m_type][k+1]->GetVariance();
408  }
409 
410  // second leg of the trigger under condition of having the first leg
411  for( unsigned int k = 0, K = m_current_evt_weights[m_type].size(); k < K; k += 4 ) {
412  double variance_k = 0.;
413  double variance_temp = 1.;
414  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
415  variance_temp *= (1. - m_current_evt_weights[m_type][i]->GetExpectancy());
416  if( i == k ) continue;
417  variance_temp *= (1. - m_current_evt_weights[m_type][i+2]->GetExpectancy());
418  }
419  variance_k += variance_temp;
420  variance_temp = 0.;
421  for( unsigned int j = 0, J = m_current_evt_weights[m_type].size(); j < J; j+= 4 ) {
422  double variance_ijk_temp = m_current_evt_weights[m_type][j]->GetExpectancy()*m_current_evt_weights[m_type][j+3]->GetExpectancy();
423  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
424  if( j == i ) continue;
425  variance_ijk_temp *= (1.0 - m_current_evt_weights[m_type][i]->GetExpectancy());
426  if( i == k ) continue;
427  variance_ijk_temp *= (1.0 - m_current_evt_weights[m_type][i+2]->GetExpectancy());
428  }
429  variance_temp += variance_ijk_temp;
430  }
431  variance_k += variance_temp;
432  variance_leg2_cond += variance_k*variance_k*m_current_evt_weights[m_type][k+2]->GetVariance();
433  }
434 
435  // and the single Hit term
436  for( unsigned int k = 0, K = m_current_evt_weights[m_type].size(); k < K; k += 4 ) {
437  double variance_k = - m_current_evt_weights[m_type][k]->GetExpectancy();
438  for( unsigned int i = 0, I = m_current_evt_weights[m_type].size(); i < I; i += 4 ) {
439  if( i == k ) continue;
440  variance_k *= (1.0 - m_current_evt_weights[m_type][i]->GetExpectancy())*(1.0 - m_current_evt_weights[m_type][i+3]->GetExpectancy());
441  }
442  variance_singleHit += variance_k * variance_k *m_current_evt_weights[m_type][k+3]->GetVariance();
443  }
444 
445  // now add everything
446  variance = variance_leg1 + variance_leg2 + variance_leg2_cond + variance_singleHit;
447 
448  }
449  }
450 
451  }
452  }
453  m_k_evt_weight = (1. - evt_weight);
454  m_variance = variance;
455  m_variance_sys = variance_sys;
456  }
457  m_isComputed = true;
458 }
APEvtWeight.h
APEvtWeight::GetWeightObjects
std::vector< APWeightEntry * > GetWeightObjects(ObjType type)
Returns the vector of weight objects for a specific object type.
Definition: APEvtWeight.cxx:251
APWeightEntry
Definition: APWeightEntry.h:25
APEvtWeight::m_type
ObjType m_type
Holds the object type of the event weight (muon, electron, jet or combined).
Definition: APEvtWeight.h:59
APEvtWeight::ObjType
ObjType
Definition: APEvtWeight.h:29
APEvtWeight::kMuonMO
@ kMuonMO
Definition: APEvtWeight.h:29
APEvtWeight::GetType
ObjType GetType()
Returns the type of the event weight (muon, electron, jet, ANDed, ORed).
Definition: APEvtWeight.cxx:263
APEvtWeight::kDiElectron
@ kDiElectron
Definition: APEvtWeight.h:29
APEvtWeight::GetVariance
double GetVariance()
Returns the variance.
Definition: APEvtWeight.cxx:235
APEvtWeight::kElectron
@ kElectron
Definition: APEvtWeight.h:29
APEvtWeight::kANDed
@ kANDed
Definition: APEvtWeight.h:29
APEvtWeight::kDiMuon
@ kDiMuon
Definition: APEvtWeight.h:29
APEvtWeight::GetStdDev
double GetStdDev()
Returns the standard deviation.
Definition: APEvtWeight.cxx:229
APEvtWeight::kMuon
@ kMuon
Definition: APEvtWeight.h:29
APEvtWeight::kDiJet
@ kDiJet
Definition: APEvtWeight.h:29
APEvtWeight::kTauMO
@ kTauMO
Definition: APEvtWeight.h:29
operator&&
const APEvtWeight operator&&(const APEvtWeight &a_in, const APEvtWeight &b_in)
Definition: APEvtWeight.cxx:42
APEvtWeight::m_k_evt_weight
double m_k_evt_weight
Holds the event weight.
Definition: APEvtWeight.h:55
APEvtWeight::kElectronMO
@ kElectronMO
Definition: APEvtWeight.h:29
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
APEvtWeight
Definition: APEvtWeight.h:26
APEvtWeight::m_variance_sys
double m_variance_sys
Holds the systematic variance (from systematics assigned to weights).
Definition: APEvtWeight.h:57
lumiFormat.i
int i
Definition: lumiFormat.py:92
APEvtWeight::AddWeightToEvt
void AddWeightToEvt(APWeightEntry *weight)
Adds a weight to the sum of weights.
Definition: APEvtWeight.cxx:28
APEvtWeight::kJetMO
@ kJetMO
Definition: APEvtWeight.h:29
ret
T ret(T t)
Definition: rootspy.cxx:260
APEvtWeight::kORed
@ kORed
Definition: APEvtWeight.h:29
APEvtWeight::GetWeight
double GetWeight()
Returns the event weight.
Definition: APEvtWeight.cxx:223
APEvtWeight::GetSysVariance
double GetSysVariance()
Returns the systematic variance (from systematics assigned to weights).
Definition: APEvtWeight.cxx:246
APEvtWeight::kJet
@ kJet
Definition: APEvtWeight.h:29
APEvtWeight::m_variance
double m_variance
Holds the variance.
Definition: APEvtWeight.h:56
APEvtWeight::kMOANDed
@ kMOANDed
Definition: APEvtWeight.h:29
APEvtWeight::GetSysUncert
double GetSysUncert()
Returns the systematic uncertainty (from systematics assigned to weights).
Definition: APEvtWeight.cxx:241
APEvtWeight::APEvtWeight
APEvtWeight(ObjType type)
Default constructor.
Definition: APEvtWeight.cxx:13
operator!
const APEvtWeight operator!(const APEvtWeight &a_in)
Definition: APEvtWeight.cxx:212
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
PixelConvert::GetID
unsigned int GetID(const Map &map, const unsigned int moduleID)
Definition: PixelConvert.cxx:433
APEvtWeight::~APEvtWeight
virtual ~APEvtWeight()
Default destructor.
Definition: APEvtWeight.cxx:24
operator||
const APEvtWeight operator||(const APEvtWeight &a_in, const APEvtWeight &b_in)
Definition: APEvtWeight.cxx:128
APWeightEntry.h
APEvtWeight::kMOORed
@ kMOORed
Definition: APEvtWeight.h:29
a
TList * a
Definition: liststreamerinfos.cxx:10
APEvtWeight::m_n_entries
unsigned long int m_n_entries
Holds the original amount of unweighted counts ("sum of 1's").
Definition: APEvtWeight.h:54
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
APEvtWeight::m_current_evt_weights
ClassDef(APEvtWeight, 1) protected std::vector< std::vector< APWeightEntry * > > m_current_evt_weights
< Calculates the event weight for the current entries.
Definition: APEvtWeight.h:49
APEvtWeight::NEntries
unsigned long NEntries()
Returns the unweighted number of entries.
Definition: APEvtWeight.cxx:259
I
#define I(x, y, z)
Definition: MD5.cxx:116
APEvtWeight::m_isComputed
bool m_isComputed
Flag if calculation has already been performed for current set of input weights.
Definition: APEvtWeight.h:58
APEvtWeight::kDiTau
@ kDiTau
Definition: APEvtWeight.h:29
APEvtWeight::kTau
@ kTau
Definition: APEvtWeight.h:29
fitman.k
k
Definition: fitman.py:528