ATLAS Offline Software
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
APEvtWeight Class Reference

#include <APEvtWeight.h>

Inheritance diagram for APEvtWeight:
Collaboration diagram for APEvtWeight:

Public Types

enum  ObjType {
  kMuon, kTau, kElectron, kJet,
  kMuonMO, kTauMO, kElectronMO, kJetMO,
  kDiMuon, kDiTau, kDiElectron, kDiJet,
  kANDed, kORed, kMOORed, kMOANDed
}
 

Public Member Functions

 APEvtWeight (ObjType type)
 Default constructor. More...
 
virtual ~APEvtWeight ()
 Default destructor. More...
 
void AddWeightToEvt (APWeightEntry *weight)
 Adds a weight to the sum of weights. More...
 
double GetWeight ()
 Returns the event weight. More...
 
double GetStdDev ()
 Returns the standard deviation. More...
 
double GetVariance ()
 Returns the variance. More...
 
double GetSysUncert ()
 Returns the systematic uncertainty (from systematics assigned to weights). More...
 
double GetSysVariance ()
 Returns the systematic variance (from systematics assigned to weights). More...
 
std::vector< APWeightEntry * > GetWeightObjects (ObjType type)
 Returns the vector of weight objects for a specific object type. More...
 
unsigned long NEntries ()
 Returns the unweighted number of entries. More...
 
ObjType GetType ()
 Returns the type of the event weight (muon, electron, jet, ANDed, ORed). More...
 

Public Attributes

ClassDef(APEvtWeight, 1) protected std::vector< std::vector< APWeightEntry * > > m_current_evt_weights
 < Calculates the event weight for the current entries. More...
 
unsigned long int m_n_entries
 Holds the original amount of unweighted counts ("sum of 1's"). More...
 
double m_k_evt_weight
 Holds the event weight. More...
 
double m_variance
 Holds the variance. More...
 
double m_variance_sys
 Holds the systematic variance (from systematics assigned to weights). More...
 
bool m_isComputed
 Flag if calculation has already been performed for current set of input weights. More...
 
ObjType m_type
 Holds the object type of the event weight (muon, electron, jet or combined). More...
 

Friends

const friend APEvtWeight operator&& (const APEvtWeight &a_in, const APEvtWeight &b_in)
 Operator implementing logical AND. More...
 
const friend APEvtWeight operator|| (const APEvtWeight &a_in, const APEvtWeight &b_in)
 Operator implementing logical OR. More...
 
const friend APEvtWeight operator! (const APEvtWeight &a_in)
 Operator implementing negation of weight. More...
 

Detailed Description

Class to calculate the sum of weights ("weighted counter")

Calculates the sum of weights taking into account the underlying asymmetric probability distribution. This is done by modelling the pdf and then extracting the corresponding quantiles.

Author
fabia.nosp@m.n.Ko.nosp@m.hn@ce.nosp@m.rn.c.nosp@m.h

Definition at line 26 of file APEvtWeight.h.

Member Enumeration Documentation

◆ ObjType

Enumerator
kMuon 
kTau 
kElectron 
kJet 
kMuonMO 
kTauMO 
kElectronMO 
kJetMO 
kDiMuon 
kDiTau 
kDiElectron 
kDiJet 
kANDed 
kORed 
kMOORed 
kMOANDed 

Definition at line 29 of file APEvtWeight.h.

Constructor & Destructor Documentation

◆ APEvtWeight()

APEvtWeight::APEvtWeight ( ObjType  type)

Default constructor.

Definition at line 13 of file APEvtWeight.cxx.

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),
20  m_type(type)
21 {
22 }

◆ ~APEvtWeight()

APEvtWeight::~APEvtWeight ( )
virtual

Default destructor.

Definition at line 24 of file APEvtWeight.cxx.

24  {
25  m_current_evt_weights.clear();
26 }

Member Function Documentation

◆ AddWeightToEvt()

void APEvtWeight::AddWeightToEvt ( APWeightEntry weight)

Adds a weight to the sum of weights.

Definition at line 28 of file APEvtWeight.cxx.

28  {
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 }

◆ GetStdDev()

double APEvtWeight::GetStdDev ( )

Returns the standard deviation.

Definition at line 229 of file APEvtWeight.cxx.

229  {
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 }

◆ GetSysUncert()

double APEvtWeight::GetSysUncert ( )

Returns the systematic uncertainty (from systematics assigned to weights).

Definition at line 241 of file APEvtWeight.cxx.

