ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleLevelJetsAlg.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
8
12
13namespace CP {
14
16
17 ANA_CHECK(m_jetsKey.initialize());
18 ANA_CHECK(m_eventInfoKey.initialize());
19 ANA_CHECK(m_truthLabelKey.initialize());
20 ANA_CHECK(m_decNumTruthBJetsKey.initialize());
21 ANA_CHECK(m_decNumTruthCJetsKey.initialize());
22
23 return StatusCode::SUCCESS;
24}
25
26StatusCode ParticleLevelJetsAlg::execute(const EventContext &ctx) const {
27
30
31 // accessors and decorators
37
38 // decoration availability is a property of the whole container
39 const bool hasFlav = acc_flav.isAvailable();
40
41 // the number of b- and c-jets without any event cuts applied
42 int num_bjets(0), num_cjets(0);
43
44 for (const auto* jet : *jets) {
45
46 // check the flavour label of the jet
47 if (hasFlav) {
48 int flavourLabel = acc_flav(*jet);
49 if (flavourLabel == 5)
50 num_bjets++;
51 if (flavourLabel == 4)
52 num_cjets++;
53 } else {
54 if (!m_warnedMissingLabel.exchange(true))
56 "Truth jet is missing the decoration: HadronConeExclTruthLabelID.");
57 num_bjets = num_cjets = -999;
58 break;
59 }
60 }
61
62 // decorate the EventInfo with the number of b- and c-jets
63 dec_nBJets(*eventInfo) = num_bjets;
64 dec_nCJets(*eventInfo) = num_cjets;
65
66 return StatusCode::SUCCESS;
67}
68
69} // namespace CP
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
#define ANA_CHECK(EXP)
check whether the given expression was successful
#define ANA_MSG_WARNING(xmsg,...)
Macro printing warning messages.
SG::ReadDecorHandleKey< xAOD::JetContainer > m_truthLabelKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_decNumTruthCJetsKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_decNumTruthBJetsKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
std::atomic< bool > m_warnedMissingLabel
virtual StatusCode initialize() final
virtual StatusCode execute(const EventContext &ctx) const final
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Handle class for reading a decoration on an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
Handle class for adding a decoration to an object.
Select isolated Photons, Electrons and Muons.