ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1CaloFEX
TrigT1CaloFexPerf
src
GTowerRhoSubtractionAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
GTowerRhoSubtractionAlg.h
"
6
#include "
StoreGate/ReadHandle.h
"
7
#include "
StoreGate/WriteHandle.h
"
8
#include <memory>
9
#include "
xAODCore/ShallowAuxContainer.h
"
10
#include "
xAODCore/ShallowCopy.h
"
11
#include "
xAODBase/IParticleHelpers.h
"
12
#include "TH1F.h"
13
#include "GaudiKernel/SystemOfUnits.h"
14
#include "
GTowerHelpers.h
"
15
#include "
xAODTrigger/EnergySumRoIAuxInfo.h
"
16
#include <algorithm>
17
18
namespace
19
{
20
const
static
SG::AuxElement::ConstAccessor<float> accArea(
"area"
);
21
const
static
SG::AuxElement::Decorator<std::vector<float>> decRho(
"FPGARhos"
);
22
}
// namespace
23
24
namespace
LVL1
25
{
26
GTowerRhoSubtractionAlg::GTowerRhoSubtractionAlg
(
const
std::string &
name
, ISvcLocator *pSvcLocator)
27
:
AthReentrantAlgorithm
(
name
, pSvcLocator)
28
{
29
declareProperty
(
"InputTowers"
,
m_inputKey
=
"GCaloTower"
);
30
declareProperty
(
"OutputTowers"
,
m_outputKey
=
"GCaloTowerRhoSubtracted"
);
31
declareProperty
(
"OutputRho"
,
m_outputRhoKey
=
"GFEXRho"
);
32
declareProperty
(
"UseNegativeTowers"
,
m_useNegativeTowers
=
true
);
33
declareProperty
(
"MaxTowerEt"
,
m_maxTowerEt
= 10 * Gaudi::Units::GeV);
34
declareProperty
(
"ForcePositiveRho"
,
m_forcePosRho
=
false
);
35
}
36
37
GTowerRhoSubtractionAlg::~GTowerRhoSubtractionAlg
() {}
38
39
StatusCode
GTowerRhoSubtractionAlg::initialize
()
40
{
41
ATH_CHECK
(
m_inputKey
.initialize());
42
ATH_CHECK
(
m_outputKey
.initialize());
43
ATH_CHECK
(
m_outputRhoKey
.initialize());
44
return
StatusCode::SUCCESS;
45
}
46
47
StatusCode
GTowerRhoSubtractionAlg::execute
(
const
EventContext& ctx)
const
48
{
49
auto
inputTowers =
SG::makeHandle
(
m_inputKey
, ctx);
50
if
(!inputTowers.isValid())
51
{
52
ATH_MSG_ERROR
(
"Failed to retrieve input towers "
<<
m_inputKey
.key());
53
return
StatusCode::FAILURE;
54
}
55
auto
[outputTowers, outputTowersAux] =
xAOD::shallowCopy
(*inputTowers, ctx);
56
xAOD::setOriginalObjectLink
(*inputTowers, *outputTowers);
57
58
// Split towers into FPGAs
59
constexpr
static
std::size_t nFPGAs =
static_cast<
std::size_t
>
(
gFEX::FPGA::N_FPGAS
);
60
std::array<std::vector<const xAOD::JGTower *>, nFPGAs> fpgas;
61
// Use histograms to calculate RMSs of tower Ets for each FPGA
62
std::array<TH1F, nFPGAs> fpgaHistograms;
63
std::vector<float> fpgaRhos(3, 0.0);
64
for
(std::size_t i = 0; i < nFPGAs; ++i)
65
fpgaHistograms.at(i) = TH1F((
"hFPGA"
+ std::to_string(i)).c_str(),
""
, 50, 0, 5000);
66
for
(
const
xAOD::JGTower
*tower : *inputTowers)
67
{
68
gFEX::FPGA
fpga =
gFEX::getFPGA
(tower->eta());
69
if
(fpga ==
gFEX::FPGA::N_FPGAS
)
70
{
71
ATH_MSG_WARNING
(
"Could not classify tower as an FPGA!"
);
72
continue
;
73
}
74
fpgas.at(
static_cast<
std::size_t
>
(fpga)).push_back(tower);
75
fpgaHistograms.at(
static_cast<
std::size_t
>
(fpga)).Fill(tower->et());
76
}
77
78
// Now perform the subtraction
79
for
(std::size_t i = 0; i < nFPGAs; ++i)
80
{
81
float
threshold
= 3 * fpgaHistograms.at(i).GetRMS();
82
const
std::vector<const xAOD::JGTower *> &towers = fpgas.at(i);
83
float
rho =
calculateRho
(towers);
84
fpgaRhos.at(i) = rho;
85
for
(
const
xAOD::JGTower
*tower : towers)
86
{
87
float
area
= accArea(*tower);
88
float
etSub = tower->et() -
area
* rho;
89
// output is a shallow copy of input so the indices are guaranteed to be parallel
90
outputTowers->at(tower->index())->setEt(etSub <
threshold
? 0 : etSub);
91
}
92
}
93
94
auto
outputHandle =
SG::makeHandle
(
m_outputKey
, ctx);
95
ATH_CHECK
(outputHandle.record(std::move(outputTowers), std::move(outputTowersAux)));
96
97
// Create an EnergySumRoI container to store the rho values
98
auto
rhoCont = std::make_unique<xAOD::EnergySumRoI>();
99
auto
rhoContAux = std::make_unique<xAOD::EnergySumRoIAuxInfo>();
100
rhoCont->setStore(rhoContAux.get());
101
decRho(*rhoCont) = std::move(fpgaRhos);
102
auto
outputRhoHandle =
SG::makeHandle
(
m_outputRhoKey
, ctx);
103
ATH_CHECK
(outputRhoHandle.record(std::move(rhoCont), std::move(rhoContAux)));
104
return
StatusCode::SUCCESS;
105
}
106
107
float
GTowerRhoSubtractionAlg::calculateRho
(
const
std::vector<const xAOD::JGTower *> &towers)
const
108
{
109
float
totalEt = 0;
110
float
totalArea = 0;
111
for
(
const
xAOD::JGTower
*tower : towers)
112
{
113
if
((
m_useNegativeTowers
|| tower->et() > 0) && tower->et() <=
m_maxTowerEt
)
114
{
115
totalEt += tower->et();
116
totalArea += accArea(*tower);
117
}
118
}
119
float
rho = (totalArea == 0 ? 0.0f : totalEt / totalArea);
120
if
(
m_forcePosRho
&& rho < 0)
121
rho = 0;
122
return
rho;
123
}
124
125
}
// namespace LVL1
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
area
double area(double R)
Definition
ConvertStaveServices.cxx:42
EnergySumRoIAuxInfo.h
GTowerHelpers.h
GTowerRhoSubtractionAlg.h
IParticleHelpers.h
ShallowAuxContainer.h
ShallowCopy.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
LVL1::GTowerRhoSubtractionAlg::m_outputKey
SG::WriteHandleKey< xAOD::JGTowerContainer > m_outputKey
Definition
GTowerRhoSubtractionAlg.h:27
LVL1::GTowerRhoSubtractionAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
GTowerRhoSubtractionAlg.cxx:47
LVL1::GTowerRhoSubtractionAlg::initialize
virtual StatusCode initialize() override
Definition
GTowerRhoSubtractionAlg.cxx:39
LVL1::GTowerRhoSubtractionAlg::~GTowerRhoSubtractionAlg
virtual ~GTowerRhoSubtractionAlg() override
Definition
GTowerRhoSubtractionAlg.cxx:37
LVL1::GTowerRhoSubtractionAlg::m_outputRhoKey
SG::WriteHandleKey< xAOD::EnergySumRoI > m_outputRhoKey
Definition
GTowerRhoSubtractionAlg.h:28
LVL1::GTowerRhoSubtractionAlg::GTowerRhoSubtractionAlg
GTowerRhoSubtractionAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
GTowerRhoSubtractionAlg.cxx:26
LVL1::GTowerRhoSubtractionAlg::m_maxTowerEt
float m_maxTowerEt
Definition
GTowerRhoSubtractionAlg.h:30
LVL1::GTowerRhoSubtractionAlg::m_forcePosRho
bool m_forcePosRho
Definition
GTowerRhoSubtractionAlg.h:31
LVL1::GTowerRhoSubtractionAlg::calculateRho
float calculateRho(const std::vector< const xAOD::JGTower * > &towers) const
Definition
GTowerRhoSubtractionAlg.cxx:107
LVL1::GTowerRhoSubtractionAlg::m_useNegativeTowers
bool m_useNegativeTowers
Definition
GTowerRhoSubtractionAlg.h:29
LVL1::GTowerRhoSubtractionAlg::m_inputKey
SG::ReadHandleKey< xAOD::JGTowerContainer > m_inputKey
Definition
GTowerRhoSubtractionAlg.h:26
LVL1::gFEX::FPGA
FPGA
Definition
GTowerHelpers.h:17
LVL1::gFEX::FPGA::N_FPGAS
@ N_FPGAS
Definition
GTowerHelpers.h:21
LVL1::gFEX::getFPGA
FPGA getFPGA(float eta)
Get the FPGA code from the tower eta.
Definition
GTowerHelpers.cxx:15
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition
IZdcDataAccess.h:13
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
xAOD::JGTower
JGTower_v1 JGTower
Define the latest version of the JGTower class.
Definition
JGTower.h:15
xAOD::shallowCopy
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
xAOD::setOriginalObjectLink
bool setOriginalObjectLink(const IParticle &original, IParticle ©)
This function should be used by CP tools when they make a deep copy of an object in their correctedCo...
Definition
IParticleHelpers.cxx:30
TrigConf::name
Definition
HLTChainList.h:35
threshold
Definition
chainparser.cxx:74
Generated on
for ATLAS Offline Software by
1.17.0