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
11// accessors and decorators
12// these are done at file-level to register types with output algorithms
14 "HadronConeExclTruthLabelID");
16 "num_truth_bjets_nocuts");
18 "num_truth_cjets_nocuts");
19
21
22 ANA_CHECK(m_jetsKey.initialize());
23 ANA_CHECK(m_eventInfoKey.initialize());
24
25 return StatusCode::SUCCESS;
26}
27
28StatusCode ParticleLevelJetsAlg::execute(const EventContext &ctx) const {
29
32
33 // the number of b- and c-jets without any event cuts applied
34 int num_bjets(0), num_cjets(0);
35
36 for (const auto* jet : *jets) {
37
38 // check the flavour label of the jet
39 if (acc_flav.isAvailable(*jet)) {
40 int flavourLabel = acc_flav(*jet);
41 if (flavourLabel == 5)
42 num_bjets++;
43 if (flavourLabel == 4)
44 num_cjets++;
45 } else {
47 "Truth jet is missing the decoration: HadronConeExclTruthLabelID.");
48 num_bjets = num_cjets = -999;
49 }
50 }
51
52 // decorate the EventInfo with the number of b- and c-jets
53 dec_nBJets(*eventInfo) = num_bjets;
54 dec_nCJets(*eventInfo) = num_cjets;
55
56 return StatusCode::SUCCESS;
57}
58
59} // 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.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
Select isolated Photons, Electrons and Muons.
static const SG::Decorator< int > dec_nBJets("num_truth_bjets_nocuts")
static const SG::ConstAccessor< int > acc_flav("HadronConeExclTruthLabelID")
static const SG::Decorator< int > dec_nCJets("num_truth_cjets_nocuts")