ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigCost
RatesAnalysis
src
PileupProfileWeight.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
PileupProfileWeight.h
"
6
7
#include "
xAODEventInfo/EventInfo.h
"
8
9
#include <fstream>
10
11
StatusCode
PileupProfileWeight::initialize
() {
12
std::ifstream
fs
(
m_weightsFile
);
13
try
{
14
m_weightsMap
= nlohmann::json::parse(
fs
);
15
}
catch
(
const
std::exception&) {
16
ATH_MSG_ERROR
(
"Failed to parse input "
<<
m_weightsFile
);
17
return
StatusCode::FAILURE;
18
}
19
return
StatusCode::SUCCESS;
20
}
21
22
StatusCode
PileupProfileWeight::getValue
(
double
& value)
const
{
23
const
xAOD::EventInfo
* evt {
nullptr
};
24
ATH_CHECK
(evtStore()->retrieve(evt,
"EventInfo"
));
25
26
auto
mu_actual =
static_cast<
std::size_t
>
(std::ceil(evt->actualInteractionsPerCrossing()));
27
auto
mu = std::to_string(mu_actual);
28
29
// mu values that are not included in the weight mapping will be skipped
30
if
(
m_weightsMap
.find(mu) ==
m_weightsMap
.end()) {
31
value = 0.0;
32
return
StatusCode::SUCCESS;
33
}
34
35
// retrieve the weigths
36
try
{
37
auto
wt =
m_weightsMap
.at(mu).get<
double
>();
38
value = wt;
39
}
catch
(
const
std::exception&) {
40
ATH_MSG_ERROR
(
"Failed to get the mu weight!"
);
41
return
StatusCode::FAILURE;
42
}
43
44
return
StatusCode::SUCCESS;
45
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
fs
static Double_t fs
Definition
LArPhysWaveHECTool.cxx:37
PileupProfileWeight.h
PileupProfileWeight::m_weightsFile
Gaudi::Property< std::string > m_weightsFile
Definition
PileupProfileWeight.h:27
PileupProfileWeight::m_weightsMap
nlohmann::json m_weightsMap
Definition
PileupProfileWeight.h:28
PileupProfileWeight::initialize
virtual StatusCode initialize() override
Definition
PileupProfileWeight.cxx:11
PileupProfileWeight::getValue
virtual StatusCode getValue(double &value) const override
Definition
PileupProfileWeight.cxx:22
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0