ATLAS Offline Software
Loading...
Searching...
No Matches
MHTFex.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4
5/******************************************************************************
6 * @package Trigger/TrigAlgorithms/TrigEFMissingET
7 * @file MHTFex.cxx
8 *
9 * Implementation of the mht fex class
10 * @author Jon Burr
11 *****************************************************************************/
12
13#include "MHTFex.h"
15#include <array>
16
17namespace HLT { namespace MET {
18 MHTFex::MHTFex(const std::string& name, ISvcLocator* pSvcLocator) :
19 FexBase(name, pSvcLocator)
20 {}
21
22 StatusCode MHTFex::initialize()
23 {
24 CHECK( m_jetKey.initialize() );
25 return initializeBase({"JETB1", "JETB2", "JETE1", "JETE2"});
26 }
27
28 StatusCode MHTFex::fillMET(
30 const EventContext& context,
31 MonGroupBuilder&) const
32 {
33 // Retrieve the inputs
34 auto jets = SG::makeHandle(m_jetKey, context);
35 if (!jets.isValid())
36 {
37 ATH_MSG_ERROR("Failed to retrieve " << m_jetKey);
38 return StatusCode::FAILURE;
39 }
40
41 // Prepare the output values
42 std::array<METComponent, 4> mhtSums;
43 for (const xAOD::Jet* ijet : *jets) {
44 // Apply the pT selection
45 if (ijet->pt() < (isCentral(ijet) ? m_centralPtCut : m_forwardPtCut) )
46 continue;
47 // Get the right MET component
48 std::size_t componentIdx = 0;
49 if (ijet->eta() < 0)
50 ++componentIdx;
51 if (!isCentral(ijet) )
52 componentIdx += 2;
53 mhtSums.at(componentIdx) += ijet->p4();
54 }
55
56 // Save the full sum
57 std::accumulate(mhtSums.begin(), mhtSums.end(), METComponent{}).fillMET(met);
58 // Save each component
59 for (std::size_t ii = 0; ii < 4; ++ii)
60 mhtSums.at(ii).fillMETComponent(ii, met);
61
62 return StatusCode::SUCCESS;
63 }
64} } //> end class HLT::MET
#define ATH_MSG_ERROR(x)
#define CHECK(...)
Evaluate an expression and check for errors.
FexBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition FexBase.cxx:43
StatusCode initializeBase(const std::vector< std::string > &componentNames)
Initialize the base class.
Definition FexBase.cxx:48
Helper struct to build up MET values before moving them into the EDM.
SG::ReadHandleKey< xAOD::JetContainer > m_jetKey
Input jets.
Definition MHTFex.h:41
MHTFex(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition MHTFex.cxx:18
virtual StatusCode fillMET(xAOD::TrigMissingET &met, const EventContext &context, MonGroupBuilder &monitors) const override
Calculate and fill the output MET value.
Definition MHTFex.cxx:28
Gaudi::Property< float > m_forwardPtCut
Forward pT cut.
Definition MHTFex.h:51
bool isCentral(const xAOD::Jet *ijet) const
Is a jet central or forward.
Definition MHTFex.h:69
virtual StatusCode initialize() override
Initialize the fex.
Definition MHTFex.cxx:22
Gaudi::Property< float > m_centralPtCut
Central pT cut.
Definition MHTFex.h:48
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Jet_v1 Jet
Definition of the current "jet version".
TrigMissingET_v1 TrigMissingET
Define the most recent version of the TrigMissingET class.