ATLAS Offline Software
Reconstruction
DiTauRecTools
Root
DiTauDiscriminantTool.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 "
DiTauRecTools/DiTauDiscriminantTool.h
"
6
7
// Core include(s):
8
#include "AthLinks/ElementLink.h"
9
10
// EDM include(s):
11
#include "
xAODTau/DiTauJet.h
"
12
#include "
xAODTau/DiTauJetContainer.h
"
13
14
#include "
DiTauRecTools/HelperFunctions.h
"
15
#include "
PathResolver/PathResolver.h
"
16
17
18
using namespace
DiTauRecTools
;
19
20
//=================================PUBLIC-PART==================================
21
//______________________________________________________________________________
22
DiTauDiscriminantTool::DiTauDiscriminantTool(
const
std::string&
name
)
23
: AsgTool(
name
)
24
, m_bdt()
25
, m_eDecayMode(
DecayMode
::
Default
)
26
{
27
declareProperty
(
"WeightsFile"
, m_sWeightsFile =
"tauRecTools/R22_preprod/DiTau_JetBDT_winter2024.weights.root"
);
28
declareProperty
(
"BDTScoreName"
, m_sBDTScoreName =
"JetBDT"
);
29
declareProperty
(
"DiTauDecayChannel"
, m_sDecayMode =
"HadHad"
);
30
}
31
32
//______________________________________________________________________________
33
DiTauDiscriminantTool::~DiTauDiscriminantTool( )
34
=
default
;
35
36
//______________________________________________________________________________
37
StatusCode
DiTauDiscriminantTool::initialize
()
38
{
39
ATH_MSG_INFO
(
"Initializing DiTauDiscriminantTool"
);
40
ATH_MSG_DEBUG
(
"path to weights file: "
<< m_sWeightsFile );
41
42
if
(m_sDecayMode ==
"HadHad"
)
43
m_eDecayMode = DecayMode::HadHad;
44
if
(m_eDecayMode ==
DecayMode::Default
)
45
ATH_MSG_ERROR
(
"No valid DecayMode initialized for DiTauDiscriminantTool. Possible Options: HadHad"
);
46
47
switch
(m_eDecayMode){
48
case
(DecayMode::HadHad):
49
m_mIDSpectators = {
50
{
"ditau_pt"
,
new
float
(0)},
51
{
"mu"
,
new
float
(0)},
52
{
"pt_weight"
,
new
float
(0)},
53
{
"isSignal"
,
new
float
(0)}
54
};
55
56
m_mIDVariables = {
57
{
"f_core_lead"
,
new
float
(0)},
// used
58
{
"f_core_subl"
,
new
float
(0)},
// used
59
{
"f_subjet_lead"
,
new
float
(0)},
60
{
"f_subjet_subl"
,
new
float
(0)},
// used
61
{
"f_subjets"
,
new
float
(0)},
// used
62
{
"f_track_lead"
,
new
float
(0)},
63
{
"f_track_subl"
,
new
float
(0)},
64
{
"R_max_lead"
,
new
float
(0)},
// used
65
{
"R_max_subl"
,
new
float
(0)},
// used
66
{
"n_Subjets"
,
new
float
(0)},
67
{
"n_track"
,
new
float
(0)},
// used
68
{
"n_tracks_lead"
,
new
float
(0)},
// used
69
{
"n_tracks_subl"
,
new
float
(0)},
70
{
"n_isotrack"
,
new
float
(0)},
71
{
"R_track"
,
new
float
(0)},
72
{
"R_track_core"
,
new
float
(0)},
73
{
"R_track_all"
,
new
float
(0)},
74
{
"R_isotrack"
,
new
float
(0)},
// used
75
{
"R_core_lead"
,
new
float
(0)},
76
{
"R_core_subl"
,
new
float
(0)},
77
{
"R_tracks_lead"
,
new
float
(0)},
78
{
"R_tracks_subl"
,
new
float
(0)},
// used
79
{
"m_track"
,
new
float
(0)},
80
{
"m_track_core"
,
new
float
(0)},
81
{
"m_core_lead"
,
new
float
(0)},
82
{
"log(m_core_lead)"
,
new
float
(0)},
// used
83
{
"m_core_subl"
,
new
float
(0)},
84
{
"log(m_core_subl)"
,
new
float
(0)},
// used
85
{
"m_track_all"
,
new
float
(0)},
86
{
"m_tracks_lead"
,
new
float
(0)},
87
{
"log(m_tracks_lead)"
,
new
float
(0)},
// used
88
{
"m_tracks_subl"
,
new
float
(0)},
89
{
"log(m_tracks_subl)"
,
new
float
(0)},
// used
90
{
"E_frac_subl"
,
new
float
(0)},
91
{
"E_frac_subsubl"
,
new
float
(0)},
92
{
"R_subjets_subl"
,
new
float
(0)},
93
{
"R_subjets_subsubl"
,
new
float
(0)},
94
{
"d0_leadtrack_lead"
,
new
float
(0)},
95
{
"log(abs(d0_leadtrack_lead))"
,
new
float
(0)},
// used
96
{
"d0_leadtrack_subl"
,
new
float
(0)},
97
{
"log(abs(d0_leadtrack_subl))"
,
new
float
(0)},
// used
98
{
"f_isotracks"
,
new
float
(0)},
99
{
"log(f_isotracks)"
,
new
float
(0)},
// used
100
};
101
102
break
;
103
default
:
104
ATH_MSG_ERROR
(
"No valid DecayMode"
);
105
break
;
106
}
107
108
109
110
ATH_CHECK
(parseWeightsFile());
111
112
// m_bIsInitialized = true;
113
return
StatusCode::SUCCESS;
114
}
115
117
// Wrapper functions //
119
/*double DiTauDiscriminantTool::getJetBDTScore(const xAOD::DiTauJet& xDiTau)
120
{
121
//ATH_CHECK(execute(xDiTau));
122
123
execute(xDiTau);
124
const static SG::AuxElement::ConstAccessor<double> accBDTScore(m_sBDTScoreName);
125
return accBDTScore(xDiTau);
126
} */
127
128
StatusCode
DiTauDiscriminantTool::execute
(
const
xAOD::DiTauJet
& xDiTau){
129
130
setIDVariables(xDiTau);
131
132
double
bdtScore = m_bdt->GetClassification();
133
134
const
static
SG::AuxElement::Decorator<double>
decBDTScore(m_sBDTScoreName);
135
decBDTScore(xDiTau) = bdtScore;
136
137
std::cout <<
"Jet BDT score: "
<< bdtScore << std::endl;
138
139
ATH_MSG_DEBUG
(
"Jet BDT score: "
<< bdtScore);
140
return
StatusCode::SUCCESS;
141
}
142
143
std::string DiTauDiscriminantTool::getDecayMode(){
144
return
m_sDecayMode;
145
}
146
147
//=================================PRIVATE-PART=================================
148
//______________________________________________________________________________
149
150
StatusCode
DiTauDiscriminantTool::parseWeightsFile()
151
{
152
std::string weight_file =
PathResolverFindCalibFile
(m_sWeightsFile);
153
154
ATH_MSG_DEBUG
(
"InputWeightsPath: "
<< weight_file);
155
156
m_bdt =
DiTauRecTools::configureMVABDT
( m_mIDVariables, weight_file.c_str() );
157
if
(!m_bdt) {
158
ATH_MSG_FATAL
(
"Couldn't configure MVA"
);
159
return
StatusCode::FAILURE;
160
}
161
return
StatusCode::SUCCESS;
162
}
163
164
// ----------------------------------------------------------------------------
165
void
DiTauDiscriminantTool::setIDVariables(
const
xAOD::DiTauJet
& xDiTau)
166
{
167
switch
(m_eDecayMode){
168
case
(DecayMode::HadHad):
169
setVar(
"f_core_lead"
) = xDiTau.
auxdata
<
float
>(
"f_core_lead"
);
170
setVar(
"f_core_subl"
) = xDiTau.
auxdata
<
float
>(
"f_core_subl"
);
171
setVar(
"f_subjet_lead"
) = xDiTau.
auxdata
<
float
>(
"f_subjet_lead"
);
172
setVar(
"f_subjet_subl"
) = xDiTau.
auxdata
<
float
>(
"f_subjet_subl"
);
173
setVar(
"f_subjets"
) = xDiTau.
auxdata
<
float
>(
"f_subjets"
);
174
setVar(
"f_track_lead"
) = xDiTau.
auxdata
<
float
>(
"f_track_lead"
);
175
setVar(
"f_track_subl"
) = xDiTau.
auxdata
<
float
>(
"f_track_subl"
);
176
setVar(
"R_max_lead"
) = xDiTau.
auxdata
<
float
>(
"R_max_lead"
);
177
setVar(
"R_max_subl"
) = xDiTau.
auxdata
<
float
>(
"R_max_subl"
);
178
setVar(
"n_Subjets"
) = (
float
) xDiTau.
auxdata
<
int
>(
"n_subjets"
);
179
setVar(
"n_track"
) = (
float
) xDiTau.
auxdata
<
int
>(
"n_track"
);
180
setVar(
"n_tracks_lead"
) = (
float
) xDiTau.
auxdata
<
int
>(
"n_tracks_lead"
);
181
setVar(
"n_tracks_subl"
) = (
float
) xDiTau.
auxdata
<
int
>(
"n_tracks_subl"
);
182
setVar(
"n_isotrack"
) = (
float
) xDiTau.
auxdata
<
int
>(
"n_isotrack"
);
183
setVar(
"R_track"
) = xDiTau.
auxdata
<
float
>(
"R_track"
);
184
setVar(
"R_track_core"
) = xDiTau.
auxdata
<
float
>(
"R_track_core"
);
185
setVar(
"R_track_all"
) = xDiTau.
auxdata
<
float
>(
"R_track_all"
);
186
setVar(
"R_isotrack"
) = xDiTau.
auxdata
<
float
>(
"R_isotrack"
);
187
setVar(
"R_core_lead"
) = xDiTau.
auxdata
<
float
>(
"R_core_lead"
);
188
setVar(
"R_core_subl"
) = xDiTau.
auxdata
<
float
>(
"R_core_subl"
);
189
setVar(
"R_tracks_lead"
) = xDiTau.
auxdata
<
float
>(
"R_tracks_lead"
);
190
setVar(
"R_tracks_subl"
) = xDiTau.
auxdata
<
float
>(
"R_tracks_subl"
);
191
setVar(
"m_track"
) = xDiTau.
auxdata
<
float
>(
"m_track"
);
192
setVar(
"m_track_core"
) = xDiTau.
auxdata
<
float
>(
"m_track_core"
);
193
setVar(
"m_core_lead"
) = xDiTau.
auxdata
<
float
>(
"m_core_lead"
);
194
setVar(
"log(m_core_lead)"
) =
log
(*m_mIDVariables[
"m_core_lead"
]);
195
setVar(
"m_core_subl"
) = xDiTau.
auxdata
<
float
>(
"m_core_subl"
);
196
setVar(
"log(m_core_subl)"
) =
log
(*m_mIDVariables[
"m_core_subl"
]);
197
setVar(
"m_track_all"
) = xDiTau.
auxdata
<
float
>(
"m_track_all"
);
198
setVar(
"m_tracks_lead"
) = xDiTau.
auxdata
<
float
>(
"m_tracks_lead"
);
199
setVar(
"log(m_tracks_lead)"
) =
log
(*m_mIDVariables[
"m_tracks_lead"
]);
200
setVar(
"m_tracks_subl"
) = xDiTau.
auxdata
<
float
>(
"m_tracks_subl"
);
201
setVar(
"log(m_tracks_subl)"
) =
log
(*m_mIDVariables[
"m_tracks_subl"
]);
202
setVar(
"E_frac_subl"
) = xDiTau.
auxdata
<
float
>(
"E_frac_subl"
);
203
setVar(
"E_frac_subsubl"
) = xDiTau.
auxdata
<
float
>(
"E_frac_subsubl"
);
204
setVar(
"R_subjets_subl"
) = xDiTau.
auxdata
<
float
>(
"R_subjets_subl"
);
205
setVar(
"R_subjets_subsubl"
) = xDiTau.
auxdata
<
float
>(
"R_subjets_subsubl"
);
206
setVar(
"d0_leadtrack_lead"
) = xDiTau.
auxdata
<
float
>(
"d0_leadtrack_lead"
);
207
setVar(
"log(abs(d0_leadtrack_lead))"
) =
log
(fabs(*m_mIDVariables[
"d0_leadtrack_lead"
]));
208
setVar(
"d0_leadtrack_subl"
) = xDiTau.
auxdata
<
float
>(
"d0_leadtrack_subl"
);
209
setVar(
"log(abs(d0_leadtrack_subl))"
) =
log
(fabs(*m_mIDVariables[
"d0_leadtrack_subl"
]));
210
setVar(
"f_isotracks"
) = xDiTau.
auxdata
<
float
>(
"f_isotracks"
);
211
setVar(
"log(f_isotracks)"
) =
log
(*m_mIDVariables[
"f_isotracks"
]);
212
break
;
213
default
:
214
ATH_MSG_ERROR
(
"Invalid DecayMode."
);
215
break
;
216
}
217
218
for
(
const
auto
&
var
: m_vVarNames)
219
{
220
ATH_MSG_DEBUG
(
var
<<
": "
<< m_mIDVariables[
var
]);
221
}
222
}
beamspotnt.var
var
Definition:
bin/beamspotnt.py:1394
MCP::SystVariation::Default
@ Default
Definition:
EnumDef.h:72
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition:
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
xAOD::float
float
Definition:
BTagging_v1.cxx:168
initialize
void initialize()
Definition:
run_EoverP.cxx:894
DiTauRecTools::configureMVABDT
std::unique_ptr< MVAUtils::BDT > configureMVABDT(std::map< TString, float * > &availableVars, const TString &weightFile)
Definition:
Reconstruction/DiTauRecTools/Root/HelperFunctions.cxx:46
DiTauJetContainer.h
HelperFunctions.h
LArG4FSStartPointFilterLegacy.execute
execute
Definition:
LArG4FSStartPointFilterLegacy.py:20
xAOD::TauJetParameters::DecayMode
DecayMode
Definition:
TauDefs.h:385
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition:
Decorator.h:58
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
DiTauJet.h
PathResolver.h
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:192
DiTauRecTools
Implementation of boosted di-tau ID.
Definition:
DiTauDiscriminantTool.h:36
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition:
PathResolver.cxx:431
python.CaloCondTools.log
log
Definition:
CaloCondTools.py:20
xAOD::IParticle::auxdata
T & auxdata(const std::string &name, const std::string &clsname="")
Fetch an aux data variable, as a non-const reference.
Definition:
Event/xAOD/xAODBase/xAODBase/IParticle.h:96
xAOD::DiTauJet_v1
Definition:
DiTauJet_v1.h:31
declareProperty
#define declareProperty(n, p, h)
Definition:
BaseFakeBkgTool.cxx:15
Default
DiTauDiscriminantTool.h
Generated on Sun Jun 30 2024 21:14:15 for ATLAS Offline Software by
1.8.18