ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetMissingEtID
JetSelectorTools
Root
EventCleaningTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/******************************************************************************
6
Name: EventCleaningTool
7
8
Author: Julia Gonski
9
Created: Nov 2016
10
11
Description: Class for selecting events that pass recommended jet cleaning procedure
12
******************************************************************************/
13
14
// This class header and package headers
15
#include "
JetSelectorTools/EventCleaningTool.h
"
16
#include "
JetSelectorTools/JetCleaningTool.h
"
17
#include "
JetSelectorTools/Helpers.h
"
18
19
// The xAOD jet type
20
#include "
xAODJet/Jet.h
"
21
#include "
xAODEventInfo/EventInfo.h
"
22
23
// xAOD/ASG includes
24
#include "
AsgMessaging/AsgMessaging.h
"
25
#include "
AsgDataHandles/ReadDecorHandle.h
"
26
#include "
AsgDataHandles/WriteDecorHandle.h
"
27
28
29
// STL includes
30
#include <iostream>
31
#include <cmath>
32
#include <cfloat>
33
34
// ROOT includes
35
#include "TEnv.h"
36
37
namespace
ECUtils
{
38
39
//=============================================================================
40
// Constructors
41
//=============================================================================
42
EventCleaningTool::EventCleaningTool
(
const
std::string& name)
43
:
asg
::
AsgTool
(name)
44
,
m_jetCleaningTool
(
"JetCleaningTool/JetCleaningTool"
)
45
{
46
m_jetCleaningTool
.declarePropertyFor(
this
,
"JetCleaningTool"
);
47
}
48
49
50
//=============================================================================
51
// Destructor
52
//=============================================================================
53
EventCleaningTool::~EventCleaningTool
() {}
54
55
//=============================================================================
56
// Initialize
57
//=============================================================================
58
StatusCode
EventCleaningTool::initialize
()
59
{
60
if
(
m_passJvtKey
.key() ==
""
||
m_passORKey
.key() ==
""
){
61
ATH_MSG_ERROR
(
"Tool initialized with unknown decorator names."
);
62
return
StatusCode::FAILURE;
63
}
64
if
(
m_cleaningLevel
==
""
){
65
ATH_MSG_ERROR
(
"Tool initialized with unknown cleaning level."
);
66
return
StatusCode::FAILURE;
67
}
68
if
(
m_jetContainerName
==
""
){
69
ATH_MSG_ERROR
(
"Tool initialized with no jet container name."
);
70
return
StatusCode::FAILURE;
71
}
72
73
//initialize jet cleaning tool
74
ATH_CHECK
(
m_jetCleaningTool
.setProperty(
"JetContainer"
,
m_jetContainerName
));
75
ATH_CHECK
(
m_jetCleaningTool
.setProperty(
"CutLevel"
,
m_cleaningLevel
));
76
ATH_CHECK
(
m_jetCleaningTool
.setProperty(
"UseDecorations"
,
m_useDecorations
));
//for AODs we can't use decorations
77
ATH_CHECK
(
m_jetCleaningTool
.retrieve());
78
ATH_MSG_INFO
(
"Event cleaning tool configured with cut level "
<<
m_cleaningLevel
);
79
80
m_passJvtKey
=
m_jetContainerName
+
"."
+
m_prefix
+
m_passJvtKey
.key();
81
m_passORKey
=
m_jetContainerName
+
"."
+
m_prefix
+
m_passORKey
.key();
82
m_jetCleanKey
=
m_jetContainerName
+
"."
+
m_prefix
+
"jetClean_"
+
m_cleaningLevel
;
83
84
ATH_CHECK
(
m_passJvtKey
.initialize());
85
ATH_CHECK
(
m_passORKey
.initialize());
86
ATH_CHECK
(
m_jetCleanKey
.initialize(
m_decorate
));
87
88
#ifndef XAOD_STANDALONE
89
if
(
m_suppressInputDeps
){
90
// The user has promised that this will be produced by the same alg.
91
// Tell the scheduler to ignore it to avoid circular dependencies.
92
renounce
(
m_passJvtKey
);
93
renounce
(
m_passORKey
);
94
}
95
if
(
m_suppressOutputDeps
) {
96
renounce
(
m_jetCleanKey
);
97
}
98
#endif
99
100
return
StatusCode::SUCCESS;
101
}
102
103
bool
EventCleaningTool::acceptEvent
(
const
xAOD::JetContainer
* jets)
const
104
{
105
bool
pass_pt = 0;
106
bool
pass_eta = 0;
107
bool
pass_accept = 0;
108
int
jvtDecision = 0;
109
int
orDecision = 0;
110
bool
isThisJetGood = 0;
111
bool
isEventAllGood = 1;
112
113
SG::ReadDecorHandle<xAOD::JetContainer, char>
jvtHandle(
m_passJvtKey
);
114
SG::ReadDecorHandle<xAOD::JetContainer, char>
orHandle(
m_passORKey
);
115
SG::WriteDecorHandle<xAOD::JetContainer, char>
jetCleanHandle(
m_jetCleanKey
);
116
117
for
(
auto
thisJet : *jets){
//loop over decorated jet collection
118
pass_pt = thisJet->pt() >
m_pt
;
119
pass_eta = fabs(thisJet->eta()) <
m_eta
;
120
pass_accept =
keepJet
(*thisJet);
121
jvtDecision = jvtHandle(*thisJet);
122
orDecision = !(orHandle(*thisJet));
//recall, passOR==0 means that the jet is not an overlap and should be kept!
123
124
ATH_MSG_DEBUG
(
"Jet info: pT: "
<< pass_pt <<
", eta: "
<< pass_eta <<
", accept? "
<< pass_accept <<
", jvt: "
<< jvtDecision <<
", or: "
<< orDecision);
125
if
(pass_pt && pass_eta && jvtDecision && orDecision){
//only consider jets for cleaning if they pass these requirements.
126
isThisJetGood = pass_accept;
127
isEventAllGood = isEventAllGood && isThisJetGood;
//any event with a bad jet is rejected
128
}
129
else
isThisJetGood = pass_accept;
//if it fails any one of these, it shouldn't be able to kill the whole event, but we still need to know cleaning
130
ATH_MSG_DEBUG
(
"Is jet good? "
<< isThisJetGood);
131
if
(
m_decorate
) jetCleanHandle(*thisJet) = isThisJetGood;
132
}
133
ATH_MSG_DEBUG
(
"Is event good? "
<< isEventAllGood);
134
return
isEventAllGood;
135
}
136
137
int
EventCleaningTool::keepJet
(
const
xAOD::Jet
&
jet
)
const
138
{
139
return
m_jetCleaningTool
->keep(
jet
);
140
}
141
142
}
//ECUtils
143
144
AsgMessaging.h
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_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadDecorHandle.h
Handle class for reading a decoration on an object.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
EventCleaningTool.h
Jet.h
JetCleaningTool.h
Helpers.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition
AthCommonDataStore.h:380
ECUtils::EventCleaningTool::m_jetCleanKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_jetCleanKey
Definition
EventCleaningTool.h:73
ECUtils::EventCleaningTool::EventCleaningTool
EventCleaningTool(const std::string &name="EventCleaningTool")
Create a proper constructor for Athena.
Definition
EventCleaningTool.cxx:42
ECUtils::EventCleaningTool::m_jetCleaningTool
asg::AnaToolHandle< IJetSelector > m_jetCleaningTool
Definition
EventCleaningTool.h:68
ECUtils::EventCleaningTool::~EventCleaningTool
virtual ~EventCleaningTool()
Standard destructor.
Definition
EventCleaningTool.cxx:53
ECUtils::EventCleaningTool::m_passJvtKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_passJvtKey
Definition
EventCleaningTool.h:71
ECUtils::EventCleaningTool::acceptEvent
virtual bool acceptEvent(const xAOD::JetContainer *jets) const override
Declare the interface.
Definition
EventCleaningTool.cxx:103
ECUtils::EventCleaningTool::keepJet
virtual int keepJet(const xAOD::Jet &jet) const override
Definition
EventCleaningTool.cxx:137
ECUtils::EventCleaningTool::m_pt
Gaudi::Property< double > m_pt
Definition
EventCleaningTool.h:60
ECUtils::EventCleaningTool::m_suppressOutputDeps
Gaudi::Property< bool > m_suppressOutputDeps
Definition
EventCleaningTool.h:67
ECUtils::EventCleaningTool::m_prefix
Gaudi::Property< std::string > m_prefix
Definition
EventCleaningTool.h:62
ECUtils::EventCleaningTool::m_useDecorations
Gaudi::Property< bool > m_useDecorations
Definition
EventCleaningTool.h:64
ECUtils::EventCleaningTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
EventCleaningTool.h:70
ECUtils::EventCleaningTool::m_cleaningLevel
Gaudi::Property< std::string > m_cleaningLevel
Definition
EventCleaningTool.h:65
ECUtils::EventCleaningTool::initialize
virtual StatusCode initialize() override
Initialize method.
Definition
EventCleaningTool.cxx:58
ECUtils::EventCleaningTool::m_decorate
Gaudi::Property< bool > m_decorate
Definition
EventCleaningTool.h:63
ECUtils::EventCleaningTool::m_eta
Gaudi::Property< double > m_eta
Definition
EventCleaningTool.h:61
ECUtils::EventCleaningTool::m_passORKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_passORKey
Definition
EventCleaningTool.h:72
ECUtils::EventCleaningTool::m_suppressInputDeps
Gaudi::Property< bool > m_suppressInputDeps
Definition
EventCleaningTool.h:66
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
ECUtils
Definition
EventCleaningTool.h:35
asg
Definition
DataHandleTestTool.h:28
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
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
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0