ATLAS Offline Software
METJWoJPerfFex.cxx
Go to the documentation of this file.
1 
5 #include "METJWoJPerfFex.h"
6 #include "StoreGate/ReadHandle.h"
8 #include "GaudiKernel/SystemOfUnits.h"
9 #include "GTowerHelpers.h"
10 
11 namespace
12 {
13  const static SG::AuxElement::ConstAccessor<std::vector<float>> accRho("FPGARhos");
14  const static SG::AuxElement::ConstAccessor<float> accArea("area");
15 } // namespace
16 
17 namespace 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,
63  xAOD::EnergySumRoI &met) const
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
xAOD::JGTower_v1
Description of JGTower_v1.
Definition: JGTower_v1.h:46
LVL1::gFEX::getFPGA
FPGA getFPGA(float eta)
Get the FPGA code from the tower eta.
Definition: GTowerHelpers.cxx:15
LVL1::METPerfFexBase
Definition: METPerfFexBase.h:16
LVL1::METJWoJPerfFex::m_cxValues
std::vector< float > m_cxValues
Definition: METJWoJPerfFex.h:40
fitman.ax
ax
Definition: fitman.py:522
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LVL1::METJWoJPerfFex::m_gblocksKey
SG::ReadHandleKey< xAOD::GBlockContainer > m_gblocksKey
Definition: METJWoJPerfFex.h:28
xAOD::GBlock_v1
Definition: GBlock_v1.h:17
LVL1::METJWoJPerfFex::m_axValues
std::vector< float > m_axValues
Definition: METJWoJPerfFex.h:36
EnergySumRoIAuxInfo.h
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
GTowerHelpers.h
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::METJWoJPerfFex::m_byValues
std::vector< float > m_byValues
Definition: METJWoJPerfFex.h:39
xAOD::energyY
energyY
Definition: EnergySumRoI_v1.cxx:139
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
PlotCalibFromCool.cx
cx
Definition: PlotCalibFromCool.py:666
met
Definition: IMETSignificance.h:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1::METJWoJPerfFex::m_mhtKey
SG::WriteHandleKey< xAOD::EnergySumRoI > m_mhtKey
Definition: METJWoJPerfFex.h:29
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LVL1::METJWoJPerfFex::m_cyValues
std::vector< float > m_cyValues
Definition: METJWoJPerfFex.h:41
fitman.bx
bx
Definition: fitman.py:410
LVL1::METJWoJPerfFex::m_useRho
bool m_useRho
Definition: METJWoJPerfFex.h:33
METJWoJPerfFex.h
LVL1::METPerfFexBase::initialize
virtual StatusCode initialize() override
Definition: METPerfFexBase.cxx:21
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
fitman.by
by
Definition: fitman.py:411
LVL1::METJWoJPerfFex::m_mstKey
SG::WriteHandleKey< xAOD::EnergySumRoI > m_mstKey
Definition: METJWoJPerfFex.h:30
TrigConf::name
Definition: HLTChainList.h:35
LVL1::METJWoJPerfFex::~METJWoJPerfFex
virtual ~METJWoJPerfFex() override
Definition: METJWoJPerfFex.cxx:38
LVL1::METJWoJPerfFex::m_useNegativeTowers
bool m_useNegativeTowers
Definition: METJWoJPerfFex.h:32
LVL1::METJWoJPerfFex::runFex
virtual StatusCode runFex(const EventContext &ctx, xAOD::EnergySumRoI &met) const override
Definition: METJWoJPerfFex.cxx:61
LVL1::METJWoJPerfFex::m_ptConeCut
float m_ptConeCut
Definition: METJWoJPerfFex.h:31
LVL1::METJWoJPerfFex::m_rhoKey
SG::ReadHandleKey< xAOD::EnergySumRoI > m_rhoKey
Definition: METJWoJPerfFex.h:34
LVL1::METJWoJPerfFex::METJWoJPerfFex
METJWoJPerfFex(const std::string &name, ISvcLocator *pSvcLocator)
Definition: METJWoJPerfFex.cxx:19
PlotCalibFromCool.cy
cy
Definition: PlotCalibFromCool.py:667
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
LVL1::METJWoJPerfFex::initialize
virtual StatusCode initialize() override
Definition: METJWoJPerfFex.cxx:40
LVL1::METJWoJPerfFex::m_sumEtThresholds
std::vector< float > m_sumEtThresholds
Definition: METJWoJPerfFex.h:35
LVL1::gFEX::FPGA
FPGA
Definition: GTowerHelpers.h:17
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
ReadHandle.h
Handle class for reading from StoreGate.
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
xAOD::EnergySumRoI_v2
Class describing a LVL1 energy-sum "RoI".
Definition: EnergySumRoI_v2.h:35
LVL1::METJWoJPerfFex::m_ayValues
std::vector< float > m_ayValues
Definition: METJWoJPerfFex.h:37
fitman.rho
rho
Definition: fitman.py:532
fitman.ay
ay
Definition: fitman.py:525
LVL1::METJWoJPerfFex::m_bxValues
std::vector< float > m_bxValues
Definition: METJWoJPerfFex.h:38