ATLAS Offline Software
Loading...
Searching...
No Matches
METJWoJPerfFex.cxx
Go to the documentation of this file.
1
4
5#include "METJWoJPerfFex.h"
8#include "GaudiKernel/SystemOfUnits.h"
9#include "GTowerHelpers.h"
10
11namespace
12{
13 const static SG::AuxElement::ConstAccessor<std::vector<float>> accRho("FPGARhos");
14 const static SG::AuxElement::ConstAccessor<float> accArea("area");
15} // namespace
16
17namespace LVL1
18{
19 METJWoJPerfFex::METJWoJPerfFex(const std::string &name, ISvcLocator *pSvcLocator)
20 : METPerfFexBase(name, pSvcLocator)
21 {
22 declareProperty("InputGBlocks", m_gblocksKey, "Input gBlocks");
23 declareProperty("OutputMHT", m_mhtKey, "Output container for the hard term");
24 declareProperty("OutputMST", m_mstKey, "Output container for the soft term");
25 declareProperty("PtConeCut", m_ptConeCut = 25 * Gaudi::Units::GeV, "Cone threshold to separate hard and soft terms");
26 declareProperty("UseNegativeTowers", m_useNegativeTowers = true);
27 declareProperty("UseRho", m_useRho = false);
28 declareProperty("InputRho", m_rhoKey);
29 declareProperty("SumEtThresholds", m_sumEtThresholds = {});
30 declareProperty("axValues", m_axValues = {0.98});
31 declareProperty("ayValues", m_ayValues = {0.98});
32 declareProperty("bxValues", m_bxValues = {0.4});
33 declareProperty("byValues", m_byValues = {0.4});
34 declareProperty("cxValues", m_cxValues = {0.0});
35 declareProperty("cyValues", m_cyValues = {0.0});
36 }
37
39
41 {
43 ATH_CHECK(m_gblocksKey.initialize());
44 ATH_CHECK(m_mhtKey.initialize());
45 ATH_CHECK(m_mstKey.initialize());
46 if (m_useRho)
47 ATH_CHECK(m_rhoKey.initialize());
48 if (m_axValues.size() != m_sumEtThresholds.size() + 1 ||
49 m_ayValues.size() != m_sumEtThresholds.size() + 1 ||
50 m_bxValues.size() != m_sumEtThresholds.size() + 1 ||
51 m_byValues.size() != m_sumEtThresholds.size() + 1 ||
52 m_cxValues.size() != m_sumEtThresholds.size() + 1 ||
53 m_cyValues.size() != m_sumEtThresholds.size() + 1)
54 {
55 ATH_MSG_ERROR("Incorrect number of algorithm parameter values given number of sumEt thresholds");
56 return StatusCode::FAILURE;
57 }
58 return StatusCode::SUCCESS;
59 }
60
62 const EventContext &ctx,
64 {
65 auto gblocks = SG::makeHandle(m_gblocksKey, ctx);
66 if (!gblocks.isValid())
67 {
68 ATH_MSG_ERROR("Failed to retrieve " << m_gblocksKey.key());
69 return StatusCode::FAILURE;
70 }
71 std::vector<float> rhos;
72 if (m_useRho)
73 {
74 auto rhoCont = SG::makeHandle(m_rhoKey, ctx);
75 if (!rhoCont.isValid())
76 {
77 ATH_MSG_ERROR("Failed to retrieve " << m_rhoKey.key());
78 return StatusCode::FAILURE;
79 }
80 rhos = accRho(*rhoCont);
81 }
82
83 float HTx = 0;
84 float HTy = 0;
85 float sumHT = 0;
86 float STx = 0;
87 float STy = 0;
88 float sumST = 0;
89 float sumEt = 0;
90
91 for (const xAOD::GBlock *iblock : *gblocks)
92 {
93 const xAOD::JGTower *seed = iblock->seedTower();
94 if (!seed)
95 {
96 ATH_MSG_ERROR("Could not retrieve seed tower!");
97 return StatusCode::FAILURE;
98 }
99 float seedEt = seed->et();
100 if (!m_useNegativeTowers && seedEt < 0)
101 // Skip blocks with negative seeds
102 continue;
103 // Compute global variables
104 sumEt += seedEt;
105 if (iblock->pt() > m_ptConeCut)
106 {
107 if (m_useRho)
108 {
109 gFEX::FPGA fpga = gFEX::getFPGA(seed->eta());
110 float rho = rhos.at(static_cast<std::size_t>(fpga));
111 seedEt -= rho * accArea(*seed);
112 if (seedEt < 0)
113 seedEt = 0;
114 }
115 HTx += seedEt * std::cos(seed->phi());
116 HTy += seedEt * std::sin(seed->phi());
117 sumHT += seedEt;
118 }
119 else
120 {
121 STx += seedEt * std::cos(seed->phi());
122 STy += seedEt * std::sin(seed->phi());
123 sumST += seedEt;
124 }
125 }
126 // Select the correct a/b/c values
127 float ax = m_axValues.back();
128 float ay = m_ayValues.back();
129 float bx = m_bxValues.back();
130 float by = m_byValues.back();
131 float cx = m_cxValues.back();
132 float cy = m_cyValues.back();
133 for (std::size_t idx = 0; idx < m_sumEtThresholds.size(); ++idx)
134 {
135 if (sumEt <= m_sumEtThresholds.at(idx))
136 {
137 ax = m_axValues.at(idx);
138 ay = m_ayValues.at(idx);
139 bx = m_bxValues.at(idx);
140 by = m_byValues.at(idx);
141 cx = m_cxValues.at(idx);
142 cy = m_cyValues.at(idx);
143 break;
144 }
145 }
146 float energyX = ax * HTx + bx * STx + cx;
147 float energyY = ay * HTy + by * STy + cy;
148 met.setEnergyX(energyX);
149 met.setEnergyY(energyY);
150 met.setEnergyT(sumEt);
151
152 auto mht = std::make_unique<xAOD::EnergySumRoI>();
153 auto mhtAux = std::make_unique<xAOD::EnergySumRoIAuxInfo>();
154 mht->setStore(mhtAux.get());
155 mht->setEnergyX(HTx);
156 mht->setEnergyY(HTy);
157 mht->setEnergyT(sumHT);
158 auto mhtHandle = SG::makeHandle(m_mhtKey, ctx);
159 ATH_CHECK(mhtHandle.record(std::move(mht), std::move(mhtAux)));
160
161 auto mst = std::make_unique<xAOD::EnergySumRoI>();
162 auto mstAux = std::make_unique<xAOD::EnergySumRoIAuxInfo>();
163 mst->setStore(mstAux.get());
164 mst->setEnergyX(STx);
165 mst->setEnergyY(STy);
166 mst->setEnergyT(sumST);
167 auto mstHandle = SG::makeHandle(m_mstKey, ctx);
168 ATH_CHECK(mstHandle.record(std::move(mst), std::move(mstAux)));
169
170 return StatusCode::SUCCESS;
171 }
172} // namespace LVL1
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Handle class for reading from StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< float > m_bxValues
std::vector< float > m_sumEtThresholds
std::vector< float > m_axValues
virtual StatusCode runFex(const EventContext &ctx, xAOD::EnergySumRoI &met) const override
virtual StatusCode initialize() override
std::vector< float > m_cyValues
SG::ReadHandleKey< xAOD::GBlockContainer > m_gblocksKey
SG::WriteHandleKey< xAOD::EnergySumRoI > m_mhtKey
std::vector< float > m_ayValues
virtual ~METJWoJPerfFex() override
METJWoJPerfFex(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< float > m_byValues
SG::WriteHandleKey< xAOD::EnergySumRoI > m_mstKey
std::vector< float > m_cxValues
SG::ReadHandleKey< xAOD::EnergySumRoI > m_rhoKey
METPerfFexBase(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
FPGA getFPGA(float eta)
Get the FPGA code from the tower eta.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
JGTower_v1 JGTower
Define the latest version of the JGTower class.
Definition JGTower.h:15
GBlock_v1 GBlock
Define the latest version of the GBlock class.
Definition GBlock.h:15
EnergySumRoI_v2 EnergySumRoI