ATLAS Offline Software
Loading...
Searching...
No Matches
PFLCCalibTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
8
13
17
18PFLCCalibTool::PFLCCalibTool(const std::string& type, const std::string& name, const IInterface* parent) :
19 base_class(type, name, parent)
20{
21}
22
24
25 /* Retrieve the cluster collection tool */
27
28 /* Retrieve basic local-hadron calibration tool */
30
31 /* Retrieve tools for out-of-cluster corrections */
33
35
36 /* Retrieve tool for DM corrections */
38
39 /* Retrieve calorimeter detector manager */
40 ATH_CHECK(m_caloMgrKey.initialize());
41
42 return StatusCode::SUCCESS;
43
44}
45
46StatusCode PFLCCalibTool::execute(eflowCaloObjectContainer& theEflowCaloObjectContainer) {
47
48 if (m_useLocalWeight) {
49 std::unique_ptr<eflowRecClusterContainer> theEFRecClusterContainer = m_clusterCollectionTool->retrieve(theEflowCaloObjectContainer, true);
50 /* Calibrate each cluster */
52 if (caloMgrHandle.isValid()){
53 for (auto thisEFlowRecCluster : *theEFRecClusterContainer) applyLocalWeight(thisEFlowRecCluster,**caloMgrHandle);
54 }
55 else ATH_MSG_WARNING("Invalid pointer to CaloDetDescrManage: Did NOT calibrate any topoclusters.");
56 } else {
57 /* Collect all the clusters in a temporary container (with VIEW_ELEMENTS!) */
58 std::unique_ptr<xAOD::CaloClusterContainer> tempClusterContainer = m_clusterCollectionTool->execute(theEflowCaloObjectContainer, true);
59 const EventContext& ctx=Gaudi::Hive::currentContext();
60 /* Calibrate each cluster */
61 for (auto thisCaloCluster : *tempClusterContainer){
62 /* Subsequently apply all ClusterLocalCalibTools, print debug output at each stage, if DEBUG it set */
63 ATH_CHECK(apply(ctx,m_clusterLocalCalibTool, thisCaloCluster));
64
65 ATH_CHECK(apply(ctx,m_clusterLocalCalibOOCCTool, thisCaloCluster));
66
67 ATH_CHECK(apply(ctx,m_clusterLocalCalibOOCCPi0Tool, thisCaloCluster));
68
69 ATH_CHECK(apply(ctx,m_clusterLocalCalibDMTool, thisCaloCluster));
70
71 }//loop on CaloCluster
72 }//if not use local weight scheme
73 return StatusCode::SUCCESS;
74}
75
77 return StatusCode::SUCCESS;
78}
79
80
81StatusCode PFLCCalibTool::apply(const EventContext& ctx, ToolHandle<CaloClusterProcessor>& calibTool, xAOD::CaloCluster* cluster) {
82 if (m_useLocalWeight) ATH_MSG_WARNING("Applying recalculated weights, when configuration requested to use original weights");
83 ATH_CHECK(calibTool->execute(ctx,cluster));
84 return StatusCode::SUCCESS;
85}
86
87void PFLCCalibTool::applyLocalWeight(eflowRecCluster* theEFRecClusters, const CaloDetDescrManager& calo_dd_man) {
88 xAOD::CaloCluster* theCluster = theEFRecClusters->getCluster();
89
90 /* Iterate over cells of old cluster and replicate them with energy weighted by -1 if negative and add it to the new cluster */
91 const std::map<IdentifierHash, double> weightMap = theEFRecClusters->getCellsWeight();
92
93 const CaloCell_ID* calo_id = calo_dd_man.getCaloCell_ID();
94 xAOD::CaloCluster::cell_iterator cellIter = theCluster->cell_begin();
95
96 for (;cellIter != theCluster->cell_end(); ++cellIter) {
97 const CaloCell* pCell = *cellIter;
98 IdentifierHash myHashId = calo_id->calo_cell_hash(pCell->ID());
99 if (const auto pWeight = weightMap.find(myHashId); pWeight!=weightMap.end()){
100 const double weight = pWeight->second;
101 theCluster->reweightCell(cellIter, weight);
102 }
103 }
104
105 CaloClusterKineHelper::calculateKine(theCluster, true, false);
106
108}
#define ATH_CHECK
Evaluate an expression and check for errors.
#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,...
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
ReadCondHandleKey for CaloDetDescrManager.
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibTool
virtual StatusCode initialize() override
virtual StatusCode finalize() override
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibDMTool
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibOOCCPi0Tool
static void applyLocalWeight(eflowRecCluster *theEFRecCluster, const CaloDetDescrManager &calo_dd_man)
StatusCode apply(const EventContext &ctx, ToolHandle< CaloClusterProcessor > &calibTool, xAOD::CaloCluster *cluster)
virtual StatusCode execute(eflowCaloObjectContainer &theEflowCaloObjectContainer) override
PFLCCalibTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< bool > m_useLocalWeight
Toggle which LC weights scheme to use - default is to recalculate weights, rather than use saved weig...
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibOOCCTool
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.