ATLAS Offline Software
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 
18 PFLCCalibTool::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 */
41 
42  return StatusCode::SUCCESS;
43 
44 }
45 
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 
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(m_clusterLocalCalibTool, thisCaloCluster));
64 
65  ATH_CHECK(apply(m_clusterLocalCalibOOCCTool, thisCaloCluster));
66 
68 
69  ATH_CHECK(apply(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 
81 StatusCode PFLCCalibTool::apply(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(cluster));
84  return StatusCode::SUCCESS;
85 }
86 
87 void 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 }
PFLCCalibTool::applyLocalWeight
static void applyLocalWeight(eflowRecCluster *theEFRecCluster, const CaloDetDescrManager &calo_dd_man)
Definition: PFLCCalibTool.cxx:87
eflowRecCluster
This class extends the information about a xAOD::CaloCluster.
Definition: eflowRecCluster.h:40
CaloClusterKineHelper.h
CaloClusterProcessor.h
Base class for cluster processing tools called from CaloClusterMaker that operate on individual clust...
PFLCCalibTool::initialize
virtual StatusCode initialize() override
Definition: PFLCCalibTool.cxx:23
xAOD::CaloCluster_v1::cell_begin
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version)
Definition: CaloCluster_v1.h:812
CaloRecoStatus::CALIBRATEDLHC
@ CALIBRATEDLHC
Definition: CaloRecoStatus.h:43
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
PFLCCalibTool::m_clusterLocalCalibTool
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibTool
Definition: PFLCCalibTool.h:43
CaloRecoStatus::setStatus
virtual void setStatus(const StatusIndicator &statusIndicator)
Set status.
Definition: CaloRecoStatus.h:107
eflowRecCluster::getCellsWeight
const std::map< IdentifierHash, double > & getCellsWeight() const
Definition: eflowRecCluster.h:85
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
CaloCell_ID.h
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
PFLCCalibTool::execute
virtual StatusCode execute(eflowCaloObjectContainer &theEflowCaloObjectContainer) override
Definition: PFLCCalibTool.cxx:46
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
PFLCCalibTool::m_clusterLocalCalibOOCCTool
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibOOCCTool
Definition: PFLCCalibTool.h:46
CaloCluster.h
PFLCCalibTool::m_clusterLocalCalibOOCCPi0Tool
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibOOCCPi0Tool
Definition: PFLCCalibTool.h:49
PFLCCalibTool::m_clusterCollectionTool
ToolHandle< IPFClusterCollectionTool > m_clusterCollectionTool
Tool to put all clusters into a temporary container - then we use this to calculate moments,...
Definition: PFLCCalibTool.h:40
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
eflowRecCluster::getCluster
xAOD::CaloCluster * getCluster()
Definition: eflowRecCluster.h:49
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
eflowRecCluster.h
PFLCCalibTool::PFLCCalibTool
PFLCCalibTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PFLCCalibTool.cxx:18
PFLCCalibTool::m_useLocalWeight
Gaudi::Property< bool > m_useLocalWeight
Toggle which LC weights scheme to use - default is to recalculate weights, rather than use saved weig...
Definition: PFLCCalibTool.h:55
xAOD::CaloCluster_v1::reweightCell
void reweightCell(cell_iterator it, const double weight)
Method to reweight a cell in the cluster (Beware: Kinematics not updated!)
Definition: CaloCluster_v1.h:835
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
xAOD::CaloCluster_v1::recoStatus
CaloRecoStatus & recoStatus()
Accesssor to CaloRecoStatus (non-const)
Definition: CaloCluster_v1.h:840
eflowCaloObject.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCell::ID
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition: CaloCell.h:279
PFLCCalibTool.h
CaloClusterStoreHelper.h
PFLCCalibTool::apply
StatusCode apply(ToolHandle< CaloClusterProcessor > &calibTool, xAOD::CaloCluster *cluster)
Definition: PFLCCalibTool.cxx:81
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::CaloCluster_v1::cell_end
const_cell_iterator cell_end() const
Definition: CaloCluster_v1.h:813
CaloClusterContainer.h
CaloClusterKineHelper::calculateKine
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.
Definition: CaloClusterKineHelper.cxx:223
CaloDetDescrManager::getCaloCell_ID
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
Definition: CaloDetDescrManager.cxx:1590
PFLCCalibTool::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
ReadCondHandleKey for CaloDetDescrManager.
Definition: PFLCCalibTool.h:58
PFLCCalibTool::m_clusterLocalCalibDMTool
ToolHandle< CaloClusterProcessor > m_clusterLocalCalibDMTool
Definition: PFLCCalibTool.h:52
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
eflowCaloObjectContainer
Definition: eflowCaloObject.h:100
PFLCCalibTool::finalize
virtual StatusCode finalize() override
Definition: PFLCCalibTool.cxx:76