ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
MuonID
MuonSelectorTools
src
MuonID/MuonSelectorTools/src/MuonSelectionAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MuonSelectionAlg.h
"
6
7
#include "
AthContainers/ConstDataVector.h
"
8
#include "
xAODMuon/MuonContainer.h
"
9
namespace
CP
{
10
11
MuonSelectionAlg::MuonSelectionAlg
(
const
std::string&
name
, ISvcLocator* svcloc) :
12
AthAlgorithm
(
name
, svcloc),
m_tool
(
"CP::MuonSelectionTool"
)
/*public tool*/
{
13
declareProperty
(
"Input"
,
m_inputMuons
=
""
);
14
declareProperty
(
"Output"
,
m_outputMuons
=
""
);
15
declareProperty
(
"Tool"
,
m_tool
);
16
}
17
18
StatusCode
MuonSelectionAlg::initialize
() {
19
if
(
m_inputMuons
.empty()) {
20
ATH_MSG_ERROR
(
"You must specify an INPUT muon collection"
);
21
return
StatusCode::FAILURE;
22
}
23
if
(
m_outputMuons
.empty()) {
24
ATH_MSG_ERROR
(
"You must specify an OUTPUT muon collection"
);
25
return
StatusCode::FAILURE;
26
}
27
CHECK
(
m_tool
.retrieve());
28
29
return
StatusCode::SUCCESS;
30
}
31
32
StatusCode
MuonSelectionAlg::execute
(
const
EventContext&
/*ctx*/
) {
33
// fetch input collection
34
const
xAOD::MuonContainer
* muons =
nullptr
;
35
CHECK
(
evtStore
()->retrieve(muons,
m_inputMuons
));
36
37
// create a view container for the selected muons
38
// basically acts like pointers to the selected muons in the muon container
39
ConstDataVector<xAOD::MuonContainer>
* out =
new
ConstDataVector<xAOD::MuonContainer>
(
SG::VIEW_ELEMENTS
);
40
41
for
(
const
xAOD::Muon
* iMuon : *muons) {
42
if
(
m_tool
->accept(*iMuon)) out->push_back(iMuon);
43
}
44
ATH_MSG_DEBUG
(
"Selected "
<< out->size() <<
" muons"
);
45
46
CHECK
(
evtStore
()->record(out,
m_outputMuons
));
47
// if(evtStore()->proxy(muons)->isConst()) CHECK( evtStore()->setConst(out) ); - may allow in the future
48
CHECK
(
evtStore
()->setConst(out));
// for now we just always lock everything we put into storegate
49
50
return
StatusCode::SUCCESS;
51
}
52
53
}
// namespace CP
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
MuonContainer.h
MuonSelectionAlg.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
CP::MuonSelectionAlg::m_tool
ToolHandle< CP::IMuonSelectionTool > m_tool
Definition
MuonID/MuonSelectorTools/src/MuonSelectionAlg.h:27
CP::MuonSelectionAlg::initialize
virtual StatusCode initialize()
Definition
MuonID/MuonSelectorTools/src/MuonSelectionAlg.cxx:18
CP::MuonSelectionAlg::m_outputMuons
std::string m_outputMuons
Definition
MuonID/MuonSelectorTools/src/MuonSelectionAlg.h:26
CP::MuonSelectionAlg::m_inputMuons
std::string m_inputMuons
Definition
MuonID/MuonSelectorTools/src/MuonSelectionAlg.h:25
CP::MuonSelectionAlg::execute
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition
MuonID/MuonSelectorTools/src/MuonSelectionAlg.cxx:32
CP::MuonSelectionAlg::MuonSelectionAlg
MuonSelectionAlg(const std::string &name, ISvcLocator *svcloc)
Definition
MuonID/MuonSelectorTools/src/MuonSelectionAlg.cxx:11
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
xAOD::MuonContainer
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Definition
Event/xAOD/xAODMuon/xAODMuon/MuonContainer.h:14
Generated on
for ATLAS Offline Software by
1.17.0