ATLAS Offline Software
PtAbsMassUncertaintyComponent.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 namespace jet
9 {
10 
12 // //
13 // Constructor/destructor/initialization //
14 // //
16 
19  , m_massDef(CompMassDef::UNKNOWN)
20  , m_truthLabelName("")
21  , m_truthLabels()
22 {
24 }
25 
27  : UncertaintyComponent(component)
28  , m_massDef(component.massDef)
29  , m_truthLabelName(component.LargeRJetTruthLabelName)
30  , m_truthLabels(component.LargeRJetTruthLabels)
31 {
32  ATH_MSG_DEBUG(Form("Creating PtAbsMassUncertaintyComponent named %s",m_uncHistName.Data()));
33 }
34 
36  : UncertaintyComponent(toCopy)
37  , m_massDef(toCopy.m_massDef)
38  , m_truthLabelName(toCopy.m_truthLabelName)
39  , m_truthLabels(toCopy.m_truthLabels)
40 {
41  ATH_MSG_DEBUG(Form("Creating copy of PtAbsMassUncertaintyComponent named %s",m_uncHistName.Data()));
42 }
43 
45 {
46  return new PtAbsMassUncertaintyComponent(*this);
47 }
48 
49 
51 // //
52 // Validity and uncertainty retrieval //
53 // //
55 
57 {
59 }
60 
62 {
63  // Check if we need to do anything at all - this uncertainty may be zero based on the jet truth label
64  // Truth labels are usually not expected for this component, so check if we need to do this
65  if (!m_truthLabels.empty())
66  {
67  // Truth labels are specified, so we need to check if this jet is labelled appropriately or not
69  if (!accTruthLabel.isAvailable(jet) || accTruthLabel(jet) == LargeRJetTruthLabel::UNKNOWN)
70  {
71  ATH_MSG_ERROR("Unable to retrieve the LargeRJetTruthLabel: " << m_truthLabelName << " from the jet. Please use JetTruthLabelingTool before calling this function.");
72  return JESUNC_ERROR_CODE;
73  }
74  const LargeRJetTruthLabel::TypeEnum jetTruthLabel = LargeRJetTruthLabel::intToEnum(accTruthLabel(jet));
75 
76  // We now have the truth jet label, check if it matches one of the label(s) assigned to this component
77  // The uncertainty is only applied to same-labelled jets (zero otherwise)
78  bool labelApplies = false;
79  for (const LargeRJetTruthLabel::TypeEnum aLabel : m_truthLabels)
80  {
81  if (aLabel == jetTruthLabel)
82  {
83  labelApplies = true;
84  break;
85  }
86  }
87  // If the jet is not of the relevant label, then there is no uncertainty for this jet
88  if (!labelApplies)
89  return 0;
90  }
91 
93 }
94 
95 } // end jet namespace
96 
97 
LargeRJetTruthLabel::TypeEnum
TypeEnum
Definition: LargeRJetLabelEnum.h:14
jet::PtAbsMassUncertaintyComponent::getValidityImpl
virtual bool getValidityImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition: PtAbsMassUncertaintyComponent.cxx:56
jet::UncertaintyComponent::m_energyScale
const float m_energyScale
Definition: UncertaintyComponent.h:55
LargeRJetTruthLabel::UNKNOWN
@ UNKNOWN
Definition: LargeRJetLabelEnum.h:15
jet::ComponentHelper
Definition: ConfigHelper.h:24
jet::UncertaintyComponent::m_uncHistName
const TString m_uncHistName
Definition: UncertaintyComponent.h:51
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
PtAbsMassUncertaintyComponent.h
jet::UncertaintyComponent::getValidBool
virtual bool getValidBool(const double validity) const
Definition: UncertaintyComponent.cxx:301
jet::UncertaintyHistogram::getValue
double getValue(const double var1) const
Definition: UncertaintyHistogram.cxx:141
Helpers.h
jet::UncertaintyComponent
Definition: UncertaintyComponent.h:25
JESUNC_ERROR_CODE
#define JESUNC_ERROR_CODE
Definition: Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:23
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
jet::PtAbsMassUncertaintyComponent::getUncertaintyImpl
virtual double getUncertaintyImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition: PtAbsMassUncertaintyComponent.cxx:61
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
jet::UncertaintyComponent::m_validHist
UncertaintyHistogram * m_validHist
Definition: UncertaintyComponent.h:61
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
jet::PtAbsMassUncertaintyComponent::PtAbsMassUncertaintyComponent
PtAbsMassUncertaintyComponent(const ComponentHelper &component)
Definition: PtAbsMassUncertaintyComponent.cxx:26
jet::PtAbsMassUncertaintyComponent::m_truthLabelName
std::string m_truthLabelName
Definition: PtAbsMassUncertaintyComponent.h:33
jet::UncertaintyComponent::getAbsMass
virtual double getAbsMass(const xAOD::Jet &jet, const CompMassDef::TypeEnum massDef) const
Definition: UncertaintyComponent.cxx:309
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
JESUNC_NO_DEFAULT_CONSTRUCTOR
#define JESUNC_NO_DEFAULT_CONSTRUCTOR
Definition: Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:24
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
jet::PtAbsMassUncertaintyComponent::clone
virtual PtAbsMassUncertaintyComponent * clone() const
Definition: PtAbsMassUncertaintyComponent.cxx:44
LargeRJetTruthLabel::intToEnum
TypeEnum intToEnum(const int type)
Definition: LargeRJetLabelEnum.h:57
jet::PtAbsMassUncertaintyComponent
Definition: PtAbsMassUncertaintyComponent.h:14
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
jet::UncertaintyComponent::m_uncHist
UncertaintyHistogram * m_uncHist
Definition: UncertaintyComponent.h:60
jet::PtAbsMassUncertaintyComponent::m_truthLabels
std::vector< LargeRJetTruthLabel::TypeEnum > m_truthLabels
Definition: PtAbsMassUncertaintyComponent.h:34
jet::PtAbsMassUncertaintyComponent::m_massDef
const CompMassDef::TypeEnum m_massDef
Definition: PtAbsMassUncertaintyComponent.h:30