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-2017 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
declareProperty
(
"OrderClusterByPt"
,
m_orderByPt
,
"Order clusters by calibrated Pt (input)"
);
27
}
28
29
StatusCode
CaloTopoTowerFromClusterCalibrator::execute
(
const
EventContext&
/*ctx*/
,
30
xAOD::CaloClusterContainer
* pClusCont,
31
CaloCellClusterWeights
* cellWeights)
const
32
{
33
34
// protection needed?
35
if
( cellWeights ==
nullptr
) {
36
ATH_MSG_ERROR
(
"Tower calibrator needs valid pointer to LCW weight lookup"
);
37
return
StatusCode::FAILURE;
38
}
39
41
// Calibrated clusters //
43
44
// loop towers
45
for
(
auto
pClus : *pClusCont ) {
46
// loop cells in towers
47
for
(
auto
fCell(pClus->cell_begin()); fCell != pClus->cell_end(); ++fCell ) {
48
// pick up the LCW weights (one if cell is only in one topo-cluster, two if cell is split between two) -> w_cell
49
const
CaloCellClusterWeights::weight_t
& wght(cellWeights->
at
(*fCell));
50
// pick up geometrical weight of cells in tower
51
double
weight(fCell.weight());
52
// combine the weights -> w_geo * w_cell
53
weight *= accumulateWeight(wght);
54
if
( weight == 0. ) {
55
// weight = 0 should actualy never happen!!!!
56
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"
,
57
pClus->eta(),pClus->phi(),(
size_t
)fCell->caloDDE()->calo_hash(),weight,wght.size(),fCell.weight(),weight/std::max(fCell.weight(),1e-08),
58
(
unsigned
int
)fCell->caloDDE()->getSampling(),
CaloSampling::getSamplingName
(fCell->caloDDE()->getSampling()).c_str()) );
59
}
else
{
60
// valid weight, apply to cell in tower
61
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]"
,
62
pClus->eta(),pClus->phi(),(
size_t
)fCell->caloDDE()->calo_hash(),weight,wght.size(),fCell.weight(),weight/fCell.weight()) );
63
pClus->reweightCell(fCell,weight);
// Set new weight. //
64
}
65
}
66
// preserve raw (EM) kinematics
67
double
rawE(pClus->e());
68
double
rawEta(pClus->eta());
// Clusters are instantiated with signal state CALIBRATED. The kinematics prior to the //
69
double
rawPhi(pClus->phi());
// application of LCW is EM. This code saves the EM scale kinematics. //
70
double
rawM(pClus->m());
71
// update cluster kinematics
72
CaloRec::Helpers::calculateKine
(pClus,
true
);
73
pClus->setRawE(rawE);
// The calculateKine function recombines cell signals with the updated weights (combined //
74
pClus->setRawEta(rawEta);
// LCW and tower geometry weights). After this function, the CALIBRATED state reflects //
75
pClus->setRawPhi(rawPhi);
// these combined weights. The EM scale kinematics is restored as raw (UNCALIBRATED). //
76
pClus->setRawM(rawM);
77
}
// cluster loop
78
79
// order clusters by Pt if requested
80
if
(
m_orderByPt
) {
81
std::sort
(pClusCont->
begin
(),pClusCont->
end
(),[](
xAOD::CaloCluster
* pc1,
xAOD::CaloCluster
* pc2) {
82
volatile double pt1(pc1->pt());
83
volatile double pt2(pc2->pt());
84
return ( pt1 > pt2 );
85
}
86
);
87
}
88
89
return
StatusCode::SUCCESS;
90
}
91
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
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
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
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::execute
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *pClusCont, CaloCellClusterWeights *cellWeights) const override
Tool execution.
Definition
CaloTopoTowerFromClusterCalibrator.cxx:29
CaloTopoTowerFromClusterCalibrator::m_orderByPt
bool m_orderByPt
Turn on pT ordering if true.
Definition
CaloTopoTowerFromClusterCalibrator.h:33
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