Loading [MathJax]/jax/input/TeX/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
VectorExampleTool.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 
7 //
8 // includes
9 //
10 
12 
13 //
14 // method implementations
15 //
16 
17 namespace columnar
18 {
20  VectorExampleTool (const std::string& name)
21  : AsgTool (name)
22  {}
23 
24 
25 
27  initialize ()
28  {
29  // give the base class a chance to initialize the column accessor
30  // backends
31  ANA_CHECK (initializeColumns());
32  return StatusCode::SUCCESS;
33  }
34 
35 
36 
39  {
40  // loop over all events and particles. note that this is
41  // deliberately looping by value, as the ID classes are very small
42  // and can be copied cheaply. this could have also been written as
43  // a single loop over all particles in the event range, but I chose
44  // to split it up into two loops as most tools will need to do some
45  // per-event things, e.g. retrieve `EventInfo`.
47  {
48  for (ParticleId particle : particlesHandle(event))
49  {
50  // in pactical terms we should find the index of the primary
51  // vertex, but for purposes of the example we just use the first
52  // vertex instead
53  const std::size_t index = 0;
54 
55  // it is actually safe to copy the return value of the
56  // accessors, as those are ranges that are cheap to copy
57  auto trknum = trknumAcc(particle);
58  auto trksumpt = trksumptAcc(particle);
59 
60  // this is probably not a meaningful selection, but it hopefully
61  // illustrates how to use the vector accessors
62  selectionDec(particle) = ptAcc(particle) > m_ptCut.value() && trknum.size() > index && trknum[index] > 2 && trksumpt.size() > index && trksumpt[index] > 2e3;
63  }
64  }
65  }
66 }
columnar::VectorExampleTool::ptAcc
ParticleAccessor< float > ptAcc
the pt accessor for the particle container
Definition: VectorExampleTool.h:58
columnar::VectorExampleTool::trksumptAcc
ParticleAccessor< std::vector< RetypeColumn< double, float > > > trksumptAcc
a vector accessor involving retyping
Definition: VectorExampleTool.h:76
index
Definition: index.py:1
columnar::VectorExampleTool::selectionDec
ParticleDecorator< char > selectionDec
the selection decorator for the particles
Definition: VectorExampleTool.h:87
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
columnar::VectorExampleTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: VectorExampleTool.cxx:27
columnar::ObjectRange
a class representing a continuous sequence of objects (a.k.a. a container)
Definition: ObjectRange.h:18
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
columnar::VectorExampleTool::trknumAcc
ParticleAccessor< std::vector< int > > trknumAcc
a vector column accessor
Definition: VectorExampleTool.h:66
columnar::VectorExampleTool::particlesHandle
ParticleAccessor< ObjectColumn > particlesHandle
the object accessor for the particles
Definition: VectorExampleTool.h:49
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
columnar::VectorExampleTool::m_ptCut
Gaudi::Property< float > m_ptCut
the pt cut to apply
Definition: VectorExampleTool.h:41
columnar::ObjectId
a class representing a single object (electron, muons, etc.)
Definition: ObjectId.h:18
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VectorExampleTool.h
columnar::VectorExampleTool::callEvents
virtual void callEvents(EventContextRange events) const override
Definition: VectorExampleTool.cxx:38
DeMoScan.index
string index
Definition: DeMoScan.py:364
columnar
Definition: ClusterDef.h:16
columnar::VectorExampleTool::VectorExampleTool
VectorExampleTool(const std::string &name)
Definition: VectorExampleTool.cxx:20