ATLAS Offline Software
PhysicsAnalysis
DerivationFramework
DerivationFrameworkTau
src
TauPVTrkSelectionTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// TauPVTrkSelectionTool.cxx
7
// Author: Evelina Bouhova-Thacker (e.bouhova@cern.ch)
8
//
10
11
#include "
AthContainers/ConstDataVector.h
"
12
#include "
DerivationFrameworkTau/TauPVTrkSelectionTool.h
"
13
#include "
xAODTracking/Vertex.h
"
14
#include "
TauAnalysisTools/ITauTruthTrackMatchingTool.h
"
15
#include "
xAODTau/TauJetContainer.h
"
16
#include "
AthContainers/ConstAccessor.h
"
17
18
namespace
DerivationFramework
{
19
20
TauPVTrkSelectionTool::TauPVTrkSelectionTool
(
const
std::string&
t
,
const
std::string&
n
,
const
IInterface*
p
) :
21
AthAlgTool
(
t
,
n
,
p
),
22
m_tauPVTracksContainerName(
"TauPVTracks"
),
23
m_tauContainerName(
"TauJets"
),
24
m_useTruth(false),
25
m_maxDeltaR(0.2),
26
m_minPt(20000.),
27
m_T3MT(
"TauAnalysisTools::TauTruthTrackMatchingTool"
)
28
{
29
declareInterface<DerivationFramework::IAugmentationTool>(
this
);
30
declareProperty
(
"TauPVTracksContainerName"
,
m_tauPVTracksContainerName
);
31
declareProperty
(
"TauContainerName"
,
m_tauContainerName
);
32
declareProperty
(
"UseTrueTracks"
,
m_useTruth
);
33
declareProperty
(
"maxDeltaR"
,
m_maxDeltaR
);
34
declareProperty
(
"minPt"
,
m_minPt
);
35
declareProperty
(
"TauTruthTrackMatchingTool"
,
m_T3MT
);
36
}
37
38
StatusCode
TauPVTrkSelectionTool::initialize
()
39
{
40
if
(
m_tauPVTracksContainerName
==
""
) {
41
ATH_MSG_ERROR
(
"No SG name provided for the output of the tau PV track selector tool!"
);
42
return
StatusCode::FAILURE;
43
}
44
CHECK
(
m_T3MT
.retrieve() );
45
return
StatusCode::SUCCESS;
46
}
47
48
StatusCode
TauPVTrkSelectionTool::finalize
()
49
{
50
return
StatusCode::SUCCESS;
51
}
52
53
StatusCode
TauPVTrkSelectionTool::addBranches
()
const
54
{
55
// check that container we want to write in SG does not yet exist
56
if
(
evtStore
()->
contains
<std::vector<float> >(
m_tauPVTracksContainerName
)) {
57
ATH_MSG_ERROR
(
"Tool is attempting to write a StoreGate key "
<<
m_tauPVTracksContainerName
<<
" which already exists. Please use a different key"
);
58
return
StatusCode::FAILURE;
59
}
60
61
const
xAOD::TrackParticleContainer
* tauPVTracks(0);
62
63
CHECK
(
select
(tauPVTracks));
64
ATH_MSG_DEBUG
(
"number of tau tracks for PV refit "
<< tauPVTracks->
size
());
65
66
if
(!
evtStore
()->contains<xAOD::TrackParticleContainer>(
m_tauPVTracksContainerName
))
67
CHECK
(
evtStore
()->record(tauPVTracks,
m_tauPVTracksContainerName
));
68
69
return
StatusCode::SUCCESS;
70
}
71
72
StatusCode
TauPVTrkSelectionTool::select
(
const
xAOD::TrackParticleContainer
*& tauPVTracks)
const
73
{
74
auto
tracks =
new
ConstDataVector<xAOD::TrackParticleContainer>
(
SG::VIEW_ELEMENTS
);
75
tauPVTracks = tracks->asDataVector();
76
77
// Get tau collection from StoreGate
78
const
xAOD::TauJetContainer
* tau_cont =
evtStore
()->retrieve<
const
xAOD::TauJetContainer
>(
m_tauContainerName
);
79
if
(tau_cont == 0)
return
StatusCode::SUCCESS;
80
ATH_MSG_DEBUG
(
"number of taus "
<< tau_cont->
size
());
81
// loop over tau container to select tracks for the PV refit
82
for
(
auto
pTau: *tau_cont ) {
83
int
tauNtracks = pTau->nTracks();
84
bool
good_tau = pTau->isTau(
xAOD::TauJetParameters::JetRNNSigMedium
);
85
float
tau_pt = pTau->pt();
86
float
tau_eta = pTau->eta();
87
bool
pass_selection =
false
;
88
if
(tau_pt >
m_minPt
&& (fabs(tau_eta) < 1.37 || (fabs(tau_eta) > 1.52 && fabs(tau_eta) < 2.5))) pass_selection =
true
;
89
static
const
SG::Decorator<char>
IsHadronicTrackDec(
"IsHadronicTrack"
);
90
for
(
int
i
= 0;
i
< tauNtracks;
i
++) {
91
#ifdef XAODTAU_VERSIONS_TAUJET_V3_H
92
const
xAOD::TauTrack
* tauTrk = pTau->
track
(
i
);
93
const
xAOD::TrackParticle
* tauTrk_trk = tauTrk->
track
();
94
#else
95
const
xAOD::TrackParticle
* tauTrk = pTau->
track
(
i
);
96
const
xAOD::TrackParticle
* tauTrk_trk = tauTrk;
97
#endif
98
if
(
m_useTruth
) {
99
// identify tracks matched to tau decay products (hadrons only)
100
if
(!
m_T3MT
->classifyTrack(*tauTrk))
continue
;
101
if
(IsHadronicTrackDec(*tauTrk)) tracks->push_back(tauTrk_trk);
102
}
else
{
103
// use all tau tracks
104
//TauTracks.push_back(const_cast<xAOD::TrackParticle*>(tauTrk));
105
float
dR = pTau->
p4
().DeltaR(tauTrk->
p4
());
106
if
(good_tau && pass_selection && dR <
m_maxDeltaR
) tracks->push_back(tauTrk_trk);
107
}
108
}
109
}
110
ATH_MSG_DEBUG
(
"tauPVTracks size "
<< tracks->size());
111
112
return
StatusCode::SUCCESS;
113
}
114
}
DerivationFramework::TauPVTrkSelectionTool::initialize
StatusCode initialize()
Definition:
TauPVTrkSelectionTool.cxx:38
DerivationFramework::TauPVTrkSelectionTool::m_T3MT
ToolHandle< TauAnalysisTools::ITauTruthTrackMatchingTool > m_T3MT
Definition:
TauPVTrkSelectionTool.h:47
python.PerfMonSerializer.p
def p
Definition:
PerfMonSerializer.py:743
ITauTruthTrackMatchingTool.h
DerivationFramework::TauPVTrkSelectionTool::select
StatusCode select(const xAOD::TrackParticleContainer *&tauPVTracks) const
Definition:
TauPVTrkSelectionTool.cxx:72
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition:
OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition:
AthCommonDataStore.h:145
DerivationFramework::TauPVTrkSelectionTool::m_tauPVTracksContainerName
std::string m_tauPVTracksContainerName
Definition:
TauPVTrkSelectionTool.h:40
DerivationFramework::TauPVTrkSelectionTool::TauPVTrkSelectionTool
TauPVTrkSelectionTool(const std::string &t, const std::string &n, const IInterface *p)
Definition:
TauPVTrkSelectionTool.cxx:20
read_hist_ntuple.t
t
Definition:
read_hist_ntuple.py:5
TauPVTrkSelectionTool.h
xAOD::TrackParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition:
TrackParticle_v1.cxx:129
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition:
AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
SG::Decorator< char >
lumiFormat.i
int i
Definition:
lumiFormat.py:92
beamspotman.n
n
Definition:
beamspotman.py:731
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
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition:
hcg.cxx:111
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition:
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework
THE reconstruction tool.
Definition:
ParticleSortingAlg.h:24
TauJetContainer.h
DataVector< xAOD::TrackParticle_v1 >
Vertex.h
DerivationFramework::TauPVTrkSelectionTool::m_maxDeltaR
double m_maxDeltaR
Definition:
TauPVTrkSelectionTool.h:44
DerivationFramework::TauPVTrkSelectionTool::finalize
StatusCode finalize()
Definition:
TauPVTrkSelectionTool.cxx:48
DerivationFramework::TauPVTrkSelectionTool::m_tauContainerName
std::string m_tauContainerName
Definition:
TauPVTrkSelectionTool.h:41
xAOD::TauJetParameters::JetRNNSigMedium
@ JetRNNSigMedium
Definition:
TauDefs.h:147
DerivationFramework::TauPVTrkSelectionTool::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition:
TauPVTrkSelectionTool.cxx:53
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition:
ConstDataVector.h:76
xAOD::TauTrack_v1
Definition:
TauTrack_v1.h:27
xAOD::TauTrack_v1::track
const TrackParticle * track() const
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:43
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
AthAlgTool
Definition:
AthAlgTool.h:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DerivationFramework::TauPVTrkSelectionTool::m_useTruth
bool m_useTruth
Definition:
TauPVTrkSelectionTool.h:43
DerivationFramework::TauPVTrkSelectionTool::m_minPt
double m_minPt
Definition:
TauPVTrkSelectionTool.h:45
Generated on Thu Jul 4 2024 21:27:56 for ATLAS Offline Software by
1.8.18