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"
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
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
static Double_t sc
virtual bool eventPassesFilter() const override
Check that the current event passes this filter.
Gaudi::Property< unsigned int > m_nMuons
Gaudi::Property< std::string > m_muonSGKey
virtual StatusCode finalize() override
Athena algtool's Hooks.
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".