ATLAS Offline Software
Loading...
Searching...
No Matches
CopyNominalSelectionAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
15//
16// method implementations
17//
18
19namespace CP
20{
21 StatusCode CopyNominalSelectionAlg ::
22 initialize ()
23 {
27 ANA_CHECK (m_systematicsList.initialize());
28
29 bool hasNominal = false;
30 for (const auto& sys : m_systematicsList.systematicsVector())
31 hasNominal |= sys.empty();
32 if (!hasNominal) {
33 ANA_MSG_ERROR ("nominal systematic not in systematics list, cannot copy nominal selection");
34 return StatusCode::FAILURE;
35 }
36
38 ANA_CHECK (m_readAccessor->fillSystematics (m_systematicsList.service(), m_systematicsList.systematicsVector(), m_particlesHandle));
39
40 return StatusCode::SUCCESS;
41 }
42
43
44
45 StatusCode CopyNominalSelectionAlg ::
46 execute (const EventContext& ctx)
47 {
48 static const SystematicSet emptySys;
49 const xAOD::IParticleContainer *nominal = nullptr;
50 ANA_CHECK (m_particlesHandle.retrieve (nominal, emptySys, ctx));
51
52 for (const auto& sys : m_systematicsList.systematicsVector())
53 {
54 if (sys.empty()) continue;
55
56 const xAOD::IParticleContainer *particles = nullptr;
57 ANA_CHECK (m_particlesHandle.retrieve (particles, sys, ctx));
58 if (particles->size() != nominal->size())
59 {
60 ANA_MSG_ERROR ("systematic container " << sys.name() << " has a different number "
61 "of objects than nominal, can't copy selections!");
62 return StatusCode::FAILURE;
63 }
64
65 for (std::size_t index = 0u; index != particles->size(); ++ index)
66 {
67 const xAOD::IParticle *particle = particles->at (index);
68 if (m_preselection.getBool (*particle, sys))
69 {
70 bool passedNominal = m_readAccessor->getBool (*nominal->at(index), &emptySys);
71 m_selectionHandle.setBool (*particle, passedNominal, sys);
72 }
73 else
74 {
75 m_selectionHandle.setBool (*particle, false, sys);
76 }
77 }
78 }
79
80 return StatusCode::SUCCESS;
81 }
82}
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
SysReadSelectionHandle m_preselection
the preselection we apply to our input
SysWriteSelectionHandle m_selectionHandle
the decoration for the asg selection
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle continer we run on
std::unique_ptr< ISelectionReadAccessor > m_readAccessor
the accessor we use
SysListHandle m_systematicsList
the systematics list we run
Class to wrap a set of SystematicVariations.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
Definition index.py:1
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.