ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleSortingAlg.cxx
Go to the documentation of this file.
1
2
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
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
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 }
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 const EventContext &ctx = Gaudi::Hive::currentContext();
119 // Increase the event counter
121
122 // Simple status message at the beginning of each event execute,
123 ATH_MSG_DEBUG ( "==> execute " << name() << " on " << m_nEventsProcessed << ". event..." );
124
125 // Call the tool
126 ATH_CHECK( m_tool->addBranches(ctx) );
127
128 return StatusCode::SUCCESS;
129}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
StringProperty m_inCollKey
Input container name.
ServiceHandle< Gaudi::Interfaces::IOptionsSvc > m_jos
The job options service (will be used to forward this algs properties to the private tool)
virtual ~ParticleSortingAlg()
Destructor:
bool m_setSortVar
This boolean is true if the user sets the 'SortVariable' property.
bool m_setSortDescending
This boolean is true if the user sets the 'SortDescending' property.
virtual StatusCode execute() override
Athena algorithm's execute hook.
StringProperty m_sortVar
Define by what parameter to sort (default: 'pt')
ParticleSortingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
StringProperty m_outCollKey
The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects.
ToolHandle< DerivationFramework::IAugmentationTool > m_tool
The ToolHandle to the private ParticleSortingTool.
virtual StatusCode finalize() override
Athena algorithm's finalize hook.
BooleanProperty m_sortDescending
Define if the container should be sorted in a descending order (default=true)
virtual StatusCode initialize() override
Athena algorithm's initalize hook.
unsigned long m_nEventsProcessed
Internal event counter.
bool m_setInCollKey
This boolean is true if the user sets the 'InputContainer' property.
bool m_setOutCollKey
This boolean is true if the user sets the 'OutputContainer' property.