ATLAS Offline Software
Loading...
Searching...
No Matches
TCFex.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 TCFex.cxx
8 *
9 * Implementation of the topocluster fex class
10 * @author Jon Burr
11 *****************************************************************************/
12
13#include "TCFex.h"
15#include <array>
16
17namespace {
18 bool isBarrel(const xAOD::CaloCluster* iclus,
20 return fabs(iclus->eta(state) ) < 1.5;
21 }
22}
23
24namespace HLT { namespace MET {
25 TCFex::TCFex(const std::string& name, ISvcLocator* pSvcLocator) :
26 FexBase(name, pSvcLocator)
27 {}
28
29 StatusCode TCFex::initialize()
30 {
31 CHECK( m_clusterKey.initialize() );
32 return initializeBase({"TCB1", "TCB2", "TCE1", "TCE2"});
33 }
34
35 StatusCode TCFex::fillMET(
37 const EventContext& context,
38 MonGroupBuilder&) const
39 {
40 // Retrieve the inputs
41 auto clusters = SG::makeHandle(m_clusterKey, context);
42 if (!clusters.isValid())
43 {
44 ATH_MSG_ERROR("Failed to retrieve " << m_clusterKey);
45 return StatusCode::FAILURE;
46 }
47
48 auto state = m_useUncalibrated ?
51
52 // Prepare the output values
53 std::array<METComponent, 4> tcSums;
54 for (const xAOD::CaloCluster* iclus : *clusters) {
55 // Pick the right component
56 std::size_t componentIdx = 0;
57 if (iclus->eta() < 0)
58 ++componentIdx;
59 if (!isBarrel(iclus, state) )
60 componentIdx += 2;
61 tcSums.at(componentIdx) += SignedKinematics::fromEnergyEtaPhiM(
62 iclus->e(state), iclus->eta(state), iclus->phi(state),
63 m_useUncalibrated ? iclus->rawM() : iclus->calM() );
64 }
65 // Save the total
66 std::accumulate(tcSums.begin(), tcSums.end(), METComponent{}).fillMET(met);
67
68 // Save each component
69 for (std::size_t ii = 0; ii < 4; ++ii)
70 tcSums.at(ii).fillMETComponent(ii, met);
71
72 return StatusCode::SUCCESS;
73 }
74} } //> 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.
static SignedKinematics fromEnergyEtaPhiM(double energy, double eta, double phi, double mass)
Factory function to construct from energy eta, phi and m.
Gaudi::Property< bool > m_useUncalibrated
Whether to use the uncalibrated clusters or not.
Definition TCFex.h:50
TCFex(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition TCFex.cxx:25
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clusterKey
Input clusters.
Definition TCFex.h:41
virtual StatusCode fillMET(xAOD::TrigMissingET &met, const EventContext &context, MonGroupBuilder &monitors) const override
Calculate and fill the output MET value.
Definition TCFex.cxx:35
virtual StatusCode initialize() override
Initialize the fex.
Definition TCFex.cxx:29
State
enum of possible signal states.
virtual double eta() const
The pseudorapidity ( ) of the particle.
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())
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrigMissingET_v1 TrigMissingET
Define the most recent version of the TrigMissingET class.