ATLAS Offline Software
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"
7 #include "StoreGate/ReadHandle.h"
11 
12 namespace HLT
13 {
14  namespace MET
15  {
16  CVFPrepAlg::CVFPrepAlg(const std::string &name, ISvcLocator *pSvcLocator)
17  : AthReentrantAlgorithm(name, pSvcLocator)
18  {
19  }
20 
22  {
24 
25  if (m_inputCVFKey.key().find(".") == std::string::npos)
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  {
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
SG::contKeyFromKey
std::string contKeyFromKey(const std::string &key)
Extract the container part of key.
Definition: DecorKeyHelpers.cxx:26
CVFPrepAlg.h
HLT::MET::CVFPrepAlg::CVFPrepAlg
CVFPrepAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: CVFPrepAlg.cxx:16
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DecorKeyHelpers.h
Some common helper functions used by decoration handles.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HLT::MET::PUClassification::ChargedHS
@ ChargedHS
Definition: PUClassification.h:20
WriteDecorHandle.h
Handle class for adding a decoration to an object.
TCS::MET
@ MET
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Types.h:16
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
HLT::MET::CVFPrepAlg::m_outputCategoryKey
SG::WriteDecorHandleKey< xAOD::CaloClusterContainer > m_outputCategoryKey
The output classifcation.
Definition: CVFPrepAlg.h:78
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HLT::MET::PUClassification::ChargedPU
@ ChargedPU
Definition: PUClassification.h:19
HLT::MET::CVFPrepAlg::m_inputClusterKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClusterKey
The input container.
Definition: CVFPrepAlg.h:72
HLT::MET::CVFPrepAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: CVFPrepAlg.cxx:46
PUClassification.h
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
HLT::MET::CVFPrepAlg::m_cvfThreshold
Gaudi::Property< float > m_cvfThreshold
The CVF threshold.
Definition: CVFPrepAlg.h:81
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ReadHandle.h
Handle class for reading from StoreGate.
HLT::MET::CVFPrepAlg::m_inputCVFKey
SG::ReadDecorHandleKey< xAOD::CaloClusterContainer > m_inputCVFKey
The input CVF key.
Definition: CVFPrepAlg.h:75
HLT::MET::CVFPrepAlg::initialize
virtual StatusCode initialize() override
Definition: CVFPrepAlg.cxx:21
HLT::MET::PUClassification::NeutralForward
@ NeutralForward
Definition: PUClassification.h:18