ATLAS Offline Software
METNoiseCutPerfFex.cxx
Go to the documentation of this file.
1 
5 #include "METNoiseCutPerfFex.h"
6 #include "StoreGate/ReadHandle.h"
7 
8 namespace LVL1
9 {
10  METNoiseCutPerfFex::METNoiseCutPerfFex(const std::string &name, ISvcLocator *pSvcLocator)
11  : METPerfFexBase(name, pSvcLocator)
12  {
13  declareProperty("InputTowers", m_towersKey, "Input JG towers");
14  declareProperty("InputTowerNoise", m_noiseName = "", "Input JG tower noise values (if used)");
15  declareProperty("UseNegativeTowers", m_useNegativeTowers = true, "Whether to use negative towers");
16  }
17 
19  {
20  }
21 
23  {
25  ATH_CHECK(m_towersKey.initialize());
26  if (!m_noiseName.empty())
27  m_noiseAcc = std::make_unique<SG::AuxElement::ConstAccessor<float>>(m_noiseName);
28  return StatusCode::SUCCESS;
29  }
30 
32  const EventContext &ctx,
33  xAOD::EnergySumRoI &met) const
34  {
35  auto towers = SG::makeHandle(m_towersKey, ctx);
36  if (!towers.isValid())
37  {
38  ATH_MSG_ERROR("Failed to retrieve " << towers);
39  return StatusCode::FAILURE;
40  }
41  float mpx = 0;
42  float mpy = 0;
43  float sumEt = 0;
44  for (const xAOD::JGTower *tower : *towers)
45  {
46  // Negative tower selection
47  if (!m_useNegativeTowers && tower->et() < 0)
48  continue;
49 
50  // Tower noise selection
51  if (m_noiseAcc)
52  {
53  if (tower->sampling() == 0)
54  {
55  if (std::abs(tower->eta()) < 3.2 && std::abs(tower->et()) < 4.5 * (*m_noiseAcc)(*tower))
56  continue;
57  }
58  else if (tower->et() < 5 * (*m_noiseAcc)(*tower))
59  continue;
60  }
61  sumEt += tower->et();
62  mpx -= tower->et() * std::cos(tower->phi());
63  mpy -= tower->et() * std::sin(tower->phi());
64  }
65 
66  // Technically the energy X value should be the negative of mpx but I think
67  // that this is how it's done in the current code
68  met.setEnergyX(mpx);
69  met.setEnergyY(mpy);
70  met.setEnergyT(sumEt);
71  return StatusCode::SUCCESS;
72  }
73 } // namespace LVL1
xAOD::JGTower_v1
Description of JGTower_v1.
Definition: JGTower_v1.h:46
LVL1::METPerfFexBase
Definition: METPerfFexBase.h:16
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LVL1::METNoiseCutPerfFex::m_useNegativeTowers
bool m_useNegativeTowers
Definition: METNoiseCutPerfFex.h:30
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::METNoiseCutPerfFex::METNoiseCutPerfFex
METNoiseCutPerfFex(const std::string &name, ISvcLocator *pSvcLocator)
Definition: METNoiseCutPerfFex.cxx:10
LVL1::METNoiseCutPerfFex::~METNoiseCutPerfFex
virtual ~METNoiseCutPerfFex() override
Definition: METNoiseCutPerfFex.cxx:18
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
met
Definition: IMETSignificance.h:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1::METNoiseCutPerfFex::m_noiseName
std::string m_noiseName
Definition: METNoiseCutPerfFex.h:29
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LVL1::METPerfFexBase::initialize
virtual StatusCode initialize() override
Definition: METPerfFexBase.cxx:21
METNoiseCutPerfFex.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigConf::name
Definition: HLTChainList.h:35
LVL1::METNoiseCutPerfFex::initialize
virtual StatusCode initialize() override
Definition: METNoiseCutPerfFex.cxx:22
RunTileMonitoring.towers
towers
Definition: RunTileMonitoring.py:133
LVL1::METNoiseCutPerfFex::runFex
virtual StatusCode runFex(const EventContext &ctx, xAOD::EnergySumRoI &met) const override
Definition: METNoiseCutPerfFex.cxx:31
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
ReadHandle.h
Handle class for reading from StoreGate.
LVL1::METNoiseCutPerfFex::m_towersKey
SG::ReadHandleKey< xAOD::JGTowerContainer > m_towersKey
Definition: METNoiseCutPerfFex.h:28
xAOD::EnergySumRoI_v2
Class describing a LVL1 energy-sum "RoI".
Definition: EnergySumRoI_v2.h:35
LVL1::METNoiseCutPerfFex::m_noiseAcc
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_noiseAcc
Definition: METNoiseCutPerfFex.h:32