ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
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 <vector>
16
#include <string>
17
18
19
// Destructor
20
DerivationFramework::ThinningToolExample::~ThinningToolExample
() {
21
}
22
23
24
// Athena initialize and finalize
25
StatusCode
DerivationFramework::ThinningToolExample::initialize
()
26
{
27
ATH_CHECK
(
m_inDetSGKey
.initialize (
m_streamName
) );
28
return
StatusCode::SUCCESS;
29
}
30
31
32
StatusCode
DerivationFramework::ThinningToolExample::finalize
()
33
{
34
ATH_MSG_INFO
(
"Processed "
<<
m_ntot
<<
" tracks, "
<<
m_npass
<<
" were retained "
);
35
return
StatusCode::SUCCESS;
36
}
37
38
39
// The thinning itself
40
StatusCode
DerivationFramework::ThinningToolExample::doThinning
(
const
EventContext& ctx)
const
41
{
42
43
// Get the track container
44
SG::ThinningHandle<xAOD::TrackParticleContainer>
tracks (
m_inDetSGKey
, ctx);
45
m_ntot
+= tracks->size();
46
// Loop over tracks, see if they pass, set mask
47
std::vector<bool> mask;
48
for
(
const
xAOD::TrackParticle
* track : *tracks) {
49
if
( track->pt() >
m_trackPtCut
) {++
m_npass
; mask.push_back(
true
);}
50
else
{ mask.push_back(
false
); }
51
}
52
tracks.
keep
(mask);
53
54
return
StatusCode::SUCCESS;
55
}
56
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:31
TrackParticleContainer.h
ThinningHandle.h
Handle for requesting thinning for a data object.
ThinningToolExample.h
DerivationFramework::ThinningToolExample::m_streamName
Gaudi::Property< std::string > m_streamName
Definition
ThinningToolExample.h:44
DerivationFramework::ThinningToolExample::m_ntot
std::atomic< unsigned int > m_ntot
Definition
ThinningToolExample.h:52
DerivationFramework::ThinningToolExample::~ThinningToolExample
virtual ~ThinningToolExample()
Destructor.
Definition
ThinningToolExample.cxx:20
DerivationFramework::ThinningToolExample::initialize
virtual StatusCode initialize() override
Definition
ThinningToolExample.cxx:25
DerivationFramework::ThinningToolExample::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition
ThinningToolExample.h:50
DerivationFramework::ThinningToolExample::finalize
virtual StatusCode finalize() override
Definition
ThinningToolExample.cxx:32
DerivationFramework::ThinningToolExample::m_trackPtCut
Gaudi::Property< double > m_trackPtCut
Definition
ThinningToolExample.h:47
DerivationFramework::ThinningToolExample::doThinning
virtual StatusCode doThinning(const EventContext &ctx) const override
Check that the current event passes this filter.
Definition
ThinningToolExample.cxx:40
DerivationFramework::ThinningToolExample::m_npass
std::atomic< unsigned int > m_npass
Definition
ThinningToolExample.h:53
SG::ThinningHandleBase::keep
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Definition
ThinningHandleBase.cxx:75
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition
ThinningHandle.h:84
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
Generated on
for ATLAS Offline Software by
1.17.0