ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ThinningUtils
src
ThinNegativeEnergyNeutralPFOsAlg.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// ThinNegativeEnergyNeutralPFOsAlg.cxx
8
// Author: Chris Young <christopher.young@cern.ch>
9
// based on similar code by Karsten Koeneke <karsten.koeneke@cern.ch>
10
// and James Catmore <James.Catmore@cern.ch>
11
// Uses thinning service to remove Neutral PFOs with negative energy
12
// Intended for use in ESD->AOD in reconstruction - use other tools
13
// for analysis (Expression evaluation is not used here)
15
16
// EventUtils includes
17
#include "
ThinNegativeEnergyNeutralPFOsAlg.h
"
18
#include "
xAODPFlow/PFOContainer.h
"
19
20
// STL includes
21
#include <algorithm>
22
23
// FrameWork includes
24
#include "Gaudi/Property.h"
25
#include "
StoreGate/ThinningHandle.h
"
26
28
// Public methods:
30
31
// Constructors
33
ThinNegativeEnergyNeutralPFOsAlg::ThinNegativeEnergyNeutralPFOsAlg
(
34
const
std::string& name,
35
ISvcLocator* pSvcLocator)
36
:
AthReentrantAlgorithm
(name, pSvcLocator)
37
,
m_nEventsProcessed
(0)
38
,
m_nNeutralPFOsProcessed
(0)
39
,
m_nNeutralPFOsThinned
(0)
40
{
41
}
42
43
// Athena Algorithm's Hooks
45
StatusCode
46
ThinNegativeEnergyNeutralPFOsAlg::initialize
()
47
{
48
ATH_MSG_DEBUG
(
"Initializing "
<< name() <<
"..."
);
49
50
// Print out the used configuration
51
ATH_MSG_DEBUG
(
" using = "
<<
m_streamName
);
52
53
// Is truth thinning required?
54
if
(!
m_doThinning
) {
55
ATH_MSG_INFO
(
"Negative energy NeutralPFO thinning not required"
);
56
}
else
{
57
ATH_MSG_INFO
(
"Negative energy NeutralPFOs will be thinned"
);
58
}
59
60
if
(
m_doThinning
&&
m_streamName
.empty()) {
61
ATH_MSG_ERROR
(
"StreamName property has not been initialized."
);
62
return
StatusCode::FAILURE;
63
}
64
ATH_CHECK
(
m_neutralPFOsKey
.initialize(
65
m_streamName
,
m_doThinning
&& !
m_neutralPFOsKey
.key().empty()));
66
ATH_CHECK
(
m_LCNeutralPFOsKey
.initialize(
67
m_streamName
,
m_doThinning
&& !
m_LCNeutralPFOsKey
.key().empty()));
68
69
// Initialize the counters to zero
70
m_nEventsProcessed
= 0;
71
m_nNeutralPFOsProcessed
= 0;
72
m_nNeutralPFOsThinned
= 0;
73
74
ATH_MSG_DEBUG
(
"==> done with initialize "
<< name() <<
"..."
);
75
76
return
StatusCode::SUCCESS;
77
}
78
79
StatusCode
80
ThinNegativeEnergyNeutralPFOsAlg::finalize
()
81
{
82
ATH_MSG_DEBUG
(
"Finalizing "
<< name() <<
"..."
);
83
ATH_MSG_INFO
(
"Processed "
<<
m_nEventsProcessed
<<
" events containing "
84
<<
m_nNeutralPFOsProcessed
<<
" NeutralPFOs"
);
85
ATH_MSG_INFO
(
"Removed "
<<
m_nNeutralPFOsThinned
86
<<
" negative energy NeutralPFOs "
);
87
return
StatusCode::SUCCESS;
88
}
89
90
StatusCode
91
ThinNegativeEnergyNeutralPFOsAlg::execute
(
const
EventContext& ctx)
const
92
{
93
// Increase the event counter
94
m_nEventsProcessed
.fetch_add(1, std::memory_order_relaxed);
95
96
// Is truth thinning required?
97
if
(!
m_doThinning
||
m_neutralPFOsKey
.key().empty()) {
98
return
StatusCode::SUCCESS;
99
}
100
101
SG::ThinningHandle<xAOD::FlowElementContainer>
neutralFEs(
m_neutralPFOsKey
,
102
ctx);
103
std::vector<bool> mask;
104
int
nNeutralFEs = neutralFEs->size();
105
m_nNeutralPFOsProcessed
.fetch_add(nNeutralFEs, std::memory_order_relaxed);
106
mask.assign(nNeutralFEs,
false
);
107
108
unsigned
long
int
nNeutralPFOsThinned = 0;
109
for
(
int
i = 0; i < nNeutralFEs; i++) {
110
const
xAOD::FlowElement
* neutralFE = (*neutralFEs)[i];
111
if
(neutralFE->
pt
() > 0.0)
112
mask[i] =
true
;
113
else
{
114
++nNeutralPFOsThinned;
115
}
116
}
117
118
m_nNeutralPFOsThinned
.fetch_add(nNeutralPFOsThinned,
119
std::memory_order_relaxed);
120
neutralFEs.
keep
(mask);
121
122
if
(!
m_LCNeutralPFOsKey
.key().empty()) {
123
SG::ThinningHandle<xAOD::FlowElementContainer>
LCNeutralFEs(
124
m_LCNeutralPFOsKey
, ctx);
125
// LC PFOs are thinned based on the energy of the (EM-scale) originals
126
LCNeutralFEs.
keep
(mask);
127
}
128
return
StatusCode::SUCCESS;
129
}
130
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
PFOContainer.h
ThinNegativeEnergyNeutralPFOsAlg.h
ThinningHandle.h
Handle for requesting thinning for a data object.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
SG::ThinningHandleBase::keep
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Definition
ThinningHandleBase.cxx:75
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition
ThinningHandle.h:84
ThinNegativeEnergyNeutralPFOsAlg::m_doThinning
BooleanProperty m_doThinning
Should the thinning run?
Definition
ThinNegativeEnergyNeutralPFOsAlg.h:53
ThinNegativeEnergyNeutralPFOsAlg::ThinNegativeEnergyNeutralPFOsAlg
ThinNegativeEnergyNeutralPFOsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition
ThinNegativeEnergyNeutralPFOsAlg.cxx:33
ThinNegativeEnergyNeutralPFOsAlg::finalize
virtual StatusCode finalize() override final
Athena algorithm's finalize hook.
Definition
ThinNegativeEnergyNeutralPFOsAlg.cxx:80
ThinNegativeEnergyNeutralPFOsAlg::m_nNeutralPFOsThinned
std::atomic< unsigned long > m_nNeutralPFOsThinned
Definition
ThinNegativeEnergyNeutralPFOsAlg.h:77
ThinNegativeEnergyNeutralPFOsAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Athena algorithm's execute hook.
Definition
ThinNegativeEnergyNeutralPFOsAlg.cxx:91
ThinNegativeEnergyNeutralPFOsAlg::m_LCNeutralPFOsKey
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_LCNeutralPFOsKey
Definition
ThinNegativeEnergyNeutralPFOsAlg.h:67
ThinNegativeEnergyNeutralPFOsAlg::initialize
virtual StatusCode initialize() override final
Athena algorithm's initalize hook.
Definition
ThinNegativeEnergyNeutralPFOsAlg.cxx:46
ThinNegativeEnergyNeutralPFOsAlg::m_neutralPFOsKey
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_neutralPFOsKey
Names of the containers to thin.
Definition
ThinNegativeEnergyNeutralPFOsAlg.h:61
ThinNegativeEnergyNeutralPFOsAlg::m_nNeutralPFOsProcessed
std::atomic< unsigned long > m_nNeutralPFOsProcessed
Definition
ThinNegativeEnergyNeutralPFOsAlg.h:76
ThinNegativeEnergyNeutralPFOsAlg::m_streamName
StringProperty m_streamName
Definition
ThinNegativeEnergyNeutralPFOsAlg.h:45
ThinNegativeEnergyNeutralPFOsAlg::m_nEventsProcessed
std::atomic< unsigned long > m_nEventsProcessed
Counters.
Definition
ThinNegativeEnergyNeutralPFOsAlg.h:75
xAOD::FlowElement_v1::pt
virtual double pt() const override
xAOD::FlowElement
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition
FlowElement.h:16
Generated on
for ATLAS Offline Software by
1.17.0