ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
EventShapes
EventShapeTools
Root
EventDensityTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// EventDensityTool.cxx
6
7
#include "
EventShapeTools/EventDensityTool.h
"
8
#include "fastjet/JetDefinition.hh"
9
#include "fastjet/AreaDefinition.hh"
10
#include "fastjet/ClusterSequenceArea.hh"
11
#include "
xAODEventShape/EventShape.h
"
12
#include "
xAODEventShape/EventShapeAuxInfo.h
"
13
#include "
JetEDM/PseudoJetVector.h
"
14
#include "
AsgDataHandles/ReadHandle.h
"
15
#include "
AsgDataHandles/WriteHandle.h
"
16
17
using
fastjet::JetAlgorithm;
18
using
fastjet::JetDefinition;
19
using
fastjet::ClusterSequence;
20
using
fastjet::ClusterSequenceArea;
21
using
fastjet::AreaDefinition;
22
using
fastjet::VoronoiAreaSpec;
23
24
//**********************************************************************
25
26
EventDensityTool::EventDensityTool
(
const
std::string& name)
27
:
asg
::
AsgTool
(name),
28
m_useAreaFourMom
(true)
29
{
30
declareProperty
(
"JetAlgorithm"
,
m_jetalg
=
"Kt"
);
31
declareProperty
(
"JetRadius"
,
m_jetrad
= 0.4);
32
declareProperty
(
"AbsRapidityMin"
,
m_rapmin
= 0.0);
33
declareProperty
(
"AbsRapidityMax"
,
m_rapmax
= 2.0);
34
declareProperty
(
"AreaDefinition"
,
m_areadef
=
"Voronoi"
);
35
declareProperty
(
"VoronoiRfact"
,
m_vrfact
= 1.0);
36
declareProperty
(
"UseFourMomArea"
,
m_useAreaFourMom
);
37
declareProperty
(
"TrigPseudoJetGetter"
,
m_trigPJGet
);
38
}
39
40
//**********************************************************************
41
42
EventDensityTool::~EventDensityTool
() {}
43
44
//**********************************************************************
45
46
StatusCode
EventDensityTool::initialize
() {
47
ATH_MSG_DEBUG
(
"Initializing "
<< name() <<
"..."
);
48
49
// Initialise output handle
50
ATH_CHECK
(
m_outEDKey
.initialize() );
51
52
// Fetch the fastjet algorithm enum
53
JetAlgorithm
fjalg;
54
if
(
m_jetalg
==
"Kt"
) fjalg = fastjet::kt_algorithm;
55
else
if
(
m_jetalg
==
"AntiKt"
) fjalg = fastjet::antikt_algorithm;
56
else
if
(
m_jetalg
==
"CamKt"
) fjalg = fastjet::cambridge_algorithm;
57
else
{
58
ATH_MSG_ERROR
(
"Invalid jet algorithm name: "
<<
m_jetalg
);
59
ATH_MSG_ERROR
(
"Allowed values are Kt, CamKt, AntiKt, etc."
);
60
return
StatusCode::FAILURE;
61
}
62
63
// Build jet definition.
64
m_fjjetdef
= JetDefinition(fjalg,
m_jetrad
);
65
66
// Build area definition.
67
if
(
m_areadef
==
"Voronoi"
) {
68
m_fjareadef
= AreaDefinition(fastjet::voronoi_area, VoronoiAreaSpec(
m_vrfact
));
69
}
else
if
(
m_areadef
==
"Active"
||
m_useAreaFourMom
) {
70
// Default is fine here for now.
71
// Later might want to switch to seeds and binning used in jet reco.
72
// See JetRec/JetFinder for that.
73
}
else
{
74
ATH_MSG_WARNING
(
"Unsupported area option: "
<<
m_areadef
);
75
return
StatusCode::FAILURE;
76
}
77
78
// Build the jet selector.
79
if
(
m_rapmin
>= 0.0 &&
m_rapmax
>
m_rapmin
) {
80
m_fjselector
= fastjet::SelectorAbsRapRange(
m_rapmin
,
m_rapmax
);
81
}
else
{
82
ATH_MSG_WARNING
(
"Invalid absolute rapidity range: ("
83
<<
m_rapmin
<<
", "
<<
m_rapmax
<<
")"
);
84
return
StatusCode::FAILURE;
85
}
86
ATH_MSG_DEBUG
(
"Configured properties:"
);
87
ATH_MSG_DEBUG
(
" JetAlgorithm: "
<<
m_jetalg
);
88
ATH_MSG_DEBUG
(
" JetRadius: "
<<
m_jetrad
);
89
if
(!
m_inPJKey
.key().empty()) {
90
ATH_MSG_INFO
(
" Input: "
<<
m_inPJKey
.key() <<
" -> Output: "
<<
m_outEDKey
.key());
91
}
else
{
92
ATH_MSG_INFO
(
" TrigPJGetter: "
<<
m_trigPJGet
.name() <<
" -> Output: "
<<
m_outEDKey
.key());
93
}
94
ATH_MSG_DEBUG
(
" AbsRapidityMin: "
<<
m_rapmin
);
95
ATH_MSG_DEBUG
(
" AbsRapidityMax: "
<<
m_rapmax
);
96
ATH_MSG_DEBUG
(
" AreaDefinition: "
<<
m_areadef
);
97
ATH_MSG_DEBUG
(
" VoronoiRfact: "
<<
m_vrfact
);
98
ATH_MSG_DEBUG
(
"Derived properties:"
);
99
ATH_MSG_DEBUG
(
" Fastjet jet defn: "
<<
m_fjjetdef
.description());
100
ATH_MSG_DEBUG
(
" Fastjet area defn: "
<<
m_fjareadef
.description());
101
ATH_MSG_DEBUG
(
" Fastjet jet selector: "
<<
m_fjselector
.description());
102
ATH_MSG_DEBUG
(
" Use area four-momentum: "
<<
m_useAreaFourMom
);
103
104
// Input sources
105
if
(!
m_inPJKey
.key().empty() &&
m_trigPJGet
.empty()) {
106
ATH_CHECK
(
m_inPJKey
.initialize() );
107
}
108
// { FIXME: To be removed when trigger moves to handles fully
109
else
if
(
m_inPJKey
.key().empty() && !
m_trigPJGet
.empty()) {
110
ATH_CHECK
(
m_trigPJGet
.retrieve() );
111
}
112
// } FIXME
113
else
{
114
ATH_MSG_ERROR
(
"Inconsistent/ambiguous input setup."
115
<<
" InPJKey: "
<<
m_inPJKey
.key()
116
<<
" TrigPJGetter: "
<<
m_trigPJGet
.name() );
117
return
StatusCode::FAILURE;
118
}
119
120
return
StatusCode::SUCCESS;
121
}
122
123
//**********************************************************************
124
125
StatusCode
EventDensityTool::fillEventShape
()
const
{
126
127
ATH_MSG_DEBUG
(
"Begin fillEventShape()"
);
128
129
std::unique_ptr<xAOD::EventShape> eventShape(std::make_unique<xAOD::EventShape>());
130
std::unique_ptr<xAOD::EventShapeAuxInfo> eventShapeaux(std::make_unique<xAOD::EventShapeAuxInfo>());
131
eventShape->setStore( eventShapeaux.get() );
132
133
// Change the order: first fill the object and then record
134
ATH_CHECK
(
fillEventShape
(eventShape.get()));
135
136
auto
h_out = makeHandle(
m_outEDKey
);
137
if
( ! h_out.record(std::move(eventShape), std::move(eventShapeaux) )) {
138
ATH_MSG_WARNING
(
"Unable to write new EventShape and aux store to event store: "
<<
m_outEDKey
.key());
139
}
else
{
140
ATH_MSG_DEBUG
(
"Created new EventShape container: "
<<
m_outEDKey
.key());
141
}
142
143
return
StatusCode::SUCCESS;
144
}
145
146
//**********************************************************************
147
StatusCode
EventDensityTool::fillEventShape
(
xAOD::EventShape
*eventShape)
const
{
148
149
if
(!
m_inPJKey
.key().empty() &&
m_trigPJGet
.empty()) {
150
auto
h_in = makeHandle(
m_inPJKey
);
151
if
( ! h_in.isValid() ) {
152
ATH_MSG_ERROR
(
"No input PseudoJetContainer "
<<
m_inPJKey
.key() );
153
return
StatusCode::FAILURE;
154
}
155
if
( h_in->size() == 0 ) {
156
ATH_MSG_DEBUG
(
"Input PseudoJetContainer size()=0 for pseudojets from "
<<
m_inPJKey
.key() );
157
}
else
{
158
ATH_MSG_DEBUG
(
"Retrieved input pseudojets "
<<
m_inPJKey
.key() <<
" , count: "
<< h_in->size());
159
}
160
return
fillEventShape
(eventShape, *(h_in->casVectorPseudoJet()));
161
}
162
// { FIXME: To be removed when trigger moves to handles fully
163
else
if
(
m_inPJKey
.key().empty() && !
m_trigPJGet
.empty()) {
164
const
PseudoJetVector
& ppjv = *(
m_trigPJGet
->get());
165
// !!! FIXME !!! Downgraded ERROR to WARNING and no FAILURE
166
if
( ppjv.size() == 0 ) {
167
ATH_MSG_WARNING
(
"Input PseudoJetVector size()=0 for pseudojets from "
<<
m_trigPJGet
.name() );
168
//return StatusCode::FAILURE;
169
}
else
{
170
ATH_MSG_DEBUG
(
"Retrieved input pseudojets "
<<
m_trigPJGet
.name() <<
" , count: "
<< ppjv.size());
171
}
172
return
fillEventShape
(eventShape, ppjv);
173
}
174
// } FIXME
175
176
return
StatusCode::FAILURE;
177
}
178
179
//**********************************************************************
180
181
StatusCode
EventDensityTool::
182
fillEventShape
(
xAOD::EventShape
* eventShape,
const
PseudoJetVector
& pjv)
const
{
183
ATH_MSG_DEBUG
(
"Input pseudojet count: "
<< pjv.size());
184
ATH_MSG_DEBUG
(
"Event shape container address: "
<< eventShape);
185
186
for
(
const
auto
& pj : pjv) {
187
ATH_MSG_DEBUG
(
" pj input e="
<<pj.e() <<
" pz="
<<pj.pz() <<
" px="
<<pj.px() );
188
}
189
// Find jets.
190
std::unique_ptr<ClusterSequenceArea> pcsa=std::make_unique<ClusterSequenceArea>(pjv,
m_fjjetdef
,
m_fjareadef
);
191
ATH_MSG_DEBUG
(
"Found jet count: "
<< pcsa->inclusive_jets().size());
192
193
// Extract rho.
194
double
rho, sigma,
area
;
195
pcsa->get_median_rho_and_sigma(
m_fjselector
,
m_useAreaFourMom
, rho, sigma,
area
);
196
ATH_MSG_DEBUG
(
" calculated rho="
<< rho);
197
198
// Record rho.
199
200
// Fill the EventShape object
201
const
static
SG::AuxElement::Accessor<float> rhoDec(
"Density"
);
202
const
static
SG::AuxElement::Accessor<float> sigmaDec(
"DensitySigma"
);
203
const
static
SG::AuxElement::Accessor<float> areaDec(
"DensityArea"
);
204
rhoDec(*eventShape) = rho;
205
sigmaDec(*eventShape) = sigma;
206
areaDec(*eventShape) =
area
;
207
208
ATH_MSG_DEBUG
(
"Recorded event density: = "
<< 0.001*rho <<
" GeV"
);
209
210
return
StatusCode::SUCCESS;
211
}
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_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
area
double area(double R)
Definition
ConvertStaveServices.cxx:42
EventDensityTool.h
EventShapeAuxInfo.h
EventShape.h
PseudoJetVector
std::vector< fastjet::PseudoJet > PseudoJetVector
Definition
JetConstituentFiller.cxx:17
PseudoJetVector.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
EventDensityTool::initialize
StatusCode initialize()
Initialization.
Definition
EventDensityTool.cxx:46
EventDensityTool::m_useAreaFourMom
bool m_useAreaFourMom
Definition
EventDensityTool.h:92
EventDensityTool::m_jetrad
float m_jetrad
Definition
EventDensityTool.h:82
EventDensityTool::m_vrfact
float m_vrfact
Definition
EventDensityTool.h:86
EventDensityTool::m_rapmax
float m_rapmax
Definition
EventDensityTool.h:84
EventDensityTool::m_fjareadef
fastjet::AreaDefinition m_fjareadef
Definition
EventDensityTool.h:90
EventDensityTool::m_inPJKey
SG::ReadHandleKey< PseudoJetContainer > m_inPJKey
Definition
EventDensityTool.h:77
EventDensityTool::m_outEDKey
SG::WriteHandleKey< xAOD::EventShape > m_outEDKey
Definition
EventDensityTool.h:78
EventDensityTool::m_areadef
std::string m_areadef
Definition
EventDensityTool.h:85
EventDensityTool::EventDensityTool
EventDensityTool(const std::string &name)
Constructor with parameters:
Definition
EventDensityTool.cxx:26
EventDensityTool::m_trigPJGet
ToolHandle< IPseudoJetGetter > m_trigPJGet
Definition
EventDensityTool.h:74
EventDensityTool::~EventDensityTool
~EventDensityTool()
Destructor:
Definition
EventDensityTool.cxx:42
EventDensityTool::fillEventShape
StatusCode fillEventShape() const
Action.
Definition
EventDensityTool.cxx:125
EventDensityTool::m_fjjetdef
fastjet::JetDefinition m_fjjetdef
Definition
EventDensityTool.h:89
EventDensityTool::m_jetalg
std::string m_jetalg
Definition
EventDensityTool.h:81
EventDensityTool::m_rapmin
float m_rapmin
Definition
EventDensityTool.h:83
EventDensityTool::m_fjselector
fastjet::Selector m_fjselector
Definition
EventDensityTool.h:91
JetAlgorithm
Definition
JetAlgorithm.h:17
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
asg
Definition
DataHandleTestTool.h:28
xAOD::EventShape
EventShape_v1 EventShape
Definition of the current event format version.
Definition
EventShape.h:16
Generated on
for ATLAS Offline Software by
1.17.0