ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetTagging
FlavorTagDiscriminants
src
TruthPVzRelativeToBeamspotAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Header file
6
#include "
FlavorTagDiscriminants/TruthPVzRelativeToBeamspotAlg.h
"
7
8
// Read and write handles
9
#include "
StoreGate/ReadHandle.h
"
10
#include "
StoreGate/ReadDecorHandle.h
"
11
#include "
StoreGate/WriteDecorHandle.h
"
12
13
#include <cmath>
14
#include <limits>
15
16
17
namespace
FlavorTagDiscriminants
{
18
19
TruthPVzRelativeToBeamspotAlg::TruthPVzRelativeToBeamspotAlg
(
20
const
std::string& name, ISvcLocator* loc)
21
:
AthReentrantAlgorithm
(name, loc) {}
22
23
24
StatusCode
TruthPVzRelativeToBeamspotAlg::initialize
() {
25
ATH_MSG_DEBUG
(
"Initializing "
<< name());
26
27
ATH_CHECK
(
m_jetCollectionKey
.initialize());
28
ATH_CHECK
(
m_truthPVzKey
.initialize());
29
ATH_CHECK
(
m_outputKey
.initialize());
30
ATH_CHECK
(
m_eventInfoKey
.initialize());
31
32
return
StatusCode::SUCCESS;
33
}
34
35
36
StatusCode
TruthPVzRelativeToBeamspotAlg::execute
(
const
EventContext& ctx)
const
{
37
ATH_MSG_DEBUG
(
"Executing "
<< name());
38
39
// Read out jets
40
SG::ReadHandle<xAOD::IParticleContainer>
jets(
m_jetCollectionKey
, ctx);
41
if
(!jets.isValid()) {
42
ATH_MSG_ERROR
(
"Failed to retrieve jet container with key "
<<
m_jetCollectionKey
.key());
43
return
StatusCode::FAILURE;
44
}
45
46
// Read out the beamspot position
47
SG::ReadHandle<xAOD::EventInfo>
eventInfo(
m_eventInfoKey
, ctx);
48
if
(!eventInfo.
isValid
()) {
49
ATH_MSG_ERROR
(
"Failed to retrieve EventInfo with key "
<<
m_eventInfoKey
.key());
50
return
StatusCode::FAILURE;
51
}
52
const
double
beamPosZ = eventInfo->beamPosZ();
53
54
SG::ReadDecorHandle<xAOD::IParticleContainer, float>
truthPVz(
m_truthPVzKey
, ctx);
55
SG::WriteDecorHandle<xAOD::IParticleContainer, float>
relToBeamspot(
m_outputKey
, ctx);
56
57
for
(
const
xAOD::IParticle
*
jet
: *jets) {
58
const
double
zed = truthPVz(*
jet
);
59
relToBeamspot(*
jet
) = std::isfinite(zed)
60
?
static_cast<
float
>
(zed - beamPosZ)
61
: std::numeric_limits<float>::quiet_NaN();
62
}
63
64
return
StatusCode::SUCCESS;
65
}
66
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
TruthPVzRelativeToBeamspotAlg.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
FlavorTagDiscriminants::TruthPVzRelativeToBeamspotAlg::m_jetCollectionKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_jetCollectionKey
Definition
TruthPVzRelativeToBeamspotAlg.h:38
FlavorTagDiscriminants::TruthPVzRelativeToBeamspotAlg::TruthPVzRelativeToBeamspotAlg
TruthPVzRelativeToBeamspotAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TruthPVzRelativeToBeamspotAlg.cxx:19
FlavorTagDiscriminants::TruthPVzRelativeToBeamspotAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TruthPVzRelativeToBeamspotAlg.cxx:36
FlavorTagDiscriminants::TruthPVzRelativeToBeamspotAlg::initialize
virtual StatusCode initialize() override
Definition
TruthPVzRelativeToBeamspotAlg.cxx:24
FlavorTagDiscriminants::TruthPVzRelativeToBeamspotAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
TruthPVzRelativeToBeamspotAlg.h:49
FlavorTagDiscriminants::TruthPVzRelativeToBeamspotAlg::m_truthPVzKey
SG::ReadDecorHandleKey< xAOD::IParticleContainer > m_truthPVzKey
Definition
TruthPVzRelativeToBeamspotAlg.h:41
FlavorTagDiscriminants::TruthPVzRelativeToBeamspotAlg::m_outputKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_outputKey
Definition
TruthPVzRelativeToBeamspotAlg.h:45
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
FlavorTagDiscriminants
Definition
CaloChargedFlowDecoratorAlg.h:15
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
Generated on
for ATLAS Offline Software by
1.17.0