ATLAS Offline Software
Loading...
Searching...
No Matches
AsgUnionPreselectionAlg.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// includes
9//
10
12
13#include <xAODBase/IParticle.h>
14
15//
16// method implementations
17//
18
19namespace CP
20{
21
22 StatusCode AsgUnionPreselectionAlg ::
23 initialize ()
24 {
25 if (m_selectionDecoration.empty())
26 {
27 ANA_MSG_ERROR("Selection decoration can not be empty.");
28 return StatusCode::FAILURE;
29 }
30 if (m_preselection.empty())
31 {
32 ANA_MSG_ERROR("Preselection can not be empty.");
33 return StatusCode::FAILURE;
34 }
35
38 ANA_CHECK (m_systematicsList.initialize());
39
41
42 return StatusCode::SUCCESS;
43 }
44
45
46
47 StatusCode AsgUnionPreselectionAlg ::
48 execute ()
49 {
50 // first loop through systematics and set the default selection
51 for (const auto& sys : m_systematicsList.systematicsVector())
52 {
53 const xAOD::IParticleContainer *particles = nullptr;
54 ANA_CHECK (m_particlesHandle.retrieve (particles, sys));
55 for (auto *particle : *particles)
56 {
57 (*m_decorator) (*particle) = false;
58 }
59 }
60
61 // second loop through systematics, and set the selection to true if
62 // particle passes the selection
63 for (const auto& sys : m_systematicsList.systematicsVector())
64 {
65 const xAOD::IParticleContainer *particles = nullptr;
66 ANA_CHECK (m_particlesHandle.retrieve (particles, sys));
67 for (auto *particle : *particles)
68 {
69 if (!(*m_decorator) (*particle) && m_preselection.getBool (*particle, sys))
70 (*m_decorator) (*particle) = true;
71 }
72 }
73
74 return StatusCode::SUCCESS;
75 }
76
77} // namespace CP
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
std::optional< SG::Decorator< char > > m_decorator
the accessor for m_selectionDecoration
Gaudi::Property< std::string > m_selectionDecoration
the decoration of the selection
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle continer we run on
SysListHandle m_systematicsList
the systematics list we run and have containers
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Select isolated Photons, Electrons and Muons.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.