ATLAS Offline Software
Loading...
Searching...
No Matches
ModularExampleTool.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 ModularExampleTool ::
20 ModularExampleTool (const std::string& name)
21 : AsgTool (name)
22 {}
23
24
25
26 StatusCode ModularExampleTool ::
27 initialize ()
28 {
29 m_subtoolPt = std::make_unique<SubtoolPt> (m_ptCut.value());
30
31 // all subtools need to be connected to the base class, so that the
32 // accessors can be properly connected in columnar mode.
33 addSubtool (*m_subtoolPt);
34
37 m_subtoolEta = std::make_unique<SubtoolEta> (this, m_etaCut.value());
38
39 // give the base class a chance to initialize the column accessor
40 // backends
41 ANA_CHECK (initializeColumns());
42 return StatusCode::SUCCESS;
43 }
44
45
46
47 void ModularExampleTool ::
48 callEvents (EventContextRange events) const
49 {
50 // loop over all events and particles. note that this is
51 // deliberately looping by value, as the ID classes are very small
52 // and can be copied cheaply. this could have also been written as
53 // a single loop over all particles in the event range, but I chose
54 // to split it up into two loops as most tools will need to do some
55 // per-event things, e.g. retrieve `EventInfo`.
56 for (columnar::EventContextId event : events)
57 {
58 for (columnar::ParticleId particle : particlesHandle(event))
59 {
60 selectionDec(particle) = m_subtoolPt->select (particle) && m_subtoolEta->select (particle);
61 }
62 }
63 }
64
65
66
67 ModularExampleTool::SubtoolPt ::
68 SubtoolPt (float val_cutValue)
69 : m_cutValue (val_cutValue)
70 {}
71
72
73
74 bool ModularExampleTool::SubtoolPt ::
75 select (ParticleId particle) const
76 {
77 return ptAcc(particle) > m_cutValue;
78 }
79
80
81
82 ModularExampleTool::SubtoolEta ::
83 SubtoolEta (ColumnarTool<> *val_parent, float val_cutValue)
84 : ColumnarTool<> (val_parent), m_cutValue (val_cutValue)
85 {}
86
87
88
89 bool ModularExampleTool::SubtoolEta ::
90 select (ParticleId particle) const
91 {
92 return std::abs(etaAcc(particle)) < m_cutValue;
93 }
94}
#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
std::unique_ptr< SubtoolEta > m_subtoolEta
std::unique_ptr< SubtoolPt > m_subtoolPt
Gaudi::Property< float > m_etaCut
the eta cut to apply
ParticleDecorator< char > selectionDec
the selection decorator for the particles
ParticleAccessor< ObjectColumn > particlesHandle
the object accessor for the particles
Gaudi::Property< float > m_ptCut
the pt cut to apply
ObjectRange< ContainerId::eventContext > EventContextRange
ObjectId< ContainerId::particle > ParticleId
Definition ParticleDef.h:36
ObjectId< ContainerId::eventContext > EventContextId