ATLAS Offline Software
ThinningToolExample.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // ThinningToolExample.cxx, (c) ATLAS Detector software
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 
15 #include "GaudiKernel/ThreadLocalContext.h"
16 #include <vector>
17 #include <string>
18 
19 // Constructor
21  const std::string& n,
22  const IInterface* p ) :
23  base_class(t,n,p),
24  m_ntot(0),
25  m_npass(0),
26  m_trackPtCut(20.0)
27  {
28  declareProperty("TrackPtCut", m_trackPtCut);
29  }
30 
31 // Destructor
33 }
34 
35 // Athena initialize and finalize
37 {
38  ATH_MSG_VERBOSE("initialize() ...");
39  ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
40  return StatusCode::SUCCESS;
41 }
43 {
44  ATH_MSG_VERBOSE("finalize() ...");
45  ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
46  return StatusCode::SUCCESS;
47 }
48 
49 // The thinning itself
51 {
52  const EventContext& ctx = Gaudi::Hive::currentContext();
53 
54  // Get the track container
55  SG::ThinningHandle<xAOD::TrackParticleContainer> tracks (m_inDetSGKey, ctx);
56  m_ntot+=tracks->size();
57  // Loop over tracks, see if they pass, set mask
58  std::vector<bool> mask;
59  for (xAOD::TrackParticleContainer::const_iterator trackIt=tracks->begin(); trackIt!=tracks->end(); ++trackIt) {
60  if ( (*trackIt)->pt() > m_trackPtCut ) {++m_npass; mask.push_back(true);}
61  else { mask.push_back(false); }
62  }
63  tracks.keep (mask);
64 
65  return StatusCode::SUCCESS;
66 }
67 
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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:32
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::ThinningToolExample::initialize
virtual StatusCode initialize() override
Definition: ThinningToolExample.cxx:36
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
SG::ThinningHandleBase::keep
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Definition: ThinningHandleBase.cxx:68
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DerivationFramework::ThinningToolExample::ThinningToolExample
ThinningToolExample(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: ThinningToolExample.cxx:20
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::ThinningToolExample::finalize
virtual StatusCode finalize() override
Definition: ThinningToolExample.cxx:42
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
DerivationFramework::ThinningToolExample::doThinning
virtual StatusCode doThinning() const override
Check that the current event passes this filter.
Definition: ThinningToolExample.cxx:50
DerivationFramework::ThinningToolExample::m_trackPtCut
double m_trackPtCut
Definition: ThinningToolExample.h:55
TrackParticleContainer.h