52 StatusCode::enableFailure();
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");
73 TString mcType =
argv[3];
75 TString component =
argv[5];
76 TString isDataStr =
argv[6];
82 printf(
"Only pdf output files are currently supported\n");
86 if (jet::utils::vectorize<TString>(component,
",").
size() != 2)
88 printf(
"Bad component formatting, got \"%s\"\n",component.Data());
91 TString
compName = jet::utils::vectorize<TString>(component,
",").at(0);
92 float shift =
atof(jet::utils::vectorize<TString>(component,
",").at(1));
95 if (!isDataStr.CompareTo(
"true",TString::kIgnoreCase))
97 else if (!isDataStr.CompareTo(
"false",TString::kIgnoreCase))
101 printf(
"Unable to determine whether to configure for data or MC: %s\n",isDataStr.Data());
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())
117 if (
tool->setScaleToGeV().isFailure())
119 if (
tool->initialize().isFailure())
140 if (!
tool->isAffectedBySystematic(variation))
142 printf(
"The specified variation was not recognized: JET_%s\n",
compName.Data());
147 if (
tool->applySystematicVariation(syst) != StatusCode::SUCCESS)
149 printf(
"Failed to apply systematic variation\n");
154 const size_t compIndex =
tool->getComponentIndex(
"JET_"+
compName);
155 const std::set<jet::CompScaleVar::TypeEnum> scaleVars =
tool->getComponentScaleVars(compIndex);
163 canvas.SetMargin(0.12,0.04,0.15,0.04);
164 canvas.SetFillStyle(4000);
166 canvas.SetFrameBorderMode(0);
175 tex.SetTextSize(0.04);
181 const double pT = 1000;
182 const double mass = 100;
183 const double phi = 0;
185 const int numSmear = 100000;
187 for (
const double eta : etaVals)
190 TH1D smearPt(Form(
"smearPt_eta%.2f",
eta),
"",100,500,1500);
191 TH1D smearMass(Form(
"smearMass_eta%.2f",
eta),
"",100,50,150);
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");
202 for (
int iSmear = 0; iSmear < numSmear; ++iSmear)
207 printf(
"Error while smearing, iteration %d\n",iSmear);
211 smearPt.Fill(
jet->pt());
212 smearMass.Fill(
jet->m());
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);
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;
227 TF1 fitPt(
"fitPt",
"gaus");
228 smearPt.Fit(&fitPt,
"E");
229 TF1 fitMass(
"fitMass",
"gaus");
230 smearMass.Fit(&fitMass,
"E");
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));
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));
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));
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));
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));
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));