ATLAS Offline Software
Loading...
Searching...
No Matches
PFUnifiedLCCalibTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "PFData.h"
7#include "eflowCaloObject.h"
8#include "eflowRecCluster.h"
9
14
18
19PFUnifiedLCCalibTool::PFUnifiedLCCalibTool(const std::string& type, const std::string& name, const IInterface* parent) :
20 base_class(type, name, parent)
21{
22}
23
25
26 /* Retrieve the cluster collection tool */
28
29 /* Retrieve basic local-hadron calibration tool */
31
32 /* Retrieve tools for out-of-cluster corrections */
34
36
37 /* Retrieve tool for DM corrections */
39
40 /* Retrieve calorimeter detector manager */
41 ATH_CHECK(m_caloMgrKey.initialize());
42
43 return StatusCode::SUCCESS;
44
45}
46
47StatusCode PFUnifiedLCCalibTool::processPFlowData(const EventContext& ctx, PFData &thePFData) const {
48
49 if (!thePFData.caloObjects) {
50 ATH_MSG_ERROR("PFData::caloObjects is null; caller must set it before invoking the LC calib tool");
51 return StatusCode::FAILURE;
52 }
53
54 eflowCaloObjectContainer *theEflowCaloObjectContainer = thePFData.caloObjects;
55
56 if (m_useLocalWeight) {
57 std::unique_ptr<eflowRecClusterContainer> theEFRecClusterContainer = m_clusterCollectionTool->retrieve(*theEflowCaloObjectContainer, true);
58 /* Calibrate each cluster */
60 if (caloMgrHandle.isValid()){
61 for (auto thisEFlowRecCluster : *theEFRecClusterContainer) applyLocalWeight(thisEFlowRecCluster,**caloMgrHandle);
62 }
63 else ATH_MSG_WARNING("Invalid pointer to CaloDetDescrManage: Did NOT calibrate any topoclusters.");
64 } else {
65 /* Collect all the clusters in a temporary container (with VIEW_ELEMENTS!) */
66 std::unique_ptr<xAOD::CaloClusterContainer> tempClusterContainer = m_clusterCollectionTool->execute(*theEflowCaloObjectContainer, true);
67 /* Calibrate each cluster */
68 for (auto thisCaloCluster : *tempClusterContainer){
69 /* Subsequently apply all ClusterLocalCalibTools, print debug output at each stage, if DEBUG it set */
70 ATH_CHECK(apply(ctx,m_clusterLocalCalibTool, thisCaloCluster));
71
72 ATH_CHECK(apply(ctx,m_clusterLocalCalibOOCCTool, thisCaloCluster));
73
74 ATH_CHECK(apply(ctx,m_clusterLocalCalibOOCCPi0Tool, thisCaloCluster));
75
76 ATH_CHECK(apply(ctx,m_clusterLocalCalibDMTool, thisCaloCluster));
77
78 }//loop on CaloCluster
79 }//if not use local weight scheme
80 return StatusCode::SUCCESS;
81}
82
83StatusCode PFUnifiedLCCalibTool::apply(const EventContext& ctx, const ToolHandle<CaloClusterProcessor>& calibTool, xAOD::CaloCluster* cluster) const {
84 if (m_useLocalWeight) ATH_MSG_WARNING("Applying recalculated weights, when configuration requested to use original weights");
85 ATH_CHECK(calibTool->execute(ctx,cluster));
86 return StatusCode::SUCCESS;
87}
88
90 xAOD::CaloCluster* theCluster = theEFRecClusters->getCluster();
91
92 /* Iterate over cells of old cluster and replicate them with energy weighted by -1 if negative and add it to the new cluster */
93 const std::map<IdentifierHash, double> weightMap = theEFRecClusters->getCellsWeight();
94
95 const CaloCell_ID* calo_id = calo_dd_man.getCaloCell_ID();
96 xAOD::CaloCluster::cell_iterator cellIter = theCluster->cell_begin();
97
98 for (;cellIter != theCluster->cell_end(); ++cellIter) {
99 const CaloCell* pCell = *cellIter;
100 IdentifierHash myHashId = calo_id->calo_cell_hash(pCell->ID());
101 if (const auto pWeight = weightMap.find(myHashId); pWeight!=weightMap.end()){
102 const double weight = pWeight->second;
103 theCluster->reweightCell(cellIter, weight);
104 }
105 }
106
107 CaloClusterKineHelper::calculateKine(theCluster, true, false);
108
110}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
Base class for cluster processing tools called from CaloClusterMaker that operate on individual clust...
Definition of CaloDetDescrManager.
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
This class provides the client interface for accessing the detector description information common to...
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
virtual void setStatus(const StatusIndicator &statusIndicator)
Set status.
This is a "hash" representation of an Identifier.
ToolHandle< IPFClusterCollectionTool > m_clusterCollectionTool
Tool to put all clusters into a temporary container - then we use this to calculate moments,...
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibOOCCTool
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
ReadCondHandleKey for CaloDetDescrManager.
StatusCode apply(const EventContext &ctx, const ToolHandle< CaloClusterProcessor > &calibTool, xAOD::CaloCluster *cluster) const
virtual StatusCode initialize() override
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibDMTool
Gaudi::Property< bool > m_useLocalWeight
Toggle which LC weights scheme to use - default is to recalculate weights, rather than use saved weig...
static void applyLocalWeight(eflowRecCluster *theEFRecCluster, const CaloDetDescrManager &calo_dd_man)
virtual StatusCode processPFlowData(const EventContext &ctx, PFData &thePFData) const override
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibTool
PFUnifiedLCCalibTool(const std::string &type, const std::string &name, const IInterface *parent)
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibOOCCPi0Tool
This class extends the information about a xAOD::CaloCluster.
xAOD::CaloCluster * getCluster()
const std::map< IdentifierHash, double > & getCellsWeight() const
void reweightCell(cell_iterator it, const double weight)
Method to reweight a cell in the cluster (Beware: Kinematics not updated!).
CaloClusterCellLink::iterator cell_iterator
Iterator of the underlying CaloClusterCellLink (non-const version).
const_cell_iterator cell_end() const
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version).
CaloRecoStatus & recoStatus()
Accesssor to CaloRecoStatus (non-const).
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
eflowCaloObjectContainer * caloObjects
Definition PFData.h:17