ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloTopoTowerFromClusterCalibrator.cxx
Go to the documentation of this file.
1
/* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration */
2
3
#include "
CaloTopoTowerFromClusterCalibrator.h
"
4
#include "
CaloTopoClusterFromTowerHelpers.h
"
5
6
#include "
CaloEvent/CaloCellClusterWeights.h
"
7
8
#include "CaloGeoHelpers/CaloSampling.h"
9
10
#include <numeric>
11
12
namespace
{
13
double
accumulateWeight(
const
CaloCellClusterWeights::weight_t
& wght)
// A cell can be split across clusters (usually only two). //
14
{
return
wght.empty()
// It thus receives two different calibration weights, //
15
? 0.
// including geometrical weight introduced by splitting. //
16
: wght.size() == 1
// The overall weight is the sum of the two. //
17
? wght.front()
18
: std::accumulate(wght.begin(),wght.end(),0.);
19
}
20
}
21
22
CaloTopoTowerFromClusterCalibrator::CaloTopoTowerFromClusterCalibrator
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* pParent)
23
:
AthAlgTool
(
type
,name,pParent)
24
{
25
declareInterface<CaloTowerCollectionProcessor>(
this
);
26
}
27
28
StatusCode
CaloTopoTowerFromClusterCalibrator::execute
(
const
EventContext&
/*ctx*/
,
29
xAOD::CaloClusterContainer
* pClusCont,
30
CaloCellClusterWeights
* cellWeights)
const
31
{
32
33
// protection needed?
34
if
( cellWeights ==
nullptr
) {
35
ATH_MSG_ERROR
(
"Tower calibrator needs valid pointer to LCW weight lookup"
);
36
return
StatusCode::FAILURE;
37
}
38
40
// Calibrated clusters //
42
43
// loop towers
44
for
(
auto
pClus : *pClusCont ) {
45
// loop cells in towers
46
for
(
auto
fCell(pClus->cell_begin()); fCell != pClus->cell_end(); ++fCell ) {
47
// pick up the LCW weights (one if cell is only in one topo-cluster, two if cell is split between two) -> w_cell
48
const
CaloCellClusterWeights::weight_t
& wght(cellWeights->
at
(*fCell));
49
// pick up geometrical weight of cells in tower
50
double
weight(fCell.weight());
51
// combine the weights -> w_geo * w_cell
52
weight *= accumulateWeight(wght);
53
if
( weight == 0. ) {
54
// weight = 0 should actualy never happen!!!!
55
ATH_MSG_DEBUG
(
CaloRec::Helpers::fmtMsg
(
"[NO_LCW_REWEIGHT] Tower (%6.3f,%6.3f) cell [%6zu] weight = %6.3f [# LCW weights %zu geo %6.3f LCW %6.3f] SamplingID %2u Name \042%s\042"
,
56
pClus->eta(),pClus->phi(),(
size_t
)fCell->caloDDE()->calo_hash(),weight,wght.size(),fCell.weight(),weight/std::max(fCell.weight(),1e-08),
57
(
unsigned
int
)fCell->caloDDE()->getSampling(),
CaloSampling::getSamplingName
(fCell->caloDDE()->getSampling()).c_str()) );
58
}
else
{
59
// valid weight, apply to cell in tower
60
ATH_MSG_DEBUG
(
CaloRec::Helpers::fmtMsg
(
"[DO_LCW_REWEIGHT] Tower (%6.3f,%6.3f) cell [%6zu] weight = %6.3f [# LCW weights %zu geo %6.3f LCW %6.3f]"
,
61
pClus->eta(),pClus->phi(),(
size_t
)fCell->caloDDE()->calo_hash(),weight,wght.size(),fCell.weight(),weight/fCell.weight()) );
62
pClus->reweightCell(fCell,weight);
// Set new weight. //
63
}
64
}
65
// preserve raw (EM) kinematics
66
double
rawE(pClus->e());
67
double
rawEta(pClus->eta());
// Clusters are instantiated with signal state CALIBRATED. The kinematics prior to the //
68
double
rawPhi(pClus->phi());
// application of LCW is EM. This code saves the EM scale kinematics. //
69
double
rawM(pClus->m());
70
// update cluster kinematics
71
CaloRec::Helpers::calculateKine
(pClus,
true
);
72
pClus->setRawE(rawE);
// The calculateKine function recombines cell signals with the updated weights (combined //
73
pClus->setRawEta(rawEta);
// LCW and tower geometry weights). After this function, the CALIBRATED state reflects //
74
pClus->setRawPhi(rawPhi);
// these combined weights. The EM scale kinematics is restored as raw (UNCALIBRATED). //
75
pClus->setRawM(rawM);
76
}
// cluster loop
77
78
// order clusters by Pt if requested
79
if
(
m_orderByPt
) {
80
std::sort
(pClusCont->
begin
(),pClusCont->
end
(),[](
xAOD::CaloCluster
* pc1,
xAOD::CaloCluster
* pc2) {
81
volatile double pt1(pc1->pt());
82
volatile double pt2(pc2->pt());
83
return ( pt1 > pt2 );
84
}
85
);
86
}
87
88
return
StatusCode::SUCCESS;
89
}
90
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
CaloCellClusterWeights.h
CaloTopoClusterFromTowerHelpers.h
CaloTopoTowerFromClusterCalibrator.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
CaloCellClusterWeights
Hash lookup of calibration weights for calorimeter cells.
Definition
CaloCellClusterWeights.h:23
CaloCellClusterWeights::weight_t
std::vector< double > weight_t
Type of weight.
Definition
CaloCellClusterWeights.h:28
CaloCellClusterWeights::at
const weight_t & at(size_t hash) const
Accessing value using function and hash.
Definition
CaloCellClusterWeights.cxx:31
CaloSampling::getSamplingName
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
Definition
Calorimeter/CaloGeoHelpers/Root/CaloSampling.cxx:18
CaloTopoTowerFromClusterCalibrator::CaloTopoTowerFromClusterCalibrator
CaloTopoTowerFromClusterCalibrator(const std::string &type, const std::string &name, const IInterface *pParent)
Tool constructor.
Definition
CaloTopoTowerFromClusterCalibrator.cxx:22
CaloTopoTowerFromClusterCalibrator::m_orderByPt
Gaudi::Property< bool > m_orderByPt
Turn on pT ordering if true.
Definition
CaloTopoTowerFromClusterCalibrator.h:33
CaloTopoTowerFromClusterCalibrator::execute
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *pClusCont, CaloCellClusterWeights *cellWeights) const override
Tool execution.
Definition
CaloTopoTowerFromClusterCalibrator.cxx:28
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
CaloRec::Helpers::calculateKine
bool calculateKine(xAOD::CaloCluster *pClus, bool onlyKine=false)
Kinematic updates.
Definition
CaloTopoClusterFromTowerHelpers.cxx:119
CaloRec::Helpers::fmtMsg
std::string fmtMsg(const char *fmt,...)
Definition
CaloTopoClusterFromTowerHelpers.cxx:14
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
type
Generated on
for ATLAS Offline Software by
1.17.0