ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRec
src
PseudoJetMerger.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <numeric>
// for std::accumulate
6
7
#include "
JetRec/PseudoJetMerger.h
"
8
#include "
AsgDataHandles/ReadHandle.h
"
9
#include "
AsgDataHandles/WriteHandle.h
"
10
11
StatusCode
PseudoJetMerger::initialize
() {
12
ATH_MSG_DEBUG
(
"Initializing..."
);
13
14
if
(
m_inputPJC
.empty() ||
m_outcoll
.key().empty()) {
15
if
(
m_inputPJC
.empty() ) {
ATH_MSG_ERROR
(
"Input container array is empty! "
<<
m_inputPJC
.size() );}
16
else
{
ATH_MSG_ERROR
(
"OutputContainer container array is empty! "
<<
m_outcoll
.key() );}
17
return
StatusCode::FAILURE;
18
}
19
20
// Ugly check but no other good way of testing at initialisation
21
auto
add_if_ghost = [](
unsigned
int
sum_ghosts,
const
SG::ReadHandleKey<PseudoJetContainer>
& pjckey) {
22
return
sum_ghosts + (pjckey.key().
find
(
"Ghost"
)!=std::string::npos);
23
};
24
unsigned
int
N_ghosts = std::accumulate(
m_inputPJC
.begin(),
m_inputPJC
.end(), 0, add_if_ghost);
25
if
(
m_inputPJC
.size()-N_ghosts!=1) {
26
ATH_MSG_ERROR
(
"List of input pseudojet containers to be merged must have exactly one non-ghost collection!"
);
27
return
StatusCode::FAILURE;
28
}
29
30
ATH_CHECK
(
m_inputPJC
.initialize() );
31
ATH_CHECK
(
m_outcoll
.initialize() );
32
33
return
StatusCode::SUCCESS;
34
}
35
36
37
StatusCode
PseudoJetMerger::execute
(
const
EventContext& ctx)
const
{
38
39
auto
allPseudoJets = std::make_unique<PseudoJetContainer>();
40
41
for
(
const
auto
& pjcKey :
m_inputPJC
) {
42
SG::ReadHandle<PseudoJetContainer>
pjcHandle( pjcKey, ctx );
43
if
(!pjcHandle.
isValid
()){
44
ATH_MSG_ERROR
(
"Can't retrieve PseudoJetContainer "
<< pjcKey.key() );
return
StatusCode::FAILURE;
45
}
46
allPseudoJets->append( pjcHandle.
get
() );
47
}
48
49
SG::WriteHandle<PseudoJetContainer>
outHandle(
m_outcoll
, ctx);
50
ATH_MSG_DEBUG
(
"Merged PseudoJetContainer \""
<<
m_outcoll
.key() <<
"\" has size "
<< allPseudoJets->size());
51
ATH_CHECK
( outHandle.
record
(std::move(allPseudoJets)) );
52
53
return
StatusCode::SUCCESS;
54
}
55
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_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.
PseudoJetMerger.h
PseudoJetMerger::m_inputPJC
SG::ReadHandleKeyArray< PseudoJetContainer > m_inputPJC
Definition
PseudoJetMerger.h:55
PseudoJetMerger::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
PseudoJetMerger.cxx:37
PseudoJetMerger::initialize
virtual StatusCode initialize() override
Initialization.
Definition
PseudoJetMerger.cxx:11
PseudoJetMerger::m_outcoll
SG::WriteHandleKey< PseudoJetContainer > m_outcoll
Output collection name.
Definition
PseudoJetMerger.h:58
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition
StoreGate/StoreGate/ReadHandleKey.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
Generated on
for ATLAS Offline Software by
1.17.0