ATLAS Offline Software
Loading...
Searching...
No Matches
GepMETAlg.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4
5#include "./GepMETAlg.h"
7
8GepMETAlg::GepMETAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
9 AthReentrantAlgorithm( name, pSvcLocator ){
10}
11
12
14
15
17 ATH_MSG_INFO ("Initializing " << name() << "...");
18 CHECK(m_caloClustersKey.initialize());
19 CHECK(m_outputMETKey.initialize());
20
21 return StatusCode::SUCCESS;
22}
23
24StatusCode GepMETAlg::finalize() {
25 ATH_MSG_INFO ("Finalizing " << name() << "...");
26 return StatusCode::SUCCESS;
27}
28
29StatusCode 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
Scalar phi() const
phi method
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
virtual void setFilterPassed(bool state, const EventContext &ctx) const
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClustersKey
Definition GepMETAlg.h:22
virtual StatusCode finalize()
Definition GepMETAlg.cxx:24
SG::WriteHandleKey< xAOD::EnergySumRoI > m_outputMETKey
Definition GepMETAlg.h:25
virtual StatusCode execute(const EventContext &) const
Definition GepMETAlg.cxx:29
virtual StatusCode initialize()
Definition GepMETAlg.cxx:16
virtual ~GepMETAlg()
Definition GepMETAlg.cxx:13
GepMETAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition GepMETAlg.cxx:8
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
EnergySumRoIAuxInfo_v2 EnergySumRoIAuxInfo
Declare the most recent version of the energy-sum auxiliary info.
Extra patterns decribing particle interation process.