241  {
242  if (!m_isComputed) Compute();
243  return sqrt(m_variance_sys);
244 }

◆ GetSysVariance()

double APEvtWeight::GetSysVariance ( )

Returns the systematic variance (from systematics assigned to weights).

Definition at line 246 of file APEvtWeight.cxx.

246  {
247  if (!m_isComputed) Compute();
248  return m_variance_sys;
249 }

◆ GetType()

APEvtWeight::ObjType APEvtWeight::GetType ( )

Returns the type of the event weight (muon, electron, jet, ANDed, ORed).

Definition at line 263 of file APEvtWeight.cxx.

263  {
264  return m_type;
265 }

◆ GetVariance()

double APEvtWeight::GetVariance ( )

Returns the variance.

Definition at line 235 of file APEvtWeight.cxx.

235  {
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 }

◆ GetWeight()

double APEvtWeight::GetWeight ( )

Returns the event weight.

Definition at line 223 of file APEvtWeight.cxx.

223  {
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 }

◆ GetWeightObjects()

vector< APWeightEntry * > APEvtWeight::GetWeightObjects ( ObjType  type)

Returns the vector of weight objects for a specific object type.

Definition at line 251 of file APEvtWeight.cxx.

251  {
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 }

◆ NEntries()

unsigned long APEvtWeight::NEntries ( )

Returns the unweighted number of entries.

Definition at line 259 of file APEvtWeight.cxx.

259  {
260  return m_n_entries;
261 }

Friends And Related Function Documentation

◆ operator!

const friend APEvtWeight operator! ( const APEvtWeight a_in)
friend

Operator implementing negation of weight.

Definition at line 212 of file APEvtWeight.cxx.

212  {
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 }

◆ operator&&

const friend APEvtWeight operator&& ( const APEvtWeight a_in,
const APEvtWeight b_in 
)
friend

Operator implementing logical AND.

Definition at line 42 of file APEvtWeight.cxx.

42  {
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 }

◆ operator||

const friend APEvtWeight operator|| ( const APEvtWeight a_in,
const APEvtWeight b_in 
)
friend

Operator implementing logical OR.

Definition at line 128 of file APEvtWeight.cxx.

128  {
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 }

Member Data Documentation

◆ m_current_evt_weights

ClassDef (APEvtWeight,1) protected std::vector< std::vector< APWeightEntry* > > APEvtWeight::m_current_evt_weights

< Calculates the event weight for the current entries.

Holds the weights for muons, electrons and jets in the current event.

Definition at line 53 of file APEvtWeight.h.

◆ m_isComputed

bool APEvtWeight::m_isComputed

Flag if calculation has already been performed for current set of input weights.

Definition at line 58 of file APEvtWeight.h.

◆ m_k_evt_weight

double APEvtWeight::m_k_evt_weight

Holds the event weight.

Definition at line 55 of file APEvtWeight.h.

◆ m_n_entries

unsigned long int APEvtWeight::m_n_entries

Holds the original amount of unweighted counts ("sum of 1's").

Definition at line 54 of file APEvtWeight.h.

◆ m_type

ObjType APEvtWeight::m_type

Holds the object type of the event weight (muon, electron, jet or combined).

Definition at line 59 of file APEvtWeight.h.

◆ m_variance

double APEvtWeight::m_variance

Holds the variance.

Definition at line 56 of file APEvtWeight.h.

◆ m_variance_sys

double APEvtWeight::m_variance_sys

Holds the systematic variance (from systematics assigned to weights).

Definition at line 57 of file APEvtWeight.h.


The documentation for this class was generated from the following files:
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::kDiElectron
@ kDiElectron
Definition: APEvtWeight.h:29
APEvtWeight::kElectron
@ kElectron
Definition: APEvtWeight.h:29
APEvtWeight::kANDed
@ kANDed
Definition: APEvtWeight.h:29
APEvtWeight::kDiMuon
@ kDiMuon
Definition: APEvtWeight.h:29
APEvtWeight::kMuon
@ kMuon
Definition: APEvtWeight.h:29
APEvtWeight::kDiJet
@ kDiJet
Definition: APEvtWeight.h:29
APEvtWeight::kTauMO
@ kTauMO
Definition: APEvtWeight.h:29
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
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::kJetMO
@ kJetMO
Definition: APEvtWeight.h:29
ret
T ret(T t)
Definition: rootspy.cxx:260
APEvtWeight::kORed
@ kORed
Definition: APEvtWeight.h:29
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
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
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
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