ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetCalibAlgs
TRT_CalibAlgs
src
TRTOccupancyInclude.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/* *******************************************************************
6
7
TRTOccupancyInclude.cxx : Simple code to include Occupancy inside event info xAOD
8
9
* ***************************************************************** */
10
11
#include "
TRT_CalibAlgs/TRTOccupancyInclude.h
"
12
#include "
xAODEventInfo/EventInfo.h
"
13
14
#include "
StoreGate/ReadHandle.h
"
15
#include "
CxxUtils/checker_macros.h
"
16
17
TRTOccupancyInclude::TRTOccupancyInclude
(
const
std::string& name, ISvcLocator* pSvcLocator) :
18
AthAlgorithm
(name, pSvcLocator),
19
m_LocalOccTool
()
20
{
21
declareProperty
(
"TRT_LocalOccupancyTool"
,
m_LocalOccTool
);
22
}
23
24
//---------------------------------------------------------------------
25
26
TRTOccupancyInclude::~TRTOccupancyInclude
(
void
)
27
{}
28
29
//--------------------------------------------------------------------------
30
31
StatusCode
TRTOccupancyInclude::initialize
()
32
{
33
if
(
m_LocalOccTool
.retrieve().isFailure() ){
34
ATH_MSG_ERROR
(
" Failed to retrieve TRT Local Occupancy tool: "
<<
m_LocalOccTool
);
35
return
StatusCode::FAILURE;
36
}
37
else
{
38
ATH_MSG_INFO
(
"Retrieved tool "
<<
m_LocalOccTool
);
39
}
40
41
ATH_CHECK
(
m_eventInfoKey
.initialize());
42
43
return
StatusCode::SUCCESS;
44
}
45
46
//---------------------------------------------------------------------
47
48
StatusCode
TRTOccupancyInclude::execute
(
const
EventContext& ctx)
49
{
50
msg
(MSG::DEBUG) <<
"execute()"
<<
endmsg
;
51
52
53
SG::ReadHandle<xAOD::EventInfo>
evtInfo(
m_eventInfoKey
, ctx);
54
if
(not evtInfo.
isValid
()) {
55
ATH_MSG_WARNING
(
" Cannot access to event info."
);
56
return
StatusCode::SUCCESS;
57
}
58
59
const
xAOD::EventInfo
* eventInfo = evtInfo.
cptr
();
60
61
std::vector<float> TRTOccu =
m_LocalOccTool
->GlobalOccupancy(ctx);
62
if
(TRTOccu.size() > 6) {
63
64
static
const
SG::AuxElement::Decorator< float > decEventInfo_occupancy0(
"TRTOccGlobal"
);
65
decEventInfo_occupancy0( *eventInfo ) = TRTOccu.at(0);
66
67
static
const
SG::AuxElement::Decorator< float > decEventInfo_occupancy1(
"TRTOccBarrelC"
);
68
decEventInfo_occupancy1( *eventInfo ) = TRTOccu.at(1);
69
70
static
const
SG::AuxElement::Decorator< float > decEventInfo_occupancy2(
"TRTOccEndcapAC"
);
71
decEventInfo_occupancy2( *eventInfo ) = TRTOccu.at(2);
72
73
static
const
SG::AuxElement::Decorator< float > decEventInfo_occupancy3(
"TRTOccEndcapBC"
);
74
decEventInfo_occupancy3( *eventInfo ) = TRTOccu.at(3);
75
76
static
const
SG::AuxElement::Decorator< float > decEventInfo_occupancy4(
"TRTOccBarrelA"
);
77
decEventInfo_occupancy4( *eventInfo ) = TRTOccu.at(4);
78
79
static
const
SG::AuxElement::Decorator< float > decEventInfo_occupancy5(
"TRTOccEndcapAA"
);
80
decEventInfo_occupancy5( *eventInfo ) = TRTOccu.at(5);
81
82
static
const
SG::AuxElement::Decorator< float > decEventInfo_occupancy6(
"TRTOccEndcapBA"
);
83
decEventInfo_occupancy6( *eventInfo ) = TRTOccu.at(6);
84
}
85
86
return
StatusCode::SUCCESS;
87
}
88
89
//---------------------------------------------------------------------
90
91
StatusCode
TRTOccupancyInclude::finalize
()
92
{
93
msg
(MSG::INFO) <<
"finalise()"
<<
endmsg
;
94
return
StatusCode::SUCCESS;
95
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
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_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ReadHandle.h
Handle class for reading from StoreGate.
TRTOccupancyInclude.h
checker_macros.h
Define macros for attributes used to control the static checker.
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
TRTOccupancyInclude::finalize
StatusCode finalize(void)
Definition
TRTOccupancyInclude.cxx:91
TRTOccupancyInclude::m_LocalOccTool
ToolHandle< InDet::ITRT_LocalOccupancy > m_LocalOccTool
the track selector tool
Definition
TRTOccupancyInclude.h:50
TRTOccupancyInclude::initialize
StatusCode initialize(void)
Definition
TRTOccupancyInclude.cxx:31
TRTOccupancyInclude::TRTOccupancyInclude
TRTOccupancyInclude(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TRTOccupancyInclude.cxx:17
TRTOccupancyInclude::~TRTOccupancyInclude
~TRTOccupancyInclude(void)
Definition
TRTOccupancyInclude.cxx:26
TRTOccupancyInclude::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TRTOccupancyInclude.cxx:48
TRTOccupancyInclude::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
TRTOccupancyInclude.h:51
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0