ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkExamples
src
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 "
StoreGate/ReadHandle.h
"
15
#include <vector>
16
#include <string>
17
18
19
StatusCode
DerivationFramework::SkimmingToolExample::initialize
()
20
{
21
ATH_CHECK
(
m_muonSGKey
.initialize());
22
return
StatusCode::SUCCESS;
23
}
24
25
26
StatusCode
DerivationFramework::SkimmingToolExample::finalize
()
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
34
bool
DerivationFramework::SkimmingToolExample::eventPassesFilter
(
const
EventContext& ctx)
const
35
{
36
++
m_ntot
;
37
38
// Retrieve muon container
39
SG::ReadHandle<xAOD::MuonContainer>
muons(
m_muonSGKey
, ctx);
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
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x,...)
Definition
AthMsgStreamMacros.h:48
SkimmingToolExample.h
ReadHandle.h
Handle class for reading from StoreGate.
DerivationFramework::SkimmingToolExample::eventPassesFilter
virtual bool eventPassesFilter(const EventContext &ctx) const override
Check that the current event passes this filter.
Definition
SkimmingToolExample.cxx:34
DerivationFramework::SkimmingToolExample::m_muonPtCut
Gaudi::Property< double > m_muonPtCut
Definition
SkimmingToolExample.h:52
DerivationFramework::SkimmingToolExample::m_nMuons
Gaudi::Property< unsigned int > m_nMuons
Definition
SkimmingToolExample.h:49
DerivationFramework::SkimmingToolExample::m_ntot
std::atomic< unsigned int > m_ntot
Definition
SkimmingToolExample.h:54
DerivationFramework::SkimmingToolExample::initialize
virtual StatusCode initialize() override
Athena algtool's Hooks.
Definition
SkimmingToolExample.cxx:19
DerivationFramework::SkimmingToolExample::m_muonSGKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonSGKey
Definition
SkimmingToolExample.h:46
DerivationFramework::SkimmingToolExample::finalize
virtual StatusCode finalize() override
Definition
SkimmingToolExample.cxx:26
DerivationFramework::SkimmingToolExample::m_npass
std::atomic< unsigned int > m_npass
Definition
SkimmingToolExample.h:55
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Muon.h:13
Generated on
for ATLAS Offline Software by
1.17.0