ATLAS Offline Software
SkimmingToolExample.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // SkimmingToolExample.cxx, (c) ATLAS Detector software
8 // Author: James Catmore (James.Catmore@cern.ch)
9 // Based on the Integrated Simulation Framework
10 // This is a trivial example of an implementation of a skimming tool
11 // which only passes events with N combined muons passing a pt cut of M
12 
13 #include "SkimmingToolExample.h"
14 #include <vector>
15 #include <string>
16 
17 
19 {
20  ATH_MSG_INFO("Processed "<< m_ntot <<" events, "<< m_npass<<" events passed filter ");
21  return StatusCode::SUCCESS;
22 }
23 
24 
25 // The filter itself
27 {
28  ++m_ntot;
29 
30  // Retrieve muon container
31  const xAOD::MuonContainer* muons{nullptr};
32  StatusCode sc = evtStore()->retrieve(muons,m_muonSGKey);
33  if (sc.isFailure()) {
34  ATH_MSG_FATAL("No muon collection with name " << m_muonSGKey << " found in StoreGate!");
35  return false;
36  }
37 
38  // Loop over muons, count up and set decision
39  unsigned int nGoodMu{0};
40  for (const xAOD::Muon* muon : *muons) {
41  if ( muon->muonType() == xAOD::Muon::Combined && muon->pt() > m_muonPtCut ) ++nGoodMu;
42  }
43  bool acceptEvent{false};
44  if (nGoodMu >= m_nMuons) {
45  acceptEvent = true;
46  ++m_npass;
47  }
48  return acceptEvent;
49 
50 }
51 
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::SkimmingToolExample::finalize
virtual StatusCode finalize() override
Athena algtool's Hooks.
Definition: SkimmingToolExample.cxx:18
SkimmingToolExample.h
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
DerivationFramework::SkimmingToolExample::eventPassesFilter
virtual bool eventPassesFilter() const override
Check that the current event passes this filter.
Definition: SkimmingToolExample.cxx:26
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DerivationFramework::SkimmingToolExample::m_ntot
std::atomic< unsigned int > m_ntot
Definition: SkimmingToolExample.h:52
DerivationFramework::SkimmingToolExample::m_npass
std::atomic< unsigned int > m_npass
Definition: SkimmingToolExample.h:53
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Trk::Combined
@ Combined
Definition: TrackSummaryTool.h:32