ATLAS Offline Software
Loading...
Searching...
No Matches
PFSumFex.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4
5/******************************************************************************
6 * @package Trigger/TrigAlgorithms/TrigEFMissingET
7 * @file PFSumFex.cxx
8 *
9 * Implementation of the PFlow fex class
10 * @author Jon Burr
11 *****************************************************************************/
12
13#include "PFSumFex.h"
15#include <array>
16
17namespace HLT { namespace MET {
18
19 PFSumFex::PFSumFex(const std::string& name, ISvcLocator* pSvcLocator) :
20 FexBase(name, pSvcLocator)
21 {}
22
24 {
25 CHECK( m_neutralPFOKey.initialize() );
26 CHECK( m_chargedPFOKey.initialize() );
27 return initializeBase({"NeutralPFOs", "ChargedHSPFOs", "ChargedPUPFOs"});
28 }
29
32 const EventContext& context,
33 MonGroupBuilder&) const
34 {
35 auto charged = SG::makeHandle(m_chargedPFOKey, context);
36 if (!charged.isValid())
37 {
38 ATH_MSG_ERROR("Failed to retrieve " << m_chargedPFOKey);
39 return StatusCode::FAILURE;
40 }
41 auto neutral = SG::makeHandle(m_neutralPFOKey, context);
42 if (!neutral.isValid())
43 {
44 ATH_MSG_ERROR("Failed to retrieve " << m_neutralPFOKey);
45 return StatusCode::FAILURE;
46 }
47
48 std::array<METComponent, 3> pfoSums;
49 for (const xAOD::IParticle* ipfo : *neutral)
50 // 0 is the 'NeutralPFOs' component
51 pfoSums.at(0) += *ipfo;
52 const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV");
53 for (const xAOD::IParticle* ipfo : *charged)
54 // 1 is the 'ChargedHSPFOs' component, 2 is the 'ChargedPUPFOs' component
55 (PVMatchedAcc(*ipfo) ? pfoSums.at(1) : pfoSums.at(2) ) += *ipfo;
56
57 // Sum together the components
58 METComponent total = pfoSums.at(0) + pfoSums.at(1);
60 total += pfoSums.at(2);
61 total.fillMET(met);
62 for (std::size_t ii = 0; ii < 3; ++ii)
63 pfoSums.at(ii).fillMETComponent(ii, met);
64 return StatusCode::SUCCESS;
65 }
66} } //> end namespace 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.
void fillMET(xAOD::TrigMissingET &met) const
Fill the main component of the MET with this.
virtual StatusCode initialize() override
Initialize the fex.
Definition PFSumFex.cxx:23
virtual StatusCode fillMET(xAOD::TrigMissingET &met, const EventContext &context, MonGroupBuilder &monitors) const override
Calculate and fill the output MET value.
Definition PFSumFex.cxx:30
PFSumFex(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition PFSumFex.cxx:19
SG::ReadHandleKey< xAOD::IParticleContainer > m_chargedPFOKey
Input charged PFOs.
Definition PFSumFex.h:44
SG::ReadHandleKey< xAOD::IParticleContainer > m_neutralPFOKey
Input neutral PFOs.
Definition PFSumFex.h:41
Gaudi::Property< bool > m_chargedOnlyFromPV
Whether to only include charged PFOs that are matched to the PV vertex.
Definition PFSumFex.h:47
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:570
Class providing the definition of the 4-vector interface.
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())
TrigMissingET_v1 TrigMissingET
Define the most recent version of the TrigMissingET class.