ATLAS Offline Software
MuonQualityUpdaterAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "xAODCore/ShallowCopy.h"
8 #include "xAODMuon/Muon.h"
10 #include "xAODMuon/MuonContainer.h"
11 
12 namespace CP {
13 
14  MuonQualityUpdaterAlg::MuonQualityUpdaterAlg(const std::string& name, ISvcLocator* svcloc) :
15  AthAlgorithm(name, svcloc), m_tool("CP::MuonSelectionTool") /*public tool*/ {
16  declareProperty("Input", m_input_muons = "");
17  declareProperty("Output", m_output_muons = "");
18  declareProperty("Tool", m_tool);
19  }
20 
22  if (m_input_muons == "") {
23  ATH_MSG_ERROR("You must specify an input muon collection");
24  return StatusCode::FAILURE;
25  }
26  CHECK(m_tool.retrieve());
27 
28  return StatusCode::SUCCESS;
29  }
30 
32  // fetch input collection
33  const xAOD::MuonContainer* muons = 0;
35 
36  // create a shallow copy container for the outputs
37  auto OutMuons = xAOD::shallowCopyContainer(*muons);
38  CHECK(evtStore()->record(OutMuons.first, m_output_muons));
39  CHECK(evtStore()->record(OutMuons.second, m_output_muons + "Aux."));
40 
41  for (xAOD::Muon* muon : *(OutMuons.first)) {
42  m_tool->setQuality(*muon);
43  m_tool->setPassesHighPtCuts(*muon);
44  m_tool->setPassesIDCuts(*muon);
45  // m_tool->setPassesLowPtEfficiencyCuts(*muon);
46  }
47 
48  return StatusCode::SUCCESS;
49  }
50 
51 } // namespace CP
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ShallowCopy.h
CP::MuonQualityUpdaterAlg::m_input_muons
std::string m_input_muons
Definition: MuonQualityUpdaterAlg.h:22
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
CP::MuonQualityUpdaterAlg::initialize
virtual StatusCode initialize()
Definition: MuonQualityUpdaterAlg.cxx:21
Muon.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::MuonQualityUpdaterAlg::execute
virtual StatusCode execute()
Definition: MuonQualityUpdaterAlg.cxx:31
MuonAuxContainer.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::MuonQualityUpdaterAlg::MuonQualityUpdaterAlg
MuonQualityUpdaterAlg(const std::string &name, ISvcLocator *svcloc)
Definition: MuonQualityUpdaterAlg.cxx:14
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CP::MuonQualityUpdaterAlg::m_output_muons
std::string m_output_muons
Definition: MuonQualityUpdaterAlg.h:23
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CP::MuonQualityUpdaterAlg::m_tool
ToolHandle< CP::IMuonSelectionTool > m_tool
Definition: MuonQualityUpdaterAlg.h:24
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::shallowCopyContainer
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, [[maybe_unused]] const EventContext &ctx)
Function making a shallow copy of a constant container.
Definition: ShallowCopy.h:110
MuonContainer.h
MuonQualityUpdaterAlg.h