ATLAS Offline Software
Loading...
Searching...
No Matches
MomentumAccessorExampleTool.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
17namespace columnar
18{
19 MomentumAccessorExampleTool ::
20 MomentumAccessorExampleTool (const std::string& name)
21 : AsgTool (name)
22 {}
23
24
25
26 StatusCode MomentumAccessorExampleTool ::
27 initialize ()
28 {
29 if (auto type = objectTypeAcc.staticType())
30 resetObjectType (momAcc, *this, *type);
31 else
32 ANA_MSG_INFO ("ObjectTypeAccessor: no object type set, using default");
33
34 // give the base class a chance to initialize the column accessor
35 // backends
36 ANA_CHECK (initializeColumns());
37 return StatusCode::SUCCESS;
38 }
39
40
41
42 void MomentumAccessorExampleTool ::
43 callSingleEvent (ParticleRange particles) const
44 {
45 for (ParticleId particle : particles)
46 {
47 selectionDec(particle) = momAcc.e(particle) > m_energyCut.value();
48 }
49 }
50
51
52
53 void MomentumAccessorExampleTool ::
54 callEvents (EventContextRange events) const
55 {
56 // loop over all events and particles. note that this is
57 // deliberately looping by value, as the ID classes are very small
58 // and can be copied cheaply. this could have also been written as
59 // a single loop over all particles in the event range, but I chose
60 // to split it up into two loops as most tools will need to do some
61 // per-event things, e.g. retrieve `EventInfo`.
62 for (columnar::EventContextId event : events)
63 {
65 }
66 }
67}
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
MomentumAccessors< ContainerId::particle > momAcc
the momentum accessors for the particle container
Gaudi::Property< float > m_energyCut
the energy cut to apply
void callSingleEvent(ParticleRange particles) const
ObjectTypeAccessor< ContainerId::particle > objectTypeAcc
the object type accessor for the particle container
ParticleAccessor< ObjectColumn > particlesHandle
the object accessor for the particles
ParticleDecorator< char > selectionDec
the selection decorator for the particles
ObjectRange< ContainerId::particle > ParticleRange
Definition ParticleDef.h:35
void resetObjectType(MomentumAccessors< CI, CM > &accessors, ColumnarTool< CM > &columnarTool, xAODType::ObjectType type)
ObjectRange< ContainerId::eventContext > EventContextRange
ObjectId< ContainerId::particle > ParticleId
Definition ParticleDef.h:36
ObjectId< ContainerId::eventContext > EventContextId