ATLAS Offline Software
Loading...
Searching...
No Matches
EventCleaningTestAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM includes
6
7// Local includes
10
11
12//-----------------------------------------------------------------------------
13// Constructor
14//-----------------------------------------------------------------------------
16 ISvcLocator* svcLoc)
17 : AthAlgorithm(name, svcLoc) {}
18
19//-----------------------------------------------------------------------------
20// Initialize
21//-----------------------------------------------------------------------------
23{
24 ATH_MSG_INFO("Initialize");
25
26 // Try to retrieve the tool
27 ATH_CHECK( m_ecTool.retrieve() );
28 ATH_CHECK( m_jetKey.initialize());
29 ATH_CHECK( m_evtKey.initialize() );
30 // Create the decorator
31 // Use an if statement to leave a legacy
32 auto labelString = m_cleaningLevel;
33 if (m_jetKey.key() == "AntiKt4EMTopoJets") {
34 labelString = m_cleaningLevel + "_EMTopo";
35 }
36 else {}
37
38 m_evtInfoDecor = m_evtKey.key() + "." + m_prefix + "eventClean_"+labelString;
40 return StatusCode::SUCCESS;
41}
42
43//-----------------------------------------------------------------------------
44// Execute
45//-----------------------------------------------------------------------------
47{
48 const EventContext& ctx = Gaudi::Hive::currentContext();
49 // Jets
51 if (!jets.isValid()) {
52 ATH_MSG_FATAL("Failed to retrieve jet collection "<<m_jetKey.fullKey());
53 return StatusCode::FAILURE;
54 }
55 // Apply the event cleaning
56 bool result = m_ecTool->acceptEvent(jets.cptr());
57
58 //Decorate event
59 if(m_doEvent){
61 if (!eventInfo.isValid()){
62 ATH_MSG_FATAL("Failed to retrieve the event info "<<m_evtKey.fullKey());
63 return StatusCode::FAILURE;
64 }
65 eventInfo(*eventInfo) = result;
66 }
67
68 return StatusCode::SUCCESS;
69}
70
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
Handle class for adding a decoration to an object.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Property< std::string > m_cleaningLevel
SG::WriteDecorHandleKey< xAOD::EventInfo > m_evtInfoDecor
Gaudi::Property< std::string > m_prefix
Configuration.
virtual StatusCode execute() override
Execute the algorithm.
Gaudi::Property< bool > m_doEvent
EventCleaningTestAlg(const std::string &name, ISvcLocator *svcLoc)
Standard algorithm constructor.
ToolHandle< ECUtils::IEventCleaningTool > m_ecTool
SG::ReadHandleKey< xAOD::JetContainer > m_jetKey
virtual StatusCode initialize() override
Initialize the algorithm.
SG::ReadHandleKey< xAOD::EventInfo > m_evtKey
Handle class for adding a decoration to an object.