ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
16
17TRTOccupancyInclude::TRTOccupancyInclude(const std::string& name, ISvcLocator* pSvcLocator) :
18 AthAlgorithm (name, pSvcLocator),
20{
21 declareProperty("TRT_LocalOccupancyTool", m_LocalOccTool);
22}
23
24//---------------------------------------------------------------------
25
28
29//--------------------------------------------------------------------------
30
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
48StatusCode TRTOccupancyInclude::execute(const EventContext& ctx)
49{
50 msg(MSG::DEBUG) << "execute()" << endmsg;
51
52
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
92{
93 msg(MSG::INFO) << "finalise()" << endmsg;
94 return StatusCode::SUCCESS;
95}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
Define macros for attributes used to control the static checker.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
ToolHandle< InDet::ITRT_LocalOccupancy > m_LocalOccTool
the track selector tool
StatusCode initialize(void)
TRTOccupancyInclude(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute(const EventContext &ctx)
Execute method.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
EventInfo_v1 EventInfo
Definition of the latest event info version.