ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ThinningUtils
src
ThinNegativeEnergyCaloClustersAlg.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
// ThinNegativeEnergyCaloClustersAlg.cxx
8
// Author: James Catmore <James.Catmore@cern.ch>
9
// based on similar code by Karsten Koeneke <karsten.koeneke@cern.ch>
10
// Uses thinning service to remove CaloClusters with negative energy
11
// Intended for use in ESD->AOD in reconstruction - use other tools
12
// for analysis (Expression evaluation is not used here)
14
15
// EventUtils includes
16
#include "
ThinNegativeEnergyCaloClustersAlg.h
"
17
#include "
xAODCaloEvent/CaloClusterContainer.h
"
18
19
// STL includes
20
#include <algorithm>
21
22
// FrameWork includes
23
#include "
StoreGate/ThinningHandle.h
"
24
26
// Public methods:
28
29
// Constructors
31
ThinNegativeEnergyCaloClustersAlg::ThinNegativeEnergyCaloClustersAlg
(
32
const
std::string& name,
33
ISvcLocator* pSvcLocator)
34
:
AthReentrantAlgorithm
(name, pSvcLocator)
35
,
m_nEventsProcessed
(0)
36
,
m_nCaloClustersProcessed
(0)
37
,
m_nCaloClustersThinned
(0)
38
{}
39
40
// Athena Algorithm's Hooks
42
StatusCode
43
ThinNegativeEnergyCaloClustersAlg::initialize
()
44
{
45
ATH_MSG_DEBUG
(
"Initializing "
<< name() <<
"..."
);
46
47
// Print out the used configuration
48
ATH_MSG_DEBUG
(
" using = "
<<
m_streamName
);
49
50
// Is truth thinning required?
51
if
(!
m_doThinning
) {
52
ATH_MSG_INFO
(
"Negative energy CaloClusters thinning not required"
);
53
}
else
{
54
ATH_MSG_INFO
(
"Negative energy CaloClusters will be thinned"
);
55
}
56
57
if
(
m_doThinning
&&
m_streamName
.empty()) {
58
ATH_MSG_ERROR
(
"StreamName property has not been initialized."
);
59
return
StatusCode::FAILURE;
60
}
61
ATH_CHECK
(
m_caloClustersKey
.initialize(
m_streamName
,
m_doThinning
));
62
63
// Initialize the counters to zero
64
m_nEventsProcessed
= 0;
65
m_nCaloClustersProcessed
= 0;
66
m_nCaloClustersThinned
= 0;
67
68
ATH_MSG_DEBUG
(
"==> done with initialize "
<< name() <<
"..."
);
69
70
return
StatusCode::SUCCESS;
71
}
72
73
StatusCode
74
ThinNegativeEnergyCaloClustersAlg::finalize
()
75
{
76
ATH_MSG_DEBUG
(
"Finalizing "
<< name() <<
"..."
);
77
ATH_MSG_INFO
(
"Processed "
<<
m_nEventsProcessed
<<
" events containing "
78
<<
m_nCaloClustersProcessed
<<
" CaloClusters"
);
79
ATH_MSG_INFO
(
"Removed "
<<
m_nCaloClustersThinned
80
<<
" negative energy CaloClusters "
);
81
return
StatusCode::SUCCESS;
82
}
83
84
StatusCode
85
ThinNegativeEnergyCaloClustersAlg::execute
(
const
EventContext& ctx)
const
86
{
87
// Increase the event counter
88
m_nEventsProcessed
.fetch_add(1, std::memory_order_relaxed);
89
90
// Is thinning required?
91
if
(!
m_doThinning
) {
92
return
StatusCode::SUCCESS;
93
}
94
95
// Retrieve truth and vertex containers
96
SG::ThinningHandle<xAOD::CaloClusterContainer>
caloClusters(
m_caloClustersKey
,
97
ctx);
98
99
// Set up masks
100
std::vector<bool> mask;
101
int
nCaloClusters = caloClusters->size();
102
m_nCaloClustersProcessed
.fetch_add(nCaloClusters, std::memory_order_relaxed);
103
mask.assign(nCaloClusters,
false
);
104
105
// Loop over CaloClusters and update mask
106
unsigned
long
int
nCaloClustersThinned = 0;
107
for
(
int
i = 0; i < nCaloClusters; ++i) {
108
const
xAOD::CaloCluster
* caloCluster = (*caloClusters)[i];
109
// Retain postive energy clusters
110
if
(caloCluster->
rawE
() > 0.0) {
111
mask[i] =
true
;
112
}
else
{
113
++nCaloClustersThinned;
114
}
115
}
116
m_nCaloClustersThinned
.fetch_add(nCaloClustersThinned,
117
std::memory_order_relaxed);
118
119
// Apply masks to thinning service
120
caloClusters.
keep
(mask);
121
122
return
StatusCode::SUCCESS;
123
}
124
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
CaloClusterContainer.h
ThinNegativeEnergyCaloClustersAlg.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
ThinNegativeEnergyCaloClustersAlg::m_doThinning
BooleanProperty m_doThinning
Should the thinning run?
Definition
ThinNegativeEnergyCaloClustersAlg.h:53
ThinNegativeEnergyCaloClustersAlg::m_streamName
StringProperty m_streamName
Definition
ThinNegativeEnergyCaloClustersAlg.h:45
ThinNegativeEnergyCaloClustersAlg::initialize
virtual StatusCode initialize() override final
Athena algorithm's initalize hook.
Definition
ThinNegativeEnergyCaloClustersAlg.cxx:43
ThinNegativeEnergyCaloClustersAlg::ThinNegativeEnergyCaloClustersAlg
ThinNegativeEnergyCaloClustersAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition
ThinNegativeEnergyCaloClustersAlg.cxx:31
ThinNegativeEnergyCaloClustersAlg::finalize
virtual StatusCode finalize() override final
Athena algorithm's finalize hook.
Definition
ThinNegativeEnergyCaloClustersAlg.cxx:74
ThinNegativeEnergyCaloClustersAlg::m_nCaloClustersThinned
std::atomic< unsigned long > m_nCaloClustersThinned
Definition
ThinNegativeEnergyCaloClustersAlg.h:71
ThinNegativeEnergyCaloClustersAlg::m_nCaloClustersProcessed
std::atomic< unsigned long > m_nCaloClustersProcessed
Definition
ThinNegativeEnergyCaloClustersAlg.h:70
ThinNegativeEnergyCaloClustersAlg::m_caloClustersKey
SG::ThinningHandleKey< xAOD::CaloClusterContainer > m_caloClustersKey
Names of the containers to thin.
Definition
ThinNegativeEnergyCaloClustersAlg.h:61
ThinNegativeEnergyCaloClustersAlg::execute
StatusCode execute(const EventContext &ctx) const override final
Athena algorithm's execute hook.
Definition
ThinNegativeEnergyCaloClustersAlg.cxx:85
ThinNegativeEnergyCaloClustersAlg::m_nEventsProcessed
std::atomic< unsigned long > m_nEventsProcessed
Counters.
Definition
ThinNegativeEnergyCaloClustersAlg.h:69
xAOD::CaloCluster_v1::rawE
flt_t rawE() const
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
Generated on
for ATLAS Offline Software by
1.17.0