ATLAS Offline Software
PhysicsAnalysis
DerivationFramework
DerivationFrameworkExamples
src
ThinningToolExample.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
// ThinningToolExample.cxx
8
// Author: James Catmore (James.Catmore@cern.ch)
9
// This is a trivial example of an implementation of a thinning tool
10
// which removes all ID tracks which do not pass a user-defined cut.
11
12
#include "
ThinningToolExample.h
"
13
#include "
xAODTracking/TrackParticleContainer.h
"
14
#include "
StoreGate/ThinningHandle.h
"
15
#include "GaudiKernel/ThreadLocalContext.h"
16
#include <vector>
17
#include <string>
18
19
20
// Destructor
21
DerivationFramework::ThinningToolExample::~ThinningToolExample
() {
22
}
23
24
25
// Athena initialize and finalize
26
StatusCode
DerivationFramework::ThinningToolExample::initialize
()
27
{
28
ATH_CHECK
( m_inDetSGKey.initialize (m_streamName) );
29
return
StatusCode::SUCCESS;
30
}
31
32
33
StatusCode
DerivationFramework::ThinningToolExample::finalize
()
34
{
35
ATH_MSG_INFO
(
"Processed "
<< m_ntot <<
" tracks, "
<< m_npass<<
" were retained "
);
36
return
StatusCode::SUCCESS;
37
}
38
39
40
// The thinning itself
41
StatusCode
DerivationFramework::ThinningToolExample::doThinning
()
const
42
{
43
const
EventContext& ctx = Gaudi::Hive::currentContext();
44
45
// Get the track container
46
SG::ThinningHandle<xAOD::TrackParticleContainer>
tracks (m_inDetSGKey, ctx);
47
m_ntot += tracks->size();
48
// Loop over tracks, see if they pass, set mask
49
std::vector<bool>
mask
;
50
for
(
const
xAOD::TrackParticle
*
track
: *tracks) {
51
if
(
track
->pt() > m_trackPtCut ) {++m_npass;
mask
.push_back(
true
);}
52
else
{
mask
.push_back(
false
); }
53
}
54
tracks.keep (
mask
);
55
56
return
StatusCode::SUCCESS;
57
}
58
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition:
AthMsgStreamMacros.h:31
ThinningHandle.h
Handle for requesting thinning for a data object.
ThinningToolExample.h
DerivationFramework::ThinningToolExample::~ThinningToolExample
virtual ~ThinningToolExample()
Destructor.
Definition:
ThinningToolExample.cxx:21
DerivationFramework::ThinningToolExample::initialize
virtual StatusCode initialize() override
Definition:
ThinningToolExample.cxx:26
python.utils.AtlRunQueryLookup.mask
string mask
Definition:
AtlRunQueryLookup.py:459
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition:
ThinningHandle.h:84
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
DerivationFramework::ThinningToolExample::finalize
virtual StatusCode finalize() override
Definition:
ThinningToolExample.cxx:33
DerivationFramework::ThinningToolExample::doThinning
virtual StatusCode doThinning() const override
Check that the current event passes this filter.
Definition:
ThinningToolExample.cxx:41
xAOD::track
@ track
Definition:
TrackingPrimitives.h:513
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:43
TrackParticleContainer.h
Generated on Mon Sep 29 2025 21:20:14 for ATLAS Offline Software by
1.8.18