ATLAS Offline Software
Loading...
Searching...
No Matches
ConstantUncertaintyComponent.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8#include <cmath>
9
10namespace jet
11{
12
14// //
15// Constructor/destructor/initialization //
16// //
18
27
29 : UncertaintyComponent(component,0)
30 , m_name(component.name)
31 , m_value(component.constantValue)
32 , m_histSpecified(!component.uncNames.empty())
33{
34 ATH_MSG_DEBUG(Form("Creating ConstantUncertaintyComponent named %s",m_name.Data()));
35}
36
38 : UncertaintyComponent(toCopy)
39 , m_name(toCopy.m_name)
40 , m_value(toCopy.m_value)
42{
43 ATH_MSG_DEBUG(Form("Creating copy of ConstantUncertaintyComponent named %s",m_name.Data()));
44}
45
50
51StatusCode ConstantUncertaintyComponent::initialize(TFile* /*histFile*/)
52{
53 // Prevent double-initialization
54 if (m_isInit)
55 {
56 ATH_MSG_ERROR("Component is already initialized: " << getName().Data());
57 return StatusCode::FAILURE;
58 }
59
60 // Fail loudly rather than silently ignoring a histogram the config asked for
62 {
63 ATH_MSG_ERROR("Constant component specifies a Hists key, which it cannot use: " << getName().Data());
64 return StatusCode::FAILURE;
65 }
66 if (m_validHistName != "")
67 {
68 ATH_MSG_ERROR("Constant component specifies a VHist key, which it cannot use: " << getName().Data());
69 return StatusCode::FAILURE;
70 }
71
72 if (!std::isfinite(m_value))
73 {
74 ATH_MSG_ERROR("Constant component has a non-finite Value: " << getName().Data());
75 return StatusCode::FAILURE;
76 }
77 if (m_value < 0)
78 {
79 ATH_MSG_ERROR("Constant component has a negative Value, use a positive fraction and let the "
80 "systematic sign come from the requested variation: " << getName().Data());
81 return StatusCode::FAILURE;
82 }
83
84 ATH_MSG_DEBUG("Successfully initialized ConstantUncertaintyComponent named " << getName().Data()
85 << " with a flat fractional uncertainty of " << m_value);
86
87 m_isInit = true;
88 return StatusCode::SUCCESS;
89}
90
91
93// //
94// Methods to test for special cases //
95// //
97
99{
100 if (!m_isInit)
101 {
102 ATH_MSG_ERROR("Cannot call method before initialization, component: " << getName().Data());
103 return false;
104 }
105 return std::fabs(m_value) < 1.e-8;
106}
107
108
110// //
111// Uncertainty/validity retrieval methods //
112// //
114
116{
117 // A flat uncertainty has no parametrisation, so it has no validity range either.
118 return true;
119}
120
125
126} // end jet namespace
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
@ Data
Definition BaseObject.h:11
static const Attributes_t empty
virtual ConstantUncertaintyComponent * clone() const
virtual double getUncertaintyImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
virtual StatusCode initialize(TFile *histFile)
Deliberately does not touch the histogram file: there is no histogram.
virtual bool getValidityImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
const bool m_histSpecified
Set if the config also asked for a histogram, which is a configuration error.
virtual TString getName() const
The base class reports the histogram name, which this component does not have.
ConstantUncertaintyComponent(const ComponentHelper &component)
UncertaintyComponent(const ComponentHelper &component, const size_t numHist=1)
Jet_v1 Jet
Definition of the current "jet version".
EventInfo_v1 EventInfo
Definition of the latest event info version.