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)
12 , m_IPFBaseTools(this)
14{
15 declareProperty("SubtractionToolList", m_IPFSubtractionTools, "List of Private Subtraction IPFSubtractionTools");
16 declareProperty("BaseToolList", m_IPFBaseTools, "List of Private IPFBaseTools");
17 declareProperty("UnifiedBaseTools", m_IPFUnifiedBaseTools, "List of Private IPFUnifiedBaseTools");
18}
19
21
24 ATH_CHECK(m_IPFBaseTools.retrieve());
26
28
32
33 if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
34
35 printTools();
36
37 return StatusCode::SUCCESS;
38}
39
40StatusCode PFAlgorithm::execute(const EventContext& ctx) const{
41 // Define monitored quantities
42 auto t_exec = Monitored::Timer<std::chrono::milliseconds>( "TIME_execute" );
43 Monitored::ScopedTimer execution_time(t_exec);
44 auto t_subtract = Monitored::Timer<std::chrono::milliseconds>( "TIME_subtract" );
45 auto N_efrClusters = Monitored::Scalar( "N_efrClusters", 0 );
46
47 ATH_MSG_DEBUG("Executing");
48
50 ATH_CHECK(eflowCaloObjectsWriteHandle.record(std::make_unique<eflowCaloObjectContainer>()));
51 eflowCaloObjectContainer* theElowCaloObjectContainer = eflowCaloObjectsWriteHandle.ptr();
52
54 ATH_CHECK(caloClustersWriteHandle.record(std::make_unique<xAOD::CaloClusterContainer>(),
55 std::make_unique<xAOD::CaloClusterAuxContainer>()));
56 ATH_MSG_DEBUG("CaloClusterWriteHandle has container of size" << caloClustersWriteHandle->size());
57
59 eflowRecTrackContainer localEFlowRecTrackContainer(*eflowRecTracksReadHandle.ptr());
60
61 /* Record the eflowRecCluster output container */
63 ATH_CHECK(eflowRecClustersWriteHandle.record(std::make_unique<eflowRecClusterContainer>()));
64 eflowRecClusterContainer& theEFlowRecClusterContainerReference = *(eflowRecClustersWriteHandle.ptr());
65
66 xAOD::CaloClusterContainer& theCaloClusterContainerReference = *(caloClustersWriteHandle.ptr());
67 ATH_CHECK(m_IPFClusterSelectorTool->execute(theEFlowRecClusterContainerReference, theCaloClusterContainerReference));
68
69 // Explicitly start/stop the timer around the subtraction tool calls
70 t_subtract.start();
71 /* Run the SubtractionTools */
72
73 if (m_useUnified){
75 data.caloObjects = theElowCaloObjectContainer;
76
77 PFTrackFiller::fillTracksToConsider(data, localEFlowRecTrackContainer);
78
79 PFClusterFiller::fillClustersToConsider(data, theEFlowRecClusterContainerReference);
80
81 for (const auto& thisIPFUnifiedBaseTool : m_IPFUnifiedBaseTools){
82 ATH_CHECK(thisIPFUnifiedBaseTool->processPFlowData(ctx, data));
83 }
84 }
85
86 else{
87 for (auto thisIPFSubtractionTool : m_IPFSubtractionTools){
88 thisIPFSubtractionTool->execute(
89 ctx,
90 theElowCaloObjectContainer,
91 &localEFlowRecTrackContainer,
92 &theEFlowRecClusterContainerReference);
93 }
94 t_subtract.stop();
95
96 if (msgLvl(MSG::DEBUG)) {
97 for (auto thisEFTrack : localEFlowRecTrackContainer) {
98 msg() << "This efRecTrack has E,pt,eta and phi of " << thisEFTrack->getTrack()->e() << ", "
99 << thisEFTrack->getTrack()->pt() << ", " << thisEFTrack->getTrack()->eta() << " and "
100 << thisEFTrack->getTrack()->phi() << endmsg;
101 }
102
103 for (auto thisEFCluster : *(eflowRecClustersWriteHandle.ptr())) {
104 msg() << "This efRecCluster has E,pt,eta and phi of " << thisEFCluster->getCluster()->e() << ","
105 << thisEFCluster->getCluster()->pt() << ", " << thisEFCluster->getCluster()->eta() << " and "
106 << thisEFCluster->getCluster()->phi() << endmsg;
107 }
108 }
109
110 N_efrClusters = theEFlowRecClusterContainerReference.size();
111
112 /* Run the other AglTools */
113 for (auto thisIPFBaseTool : m_IPFBaseTools){
114 ATH_CHECK(thisIPFBaseTool->execute(ctx, *theElowCaloObjectContainer));
115 }
116 }
117
118 auto mon = Monitored::Group(m_monTool, t_exec, t_subtract, N_efrClusters);
119 return StatusCode::SUCCESS;
120}
121
122StatusCode PFAlgorithm::finalize(){ return StatusCode::SUCCESS;}
123
125 ATH_MSG_VERBOSE(" ");
126 ATH_MSG_VERBOSE("List of IPFSubtraction tools in execution sequence:");
127 ATH_MSG_VERBOSE("------------------------------------");
128 ATH_MSG_VERBOSE(" ");
129 unsigned int subtractionToolCtr = 0;
130 for (auto thisIPFSubtractionTool : m_IPFSubtractionTools){
131 subtractionToolCtr++;
132 ATH_MSG_VERBOSE(std::setw(2) << std::setiosflags(std::ios_base::right) << subtractionToolCtr << ".) "
133 << std::resetiosflags(std::ios_base::right) << std::setw(36) << std::setfill('.')
134 << std::setiosflags(std::ios_base::left) << thisIPFSubtractionTool->type() << std::setfill('.')
135 << thisIPFSubtractionTool->name() << std::setfill(' '));
136 }
137 ATH_MSG_VERBOSE(" ");
138 ATH_MSG_VERBOSE("------------------------------------");
139
140 ATH_MSG_VERBOSE(" ");
141 ATH_MSG_VERBOSE("List of IPFBase tools in execution sequence:");
142 ATH_MSG_VERBOSE("------------------------------------");
143 ATH_MSG_VERBOSE(" ");
144 unsigned int baseToolCtr = 0;
145 for (auto thisIPFBaseTool : m_IPFBaseTools){
146 baseToolCtr++;
147 ATH_MSG_VERBOSE(std::setw(2) << std::setiosflags(std::ios_base::right) << baseToolCtr << ".) "
148 << std::resetiosflags(std::ios_base::right) << std::setw(36) << std::setfill('.')
149 << std::setiosflags(std::ios_base::left) << thisIPFBaseTool->type() << std::setfill('.')
150 << thisIPFBaseTool->name() << std::setfill(' '));
151 }
152 ATH_MSG_VERBOSE(" ");
153 ATH_MSG_VERBOSE("------------------------------------");
154
155
156}
157
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.