ATLAS Offline Software
Loading...
Searching...
No Matches
FakeBkgTools::Yield Struct Reference

a structure to hold an event yield together with a statistical uncertainty and a variable number of systematic uncertainties More...

#include <FakeBkgInternals.h>

Inheritance diagram for FakeBkgTools::Yield:
Collaboration diagram for FakeBkgTools::Yield:

Public Member Functions

Yieldadd (const Yield &rhs, float weight=1.f)
 add() treats systematic uncertainties as correlated and updates (or creates) the total statistical uncertainty (RMS)
Yieldadd (const Weight &rhs, float weight=1.f)
float stat () const
 Helper function to extract the total statistical uncertainty from the 'uncertainties' field; it returns the symmetrized uncertainties[Uncertainty::totalStat()] if present, else fabs(value) (not 0!)
float syst () const
 Helper function to extract the total systematic uncertainty from the 'uncertainties' field; it is computed as the quadratic sum of all symmetrized systematic uncertainties.
float value (const CP::BaseFakeBkgTool *tool) const
Efficiencyadd (const Efficiency &rhs, float weight=1.f)
 key = source of uncertainty (ID), value = up/down
Efficiencymultiply (const Efficiency &rhs, float weight=1.f)
 the first version of multiply() takes the product of two Efficiencies, setting the up and down variations for each uncertainty to give the correct variation for the product
Efficiencymultiply (float weight)
EfficiencysetToConst (float value=1.f)
 setToConst() sets the nominal and all varied values to the same constant
EfficiencysubFromOne ()
 subFromOne() sets nominal and varied values to 1 - previous value.

Public Attributes

Uncertainty stat2
float nominal = 0
std::map< uint16_t, FakeBkgTools::Uncertaintyuncertainties

Detailed Description

a structure to hold an event yield together with a statistical uncertainty and a variable number of systematic uncertainties

Definition at line 69 of file FakeBkgInternals.h.

Member Function Documentation

◆ add() [1/3]

Efficiency & FakeBkgTools::Efficiency::add ( const Efficiency & rhs,
float weight = 1.f )
inlineinherited

key = source of uncertainty (ID), value = up/down

add() treats systematic uncertainties as correlated and updates (or creates) the total statistical uncertainty (RMS)

Systematic uncertainties

Central value

Definition at line 208 of file FakeBkgInternals.h.

209{
211 for(auto& kv : rhs.uncertainties)
212 {
213 auto r = uncertainties.emplace(kv);
214 if(r.second) r.first->second *= weight;
215 else r.first->second += weight * kv.second;
216 }
218 nominal += weight * rhs.nominal;
219 return *this;
220}
int r
Definition globals.cxx:22
std::map< uint16_t, FakeBkgTools::Uncertainty > uncertainties
std::map< uint16_t, FakeBkgTools::Uncertainty > uncertainties

◆ add() [2/3]

Yield & FakeBkgTools::Yield::add ( const Weight & rhs,
float weight = 1.f )
inline

Systematic uncertainties

Statistical uncertainty ("RMS of weights")

Central value

Definition at line 173 of file FakeBkgInternals.h.

174{
176 for(auto& kv : rhs.uncertainties)
177 {
178 auto r = uncertainties.emplace(kv);
179 if(r.second) r.first->second *= weight;
180 else r.first->second += weight * kv.second;
181 }
183 float ds2 = pow(weight * rhs.nominal, 2);
184 stat2.up += ds2;
185 stat2.down += ds2;
187 nominal += weight * rhs.nominal;
188 return *this;
189}
constexpr int pow(int base, int exp) noexcept

◆ add() [3/3]

Yield & FakeBkgTools::Yield::add ( const Yield & rhs,
float weight = 1.f )
inline

add() treats systematic uncertainties as correlated and updates (or creates) the total statistical uncertainty (RMS)

Systematic uncertainties

Statistical uncertainty ("RMS of weights")

Central value

Definition at line 191 of file FakeBkgInternals.h.

192{
194 for(auto& kv : rhs.uncertainties)
195 {
196 auto r = uncertainties.emplace(kv);
197 if(r.second) r.first->second *= weight;
198 else r.first->second += weight * kv.second;
199 }
201 stat2.up += weight * weight * rhs.stat2.up;
202 stat2.down += weight * weight * rhs.stat2.down;
204 nominal += weight * rhs.nominal;
205 return *this;
206}

