ATLAS Offline Software
PtLogPtMassForTagSFUncertaintyComponent.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 // TODO: enable when BoostedJetTaggers are available
9 // #include "BoostedJetTaggers/TagResultEnum.h"
10 namespace jet
11 {
12 
14 // //
15 // Constructor/destructor/initialization //
16 // //
18 
21  , m_massDef(CompMassDef::UNKNOWN)
22  , m_labels()
23  , m_largeRJetTruthLabelName("")
24  , m_region()
25  , m_result_name()
26 {
28 }
29 
31  : UncertaintyComponent(component)
32  , m_massDef(component.massDef)
33  , m_labels(component.LargeRJetTruthLabelsForSF)
34  , m_largeRJetTruthLabelName(component.LargeRJetTruthLabelName)
35  , m_region(component.RegionForSF)
36  , m_result_name(component.ResultName)
37 {
38  ATH_MSG_DEBUG(Form("Creating PtLogPtMassForTagSFUncertaintyComponent named %s",m_uncHistName.Data()));
39 }
40 
42  : UncertaintyComponent(toCopy)
43  , m_massDef(toCopy.m_massDef)
44  , m_labels(toCopy.m_labels)
45  , m_largeRJetTruthLabelName(toCopy.m_largeRJetTruthLabelName)
46  , m_region(toCopy.m_region)
47  , m_result_name(toCopy.m_result_name)
48 {
49  ATH_MSG_DEBUG(Form("Creating copy of PtLogPtMassForTagSFUncertaintyComponent named %s",m_uncHistName.Data()));
50 }
51 
53 {
55 }
56 
57 
59 // //
60 // Validity and uncertainty retrieval //
61 // //
63 
65 {
67 }
68 
70 {
72  if ( !accLabel.isAvailable(jet) ){
73  ATH_MSG_ERROR("LargeRJetTruthLabel: " << m_largeRJetTruthLabelName << " is not decorrated to the jet. Please use JetTruthLabelingTool before calling this function.");
74  return JESUNC_ERROR_CODE;
75  }
76  int jetFlavorLabelInt=accLabel(jet);
77  LargeRJetTruthLabel::TypeEnum jetFlavorLabel=LargeRJetTruthLabel::intToEnum(jetFlavorLabelInt);
78 
79  float mOverPt=jet.m()/jet.pt();
80  if ( m_result_name.Contains("SmoothZ") || m_result_name.Contains("SmoothInclusiveZ") ){
81  // to apply W-tagging efficiency SF to Z-tagger, jet mass is shifted by 10GeV
82  const double WtoZmassShift = 10803;
83  mOverPt=(jet.m()-WtoZmassShift)/jet.pt();
84  if ( mOverPt < 0. ) mOverPt=1e-5;
85  }
86 
87  if ( m_result_name!="" ) {
88  // currently only TCC 2var tagger uses JESComponent.X.RegionForSF method, which correspont to m_region!="".
89 
90  // TODO: enable when BoostedJetTaggers are available
91  /*
92  SG::AuxElement::ConstAccessor<int> accResult(m_result_name.Data());
93  if ( !accResult.isAvailable(jet) ){
94  ATH_MSG_ERROR(m_result_name+" is not decorated to the jet.");
95  } else {
96  TagResult::TypeEnum myCutResult=TagResult::intToEnum(accResult(jet));
97  if ( m_region==CompTaggerRegionVar::passMpassD2_2Var ||
98  m_region==CompTaggerRegionVar::passMfailD2_2Var ||
99  m_region==CompTaggerRegionVar::failMpassD2_2Var ||
100  m_region==CompTaggerRegionVar::failMfailD2_2Var) {
101  // TCC 2Var tagger
102  if ( ! ((myCutResult==TagResult::passMpassD2_2Var && m_region==CompTaggerRegionVar::passMpassD2_2Var) ||
103  (myCutResult==TagResult::passMfailD2_2Var && m_region==CompTaggerRegionVar::passMfailD2_2Var) ||
104  (myCutResult==TagResult::failMpassD2_2Var && m_region==CompTaggerRegionVar::failMpassD2_2Var) ||
105  (myCutResult==TagResult::failMfailD2_2Var && m_region==CompTaggerRegionVar::failMfailD2_2Var)) ){
106  return 0.0;
107  }
108  } else {
109  ATH_MSG_ERROR("RegionForSF is specified in the config file, but it is not available for this tagger.");
110  return 0.0;
111  }
112  }
113  */
114  }
115 
116  bool isValidLabel=false;
118  if ( (label==CompFlavorLabelVar::t_qqb && jetFlavorLabel==LargeRJetTruthLabel::tqqb) ||
121  (label==CompFlavorLabelVar::V_qq && (jetFlavorLabel==LargeRJetTruthLabel::Wqq || jetFlavorLabel==LargeRJetTruthLabel::Zqq || jetFlavorLabel==LargeRJetTruthLabel::Wqq_From_t)) ||
125  (label==CompFlavorLabelVar::q && (jetFlavorLabel==LargeRJetTruthLabel::notruth || jetFlavorLabel==LargeRJetTruthLabel::qcd)) ) {
126  isValidLabel=true;
127  }
128  }
129  if (!isValidLabel) return 0.0;// if the type of uncertainty is not match to the jet truth label, return 0% uncertainty
130  return m_uncHist->getValue(jet.pt()*m_energyScale,log(mOverPt));
131 }
132 
133 } // end jet namespace
134 
LargeRJetTruthLabel::TypeEnum
TypeEnum
Definition: LargeRJetLabelEnum.h:14
jet::PtLogPtMassForTagSFUncertaintyComponent::clone
virtual PtLogPtMassForTagSFUncertaintyComponent * clone() const
Definition: PtLogPtMassForTagSFUncertaintyComponent.cxx:52
jet::UncertaintyComponent::getMassOverPt
virtual double getMassOverPt(const xAOD::Jet &jet, const CompMassDef::TypeEnum massDef) const
Definition: UncertaintyComponent.cxx:334
jet::UncertaintyComponent::m_energyScale
const float m_energyScale
Definition: UncertaintyComponent.h:55
jet::CompFlavorLabelVar::V_qq
@ V_qq
Definition: UncertaintyEnum.h:135
jet::CompFlavorLabelVar::t
@ t
Definition: UncertaintyEnum.h:134
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
jet::ComponentHelper
Definition: ConfigHelper.h:24
LargeRJetTruthLabel::other_From_t
@ other_From_t
Definition: LargeRJetLabelEnum.h:22
jet::CompFlavorLabelVar::W_qq_From_t
@ W_qq_From_t
Definition: UncertaintyEnum.h:138
jet::PtLogPtMassForTagSFUncertaintyComponent::m_massDef
const CompMassDef::TypeEnum m_massDef
Definition: PtLogPtMassForTagSFUncertaintyComponent.h:31
jet::UncertaintyComponent::m_uncHistName
const TString m_uncHistName
Definition: UncertaintyComponent.h:51
jet::CompFlavorLabelVar::q
@ q
Definition: UncertaintyEnum.h:140
LargeRJetTruthLabel::Zqq
@ Zqq
Definition: LargeRJetLabelEnum.h:20
LargeRJetTruthLabel::qcd
@ qcd
Definition: LargeRJetLabelEnum.h:25
jet::UncertaintyComponent::getValidBool
virtual bool getValidBool(const double validity) const
Definition: UncertaintyComponent.cxx:301
jet::PtLogPtMassForTagSFUncertaintyComponent::getValidityImpl
virtual bool getValidityImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition: PtLogPtMassForTagSFUncertaintyComponent.cxx:64
jet::UncertaintyHistogram::getValue
double getValue(const double var1) const
Definition: UncertaintyHistogram.cxx:141
Helpers.h
LargeRJetTruthLabel::notruth
@ notruth
Definition: LargeRJetLabelEnum.h:24
jet::UncertaintyComponent
Definition: UncertaintyComponent.h:25
JESUNC_ERROR_CODE
#define JESUNC_ERROR_CODE
Definition: Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:23
jet::PtLogPtMassForTagSFUncertaintyComponent::m_labels
std::vector< CompFlavorLabelVar::TypeEnum > m_labels
Definition: PtLogPtMassForTagSFUncertaintyComponent.h:32
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
LargeRJetTruthLabel::Wqq
@ Wqq
Definition: LargeRJetLabelEnum.h:17
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
jet::UncertaintyComponent::m_validHist
UncertaintyHistogram * m_validHist
Definition: UncertaintyComponent.h:61
PtLogPtMassForTagSFUncertaintyComponent.h
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
jet::CompFlavorLabelVar::W_qq
@ W_qq
Definition: UncertaintyEnum.h:136
jet::PtLogPtMassForTagSFUncertaintyComponent::getUncertaintyImpl
virtual double getUncertaintyImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition: PtLogPtMassForTagSFUncertaintyComponent.cxx:69
jet::CompFlavorLabelVar::t_other
@ t_other
Definition: UncertaintyEnum.h:139
jet::CompFlavorLabelVar::TypeEnum
TypeEnum
Definition: UncertaintyEnum.h:131
LargeRJetTruthLabel::Wqq_From_t
@ Wqq_From_t
Definition: LargeRJetLabelEnum.h:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
jet::CompFlavorLabelVar::t_qqb
@ t_qqb
Definition: UncertaintyEnum.h:133
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
jet::PtLogPtMassForTagSFUncertaintyComponent::m_result_name
const TString m_result_name
Definition: PtLogPtMassForTagSFUncertaintyComponent.h:35
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::CompFlavorLabelVar::Z_qq
@ Z_qq
Definition: UncertaintyEnum.h:137
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
jet::PtLogPtMassForTagSFUncertaintyComponent::m_largeRJetTruthLabelName
std::string m_largeRJetTruthLabelName
Definition: PtLogPtMassForTagSFUncertaintyComponent.h:33
LargeRJetTruthLabel::other_From_V
@ other_From_V
Definition: LargeRJetLabelEnum.h:23
LargeRJetTruthLabel::intToEnum
TypeEnum intToEnum(const int type)
Definition: LargeRJetLabelEnum.h:57
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
SG::ConstAccessor< T, AuxAllocator_t< T > >::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
LargeRJetTruthLabel::tqqb
@ tqqb
Definition: LargeRJetLabelEnum.h:16
jet::PtLogPtMassForTagSFUncertaintyComponent
Definition: PtLogPtMassForTagSFUncertaintyComponent.h:15
jet::PtLogPtMassForTagSFUncertaintyComponent::PtLogPtMassForTagSFUncertaintyComponent
PtLogPtMassForTagSFUncertaintyComponent(const ComponentHelper &component)
Definition: PtLogPtMassForTagSFUncertaintyComponent.cxx:30