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 <vector>
15
#include <string>
16
17
18
StatusCode
DerivationFramework::SkimmingToolExample::finalize
()
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
26
bool
DerivationFramework::SkimmingToolExample::eventPassesFilter
(
const
EventContext&
/*ctx*/
)
const
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::MuonType::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
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
SkimmingToolExample.h
DerivationFramework::SkimmingToolExample::eventPassesFilter
virtual bool eventPassesFilter(const EventContext &ctx) const override
Check that the current event passes this filter.
Definition
SkimmingToolExample.cxx:26
DerivationFramework::SkimmingToolExample::m_muonPtCut
Gaudi::Property< double > m_muonPtCut
Definition
SkimmingToolExample.h:50
DerivationFramework::SkimmingToolExample::m_nMuons
Gaudi::Property< unsigned int > m_nMuons
Definition
SkimmingToolExample.h:47
DerivationFramework::SkimmingToolExample::m_ntot
std::atomic< unsigned int > m_ntot
Definition
SkimmingToolExample.h:52
DerivationFramework::SkimmingToolExample::m_muonSGKey
Gaudi::Property< std::string > m_muonSGKey
Definition
SkimmingToolExample.h:44
DerivationFramework::SkimmingToolExample::finalize
virtual StatusCode finalize() override
Athena algtool's Hooks.
Definition
SkimmingToolExample.cxx:18
DerivationFramework::SkimmingToolExample::m_npass
std::atomic< unsigned int > m_npass
Definition
SkimmingToolExample.h:53
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
xAOD::MuonContainer
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Definition
Event/xAOD/xAODMuon/xAODMuon/MuonContainer.h:14
Generated on
for ATLAS Offline Software by
1.17.0