ATLAS Offline Software
Loading...
Searching...
No Matches
METNoiseCutPerfFex.cxx
Go to the documentation of this file.
1
4
7
8namespace 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
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,
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
#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)
METNoiseCutPerfFex(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode runFex(const EventContext &ctx, xAOD::EnergySumRoI &met) const override
SG::ReadHandleKey< xAOD::JGTowerContainer > m_towersKey
virtual ~METNoiseCutPerfFex() override
virtual StatusCode initialize() override
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_noiseAcc
METPerfFexBase(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
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
EnergySumRoI_v2 EnergySumRoI