ATLAS Offline Software
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 "eflowRec/PFAlgorithm.h"
6 
7 PFAlgorithm::PFAlgorithm(const std::string& name, ISvcLocator* pSvcLocator)
8  : AthReentrantAlgorithm(name, pSvcLocator)
9  , m_IPFSubtractionTools(this)
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 
19  ATH_CHECK(m_IPFSubtractionTools.retrieve());
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 
35 StatusCode 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 
97 StatusCode 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 
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
PFAlgorithm::m_eflowRecClustersWriteHandleKey
SG::WriteHandleKey< eflowRecClusterContainer > m_eflowRecClustersWriteHandleKey
WriteHandleKey for the eflowRecClusterContainer to write out.
Definition: PFAlgorithm.h:58
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
eflowRecClusterContainer
Definition: eflowRecCluster.h:275
PFAlgorithm::initialize
StatusCode initialize() override
Definition: PFAlgorithm.cxx:16
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CaloClusterAuxContainer.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
PFAlgorithm::finalize
StatusCode finalize() override
Definition: PFAlgorithm.cxx:97
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
PFAlgorithm::m_caloClustersWriteHandleKey
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_caloClustersWriteHandleKey
WriteHandleKey for CaloClusterContainer to be written out.
Definition: PFAlgorithm.h:66
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PFAlgorithm::PFAlgorithm
PFAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PFAlgorithm.cxx:7
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
PFAlgorithm::m_IPFBaseTools
ToolHandleArray< IPFBaseTool > m_IPFBaseTools
List of PFBaseAlgTool, which will be executed by this algorithm.
Definition: PFAlgorithm.h:47
PFAlgorithm::printTools
void printTools()
Funciton to print out list of tools if in VERBOSE mode.
Definition: PFAlgorithm.cxx:99
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
PFAlgorithm::m_eflowRecTracksReadHandleKey
SG::ReadHandleKey< eflowRecTrackContainer > m_eflowRecTracksReadHandleKey
ReadHandleKey for the eflowRecTrackContainer to be read in.
Definition: PFAlgorithm.h:50
PFAlgorithm::execute
StatusCode execute(const EventContext &ctx) const override
Definition: PFAlgorithm.cxx:35
SG::ReadHandle::ptr
const_pointer_type ptr()
Dereference the pointer.
PFAlgorithm.h
eflowRecTrackContainer
Definition: eflowRecTrack.h:194
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
PFAlgorithm::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Online monitoring tool for recording histograms of the alg in action.
Definition: PFAlgorithm.h:82
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DEBUG
#define DEBUG
Definition: page_access.h:11
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
Monitored::ScopedTimer
Helper class to create a scoped timer.
Definition: MonitoredTimer.h:95
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
eflowCaloObjectContainer
Definition: eflowCaloObject.h:100
PFAlgorithm::m_IPFClusterSelectorTool
ToolHandle< IPFClusterSelectorTool > m_IPFClusterSelectorTool
ToolHandle for the PFClusterSelectorTool which creates the set of eflowRecCluster to be used.
Definition: PFAlgorithm.h:35
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
PFAlgorithm::m_eflowCaloObjectsWriteHandleKey
SG::WriteHandleKey< eflowCaloObjectContainer > m_eflowCaloObjectsWriteHandleKey
WriteHandleKey for eflowCaloObjectContainer to be written out.
Definition: PFAlgorithm.h:74
PFAlgorithm::m_IPFSubtractionTools
ToolHandleArray< IPFSubtractionTool > m_IPFSubtractionTools
List of IPFSubtractionTool, which will be executed by this algorithm.
Definition: PFAlgorithm.h:44