ATLAS Offline Software
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
8 #include "EventCleaningTestAlg.h"
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());
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 
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
get_generator_info.result
result
Definition: get_generator_info.py:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
EventCleaningTestAlg::m_ecTool
ToolHandle< ECUtils::IEventCleaningTool > m_ecTool
Definition: EventCleaningTestAlg.h:41
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
EventCleaningTestAlg::initialize
virtual StatusCode initialize() override
Initialize the algorithm.
Definition: EventCleaningTestAlg.cxx:22
EventCleaningTestAlg::m_evtKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtKey
Definition: EventCleaningTestAlg.h:45
EventCleaningTestAlg::execute
virtual StatusCode execute() override
Execute the algorithm.
Definition: EventCleaningTestAlg.cxx:46
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EventCleaningTestAlg::m_prefix
Gaudi::Property< std::string > m_prefix
Configuration.
Definition: EventCleaningTestAlg.h:48
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
AthAlgorithm
Definition: AthAlgorithm.h:47
EventCleaningTestAlg::m_cleaningLevel
Gaudi::Property< std::string > m_cleaningLevel
Definition: EventCleaningTestAlg.h:50
EventCleaningTestAlg::m_doEvent
Gaudi::Property< bool > m_doEvent
Definition: EventCleaningTestAlg.h:52
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventCleaningTestAlg::EventCleaningTestAlg
EventCleaningTestAlg(const std::string &name, ISvcLocator *svcLoc)
Standard algorithm constructor.
Definition: EventCleaningTestAlg.cxx:15
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
EventCleaningTestAlg::m_evtInfoDecor
SG::WriteDecorHandleKey< xAOD::EventInfo > m_evtInfoDecor
Definition: EventCleaningTestAlg.h:54
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
EventCleaningTestAlg.h
EventCleaningTestAlg::m_jetKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetKey
Definition: EventCleaningTestAlg.h:43