ATLAS Offline Software
Loading...
Searching...
No Matches
PFAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4#include "PFAlgorithm.h"
6
7PFAlgorithm::PFAlgorithm(const std::string& name, ISvcLocator* pSvcLocator)
8 : AthReentrantAlgorithm(name, pSvcLocator)
10 , m_IPFBaseTools(this)
11{
12 declareProperty("SubtractionToolList", m_IPFSubtractionTools, "List of Private Subtraction IPFSubtractionTools");
13 declareProperty("BaseToolList", m_IPFBaseTools, "List of Private IPFBaseTools");
14}
15
17
20 ATH_CHECK( m_IPFBaseTools.retrieve());
21
23
27
28 if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
29
30 printTools();
31
32 return StatusCode::SUCCESS;
33}
34
35StatusCode PFAlgorithm::execute(const EventContext& ctx) const{
36 // Define monitored quantities
37 auto t_exec = Monitored::Timer<std::chrono::milliseconds>( "TIME_execute" );
38 Monitored::ScopedTimer execution_time(t_exec);
39 auto t_subtract = Monitored::Timer<std::chrono::milliseconds>( "TIME_subtract" );
40 auto N_efrClusters = Monitored::Scalar( "N_efrClusters", 0 );
41
42 ATH_MSG_DEBUG("Executing");
43
45 ATH_CHECK(eflowCaloObjectsWriteHandle.record(std::make_unique<eflowCaloObjectContainer>()));
46 eflowCaloObjectContainer* theElowCaloObjectContainer = eflowCaloObjectsWriteHandle.ptr();
47
49 ATH_CHECK(caloClustersWriteHandle.record(std::make_unique<xAOD::CaloClusterContainer>(),
50 std::make_unique<xAOD::CaloClusterAuxContainer>()));
51 ATH_MSG_DEBUG("CaloClusterWriteHandle has container of size" << caloClustersWriteHandle->size());
52
54 eflowRecTrackContainer localEFlowRecTrackContainer(*eflowRecTracksReadHandle.ptr());
55
56 /* Record the eflowRecCluster output container */
58 ATH_CHECK(eflowRecClustersWriteHandle.record(std::make_unique<eflowRecClusterContainer>()));
59 eflowRecClusterContainer& theEFlowRecClusterContainerReference = *(eflowRecClustersWriteHandle.ptr());
60
61 xAOD::CaloClusterContainer& theCaloClusterContainerReference = *(caloClustersWriteHandle.ptr());
62 ATH_CHECK(m_IPFClusterSelectorTool->execute(theEFlowRecClusterContainerReference, theCaloClusterContainerReference));
63
64 // Explicitly start/stop the timer around the subtraction tool calls
65 t_subtract.start();
66 /* Run the SubtractionTools */
67 for (auto thisIPFSubtractionTool : m_IPFSubtractionTools){
68 thisIPFSubtractionTool->execute(theElowCaloObjectContainer,&localEFlowRecTrackContainer,&theEFlowRecClusterContainerReference);
69 }
70 t_subtract.stop();
71
72 if (msgLvl(MSG::DEBUG)) {
73 for (auto thisEFTrack : localEFlowRecTrackContainer) {
74 msg() << "This efRecTrack has E,pt,eta and phi of " << thisEFTrack->getTrack()->e() << ", "
75 << thisEFTrack->getTrack()->pt() << ", " << thisEFTrack->getTrack()->eta() << " and "
76 << thisEFTrack->getTrack()->phi() << endmsg;
77 }
78
79 for (auto thisEFCluster : *(eflowRecClustersWriteHandle.ptr())) {
80 msg() << "This efRecCluster has E,pt,eta and phi of " << thisEFCluster->getCluster()->e() << ","
81 << thisEFCluster->getCluster()->pt() << ", " << thisEFCluster->getCluster()->eta() << " and "
82 << thisEFCluster->getCluster()->phi() << endmsg;
83 }
84 }
85
86 N_efrClusters = theEFlowRecClusterContainerReference.size();
87
88 /* Run the other AglTools */
89 for (auto thisIPFBaseTool : m_IPFBaseTools){
90 ATH_CHECK(thisIPFBaseTool->execute(*theElowCaloObjectContainer));
91 }
92
93 auto mon = Monitored::Group(m_monTool, t_exec, t_subtract, N_efrClusters);
94 return StatusCode::SUCCESS;
95}
96
97StatusCode PFAlgorithm::finalize(){ return StatusCode::SUCCESS;}
98
100 ATH_MSG_VERBOSE(" ");
101 ATH_MSG_VERBOSE("List of IPFSubtraction tools in execution sequence:");
102 ATH_MSG_VERBOSE("------------------------------------");
103 ATH_MSG_VERBOSE(" ");
104 unsigned int subtractionToolCtr = 0;
105 for (auto thisIPFSubtractionTool : m_IPFSubtractionTools){
106 subtractionToolCtr++;
107 ATH_MSG_VERBOSE(std::setw(2) << std::setiosflags(std::ios_base::right) << subtractionToolCtr << ".) "
108 << std::resetiosflags(std::ios_base::right) << std::setw(36) << std::setfill('.')
109 << std::setiosflags(std::ios_base::left) << thisIPFSubtractionTool->type() << std::setfill('.')
110 << thisIPFSubtractionTool->name() << std::setfill(' '));
111 }
112 ATH_MSG_VERBOSE(" ");
113 ATH_MSG_VERBOSE("------------------------------------");
114
115 ATH_MSG_VERBOSE(" ");
116 ATH_MSG_VERBOSE("List of IPFBase tools in execution sequence:");
117 ATH_MSG_VERBOSE("------------------------------------");
118 ATH_MSG_VERBOSE(" ");
119 unsigned int baseToolCtr = 0;
120 for (auto thisIPFBaseTool : m_IPFBaseTools){
121 baseToolCtr++;
122 ATH_MSG_VERBOSE(std::setw(2) << std::setiosflags(std::ios_base::right) << baseToolCtr << ".) "
123 << std::resetiosflags(std::ios_base::right) << std::setw(36) << std::setfill('.')
124 << std::setiosflags(std::ios_base::left) << thisIPFBaseTool->type() << std::setfill('.')
125 << thisIPFBaseTool->name() << std::setfill(' '));
126 }
127 ATH_MSG_VERBOSE(" ");
128 ATH_MSG_VERBOSE("------------------------------------");
129
130
131}
132
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
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:35
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:74
SG::WriteHandleKey< eflowRecClusterContainer > m_eflowRecClustersWriteHandleKey
WriteHandleKey for the eflowRecClusterContainer to write out.
Definition PFAlgorithm.h:58
StatusCode finalize() override
ToolHandleArray< IPFSubtractionTool > m_IPFSubtractionTools
List of IPFSubtractionTool, which will be executed by this algorithm.
Definition PFAlgorithm.h:44
SG::ReadHandleKey< eflowRecTrackContainer > m_eflowRecTracksReadHandleKey
ReadHandleKey for the eflowRecTrackContainer to be read in.
Definition PFAlgorithm.h:50
ToolHandleArray< IPFBaseTool > m_IPFBaseTools
List of PFBaseAlgTool, which will be executed by this algorithm.
Definition PFAlgorithm.h:47
ToolHandle< GenericMonitoringTool > m_monTool
Online monitoring tool for recording histograms of the alg in action.
Definition PFAlgorithm.h:82
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_caloClustersWriteHandleKey
WriteHandleKey for CaloClusterContainer to be written out.
Definition PFAlgorithm.h:66
void printTools()
Funciton to print out list of tools if in VERBOSE mode.
StatusCode initialize() override
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.