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
49{
50 msg(MSG::DEBUG) << "execute()" << endmsg;
51
52 const EventContext& ctx = Gaudi::Hive::currentContext();
53
55 if (not evtInfo.isValid()) {
56 ATH_MSG_WARNING(" Cannot access to event info.");
57 return StatusCode::SUCCESS;
58 }
59
60 const xAOD::EventInfo* eventInfo = evtInfo.cptr();
61
62 std::vector<float> TRTOccu = m_LocalOccTool->GlobalOccupancy(ctx);
63 if (TRTOccu.size() > 6) {
64
65 static const SG::AuxElement::Decorator< float > decEventInfo_occupancy0("TRTOccGlobal");
66 decEventInfo_occupancy0( *eventInfo ) = TRTOccu.at(0);
67
68 static const SG::AuxElement::Decorator< float > decEventInfo_occupancy1("TRTOccBarrelC");
69 decEventInfo_occupancy1( *eventInfo ) = TRTOccu.at(1);
70
71 static const SG::AuxElement::Decorator< float > decEventInfo_occupancy2("TRTOccEndcapAC");
72 decEventInfo_occupancy2( *eventInfo ) = TRTOccu.at(2);
73
74 static const SG::AuxElement::Decorator< float > decEventInfo_occupancy3("TRTOccEndcapBC");
75 decEventInfo_occupancy3( *eventInfo ) = TRTOccu.at(3);
76
77 static const SG::AuxElement::Decorator< float > decEventInfo_occupancy4("TRTOccBarrelA");
78 decEventInfo_occupancy4( *eventInfo ) = TRTOccu.at(4);
79
80 static const SG::AuxElement::Decorator< float > decEventInfo_occupancy5("TRTOccEndcapAA");
81 decEventInfo_occupancy5( *eventInfo ) = TRTOccu.at(5);
82
83 static const SG::AuxElement::Decorator< float > decEventInfo_occupancy6("TRTOccEndcapBA");
84 decEventInfo_occupancy6( *eventInfo ) = TRTOccu.at(6);
85 }
86
87 return StatusCode::SUCCESS;
88}
89
90//---------------------------------------------------------------------
91
93{
94 msg(MSG::INFO) << "finalise()" << endmsg;
95 return StatusCode::SUCCESS;
96}
#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 with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
MsgStream & msg() const
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
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)
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
EventInfo_v1 EventInfo
Definition of the latest event info version.