ATLAS Offline Software
Loading...
Searching...
No Matches
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
9namespace 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
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
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
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
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
DataVector adapter that acts like it holds const pointers.
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< CP::IMuonSelectionTool > m_tool
MuonSelectionAlg(const std::string &name, ISvcLocator *svcloc)
DataVector adapter that acts like it holds const pointers.
Select isolated Photons, Electrons and Muons.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".