ATLAS Offline Software
Loading...
Searching...
No Matches
PFAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#include "PFAlgorithm.h"
6#include "PFClusterFiller.h"
7#include "PFTrackFiller.h"
8
9PFAlgorithm::PFAlgorithm(const std::string& name, ISvcLocator* pSvcLocator)
10 : AthReentrantAlgorithm(name, pSvcLocator)
11{}
12
14
17 ATH_CHECK(m_IPFBaseTools.retrieve());
19
21
25
26 if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
27
28 printTools();
29
30 return StatusCode::SUCCESS;
31}
32
33StatusCode PFAlgorithm::execute(const EventContext& ctx) const{
34 // Define monitored quantities
35 auto t_exec = Monitored::Timer<std::chrono::milliseconds>( "TIME_execute" );
36 Monitored::ScopedTimer execution_time(t_exec);
37 auto t_subtract = Monitored::Timer<std::chrono::milliseconds>( "TIME_subtract" );
38 auto N_efrClusters = Monitored::Scalar( "N_efrClusters", 0 );
39
40 ATH_MSG_DEBUG("Executing");
41
43 ATH_CHECK(eflowCaloObjectsWriteHandle.record(std::make_unique<eflowCaloObjectContainer>()));
44 eflowCaloObjectContainer* theElowCaloObjectContainer = eflowCaloObjectsWriteHandle.ptr();
45
47 ATH_CHECK(caloClustersWriteHandle.record(std::make_unique<xAOD::CaloClusterContainer>(),
48 std::make_unique<xAOD::CaloClusterAuxContainer>()));
49 ATH_MSG_DEBUG("CaloClusterWriteHandle has container of size" << caloClustersWriteHandle->size());
50
52 eflowRecTrackContainer localEFlowRecTrackContainer(*eflowRecTracksReadHandle.ptr());
53
54 /* Record the eflowRecCluster output container */
56 ATH_CHECK(eflowRecClustersWriteHandle.record(std::make_unique<eflowRecClusterContainer>()));
57 eflowRecClusterContainer& theEFlowRecClusterContainerReference = *(eflowRecClustersWriteHandle.ptr());
58
59 xAOD::CaloClusterContainer& theCaloClusterContainerReference = *(caloClustersWriteHandle.ptr());
60 ATH_CHECK(m_IPFClusterSelectorTool->execute(theEFlowRecClusterContainerReference, theCaloClusterContainerReference));
61
62 // Explicitly start/stop the timer around the subtraction tool calls
63 t_subtract.start();
64 /* Run the SubtractionTools */
65
66 if (m_useUnified){
67 PFData data;
68 data.caloObjects = theElowCaloObjectContainer;
69
70 PFTrackFiller::fillTracksToConsider(data, localEFlowRecTrackContainer);
71
72 PFClusterFiller::fillClustersToConsider(data, theEFlowRecClusterContainerReference);
73
74 for (const auto& thisIPFUnifiedBaseTool : m_IPFUnifiedBaseTools){
75 ATH_CHECK(thisIPFUnifiedBaseTool->processPFlowData(ctx, data));
76 }
77 }
78
79 else{
80 for (auto thisIPFSubtractionTool : m_IPFSubtractionTools){
81 thisIPFSubtractionTool->execute(
82 ctx,
83 theElowCaloObjectContainer,
84 &localEFlowRecTrackContainer,
85 &theEFlowRecClusterContainerReference);
86 }
87 t_subtract.stop();
88
89 if (msgLvl(MSG::DEBUG)) {
90 for (auto thisEFTrack : localEFlowRecTrackContainer) {
91 msg() << "This efRecTrack has E,pt,eta and phi of " << thisEFTrack->getTrack()->e() << ", "
92 << thisEFTrack->getTrack()->pt() << ", " << thisEFTrack->getTrack()->eta() << " and "
93 << thisEFTrack->getTrack()->phi() << endmsg;
94 }
95
96 for (auto thisEFCluster : *(eflowRecClustersWriteHandle.ptr())) {
97 msg() << "This efRecCluster has E,pt,eta and phi of " << thisEFCluster->getCluster()->e() << ","
98 << thisEFCluster->getCluster()->pt() << ", " << thisEFCluster->getCluster()->eta() << " and "
99 << thisEFCluster->getCluster()->phi() << endmsg;
100 }
101 }
102
103 N_efrClusters = theEFlowRecClusterContainerReference.size();
104
105 /* Run the other AglTools */
106 for (auto thisIPFBaseTool : m_IPFBaseTools){
107 ATH_CHECK(thisIPFBaseTool->execute(ctx, *theElowCaloObjectContainer));
108 }
109 }
110
111 auto mon = Monitored::Group(m_monTool, t_exec, t_subtract, N_efrClusters);
112 return StatusCode::SUCCESS;
113}
114
115StatusCode PFAlgorithm::finalize(){ return StatusCode::SUCCESS;}
116
118 ATH_MSG_VERBOSE(" ");
119 ATH_MSG_VERBOSE("List of IPFSubtraction tools in execution sequence:");
120 ATH_MSG_VERBOSE("------------------------------------");
121 ATH_MSG_VERBOSE(" ");
122 unsigned int subtractionToolCtr = 0;
123 for (auto thisIPFSubtractionTool : m_IPFSubtractionTools){
124 subtractionToolCtr++;
125 ATH_MSG_VERBOSE(std::setw(2) << std::setiosflags(std::ios_base::right) << subtractionToolCtr << ".) "
126 << std::resetiosflags(std::ios_base::right) << std::setw(36) << std::setfill('.')
127 << std::setiosflags(std::ios_base::left) << thisIPFSubtractionTool->type() << std::setfill('.')
128 << thisIPFSubtractionTool->name() << std::setfill(' '));
129 }
130 ATH_MSG_VERBOSE(" ");
131 ATH_MSG_VERBOSE("------------------------------------");
132
133 ATH_MSG_VERBOSE(" ");
134 ATH_MSG_VERBOSE("List of IPFBase tools in execution sequence:");
135 ATH_MSG_VERBOSE("------------------------------------");
136 ATH_MSG_VERBOSE(" ");
137 unsigned int baseToolCtr = 0;
138 for (auto thisIPFBaseTool : m_IPFBaseTools){
139 baseToolCtr++;
140 ATH_MSG_VERBOSE(std::setw(2) << std::setiosflags(std::ios_base::right) << baseToolCtr << ".) "
141 << std::resetiosflags(std::ios_base::right) << std::setw(36) << std::setfill('.')
142 << std::setiosflags(std::ios_base::left) << thisIPFBaseTool->type() << std::setfill('.')
143 << thisIPFBaseTool->name() << std::setfill(' '));
144 }
145 ATH_MSG_VERBOSE(" ");
146 ATH_MSG_VERBOSE("------------------------------------");
147
148
149}
150
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
size_type size() const noexcept
Returns the number of elements in the collection.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
Helper class to create a scoped timer.
A monitored timer.
ToolHandle< IPFClusterSelectorTool > m_IPFClusterSelectorTool
ToolHandle for the PFClusterSelectorTool which creates the set of eflowRecCluster to be used.
Definition PFAlgorithm.h:38
PFAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< eflowCaloObjectContainer > m_eflowCaloObjectsWriteHandleKey
WriteHandleKey for eflowCaloObjectContainer to be written out.
Definition PFAlgorithm.h:80
ToolHandleArray< IPFUnifiedBaseTool > m_IPFUnifiedBaseTools
List of IPFUnifiedBaseTool, which will be executed by this algorithm.
Definition PFAlgorithm.h:53
SG::WriteHandleKey< eflowRecClusterContainer > m_eflowRecClustersWriteHandleKey
WriteHandleKey for the eflowRecClusterContainer to write out.
Definition PFAlgorithm.h:64
StatusCode finalize() override
ToolHandleArray< IPFSubtractionTool > m_IPFSubtractionTools
List of IPFSubtractionTool, which will be executed by this algorithm.
Definition PFAlgorithm.h:47
SG::ReadHandleKey< eflowRecTrackContainer > m_eflowRecTracksReadHandleKey
ReadHandleKey for the eflowRecTrackContainer to be read in.
Definition PFAlgorithm.h:56
ToolHandleArray< IPFBaseTool > m_IPFBaseTools
List of PFBaseAlgTool, which will be executed by this algorithm.
Definition PFAlgorithm.h:50
ToolHandle< GenericMonitoringTool > m_monTool
Online monitoring tool for recording histograms of the alg in action.
Definition PFAlgorithm.h:88
Gaudi::Property< bool > m_useUnified
Definition PFAlgorithm.h:96
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_caloClustersWriteHandleKey
WriteHandleKey for CaloClusterContainer to be written out.
Definition PFAlgorithm.h:72
void printTools()
Funciton to print out list of tools if in VERBOSE mode.
StatusCode initialize() override
static void fillClustersToConsider(PFData &data, eflowRecClusterContainer &recClusterContainer)
static void fillTracksToConsider(PFData &data, eflowRecTrackContainer &recTrackContainer)
const_pointer_type ptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.