ATLAS Offline Software
ParticleSortingAlg.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // ParticleSortingAlg.cxx
8 // Implementation file for class ParticleSortingAlg
9 // Author: Karsten Koeneke <karsten.koeneke@cern.ch>
11 
12 // EventUtils includes
13 #include "ParticleSortingAlg.h"
14 
15 // FrameWork includes
16 #include "Gaudi/Property.h"
18 
20 // Public methods:
22 
23 // Constructors
26  ISvcLocator* pSvcLocator ) :
27  ::AthAlgorithm( name, pSvcLocator )
28 {
29 }
30 
31 
32 
33 // Destructor
36 {}
37 
38 
39 
40 // Athena Algorithm's Hooks
43 {
44  ATH_MSG_DEBUG ("Initializing " << name() << "...");
45 
46  // Print out the used configuration
47  ATH_MSG_DEBUG ( " using = " << m_jos );
48  ATH_MSG_DEBUG ( " using = " << m_tool );
49  ATH_MSG_DEBUG ( " using = " << m_inCollKey );
50  ATH_MSG_DEBUG ( " using = " << m_outCollKey );
51  ATH_MSG_DEBUG ( " using = " << m_sortVar );
52  ATH_MSG_DEBUG ( " using = " << m_sortDescending );
53 
54 
55  // Initialize the counters to zero
56  m_nEventsProcessed = 0 ;
57 
58 
59  // Get the JobOptionService
60  // We will use this to set the properties of our private skimming tool
61  // from the properties of this algorithm.
62  ATH_MSG_VERBOSE( "Getting the JobOptionService");
63  ATH_CHECK( m_jos.retrieve() );
64 
65  // Get the full name of the private skimTool
66  ATH_MSG_VERBOSE( "Getting the full name of the tool");
67  const std::string& fullToolName = this->name() + "." + m_tool.name();
68  ATH_MSG_DEBUG( "Got the full name of the tool: " << fullToolName );
69 
70  // Now, set all properties of the private skimTool that were acutally configured
71  if (m_setInCollKey) {
72  ATH_MSG_DEBUG( "Setting property" << m_inCollKey
73  << " of private tool with name: '" << fullToolName << "'" );
74  m_jos->set (fullToolName + "." + m_inCollKey.name(), m_inCollKey.toString());
75  }
76  if (m_setOutCollKey) {
77  ATH_MSG_DEBUG( "Setting property" << m_outCollKey
78  << " of private tool with name: '" << fullToolName << "'" );
79  m_jos->set (fullToolName + "." + m_outCollKey.name(), m_outCollKey.toString());
80  }
81  if (m_setSortVar) {
82  ATH_MSG_DEBUG( "Setting property" << m_sortVar
83  << " of private tool with name: '" << fullToolName << "'" );
84  m_jos->set (fullToolName + "." + m_sortVar.name(), m_sortVar.toString());
85  }
86  if (m_setSortDescending) {
87  ATH_MSG_DEBUG( "Setting property" << m_sortDescending
88  << " of private tool with name: '" << fullToolName << "'" );
89  m_jos->set (fullToolName + "." + m_sortDescending.name(), m_sortDescending.toString());
90  }
91  ATH_MSG_DEBUG( "Done setting properties of the tool");
92 
93  // Get the skimming tool
94  ATH_CHECK( m_tool.retrieve() );
95 
96  ATH_MSG_DEBUG ( "==> done with initialize " << name() << "..." );
97 
98  return StatusCode::SUCCESS;
99 }
100 
101 
102 
104 {
105  ATH_MSG_DEBUG ("Finalizing " << name() << "...");
106 
107  // Release all tools and services
108  ATH_CHECK( m_jos.release() );
109  ATH_CHECK( m_tool.release() );
110 
111  return StatusCode::SUCCESS;
112 }
113 
114 
115 
117 {
118  // Increase the event counter
120 
121  // Simple status message at the beginning of each event execute,
122  ATH_MSG_DEBUG ( "==> execute " << name() << " on " << m_nEventsProcessed << ". event..." );
123 
124  // Call the tool
125  ATH_CHECK( m_tool->addBranches() );
126 
127  return StatusCode::SUCCESS;
128 }
ParticleSortingAlg::m_inCollKey
StringProperty m_inCollKey
Input container name.
Definition: ParticleSortingAlg.h:87
ParticleSortingAlg::ParticleSortingAlg
ParticleSortingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition: ParticleSortingAlg.cxx:25
IAugmentationTool.h
ParticleSortingAlg::initialize
virtual StatusCode initialize() override
Athena algorithm's initalize hook.
Definition: ParticleSortingAlg.cxx:42
ParticleSortingAlg::m_outCollKey
StringProperty m_outCollKey
The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects.
Definition: ParticleSortingAlg.h:94
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ParticleSortingAlg::execute
virtual StatusCode execute() override
Athena algorithm's execute hook.
Definition: ParticleSortingAlg.cxx:116
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ParticleSortingAlg::m_setSortVar
bool m_setSortVar
This boolean is true if the user sets the 'SortVariable' property.
Definition: ParticleSortingAlg.h:105
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ParticleSortingAlg::m_jos
ServiceHandle< Gaudi::Interfaces::IOptionsSvc > m_jos
The job options service (will be used to forward this algs properties to the private tool)
Definition: ParticleSortingAlg.h:78
ParticleSortingAlg::m_sortDescending
BooleanProperty m_sortDescending
Define if the container should be sorted in a descending order (default=true)
Definition: ParticleSortingAlg.h:108
ParticleSortingAlg::m_setOutCollKey
bool m_setOutCollKey
This boolean is true if the user sets the 'OutputContainer' property.
Definition: ParticleSortingAlg.h:98
ParticleSortingAlg::m_nEventsProcessed
unsigned long m_nEventsProcessed
Internal event counter.
Definition: ParticleSortingAlg.h:115
ParticleSortingAlg::m_sortVar
StringProperty m_sortVar
Define by what parameter to sort (default: 'pt')
Definition: ParticleSortingAlg.h:101
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ParticleSortingAlg::m_setInCollKey
bool m_setInCollKey
This boolean is true if the user sets the 'InputContainer' property.
Definition: ParticleSortingAlg.h:91
ParticleSortingAlg.h
ParticleSortingAlg::m_tool
ToolHandle< DerivationFramework::IAugmentationTool > m_tool
The ToolHandle to the private ParticleSortingTool.
Definition: ParticleSortingAlg.h:82
ParticleSortingAlg::m_setSortDescending
bool m_setSortDescending
This boolean is true if the user sets the 'SortDescending' property.
Definition: ParticleSortingAlg.h:112
ParticleSortingAlg::finalize
virtual StatusCode finalize() override
Athena algorithm's finalize hook.
Definition: ParticleSortingAlg.cxx:103
ParticleSortingAlg::~ParticleSortingAlg
virtual ~ParticleSortingAlg()
Destructor:
Definition: ParticleSortingAlg.cxx:35