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];
77 try{
79 else optHelper.Initialize(std::vector<TString>());
80 } catch (const std::exception& e) {
81 std::cerr<<
"Exception in optHelper.Initialize: " <<
e.what()<<std::endl;
83 } catch (...) {
84 std::cerr<<"Unknown exception in optHelper.Initialize"<<std::endl;
86 }
87
89 {
90 printf("Only pdf output files are currently supported\n");
92 }
93
95 {
96 printf("Bad component formatting, got \"%s\"\n",component.Data());
98 }
101
102 bool isData = false;
103 if (!isDataStr.CompareTo("true",TString::kIgnoreCase))
104 isData = true;
105 else if (!isDataStr.CompareTo("false",TString::kIgnoreCase))
106 isData = false;
107 else
108 {
109 printf("Unable to determine whether to configure for data or MC: %s\n",isDataStr.Data());
111 }
112
114 if (
tool->setProperty(
"JetDefinition",
jetDef.Data()).isFailure())
116 if (
tool->setProperty(
"MCType",mcType.Data()).isFailure())
118 if (
tool->setProperty(
"ConfigFile",
config.Data()).isFailure())
120 if (
tool->setProperty(
"IsData",isData).isFailure())
123 if (
tool->setProperty(
"Path",
optHelper.GetPath().Data()).isFailure())
125 if (
tool->setScaleToGeV().isFailure())
127 if (
tool->initialize().isFailure())
129
130
131
138
139
144
145
146
148 if (!
tool->isAffectedBySystematic(variation))
149 {
150 printf(
"The specified variation was not recognized: JET_%s\n",
compName.Data());
152 }
155 if (
tool->applySystematicVariation(syst) != StatusCode::SUCCESS)
156 {
157 printf("Failed to apply systematic variation\n");
159 }
160
161
162 const size_t compIndex =
tool->getComponentIndex(
"JET_"+compName);
163 const std::set<jet::CompScaleVar::TypeEnum> scaleVars =
tool->getComponentScaleVars(compIndex);
166
168
169
171 canvas.SetMargin(0.12,0.04,0.15,0.04);
172 canvas.SetFillStyle(4000);
174 canvas.SetFrameBorderMode(0);
176 canvas.Print(outFile+
"[");
177
178
179
183 tex.SetTextSize(0.04);
184
185
186
187
188
189 const double pT = 1000;
190 const double mass = 100;
191 const double phi = 0;
192 const std::vector<double> etaVals =
optHelper.GetFixedEtaVals();
193 const int numSmear = 100000;
194
195 for (
const double eta : etaVals)
196 {
197
198 TH1D smearPt(Form(
"smearPt_eta%.2f",
eta),
"",100,500,1500);
199 TH1D smearMass(Form(
"smearMass_eta%.2f",
eta),
"",100,50,150);
200 smearPt.Sumw2();
201 smearMass.Sumw2();
202 smearPt.SetStats(0);
203 smearMass.SetStats(0);
204 smearPt.GetXaxis()->SetTitle("#it{p}_{T} [GeV]");
205 smearMass.GetXaxis()->SetTitle("#it{m} [GeV]");
206 smearPt.GetYaxis()->SetTitle("Number of events");
207 smearMass.GetYaxis()->SetTitle("Number of events");
208
209
210 for (int iSmear = 0; iSmear < numSmear; ++iSmear)
211 {
214 {
215 printf("Error while smearing, iteration %d\n",iSmear);
217 }
218
219 smearPt.Fill(
jet->pt());
220 smearMass.Fill(
jet->m());
221 }
222
223
225 const double nomData =
tool->getNominalResolutionData(*
jet,scaleVar,topology);
226 const double nomMC =
tool->getNominalResolutionMC(*
jet,scaleVar,topology);
227 const double uncert =
tool->getUncertainty(compIndex,*
jet,*eInfo,scaleVar);
228
231 const double smearMC = sqrt(
pow(nomMC + fabs(shift*fullUncMC),2) -
pow(nomMC,2));
232 const double smearData = nomData !=
JESUNC_ERROR_CODE ? sqrt(
pow(nomData + fabs(shift*fullUncData),2) -
pow(nomData,2)) : 0;
233
234
235 TF1 fitPt("fitPt","gaus");
236 smearPt.Fit(&fitPt,"E");
237 TF1 fitMass("fitMass","gaus");
238 smearMass.Fit(&fitMass,"E");
239
240
241 smearPt.Draw();
242 tex.DrawLatex(0.70,0.9,
"Gaussian fit results");
243 tex.DrawLatex(0.70,0.85,Form(
"#mu = %.0f GeV",fitPt.GetParameter(1)));
244 tex.DrawLatex(0.70,0.80,Form(
"#sigma = %.1f GeV",fitPt.GetParameter(2)));
245 tex.DrawLatex(0.70,0.75,Form(
"#mu/#sigma = %.1f%%",fitPt.GetParameter(2)/fitPt.GetParameter(1)*100));
246 tex.DrawLatex(0.15,0.9,
"Expectation from tool");
247 tex.DrawLatex(0.15,0.85,
"#sigma_{smear}^{2} = (#sigma_{nom} + |N#delta#sigma|)^{2} - (#sigma_{nom})^{2}");
249 tex.DrawLatex(0.15,0.80,Form(
"#sigma_{nom}^{data}/#it{p}_{T} = %.1f%%",100*nomData));
250 else
251 tex.DrawLatex(0.15,0.80,Form(
"#sigma_{nom}^{data}/#it{p}_{T} = N/A"));
252 tex.DrawLatex(0.15,0.75,Form(
"#sigma_{nom}^{MC}/#it{p}_{T} = %.1f%%",100*nomMC));
253 tex.DrawLatex(0.15,0.70,Form(
"#delta#sigma/#it{p}_{T} = %.1f%%",100*uncert));
254 tex.DrawLatex(0.15,0.65,Form(
"N_{sigma} = %+.1f",shift));
256 tex.DrawLatex(0.15,0.55,Form(
"#sigma_{smear}^{data}/#it{p}_{T} = %.1f%%",100*smearData));
257 else
258 tex.DrawLatex(0.15,0.55,Form(
"#sigma_{smear}^{data}/#it{p}_{T} = N/A"));
259 tex.DrawLatex(0.15,0.50,Form(
"#sigma_{smear}^{MC}/#it{p}_{T} = %.1f%%",100*smearMC));
261
262
263
264 smearMass.Draw();
265 tex.DrawLatex(0.70,0.9,
"Gaussian fit results");
266 tex.DrawLatex(0.70,0.85,Form(
"#mu = %.0f GeV",fitMass.GetParameter(1)));
267 tex.DrawLatex(0.70,0.80,Form(
"#sigma = %.1f GeV",fitMass.GetParameter(2)));
268 tex.DrawLatex(0.70,0.75,Form(
"#mu/#sigma = %.1f%%",fitMass.GetParameter(2)/fitMass.GetParameter(1)*100));
269 tex.DrawLatex(0.15,0.9,
"Expectation from tool");
270 tex.DrawLatex(0.15,0.85,
"#sigma_{smear}^{2} = (#sigma_{nom} + |N#delta#sigma|)^{2} - (#sigma_{nom})^{2}");
272 tex.DrawLatex(0.15,0.80,Form(
"#sigma_{nom}^{data}/#it{p}_{T} = %.1f%%",100*nomData));
273 else
274 tex.DrawLatex(0.15,0.80,Form(
"#sigma_{nom}^{data}/#it{p}_{T} = N/A"));
275 tex.DrawLatex(0.15,0.75,Form(
"#sigma_{nom}^{MC}/#it{p}_{T} = %.1f%%",100*nomMC));
276 tex.DrawLatex(0.15,0.70,Form(
"#delta#sigma/#it{p}_{T} = %.1f%%",100*uncert));
277 tex.DrawLatex(0.15,0.65,Form(
"N_{sigma} = %+.1f",shift));
279 tex.DrawLatex(0.15,0.55,Form(
"#sigma_{smear}^{data}/#it{p}_{T} = %.1f%%",100*smearData));
280 else
281 tex.DrawLatex(0.15,0.55,Form(
"#sigma_{smear}^{data}/#it{p}_{T} = N/A"));
282 tex.DrawLatex(0.15,0.50,Form(
"#sigma_{smear}^{MC}/#it{p}_{T} = %.1f%%",100*smearMC));
284 }
285
286
287 canvas.Print(outFile+
"]");
288
289 return 0;
290}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
jet::OptionHelper optHelper
#define JESUNC_ERROR_CODE
@ 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)