51{
52 StatusCode::enableFailure();
54
55
56 if (argc != 7 && argc != 8)
57 {
58 printf("Expected arguments:\n");
59 printf("\t1. Output file (pdf)\n");
60 printf("\t2. Jet definition\n");
61 printf("\t3. MC type\n");
62 printf("\t4. Config file\n");
63 printf("\t5. Component name and variation\n");
64 printf("\t\tExample: \"FourVecResUnc,+1\"\n");
65 printf("\t6. IsData (\"true\" or \"false\")\n");
66 printf("\t7. Options (optional argument), semi-colon delimited, examples:\n");
67 printf("\t\tisDijet=false\n");
68 printf("\t\tisLargeR=false\n");
70 }
73 TString mcType =
argv[3];
75 TString component =
argv[5];
76 TString isDataStr =
argv[6];
78 else optHelper.Initialize(std::vector<TString>());
79
81 {
82 printf("Only pdf output files are currently supported\n");
84 }
85
87 {
88 printf("Bad component formatting, got \"%s\"\n",component.Data());
90 }
93
94 bool isData = false;
95 if (!isDataStr.CompareTo("true",TString::kIgnoreCase))
96 isData = true;
97 else if (!isDataStr.CompareTo("false",TString::kIgnoreCase))
98 isData = false;
99 else
100 {
101 printf("Unable to determine whether to configure for data or MC: %s\n",isDataStr.Data());
103 }
104
106 if (
tool->setProperty(
"JetDefinition",
jetDef.Data()).isFailure())
108 if (
tool->setProperty(
"MCType",mcType.Data()).isFailure())
110 if (
tool->setProperty(
"ConfigFile",
config.Data()).isFailure())
112 if (
tool->setProperty(
"IsData",isData).isFailure())
115 if (
tool->setProperty(
"Path",
optHelper.GetPath().Data()).isFailure())
117 if (
tool->setScaleToGeV().isFailure())
119 if (
tool->initialize().isFailure())
121
122
123
130
131
136
137
138
140 if (!
tool->isAffectedBySystematic(variation))
141 {
142 printf(
"The specified variation was not recognized: JET_%s\n",
compName.Data());
144 }
147 if (
tool->applySystematicVariation(syst) != StatusCode::SUCCESS)
148 {
149 printf("Failed to apply systematic variation\n");
151 }
152
153
154 const size_t compIndex =
tool->getComponentIndex(
"JET_"+compName);
155 const std::set<jet::CompScaleVar::TypeEnum> scaleVars =
tool->getComponentScaleVars(compIndex);
158
160
161
163 canvas.SetMargin(0.12,0.04,0.15,0.04);
164 canvas.SetFillStyle(4000);
166 canvas.SetFrameBorderMode(0);
168 canvas.Print(outFile+
"[");
169
170
171
175 tex.SetTextSize(0.04);
176
177
178
179
180
181 const double pT = 1000;
182 const double mass = 100;
183 const double phi = 0;
184 const std::vector<double> etaVals =
optHelper.GetFixedEtaVals();
185 const int numSmear = 100000;
186
187 for (
const double eta : etaVals)
188 {
189
190 TH1D smearPt(Form(
"smearPt_eta%.2f",
eta),
"",100,500,1500);
191 TH1D smearMass(Form(
"smearMass_eta%.2f",
eta),
"",100,50,150);
192 smearPt.Sumw2();
193 smearMass.Sumw2();
194 smearPt.SetStats(0);
195 smearMass.SetStats(0);
196 smearPt.GetXaxis()->SetTitle("#it{p}_{T} [GeV]");
197 smearMass.GetXaxis()->SetTitle("#it{m} [GeV]");
198 smearPt.GetYaxis()->SetTitle("Number of events");
199 smearMass.GetYaxis()->SetTitle("Number of events");
200
201
202 for (int iSmear = 0; iSmear < numSmear; ++iSmear)
203 {
206 {
207 printf("Error while smearing, iteration %d\n",iSmear);
209 }
210
211 smearPt.Fill(
jet->pt());
212 smearMass.Fill(
jet->m());
213 }
214
215
217 const double nomData =
tool->getNominalResolutionData(*
jet,scaleVar,topology);
218 const double nomMC =
tool->getNominalResolutionMC(*
jet,scaleVar,topology);
219 const double uncert =
tool->getUncertainty(compIndex,*
jet,*eInfo,scaleVar);
220
223 const double smearMC = sqrt(
pow(nomMC + fabs(shift*fullUncMC),2) -
pow(nomMC,2));
224 const double smearData = nomData !=
JESUNC_ERROR_CODE ? sqrt(
pow(nomData + fabs(shift*fullUncData),2) -
pow(nomData,2)) : 0;
225
226
227 TF1 fitPt("fitPt","gaus");
228 smearPt.Fit(&fitPt,"E");
229 TF1 fitMass("fitMass","gaus");
230 smearMass.Fit(&fitMass,"E");
231
232
233 smearPt.Draw();
234 tex.DrawLatex(0.70,0.9,
"Gaussian fit results");
235 tex.DrawLatex(0.70,0.85,Form(
"#mu = %.0f GeV",fitPt.GetParameter(1)));
236 tex.DrawLatex(0.70,0.80,Form(
"#sigma = %.1f GeV",fitPt.GetParameter(2)));
237 tex.DrawLatex(0.70,0.75,Form(
"#mu/#sigma = %.1f%%",fitPt.GetParameter(2)/fitPt.GetParameter(1)*100));
238 tex.DrawLatex(0.15,0.9,
"Expectation from tool");
239 tex.DrawLatex(0.15,0.85,
"#sigma_{smear}^{2} = (#sigma_{nom} + |N#delta#sigma|)^{2} - (#sigma_{nom})^{2}");
241 tex.DrawLatex(0.15,0.80,Form(
"#sigma_{nom}^{data}/#it{p}_{T} = %.1f%%",100*nomData));
242 else
243 tex.DrawLatex(0.15,0.80,Form(
"#sigma_{nom}^{data}/#it{p}_{T} = N/A"));
244 tex.DrawLatex(0.15,0.75,Form(
"#sigma_{nom}^{MC}/#it{p}_{T} = %.1f%%",100*nomMC));
245 tex.DrawLatex(0.15,0.70,Form(
"#delta#sigma/#it{p}_{T} = %.1f%%",100*uncert));
246 tex.DrawLatex(0.15,0.65,Form(
"N_{sigma} = %+.1f",shift));
248 tex.DrawLatex(0.15,0.55,Form(
"#sigma_{smear}^{data}/#it{p}_{T} = %.1f%%",100*smearData));
249 else
250 tex.DrawLatex(0.15,0.55,Form(
"#sigma_{smear}^{data}/#it{p}_{T} = N/A"));
251 tex.DrawLatex(0.15,0.50,Form(
"#sigma_{smear}^{MC}/#it{p}_{T} = %.1f%%",100*smearMC));
253
254
255
256 smearMass.Draw();
257 tex.DrawLatex(0.70,0.9,
"Gaussian fit results");
258 tex.DrawLatex(0.70,0.85,Form(
"#mu = %.0f GeV",fitMass.GetParameter(1)));
259 tex.DrawLatex(0.70,0.80,Form(
"#sigma = %.1f GeV",fitMass.GetParameter(2)));
260 tex.DrawLatex(0.70,0.75,Form(
"#mu/#sigma = %.1f%%",fitMass.GetParameter(2)/fitMass.GetParameter(1)*100));
261 tex.DrawLatex(0.15,0.9,
"Expectation from tool");
262 tex.DrawLatex(0.15,0.85,
"#sigma_{smear}^{2} = (#sigma_{nom} + |N#delta#sigma|)^{2} - (#sigma_{nom})^{2}");
264 tex.DrawLatex(0.15,0.80,Form(
"#sigma_{nom}^{data}/#it{p}_{T} = %.1f%%",100*nomData));
265 else
266 tex.DrawLatex(0.15,0.80,Form(
"#sigma_{nom}^{data}/#it{p}_{T} = N/A"));
267 tex.DrawLatex(0.15,0.75,Form(
"#sigma_{nom}^{MC}/#it{p}_{T} = %.1f%%",100*nomMC));
268 tex.DrawLatex(0.15,0.70,Form(
"#delta#sigma/#it{p}_{T} = %.1f%%",100*uncert));
269 tex.DrawLatex(0.15,0.65,Form(
"N_{sigma} = %+.1f",shift));
271 tex.DrawLatex(0.15,0.55,Form(
"#sigma_{smear}^{data}/#it{p}_{T} = %.1f%%",100*smearData));
272 else
273 tex.DrawLatex(0.15,0.55,Form(
"#sigma_{smear}^{data}/#it{p}_{T} = N/A"));
274 tex.DrawLatex(0.15,0.50,Form(
"#sigma_{smear}^{MC}/#it{p}_{T} = %.1f%%",100*smearMC));
276 }
277
278
279 canvas.Print(outFile+
"]");
280
281 return 0;
282}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
jet::OptionHelper optHelper
#define JESUNC_ERROR_CODE
constexpr int pow(int base, int exp) noexcept
@ Ok
The correction was done successfully.
Class to wrap a set of SystematicVariations.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Tool for accessing xAOD files outside of Athena.
A relatively simple transient store for objects created in analysis.
double atof(std::string_view str)
Converts a string into a double / float.
outFile
Comment Out Those You do not wish to run.
bool isRelResolutionType(const TypeEnum type)
TString enumToString(const TypeEnum type)
TString enumToString(const TypeEnum type)
bool vectorize(const TString &str, const TString &sep, std::vector< T > &result)
Jet_v1 Jet
Definition of the current "jet version".
EventInfoContainer_v1 EventInfoContainer
Define the latest version of the container.
EventInfo_v1 EventInfo
Definition of the latest event info version.
EventInfoAuxContainer_v1 EventInfoAuxContainer
Define the latest version of the auxiliary container.
JetAuxContainer_v1 JetAuxContainer
Definition of the current jet auxiliary container.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
void setJetKinematics(xAOD::Jet &jet, double pt, double eta, double phi, double mass)