31 {
33 ATH_CHECK(evtStore()->retrieve(evt,
"EventInfo"));
34
35
37 if (!isMC) { return StatusCode::SUCCESS; }
38
39 auto mu_actual =
static_cast<std::size_t
>(std::ceil(
evt->actualInteractionsPerCrossing()));
40
41
42
44
45
46 double pt_j0_AK4HS {5.0};
47 std::size_t idx_HS {0};
50 if (hs_jets->
size()) {
51 auto iter_jet = std::max_element(hs_jets->
begin(), hs_jets->
end(),
53 pt_j0_AK4HS = (*iter_jet)->pt() /
GeV;
55 }
56
58
59
60 std::vector<double> pt_j0_AK4PU;
63 std::unordered_map<int, double> leading_pts;
64 if (pu_jets->
size()) {
65 for (
const xAOD::Jet* pu_jet : *pu_jets) {
66 SG::ConstAccessor<int> pu_enum_acc("pileupEventNumber");
67 const uint32_t pu_enum =
static_cast<uint32_t>(pu_enum_acc.withDefault(*pu_jet, 0));
68 double pu_jet_pt = pu_jet->pt() /
GeV;
69 if (!leading_pts.contains(pu_enum) || leading_pts.at(pu_enum) < pu_jet_pt) {
70 leading_pts[pu_enum] = pu_jet_pt;
71 }
72 }
73 }
74 auto n_pileup_records = leading_pts.size();
75
76 for (const auto& pair : leading_pts) {
77 double pt = pair.second;
78 pt_j0_AK4PU.push_back(pt);
81 }
82
83
84 categories[0] += mu_actual - n_pileup_records - 1;
85
86
87 std::stringstream key_ss;
88 std::string delim {"_"};
90 if (i != 0) key_ss << delim;
92 }
93 key_ss << "," << idx_HS;
94
95 const std::string&
key = key_ss.str();
96
97
100 return StatusCode::SUCCESS;
101 }
102
104 try {
105 auto wt =
m_weightsMap.at(key).at(weightName).get<
double>();
107 } catch (const std::exception&) {
108 ATH_MSG_ERROR(
"Failed to get weight [" << weightName <<
"] in [" << key <<
"]!");
109 return StatusCode::FAILURE;
110 }
111 }
112
113 return StatusCode::SUCCESS;
114}
#define ATH_CHECK
Evaluate an expression and check for errors.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Gaudi::Property< std::vector< std::string > > m_weightsName
Gaudi::Property< std::string > m_jetCollectionHS
std::size_t getIndex(double value) const
nlohmann::json m_weightsMap
Gaudi::Property< std::string > m_jetCollectionPU
@ IS_SIMULATION
true: simulation, false: data
Jet_v1 Jet
Definition of the current "jet version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
JetContainer_v1 JetContainer
Definition of the current "jet container version".