ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetMonitoring
src
JetHistoResponseAndEff.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
AthenaMonitoringKernel/GenericMonitoringTool.h
"
6
#include "
JetMonitoring/JetHistoResponseAndEff.h
"
7
8
#include "
JetMonitoring/JetMonitoringAlg.h
"
9
#include "
FourMomUtils/xAODP4Helpers.h
"
10
#include "
CxxUtils/minmax_transformed_element.h
"
11
12
JetHistoResponseAndEff::JetHistoResponseAndEff
(
const
std::string&
type
,
const
std::string & name ,
const
IInterface* parent):
13
AthAlgTool
(
type
, name, parent ),
14
m_refContainerKey
(
"REFCONTAINER"
)
15
{
16
declareInterface<IJetHistoFiller>(
this
);
17
declareProperty
(
"RefContainerName"
,
m_refContainerKey
);
18
}
19
20
21
StatusCode
JetHistoResponseAndEff::initialize
() {
22
ATH_CHECK
(
m_refContainerKey
.initialize() );
23
ATH_MSG_DEBUG
(
" initialize "
<<
m_refContainerKey
.key());
24
return
StatusCode::SUCCESS;
25
}
26
27
28
StatusCode
JetHistoResponseAndEff::processJetContainer
(
const
JetMonitoringAlg
& parentAlg,
const
xAOD::JetContainer
& jets,
const
EventContext& ctx )
const
{
29
if
(jets.empty())
return
StatusCode::SUCCESS;
30
31
// retrieve the reference jet container (typically : truth jets)
32
SG::ReadHandle<xAOD::JetContainer>
refJets(
m_refContainerKey
, ctx);
33
if
(! refJets.
isValid
() ) {
34
ATH_MSG_ERROR
(
"evtStore() does not contain jet Collection with name "
<<
m_refContainerKey
.key());
35
return
StatusCode::FAILURE;
36
}
37
38
39
// declare the variables to be monitored by the framework
40
Monitored::Scalar<float>
refPt(
"refPt"
);
41
Monitored::Scalar<float>
refEta(
"refEta"
);
42
Monitored::Scalar<float>
relDiff(
"relDiff"
);
43
Monitored::Scalar<float>
closestDr(
"closestDr"
);
44
Monitored::Scalar<bool>
passDr1(
"passDr1"
);
45
Monitored::Scalar<bool>
passDr2(
"passDr2"
);
46
Monitored::Scalar<bool>
passDr3(
"passDr3"
);
47
48
49
std::vector<const xAOD::Jet*> listJets(jets.begin(), jets.end());
50
51
for
(
const
xAOD::Jet
* refjet : *refJets ){
52
if
(listJets.empty() )
break
;
53
auto
dr2 = [&] (
const
xAOD::Jet
* j)
54
{
return
xAOD::P4Helpers::deltaR2
(*j, *refjet); };
55
auto
[dr2min, itmin] =
CxxUtils::min_transformed_element
(listJets, dr2);
56
57
// calculate efficiency and response from matched jet
58
const
xAOD::Jet
* matched = *itmin;
59
60
// Move the matched entry to the end of the vector and pop it off.
61
auto
itend = listJets.end()-1;
62
if
(itmin != itend) {
63
std::iter_swap
(itmin, itend);
64
}
65
listJets.pop_back();
66
67
double
dr = sqrt(dr2min);
68
refPt = refjet->pt() *
m_energyScale
;
69
closestDr = dr;
70
71
// Set flag passDrX if (reco,truth) jets are closer than deltaR=0.X
72
passDr1 = dr<0.1;
73
passDr2 = dr<0.2;
74
passDr3 = dr<0.3;
75
// using these flags, the framework will fill 3 TEfficiency to draw ( efficiency_at_drX vs pT) (see also configuration) :
76
parentAlg.
fill
(
m_group
, refPt , passDr1, passDr2, passDr3 , closestDr);
77
78
if
( dr < 0.3) {
79
if
(refPt > 0.) relDiff = ( matched->
pt
()*
m_energyScale
- refPt )/refPt;
80
else
relDiff = -999;
81
refEta = refjet->eta();
82
parentAlg.
fill
(
m_group
, refPt , refEta, relDiff );
83
}
84
85
}
86
87
return
StatusCode::SUCCESS;
88
}
89
90
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
GenericMonitoringTool.h
JetHistoResponseAndEff.h
JetMonitoringAlg.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
JetHistoResponseAndEff::m_energyScale
Gaudi::Property< float > m_energyScale
Definition
JetHistoResponseAndEff.h:30
JetHistoResponseAndEff::processJetContainer
virtual StatusCode processJetContainer(const JetMonitoringAlg &parentAlg, const xAOD::JetContainer &jets, const EventContext &ctx) const
Definition
JetHistoResponseAndEff.cxx:28
JetHistoResponseAndEff::m_refContainerKey
SG::ReadHandleKey< xAOD::JetContainer > m_refContainerKey
Definition
JetHistoResponseAndEff.h:31
JetHistoResponseAndEff::m_group
Gaudi::Property< std::string > m_group
Definition
JetHistoResponseAndEff.h:29
JetHistoResponseAndEff::initialize
virtual StatusCode initialize()
Definition
JetHistoResponseAndEff.cxx:21
JetHistoResponseAndEff::JetHistoResponseAndEff
JetHistoResponseAndEff(const std::string &type, const std::string &name, const IInterface *parent)
Definition
JetHistoResponseAndEff.cxx:12
JetMonitoringAlg
A monitoring algorithm in charge of filling histogram for a JetContainer.
Definition
JetMonitoringAlg.h:26
Monitored::Scalar
Declare a monitored scalar variable.
Definition
MonitoredScalar.h:34
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::Jet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition
Jet_v1.cxx:44
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
Definition
AthMonitorAlgorithm.cxx:99
minmax_transformed_element.h
Return the minimum or maximum element from a transformed range.
CxxUtils::min_transformed_element
auto min_transformed_element(RANGE &&r, FUNC &&f)
Find the minimum transformed element in a range.
Definition
minmax_transformed_element.h:50
std::iter_swap
void iter_swap(typename DataModel_detail::iterator< DV > a, typename DataModel_detail::iterator< DV > b)
Specialization of iter_swap for DataVector/DataList.
Definition
DVL_iter_swap.h:36
xAOD::P4Helpers::deltaR2
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Definition
xAODP4Helpers.h:111
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
type
xAODP4Helpers.h
Generated on
for ATLAS Offline Software by
1.17.0