ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Columnar
ColumnarExampleTools
Root
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
11
#include <
ColumnarExampleTools/VectorExampleTool.h
>
12
13
//
14
// method implementations
15
//
16
17
namespace
columnar
18
{
19
VectorExampleTool ::
20
VectorExampleTool (
const
std::string& name)
21
:
AsgTool
(name)
22
{}
23
24
25
26
StatusCode VectorExampleTool ::
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
37
void
VectorExampleTool ::
38
callSingleEvent (
ParticleRange
particles)
const
39
{
40
// loop over all particles. note that this is deliberately looping
41
// by value, as the ID classes are very small and can be copied
42
// cheaply. this could have also been written as a single loop over
43
// all particles in the event range, but I chose to split it up into
44
// two loops as most tools will need to do some per-event things,
45
// e.g. retrieve `EventInfo`.
46
for
(
ParticleId
particle : particles)
47
{
48
// in pactical terms we should find the index of the primary
49
// vertex, but for purposes of the example we just use the first
50
// vertex instead
51
const
std::size_t
index
= 0;
52
53
// it is actually safe to copy the return value of the
54
// accessors, as those are ranges that are cheap to copy
55
auto
trknum =
trknumAcc
(particle);
56
auto
trksumpt =
trksumptAcc
(particle);
57
58
// this is probably not a meaningful selection, but it hopefully
59
// illustrates how to use the vector accessors
60
selectionDec
(particle) =
ptAcc
(particle) >
m_ptCut
.value() && trknum.size() >
index
&& trknum[
index
] > 2 && trksumpt.size() >
index
&& trksumpt[
index
] > 2e3;
61
}
62
}
63
64
65
66
void
VectorExampleTool ::
67
callEvents (
EventContextRange
events)
const
68
{
69
// loop over all events and particles. note that this is
70
// deliberately looping by value, as the ID classes are very small
71
// and can be copied cheaply. this could have also been written as
72
// a single loop over all particles in the event range, but I chose
73
// to split it up into two loops as most tools will need to do some
74
// per-event things, e.g. retrieve `EventInfo`.
75
for
(
columnar::EventContextId
event : events)
76
callSingleEvent
(
particlesHandle
(event));
77
}
78
}
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
VectorExampleTool.h
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
columnar::VectorExampleTool::trknumAcc
ParticleAccessor< std::vector< int > > trknumAcc
a vector column accessor
Definition
VectorExampleTool.h:71
columnar::VectorExampleTool::selectionDec
ParticleDecorator< char > selectionDec
the selection decorator for the particles
Definition
VectorExampleTool.h:92
columnar::VectorExampleTool::trksumptAcc
ParticleAccessor< std::vector< RetypeColumn< double, float > > > trksumptAcc
a vector accessor involving retyping
Definition
VectorExampleTool.h:81
columnar::VectorExampleTool::particlesHandle
ParticleAccessor< ObjectColumn > particlesHandle
the object accessor for the particles
Definition
VectorExampleTool.h:54
columnar::VectorExampleTool::ptAcc
ParticleAccessor< float > ptAcc
the pt accessor for the particle container
Definition
VectorExampleTool.h:63
columnar::VectorExampleTool::callSingleEvent
void callSingleEvent(ParticleRange particles) const
Definition
VectorExampleTool.cxx:38
columnar::VectorExampleTool::m_ptCut
Gaudi::Property< float > m_ptCut
the pt cut to apply
Definition
VectorExampleTool.h:46
columnar
Definition
ClusterDef.h:16
columnar::EventContextRange
ObjectRange< EventContextDef > EventContextRange
Definition
ContainerId.h:211
columnar::EventContextId
ObjectId< EventContextDef > EventContextId
Definition
ContainerId.h:212
columnar::ParticleId
ObjectId< ParticleDef > ParticleId
Definition
ParticleDef.h:33
columnar::ParticleRange
ObjectRange< ParticleDef > ParticleRange
Definition
ParticleDef.h:32
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0