ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigAlgorithms
TrigEFMissingET
src
NNHLTFex.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
/******************************************************************************
6
* @package Trigger/TrigAlgorithms/TrigEFMissingET
7
* @file NNHLTFex.cxx
8
*
9
* Implementation of the HLT NN combination fex class
10
* @author Zhelun Li
11
*****************************************************************************/
12
13
#include "
NNHLTFex.h
"
14
#include "
TrigEFMissingET/METComponent.h
"
15
#include <array>
16
#include "
PathResolver/PathResolver.h
"
17
#include "GaudiKernel/SystemOfUnits.h"
18
#include <istream>
19
#include <fstream>
20
21
namespace
HLT::MET
{
22
23
NNHLTFex::NNHLTFex
(
const
std::string& name, ISvcLocator* pSvcLocator) :
24
FexBase
(name, pSvcLocator),
25
m_graphNN
(nullptr)
26
{
27
}
28
29
StatusCode
NNHLTFex::initialize
()
30
{
31
std::string fullName =
PathResolver::find_calib_file
(
m_filename
);
32
if
(fullName.empty()){
33
ATH_MSG_ERROR
(
"Failed to find NN configuration file'"
<<
m_filename
<<
"'!"
);
34
return
StatusCode::FAILURE;
35
}
36
std::ifstream inputNN(fullName);
37
m_configNN
= lwt::parse_json_graph(inputNN);
38
if
(
m_configNN
.inputs.size() != 1)
return
StatusCode::FAILURE;
//only one input node allowed
39
m_graphNN
= std::make_unique<lwt::LightweightGraph>(
m_configNN
);
40
CHECK
(
m_triggerMETs
.initialize());
41
return
initializeBase
({
"HLTMET"
});
42
}
43
44
StatusCode
NNHLTFex::fillMET
(
45
xAOD::TrigMissingET
&
met
,
46
const
EventContext& context,
47
MonGroupBuilder
&)
const
48
{
49
//for lwtnn:
50
std::map<std::string, std::map<std::string, double> > inputs;
51
for
(
const
SG::ReadHandleKey<xAOD::TrigMissingETContainer>
&key :
m_triggerMETs
)
52
{
53
std::string name = key.key();
54
SG::ReadHandle<xAOD::TrigMissingETContainer>
met
=
SG::makeHandle
(key,context);
55
if
(!
met
.isValid())
56
{
57
ATH_MSG_ERROR
(
"Failed to retrieve "
<< key);
58
return
StatusCode::FAILURE;
59
}
60
61
if
(
met
->size() == 0)
62
{
63
inputs[
"node_0"
].insert(std::pair<std::string, double>(name+
".met"
,-1) );
64
inputs[
"node_0"
].insert(std::pair<std::string, double>(name+
".sumet"
,-1) );
65
}
66
else
67
{
68
const
xAOD::TrigMissingET
&metObj = *(
met
->at(0));
69
float
mpx = metObj.
ex
();
70
float
mpy = metObj.
ey
();
71
inputs[
"node_0"
].insert(std::pair<std::string, double>(name+
".met"
,sqrt(mpx * mpx + mpy * mpy)/Gaudi::Units::GeV) );
72
inputs[
"node_0"
].insert(std::pair<std::string, double>(name+
".sumet"
,metObj.
sumEt
()/Gaudi::Units::GeV) );
73
}
74
}
75
76
std::map<std::string, double> outputNN =
m_graphNN
->compute(inputs);
77
auto
NN_MET=outputNN[
"out_0"
]*Gaudi::Units::GeV;
78
//The NN only estimates the MET. Setting to mpx. But this means that only the total MET makes sense. mpx,mpy,mpz,sumEt
79
// are no available. Be careful!
80
met
.setEx(NN_MET);
81
82
return
StatusCode::SUCCESS;
83
}
84
}
//> end namespace HLT::MET
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
METComponent.h
NNHLTFex.h
PathResolver.h
HLT::MET::FexBase::FexBase
FexBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
FexBase.cxx:43
HLT::MET::FexBase::initializeBase
StatusCode initializeBase(const std::vector< std::string > &componentNames)
Initialize the base class.
Definition
FexBase.cxx:48
HLT::MET::MonGroupBuilder
Definition
MonGroupBuilder.h:33
HLT::MET::NNHLTFex::initialize
virtual StatusCode initialize() override
Initialize the fex.
Definition
NNHLTFex.cxx:29
HLT::MET::NNHLTFex::m_configNN
lwt::GraphConfig m_configNN
Definition
NNHLTFex.h:52
HLT::MET::NNHLTFex::m_graphNN
std::unique_ptr< lwt::LightweightGraph > m_graphNN
Definition
NNHLTFex.h:53
HLT::MET::NNHLTFex::NNHLTFex
NNHLTFex(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
NNHLTFex.cxx:23
HLT::MET::NNHLTFex::m_filename
Gaudi::Property< std::string > m_filename
Definition
NNHLTFex.h:49
HLT::MET::NNHLTFex::fillMET
virtual StatusCode fillMET(xAOD::TrigMissingET &met, const EventContext &context, MonGroupBuilder &monitors) const override
Calculate and fill the output MET value.
Definition
NNHLTFex.cxx:44
HLT::MET::NNHLTFex::m_triggerMETs
SG::ReadHandleKeyArray< xAOD::TrigMissingETContainer > m_triggerMETs
Definition
NNHLTFex.h:47
PathResolver::find_calib_file
static std::string find_calib_file(const std::string &logical_file_name)
Definition
PathResolver.cxx:272
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition
StoreGate/StoreGate/ReadHandleKey.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
xAOD::TrigMissingET_v1::ex
float ex() const
Get the x component of the missing energy.
xAOD::TrigMissingET_v1::sumEt
float sumEt() const
Get the sum of the ET of the missing energy.
xAOD::TrigMissingET_v1::ey
float ey() const
Get the y component of the missing energy.
HLT::MET
Definition
METComponent.cxx:8
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
met
Definition
IMETSignificance.h:24
xAOD::TrigMissingET
TrigMissingET_v1 TrigMissingET
Define the most recent version of the TrigMissingET class.
Definition
Event/xAOD/xAODTrigMissingET/xAODTrigMissingET/TrigMissingET.h:12
Generated on
for ATLAS Offline Software by
1.17.0