ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleLevelJetsAlg.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
8
9namespace CP {
10
12
13 ANA_CHECK(m_jetsKey.initialize());
14 ANA_CHECK(m_eventInfoKey.initialize());
15
16 return StatusCode::SUCCESS;
17}
18
19StatusCode ParticleLevelJetsAlg::execute(const EventContext &ctx) const {
20
23
24 // accessors
25 static const SG::ConstAccessor<int> acc_flav(
26 "HadronConeExclTruthLabelID");
27
28 // decorators
29 static const SG::Decorator<int> dec_nBJets(
30 "num_truth_bjets_nocuts");
31 static const SG::Decorator<int> dec_nCJets(
32 "num_truth_cjets_nocuts");
33
34 // the number of b- and c-jets without any event cuts applied
35 int num_bjets(0), num_cjets(0);
36
37 for (const auto* jet : *jets) {
38
39 // check the flavour label of the jet
40 if (acc_flav.isAvailable(*jet)) {
41 int flavourLabel = acc_flav(*jet);
42 if (flavourLabel == 5)
43 num_bjets++;
44 if (flavourLabel == 4)
45 num_cjets++;
46 } else {
48 "Truth jet is missing the decoration: HadronConeExclTruthLabelID.");
49 num_bjets = num_cjets = -999;
50 }
51 }
52
53 // decorate the EventInfo with the number of b- and c-jets
54 dec_nBJets(*eventInfo) = num_bjets;
55 dec_nCJets(*eventInfo) = num_cjets;
56
57 return StatusCode::SUCCESS;
58}
59
60} // namespace CP
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
virtual StatusCode initialize() final
virtual StatusCode execute(const EventContext &ctx) const final
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
Select isolated Photons, Electrons and Muons.