ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRec
Root
JetGroomer.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 "
JetRec/JetGroomer.h
"
6
7
#include "
AsgDataHandles/ReadHandle.h
"
8
#include "fastjet/PseudoJet.hh"
9
#include "
JetRec/PseudoJetContainer.h
"
10
11
using
xAOD::JetContainer
;
12
13
using namespace
JetGrooming
;
14
15
16
StatusCode
JetGroomer::initialize
() {
17
18
ATH_MSG_DEBUG
(
"Initializing..."
);
19
20
if
(
m_inputJetContainer
.empty()){
21
ATH_MSG_ERROR
(
"Jet grooming requested with no input ungroomed jets"
);
22
return
StatusCode::FAILURE;
23
}
else
if
(
m_inputPseudoJets
.empty()){
24
ATH_MSG_ERROR
(
"Jet grooming requested with no input pseudojets"
);
25
return
StatusCode::FAILURE;
26
}
27
else
{
28
if
(!
m_finalPseudoJets
.empty()){
29
ATH_MSG_WARNING
(
"A non-empty value was found for the FinalPseudoJets WriteHandleKey -- this will be ignored!"
);
30
}
31
32
ATH_CHECK
(
m_inputJetContainer
.initialize());
33
ATH_CHECK
(
m_inputPseudoJets
.initialize());
34
m_finalPseudoJets
= name() +
"FinalPJ"
;
35
ATH_CHECK
(
m_finalPseudoJets
.initialize());
36
}
37
38
return
StatusCode::SUCCESS;
39
}
40
41
42
// Common operations for any jet groomer
43
std::pair<std::unique_ptr<xAOD::JetContainer>,std::unique_ptr<SG::IAuxStore> >
JetGroomer::getJets
()
const
{
44
// Return this in case of any problems
45
auto
nullreturn = std::make_pair(std::unique_ptr<xAOD::JetContainer>(
nullptr
), std::unique_ptr<SG::IAuxStore>(
nullptr
));
46
47
// -----------------------
48
// retrieve input
49
SG::ReadHandle<xAOD::JetContainer>
jetContHandle(
m_inputJetContainer
);
50
if
(!jetContHandle.
isValid
()) {
51
ATH_MSG_ERROR
(
"No valid JetContainer with key "
<<
m_inputJetContainer
.key());
52
return
nullreturn;
53
}
54
55
SG::ReadHandle<PseudoJetContainer>
pjContHandle(
m_inputPseudoJets
);
56
if
(!pjContHandle.
isValid
()) {
57
ATH_MSG_ERROR
(
"No valid PseudoJetContainer with key "
<<
m_inputPseudoJets
.key());
58
return
nullreturn;
59
}
60
61
// Build the container to be returned
62
// Avoid memory leaks with unique_ptr
63
auto
groomedJets = std::make_unique<xAOD::JetContainer>();
64
auto
auxCont = std::make_unique<xAOD::JetAuxContainer>();
65
groomedJets->setStore(auxCont.get());
66
67
// -----------------------
68
// Build a new pointer to a PseudoJetVector containing the final groomed PseudoJets
69
// This allows us to own the vector of PseudoJet which we will put in the evt store.
70
// Thus the contained PseudoJet will be kept frozen there and we can safely use pointer to them from the xAOD::Jet objects
71
auto
groomPJVector = std::make_unique<PseudoJetVector>( );
72
groomPJVector->resize( jetContHandle->size() );
73
74
// loop over input jets
75
for
(
const
xAOD::Jet
* parentJet: *jetContHandle){
76
// Child will create a groomed jet and insert it into the output container
77
this->
insertGroomedJet
(*parentJet, *pjContHandle, *groomedJets, *groomPJVector);
78
}
79
80
// -------------------------------------
81
// record final PseudoJetVector
82
SG::WriteHandle<PseudoJetVector>
pjVectorHandle(
m_finalPseudoJets
);
83
if
(!pjVectorHandle.
record
(std::move(groomPJVector))){
84
ATH_MSG_ERROR
(
"Can't record PseudoJetVector under key "
<<
m_finalPseudoJets
);
85
return
nullreturn;
86
}
87
88
return
std::make_pair(std::move(groomedJets),std::move(auxCont));
89
}
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_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.
JetGroomer.h
PseudoJetContainer.h
JetGrooming::JetGroomer::m_inputPseudoJets
SG::ReadHandleKey< PseudoJetContainer > m_inputPseudoJets
This is the input to the parent JetContainer. It is needed in order to re-assign the ghost constituen...
Definition
JetGroomer.h:58
JetGrooming::JetGroomer::insertGroomedJet
virtual void insertGroomedJet(const xAOD::Jet &, const PseudoJetContainer &, xAOD::JetContainer &, PseudoJetVector &) const =0
JetGrooming::JetGroomer::getJets
virtual std::pair< std::unique_ptr< xAOD::JetContainer >, std::unique_ptr< SG::IAuxStore > > getJets() const override final
Method to build the collection and return it to the caller.
Definition
JetGroomer.cxx:43
JetGrooming::JetGroomer::m_finalPseudoJets
SG::WriteHandleKey< PseudoJetVector > m_finalPseudoJets
Definition
JetGroomer.h:60
JetGrooming::JetGroomer::m_inputJetContainer
SG::ReadHandleKey< xAOD::JetContainer > m_inputJetContainer
Handle Input JetContainer (this contains the parent ungroomed jets to be trimmed).
Definition
JetGroomer.h:55
JetGrooming::JetGroomer::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetGroomer.cxx:16
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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.
JetGrooming
Definition
JetGroomer.h:33
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0