ATLAS Offline Software
Loading...
Searching...
No Matches
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
19
20// STL includes
21#include <algorithm>
22
23// FrameWork includes
24#include "Gaudi/Property.h"
26
28// Public methods:
30
31// Constructors
34 const std::string& name,
35 ISvcLocator* pSvcLocator)
36 : AthReentrantAlgorithm(name, pSvcLocator)
40{
41}
42
43// Athena Algorithm's Hooks
45StatusCode
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()));
67 m_streamName, m_doThinning && !m_LCNeutralPFOsKey.key().empty()));
68
69 // Initialize the counters to zero
73
74 ATH_MSG_DEBUG("==> done with initialize " << name() << "...");
75
76 return StatusCode::SUCCESS;
77}
78
79StatusCode
81{
82 ATH_MSG_DEBUG("Finalizing " << name() << "...");
83 ATH_MSG_INFO("Processed " << m_nEventsProcessed << " events containing "
84 << m_nNeutralPFOsProcessed << " NeutralPFOs");
86 << " negative energy NeutralPFOs ");
87 return StatusCode::SUCCESS;
88}
89
90StatusCode
91ThinNegativeEnergyNeutralPFOsAlg::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
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()) {
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Handle for requesting thinning for a data object.
An algorithm that can be simultaneously executed in multiple threads.
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Handle for requesting thinning for a data object.
BooleanProperty m_doThinning
Should the thinning run?
ThinNegativeEnergyNeutralPFOsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual StatusCode finalize() override final
Athena algorithm's finalize hook.
virtual StatusCode execute(const EventContext &ctx) const override final
Athena algorithm's execute hook.
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_LCNeutralPFOsKey
virtual StatusCode initialize() override final
Athena algorithm's initalize hook.
SG::ThinningHandleKey< xAOD::FlowElementContainer > m_neutralPFOsKey
Names of the containers to thin.
std::atomic< unsigned long > m_nNeutralPFOsProcessed
std::atomic< unsigned long > m_nEventsProcessed
Counters.
virtual double pt() const override
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16