ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
FakeBkgTools
Root
ApplyE2YFakeRate.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
#include "
FakeBkgTools/ApplyE2YFakeRate.h
"
6
#include "
FakeBkgTools/FakeBkgInternals.h
"
7
#include <cmath>
8
9
using namespace
CP
;
10
using namespace
FakeBkgTools
;
11
//=============================================================================
12
// Constructor
13
//=============================================================================
14
ApplyE2YFakeRate::ApplyE2YFakeRate
(
const
std::string&
name
) :
15
BaseLinearFakeBkgTool
(
name
)
16
{
17
declareProperty
(
"e2y_option"
,
m_e2y_option
,
"0-apply e2y rate SF, 1-apply e2y rate"
);
18
19
}
20
21
//=============================================================================
22
// Destructor
23
//=============================================================================
24
ApplyE2YFakeRate::~ApplyE2YFakeRate
()
25
{
26
}
27
28
FakeBkgTools::Client
ApplyE2YFakeRate::clientForDB
()
29
{
30
return
FakeBkgTools::Client::E2Y_FAKE
;
31
}
32
33
StatusCode
ApplyE2YFakeRate::initialize
()
34
{
35
return
BaseLinearFakeBkgTool::initialize
();
36
}
37
38
StatusCode
ApplyE2YFakeRate::addEventCustom
()
39
{
40
m_cachedWeights
.clear();
41
42
return
incrementTotalYield
();
43
}
44
45
StatusCode
ApplyE2YFakeRate::getEventWeightCustom
(
46
FakeBkgTools::Weight
& weight,
const
FakeBkgTools::FinalState
&
fs
) {
47
48
const
size_t
n =
m_particles
.size();
49
const
size_t
nc = (1 << n);
50
51
// the E2Y method has no extra selection information in tool
52
// fill all particles bitset to 1
53
FSBitset
tights(nc-1);
54
std::array<
double
,
maxParticles
()>dev;
//first-order partial derivative
55
std::fill_n(dev.begin(), n, 0);
56
57
// m_e2y_option == 1: Apply the electron to photon fake rate
58
// m_e2y_option == 0: Apply the electron to photon fake rate scale factor
59
// In general, we could only condider one electron fake a photon.
60
// the rate of electron wrongly reconstructed rate and idenified as photon:f = N_y^{reco}/N_e^{true}.
61
// the fake rate is defined:F = N_y^{reco}/N^_e{reco} = f/(1-f)
62
63
for
(
size_t
i=0;i<nc;i++){
64
65
// all possible conbination (e.g. for 2 particle final state):
66
// FF, FR, RF, RR
67
// if we want to calculate the weight with process = "1F"
68
// the accepted process : FR, RF
69
// weight = F1 + F2
70
// dev[0] = 1, dev[1] = 1
71
// unc = unc1 + unc2
72
73
FSBitset
reals(i);
74
if
(!
fs
.accept_process(n, reals, tights))
continue
;
75
double
wei = 1.;
76
for
(
size_t
j=0;j<n;j++){
77
if
(
m_e2y_option
== 1 &&
m_particles
[j].
type
==
xAOD::Type::Electron
){
78
double
x
= reals[j]? 1 :
m_particles
[j].fake_factor.nominal;
79
wei *=
x
;
80
double
theta
= reals[j]? 0 : 1;
81
for
(
size_t
k=0;k<n;k++){
82
if
(k != j)
theta
*= reals[k]? 1 :
m_particles
[k].fake_factor.nominal;
83
}
84
dev[j] +=
theta
;
85
}
86
else
if
(
m_e2y_option
== 0 &&
m_particles
[j].
type
==
xAOD::Type::Photon
){
87
if
(reals.count() == 0){
//only consider case all photons are from the electron fake
88
double
x
=
m_particles
[j].fake_factor.nominal;
89
wei *=
x
;
90
double
theta
= 1.;
91
for
(
size_t
k=0;k<n;k++){
92
if
(k != j)
theta
*=
m_particles
[k].fake_factor.nominal;
93
}
94
dev[j] +=
theta
;
95
}
96
else
{
97
ATH_MSG_ERROR
(
"the process is not supported.Please try to use process = '0R' instead"
);
98
return
StatusCode::FAILURE;
99
}
100
101
}
102
else
{
103
ATH_MSG_ERROR
(
"the option and particle type are not supported by this method"
);
104
return
StatusCode::FAILURE;
105
}
106
}
107
weight.nominal += wei;
108
109
}
110
for
(
size_t
i=0;i<n;i++){
111
for
(
auto
const
&kv :
m_particles
[i].fake_factor.uncertainties){
112
auto
& uncertainties = weight.uncertainties[kv.first];
113
uncertainties.up += dev[i] * kv.second.up;
114
uncertainties.down += dev[i] * kv.second.down;
115
}
116
}
117
118
119
return
StatusCode::SUCCESS;
120
}
121
122
123
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
ApplyE2YFakeRate.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
FakeBkgInternals.h
fs
static Double_t fs
Definition
LArPhysWaveHECTool.cxx:37
x
#define x
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
CP::ApplyE2YFakeRate::clientForDB
virtual FakeBkgTools::Client clientForDB() override final
This indicates which type of efficiencies/fake factor need to be filled.
Definition
ApplyE2YFakeRate.cxx:28
CP::ApplyE2YFakeRate::ApplyE2YFakeRate
ApplyE2YFakeRate(const std::string &name)
Standard constructor.
Definition
ApplyE2YFakeRate.cxx:14
CP::ApplyE2YFakeRate::m_e2y_option
int m_e2y_option
Definition
ApplyE2YFakeRate.h:41
CP::ApplyE2YFakeRate::addEventCustom
virtual StatusCode addEventCustom() override
Definition
ApplyE2YFakeRate.cxx:38
CP::ApplyE2YFakeRate::~ApplyE2YFakeRate
~ApplyE2YFakeRate()
Standard destructor.
Definition
ApplyE2YFakeRate.cxx:24
CP::ApplyE2YFakeRate::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
ApplyE2YFakeRate.cxx:33
CP::ApplyE2YFakeRate::getEventWeightCustom
virtual StatusCode getEventWeightCustom(FakeBkgTools::Weight &weight, const FakeBkgTools::FinalState &fs) override
Definition
ApplyE2YFakeRate.cxx:45
CP::BaseFakeBkgTool::m_particles
std::vector< FakeBkgTools::ParticleData > m_particles
Definition
BaseFakeBkgTool.h:85
CP::BaseLinearFakeBkgTool::BaseLinearFakeBkgTool
BaseLinearFakeBkgTool(const std::string &toolname)
Definition
BaseLinearFakeBkgTool.cxx:25
CP::BaseLinearFakeBkgTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
BaseLinearFakeBkgTool.cxx:34
CP::BaseLinearFakeBkgTool::incrementTotalYield
StatusCode incrementTotalYield()
be sure to only call this once per event! (typically at the end of addEvent())
Definition
BaseLinearFakeBkgTool.cxx:97
CP::BaseLinearFakeBkgTool::m_cachedWeights
std::map< FakeBkgTools::FinalState, FakeBkgTools::Weight > m_cachedWeights
cached weight+uncertainties for a single event Each tool derived from this base class MUST clear the ...
Definition
BaseLinearFakeBkgTool.h:67
FakeBkgTools::FinalState
Definition
FakeBkgInternals.h:98
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
FakeBkgTools
Definition
BaseFakeBkgTool.h:23
FakeBkgTools::FSBitset
std::bitset< maxCombinations()> FSBitset
Definition
FakeBkgInternals.h:95
FakeBkgTools::Client
Client
Definition
FakeBkgInternals.h:141
FakeBkgTools::Client::E2Y_FAKE
@ E2Y_FAKE
Definition
FakeBkgInternals.h:142
FakeBkgTools::maxParticles
constexpr uint8_t maxParticles()
Definition
FakeBkgInternals.h:93
xAODType::Photon
@ Photon
The object is a photon.
Definition
ObjectType.h:47
xAODType::Electron
@ Electron
The object is an electron.
Definition
ObjectType.h:46
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::double
double
Definition
CompositeParticle_v1.cxx:159
FakeBkgTools::Weight
a structure to hold a weight together with a variable number of systematic uncertainties
Definition
FakeBkgInternals.h:62
type
Generated on
for ATLAS Offline Software by
1.17.0