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 "GaudiKernel/ThreadLocalContext.h"
16#include <vector>
17#include <string>
18
19
20// Destructor
23
24
25// Athena initialize and finalize
27{
28 ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
29 return StatusCode::SUCCESS;
30}
31
32
34{
35 ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
36 return StatusCode::SUCCESS;
37}
38
39
40// The thinning itself
42{
43 const EventContext& ctx = Gaudi::Hive::currentContext();
44
45 // Get the track container
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
#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
virtual StatusCode doThinning() const override
Check that the current event passes this filter.
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
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: