ATLAS Offline Software
Loading...
Searching...
No Matches
PerJetFlavourUncertaintyComponent.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "TF1.h"
8namespace jet
9{
10
12// //
13// Constructor/destructor/initialization //
14// //
16
19 , m_absEta(false)
20 , m_labels()
21 , m_flavourType(FlavourComp::UNKNOWN)
23 , m_constrainZresponseFunc("Zjet_qFrac_AntiKt4EMPFlow")
24 , m_ZjetQuarkFrac(nullptr)
25{
27}
28
30 : UncertaintyComponent(component,1)
31 , m_absEta(CompParametrization::isAbsEta(component.parametrization))
32 , m_labels(component.truthLabels)
33 , m_flavourType(component.flavourType)
34 , m_constrainZresponse(component.constrainZresponse)
35 , m_constrainZresponseFunc(component.constrainZresponseFunc)
36{
37 ATH_MSG_DEBUG("Created PerJetFlavourUncertaintyComponent named " << m_uncHistName.Data());
38}
39
50
55
57{
58 // Call the base class first
59 if (UncertaintyComponent::initialize(histFile).isFailure())
60 return StatusCode::FAILURE;
61
62 // Ensure that the labels are sane
63 if (m_labels.empty())
64 {
65 ATH_MSG_ERROR("Specified a PerJetFlavourUncertaintyComponent without the associated labels to use: " << getName().Data());
66 return StatusCode::FAILURE;
67 }
68 for (int aLabel : m_labels)
69 {
70 if (!isSupportedLabel(aLabel))
71 {
72 ATH_MSG_ERROR("Unsupported label ID of " << aLabel << " in " << getName().Data());
73 return StatusCode::FAILURE;
74 }
75 }
76
77 // Load TF1 for Z-jet gluon fraction
79 {
80 // Find the histogram by name
81 TObject* tmp_tf1 = histFile->Get(m_constrainZresponseFunc);
82 if (!tmp_tf1)
83 {
84 ATH_MSG_ERROR(Form("Histogram file does not contain a histogram named %s",m_constrainZresponseFunc.Data()));
85 return StatusCode::FAILURE;
86 }
87 // Ensure the object is a TF1
88 m_ZjetQuarkFrac = dynamic_cast<const TF1*>(tmp_tf1);
89 if (!m_ZjetQuarkFrac)
90 {
91 ATH_MSG_ERROR(Form("Histogram file contains the expected key, but it's not a TF1* (%s)",m_constrainZresponseFunc.Data()));
92 return StatusCode::FAILURE;
93 }
94 }
95
96 // Done checking the configuration
97 return StatusCode::SUCCESS;
98}
99
100
102// //
103// Validity and uncertainty retrieval //
104// //
106
108{
109 return !m_validHist ? true : getValidBool(m_validHist->getValue(jet.pt()*m_energyScale,m_absEta ? fabs(jet.eta()) : jet.eta()));
110}
111
116
118{
119 // sigma_x = l_x * dR_x(x response modelling uncertainty)
120 // sigma_x is the flavour response uncertainty for jet type x
121 // l_x is the jet flavour label, and is 0 or 1
122 // dR_x is the response modelling uncertainty for jets of type x
123 // dR_x is typically taken as the difference in x response between Pythia and Herwig
124
125 // Check the jet label (is this uncertainty relevant?)
126 if (!checkTruthLabel(jet))
127 return 0;
128
129 // This is a jet of the relevant type
130 // Now calculate and return the uncertainty
131 const double pT = jet.pt()*m_energyScale;
132 const double eta = m_absEta ? fabs(jet.eta()) : jet.eta();
133
134 FlavourComp::TypeEnum ThisJetFlavourType = FlavourComp::UNKNOWN;
135 if(m_labels.at(0)==21 || m_labels.at(0)==0) ThisJetFlavourType = FlavourComp::PerJetResponse_Gluon;
136 else if(m_labels.at(0)==1 || m_labels.at(0)==2 || m_labels.at(0)==3) ThisJetFlavourType = FlavourComp::PerJetResponse_LQ;
137 else if(m_labels.at(0)==5) ThisJetFlavourType = FlavourComp::PerJetResponse_B;
138 else if(m_labels.at(0)==4 ) ThisJetFlavourType = FlavourComp::PerJetResponse_C;
139
140 // bool DoesItPass = false;
141 if(m_flavourType == ThisJetFlavourType){
142 double unc = m_uncHist->getValue(pT,eta);
146 }
147 // Return the uncertainty
148 return unc;
149
150 }else{ return 0;}
151
152}
153
154
155
157{
158 switch (abs(label))
159 {
160 case 1: // parton-label, up
161 case 2: // parton-label, down
162 case 3: // parton-label, strange
163 case 4: // parton-label, charm
164 case 5: // parton-label, bottom
165 case 21: // parton-label, gluon
166 case 0: // parton-label, PileUp/non-identified
167 return true;
168 default:
169 return false;
170 }
171}
172
174{
175 static const SG::AuxElement::ConstAccessor<int> truthLabelAccessor ("PartonTruthLabelID");
176 if (!truthLabelAccessor.isAvailable(jet))
177 {
178 ATH_MSG_ERROR("Unable to find PartonTruthLabelID on the jet");
179 return JESUNC_ERROR_CODE;
180 }
181 const int truthHighestEparton = abs(truthLabelAccessor(jet));
182
183 for (const int label : m_labels)
184 if (label == truthHighestEparton)
185 return true;
186 return false;
187}
188
189} // end jet namespace
190
Scalar eta() const
pseudorapidity method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
@ Data
Definition BaseObject.h:11
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual double getUncertaintyImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
virtual bool getValidityImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
PerJetFlavourUncertaintyComponent(const ComponentHelper &component)
virtual PerJetFlavourUncertaintyComponent * clone() const
double getFlavourResponseUncertainty(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
UncertaintyComponent(const ComponentHelper &component, const size_t numHist=1)
virtual TString getName() const
virtual bool getValidBool(const double validity) const
UncertaintyHistogram * m_validHist
virtual StatusCode initialize(TFile *histFile)
UncertaintyHistogram * m_uncHist
std::string label(const std::string &format, int i)
Definition label.h:19
Jet_v1 Jet
Definition of the current "jet version".
EventInfo_v1 EventInfo
Definition of the latest event info version.