ATLAS Offline Software
Loading...
Searching...
No Matches
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"
15#include <vector>
16#include <string>
17
18
19// Destructor
22
23
24// Athena initialize and finalize
26{
27 ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
28 return StatusCode::SUCCESS;
29}
30
31
33{
34 ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
35 return StatusCode::SUCCESS;
36}
37
38
39// The thinning itself
40StatusCode DerivationFramework::ThinningToolExample::doThinning(const EventContext& ctx) const
41{
42
43 // Get the track container
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
Handle for requesting thinning for a data object.
Gaudi::Property< std::string > m_streamName
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
virtual StatusCode doThinning(const EventContext &ctx) const override
Check that the current event passes this filter.
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Handle for requesting thinning for a data object.
TrackParticle_v1 TrackParticle
Reference the current persistent version: