ATLAS Offline Software
Loading...
Searching...
No Matches
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"
15#include <vector>
16#include <string>
17
18
20{
21 ATH_CHECK(m_muonSGKey.initialize());
22 return StatusCode::SUCCESS;
23}
24
25
27{
28 ATH_MSG_INFO("Processed "<< m_ntot <<" events, "<< m_npass<<" events passed filter ");
29 return StatusCode::SUCCESS;
30}
31
32
33// The filter itself
35{
36 ++m_ntot;
37
38 // Retrieve muon container
40 if (!muons.isValid()) {
41 ATH_MSG_FATAL("No muon collection with name " << m_muonSGKey.key() << " found in StoreGate!");
42 return false;
43 }
44
45 // Loop over muons, count up and set decision
46 unsigned int nGoodMu{0};
47 for (const xAOD::Muon* muon : *muons) {
48 if ( muon->muonType() == xAOD::Muon::MuonType::Combined && muon->pt() > m_muonPtCut ) ++nGoodMu;
49 }
50 bool acceptEvent{false};
51 if (nGoodMu >= m_nMuons) {
52 acceptEvent = true;
53 ++m_npass;
54 }
55 return acceptEvent;
56
57}
58
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
Handle class for reading from StoreGate.
virtual bool eventPassesFilter(const EventContext &ctx) const override
Check that the current event passes this filter.
Gaudi::Property< unsigned int > m_nMuons
virtual StatusCode initialize() override
Athena algtool's Hooks.
SG::ReadHandleKey< xAOD::MuonContainer > m_muonSGKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Muon_v1 Muon
Reference the current persistent version:
Definition Muon.h:13