ATLAS Offline Software
Loading...
Searching...
No Matches
CVFPrepAlg.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#include "CVFPrepAlg.h"
11
12namespace HLT
13{
14 namespace MET
15 {
16 CVFPrepAlg::CVFPrepAlg(const std::string &name, ISvcLocator *pSvcLocator)
17 : AthReentrantAlgorithm(name, pSvcLocator)
18 {
19 }
20
22 {
23 CHECK(m_inputClusterKey.initialize());
24
25 if (m_inputCVFKey.key().find(".") == std::string::npos)
26 m_inputCVFKey = m_inputClusterKey.key() + "." + m_inputCVFKey.key();
27 else if (SG::contKeyFromKey(m_inputCVFKey.key()) != m_inputClusterKey.key())
28 {
29 ATH_MSG_ERROR("CVF key does not match input cluster container key!");
30 return StatusCode::FAILURE;
31 }
32 CHECK(m_inputCVFKey.initialize());
33
34 if (m_outputCategoryKey.key().find(".") == std::string::npos)
37 {
38 ATH_MSG_ERROR("Output category key does not match input cluster container key!");
39 return StatusCode::FAILURE;
40 }
41 CHECK(m_outputCategoryKey.initialize());
42
43 return StatusCode::SUCCESS;
44 }
45
46 StatusCode CVFPrepAlg::execute(const EventContext &ctx) const
47 {
48 auto clusters = SG::makeHandle(m_inputClusterKey, ctx);
49 if (!clusters.isValid())
50 {
51 ATH_MSG_ERROR("Failed to retrieve " << m_inputClusterKey);
52 return StatusCode::FAILURE;
53 }
54 auto accCVF = SG::makeHandle<float>(m_inputCVFKey, ctx);
55 auto decCategory = SG::makeHandle<int>(m_outputCategoryKey, ctx);
56
57 for (const xAOD::CaloCluster *iclus : *clusters)
58 {
59 float CVF = accCVF(*iclus);
60 if (CVF < 0)
61 decCategory(*iclus) = PUClassification::NeutralForward;
62 else if (CVF < m_cvfThreshold)
63 decCategory(*iclus) = PUClassification::ChargedPU;
64 else
65 decCategory(*iclus) = PUClassification::ChargedHS;
66 }
67 return StatusCode::SUCCESS;
68 }
69
70 } // namespace MET
71} // namespace HLT
#define ATH_MSG_ERROR(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Some common helper functions used by decoration handles.
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClusterKey
The input container.
Definition CVFPrepAlg.h:47
virtual StatusCode execute(const EventContext &ctx) const override
CVFPrepAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode initialize() override
SG::WriteDecorHandleKey< xAOD::CaloClusterContainer > m_outputCategoryKey
The output classifcation.
Definition CVFPrepAlg.h:53
SG::ReadDecorHandleKey< xAOD::CaloClusterContainer > m_inputCVFKey
The input CVF key.
Definition CVFPrepAlg.h:50
Gaudi::Property< float > m_cvfThreshold
The CVF threshold.
Definition CVFPrepAlg.h:56
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
std::string contKeyFromKey(const std::string &key)
Extract the container part of key.
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.