◆ multiply() [1/2]

Efficiency & FakeBkgTools::Efficiency::multiply ( const Efficiency & rhs,
float weight = 1.f )
inlineinherited

the first version of multiply() takes the product of two Efficiencies, setting the up and down variations for each uncertainty to give the correct variation for the product

Systematic uncertainties

Central value

Definition at line 222 of file FakeBkgInternals.h.

223{
225 for(auto& kv : rhs.uncertainties)
226 {
227 auto r = uncertainties.emplace(kv);
228 if(!r.second) {
229 Uncertainty u_init = r.first->second;
230 r.first->second = nominal*kv.second;
231 r.first->second += (rhs.nominal*u_init);
232 r.first->second += (u_init*=kv.second);
233 }
234 }
236 nominal *= weight * rhs.nominal;
237 return *this;
238}
Uncertainty
specification of type information requested by the user

◆ multiply() [2/2]

Efficiency & FakeBkgTools::Efficiency::multiply ( float weight)
inlineinherited

Systematic uncertainties

Central value

Definition at line 240 of file FakeBkgInternals.h.

241{
243 for(auto& kv : uncertainties)
244 {
245 kv.second*= weight;
246 }
248 nominal *= weight;
249 return *this;
250}

◆ setToConst()

Efficiency & FakeBkgTools::Efficiency::setToConst ( float value = 1.f)
inlineinherited

setToConst() sets the nominal and all varied values to the same constant

Systematic uncertainties

Central value

Definition at line 252 of file FakeBkgInternals.h.

253{
255 for(auto& kv : uncertainties)
256 {
257 kv.second.up = 0.;
258 kv.second.down = 0.;
259 }
261 nominal = val;
262 return *this;
263}

◆ stat()

float FakeBkgTools::Yield::stat ( ) const
inline

Helper function to extract the total statistical uncertainty from the 'uncertainties' field; it returns the symmetrized uncertainties[Uncertainty::totalStat()] if present, else fabs(value) (not 0!)

Definition at line 279 of file FakeBkgInternals.h.

280{
281 return 0.5f*sqrt(stat2.up) + 0.5f*sqrt(stat2.down);
282}

◆ subFromOne()

Efficiency & FakeBkgTools::Efficiency::subFromOne ( )
inlineinherited

subFromOne() sets nominal and varied values to 1 - previous value.

Systematic uncertainties

Central value

Definition at line 265 of file FakeBkgInternals.h.

266{
268 for(auto& kv : uncertainties)
269 {
270 kv.second.up = -kv.second.up;
271 kv.second.down = -kv.second.down;
272 }
274 nominal = 1.-nominal;
275 return *this;
276}

◆ syst()

float FakeBkgTools::Yield::syst ( ) const
inline

Helper function to extract the total systematic uncertainty from the 'uncertainties' field; it is computed as the quadratic sum of all symmetrized systematic uncertainties.

Definition at line 284 of file FakeBkgInternals.h.

285{
286 double syst2 = 0;
287 for(auto& kv : uncertainties) syst2 += std::pow(0.5*(kv.second.up+kv.second.down), 2);
288 return sqrt(syst2);
289}

◆ value()

float Efficiency::value ( const CP::BaseFakeBkgTool * tool) const
inherited

Definition at line 17 of file FakeBkgInternals.cxx.

18{
19 float val = nominal;
20 for(const auto* su = tool->m_selectedUncertainties; su; su = su->next())
21 {
22 auto unc = uncertainties.find(su->UID);
23 if(unc != uncertainties.end())
24 {
25 val += su->sigma * ((su->sigma>=0)? unc->second.up : unc->second.down);
26 }
27 }
28 return val;
29}

Member Data Documentation

◆ nominal

float FakeBkgTools::Efficiency::nominal = 0
inherited

Definition at line 42 of file FakeBkgInternals.h.

◆ stat2

Uncertainty FakeBkgTools::Yield::stat2

Definition at line 71 of file FakeBkgInternals.h.

◆ uncertainties

std::map<uint16_t, FakeBkgTools::Uncertainty> FakeBkgTools::Efficiency::uncertainties
inherited

Definition at line 43 of file FakeBkgInternals.h.


The documentation for this struct was generated from the following file: