ATLAS Offline Software
GepMETAlg.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #include "./GepMETAlg.h"
7 
8 GepMETAlg::GepMETAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
9  AthReentrantAlgorithm( name, pSvcLocator ){
10 }
11 
12 
14 
15 
17  ATH_MSG_INFO ("Initializing " << name() << "...");
19  CHECK(m_outputMETKey.initialize());
20 
21  return StatusCode::SUCCESS;
22 }
23 
25  ATH_MSG_INFO ("Finalizing " << name() << "...");
26  return StatusCode::SUCCESS;
27 }
28 
29 StatusCode GepMETAlg::execute(const EventContext& context) const {
30  ATH_MSG_DEBUG ("Executing " << name() << "...");
31  setFilterPassed(false, context);
32 
33 
34  // read in clusters
35  auto h_caloClusters = SG::makeHandle(m_caloClustersKey, context);
36  CHECK(h_caloClusters.isValid());
37  ATH_MSG_DEBUG("Read in " << h_caloClusters->size() << " clusters");
38 
39  const auto& caloClusters = *h_caloClusters;
40 
41  float Ex = 0.;
42  float Ey = 0.;
43  float totalEt =0.;
44 
45  for ( const auto& cluster : caloClusters ) {
46  float et = cluster->et();
47  float phi = cluster->phi();
48 
49  Ex -= et * TMath::Cos(phi);
50  Ey -= et * TMath::Sin(phi);
51  totalEt += et;
52  }
53 
54  ATH_MSG_DEBUG( "Calculated MET Ex,Ey: " << Ex << "," << Ey);
55 
56  // write out the MET object
57  auto h_outputMET = SG::makeHandle(m_outputMETKey, context);
58 
59  auto METObj = std::make_unique<xAOD::EnergySumRoI>();
60  METObj->setStore(new xAOD::EnergySumRoIAuxInfo());
61  METObj->setEnergyX(Ex);
62  METObj->setEnergyY(Ey);
63  METObj->setEnergyT(totalEt);
64 
65  h_outputMET = std::move(METObj);
66 
67  setFilterPassed(true, context);
68  ATH_MSG_DEBUG("No of MET objects: 1");
69 
70  return StatusCode::SUCCESS;
71 }
72 
73 
GepMETAlg.h
GepMETAlg::m_caloClustersKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClustersKey
Definition: GepMETAlg.h:22
et
Extra patterns decribing particle interation process.
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
GepMETAlg::~GepMETAlg
virtual ~GepMETAlg()
Definition: GepMETAlg.cxx:13
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
EnergySumRoIAuxInfo.h
GepMETAlg::GepMETAlg
GepMETAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GepMETAlg.cxx:8
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::EnergySumRoIAuxInfo_v2
Auxiliary store for an EnergySum RoI object.
Definition: EnergySumRoIAuxInfo_v2.h:34
GepMETAlg::initialize
virtual StatusCode initialize()
Definition: GepMETAlg.cxx:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
GepMETAlg::finalize
virtual StatusCode finalize()
Definition: GepMETAlg.cxx:24
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
GepMETAlg::m_outputMETKey
SG::WriteHandleKey< xAOD::EnergySumRoI > m_outputMETKey
Definition: GepMETAlg.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
GepMETAlg::execute
virtual StatusCode execute(const EventContext &) const
Definition: GepMETAlg.cxx:29
AthReentrantAlgorithm::setFilterPassed
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Definition: AthReentrantAlgorithm.h:139