ATLAS Offline Software
Loading...
Searching...
No Matches
AsgSelectionAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
16
17//
18// method implementations
19//
20
21namespace CP
22{
23
24 StatusCode AsgSelectionAlg ::
25 initialize ()
26 {
27 if (!m_selectionTool.empty())
28 {
29 ANA_CHECK (m_selectionTool.retrieve());
33 }
34
38 ANA_CHECK (m_systematicsList.initialize());
39
40 if (!m_selectionTool.empty())
41 {
42 asg::AcceptData blankAccept (&m_selectionTool->getAcceptInfo());
43 // Just in case this isn't initially set up as a failure clear it this one
44 // time. This only calls reset on the bitset
45 blankAccept.clear();
46 m_setOnFail = selectionFromAccept(blankAccept);
47
48 if (!m_nameSvc.empty())
49 {
50 ANA_CHECK (m_nameSvc.retrieve());
51 ANA_CHECK (m_nameSvc->addAcceptInfo (m_particlesHandle.getNamePattern(), m_selectionHandle.getLabel(),
52 m_selectionTool->getAcceptInfo()));
53 }
54 }
55
56 return StatusCode::SUCCESS;
57 }
58
59
60
61 StatusCode AsgSelectionAlg ::
62 execute ()
63 {
64 for (const auto& sys : m_systematicsList.systematicsVector())
65 {
67 ANA_CHECK (m_systematicsTool->applySystematicVariation (sys));
68
69 const xAOD::IParticleContainer *particles = nullptr;
70 ANA_CHECK (m_particlesHandle.retrieve (particles, sys));
71 for (const xAOD::IParticle *particle : *particles)
72 {
73 if (m_preselection.getBool (*particle, sys))
74 {
75 if (!m_selectionTool.empty())
76 {
77 m_selectionHandle.setBits
78 (*particle, selectionFromAccept (m_selectionTool->accept (particle)), sys);
79 }
80 else
81 {
82 m_selectionHandle.setBool (*particle, true, sys);
83 }
84 }
85 else
86 {
87 if (!m_selectionTool.empty())
88 {
89 m_selectionHandle.setBits (*particle, m_setOnFail, sys);
90 }
91 else
92 {
93 m_selectionHandle.setBool (*particle, false, sys);
94 }
95 }
96 }
97 }
98
99 return StatusCode::SUCCESS;
100 }
101}
#define ANA_CHECK(EXP)
check whether the given expression was successful
SelectionType m_setOnFail
the bits to set for an object failing the preselection
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle continer we run on
SysListHandle m_systematicsList
the systematics list we run
SysWriteSelectionHandle m_selectionHandle
the decoration for the asg selection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
ISystematicsTool * m_systematicsTool
the smearing tool cast to an ISystematicsTool
ServiceHandle< ISelectionNameSvc > m_nameSvc
the ISelectionNameSvc
ToolHandle< IAsgSelectionTool > m_selectionTool
the smearing tool
Interface for all CP tools supporting systematic variations.
void clear()
Clear all bits.
Definition AcceptData.h:54
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
SelectionType selectionFromAccept(const asg::AcceptData &accept)
the selection decoration made from the given AcceptData object
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.