21 #include "../testingMacros/atlasstyle/AtlasStyle.C"
22 #include "../testingMacros/atlasstyle/AtlasLabels.C"
27 #include "TGraphErrors.h"
38 #define TESTLINE printf("Reached line %d\n",__LINE__);
47 static TBox * myTBox =
new TBox();
58 const TString
name = graph.GetName();
59 if (
name.Contains(
"Absolute") &&
name.Contains(
"JES"))
61 graph.SetLineColor(kRed);
62 graph.SetLineStyle(1);
64 else if (
name.Contains(
"Relative") &&
name.Contains(
"JES"))
66 graph.SetLineColor(kMagenta);
67 graph.SetLineStyle(6);
69 else if (
name.Contains(
"Flav. composition"))
71 graph.SetLineColor(kBlue);
72 graph.SetLineStyle(2);
73 if (!
name.CompareTo(
"Flav. composition"))
76 else if (
name.Contains(
"Flav. response"))
78 graph.SetLineColor(kGreen+1);
79 graph.SetLineStyle(3);
80 if (!
name.CompareTo(
"Flav. response"))
83 else if (
name.Contains(
"Pileup") ||
name.Contains(
"Pile-up"))
85 graph.SetLineColor(kGray+1);
86 graph.SetLineStyle(4);
88 else if (
name.Contains(
"Punch-through"))
90 graph.SetLineColor(kOrange+7);
91 graph.SetLineStyle(5);
93 else if (
name.Contains(
"nonclosure") ||
name.Contains(
"NonClosure"))
95 graph.SetLineColor(kCyan);
96 graph.SetLineStyle(7);
98 else if (
name.Contains(
"Trigger data-derived"))
100 graph.SetLineColor(kOrange+7);
101 graph.SetLineStyle(5);
104 printf(
"Unexpected name for public format, not changing style of graph: %s\n",
name.Data());
114 void DrawText(TString txt,
int col=kBlack,
double y=0.88,
double x=0.15,
int align=12,
double ts=0.042)
116 static TLatex *tex =
new TLatex();
118 tex->SetTextFont(42);
119 tex->SetTextSize(
ts);
120 tex->SetTextAlign(align);
121 tex->SetTextColor(
col);
122 tex->DrawLatex(
x,
y,txt);
126 static TLine *
l =
new TLine();
l->SetLineWidth(
lw);
l->SetLineColor(
col);
l->SetLineStyle(
ls);
127 l->DrawLineNDC(
x-0.02,
y,
x+0.02,
y);
DrawText(txt,kBlack,
y,
x+0.032,12,0.036);
154 double xlow =
h->GetXaxis()->GetXmin();
155 double xhigh =
h->GetXaxis()->GetXmax();
159 if (fabs(fabs(xlow)-fabs(xhigh)) > 0.01) {
165 double fracxaxislow = ((
x-0.02)-0.12)/(1.0-0.12-0.04);
166 double fracxaxishigh = ((
x+0.02)-0.12)/(1.0-0.12-0.04);
167 double userxlow, userxhigh;
169 userxlow =
exp(
log(xlow) + fracxaxislow*(
log(xhigh) -
log(xlow)));
170 userxhigh =
exp(
log(xlow) + fracxaxishigh*(
log(xhigh) -
log(xlow)));
182 userxlow = xlow + fracxaxislow*(xhigh - xlow);
183 userxhigh = xlow + fracxaxishigh*(xhigh - xlow);
195 double fracyaxislow = ((
y-0.015)-0.15)/(1.0-0.15-0.04);
196 double fracyaxishigh = ((
y+0.015)-0.15)/(1.0-0.15-0.04);
197 double userylow, useryhigh;
199 userylow =
exp(fracyaxislow*(
log(yhigh)));
200 useryhigh =
exp(fracyaxishigh*(
log(yhigh)));
202 userylow = fracyaxislow*yhigh;
203 useryhigh = fracyaxishigh*yhigh;
206 myTBox->SetFillColor(
h->GetFillColor());
207 myTBox->SetLineColor(
h->GetLineColor());
208 myTBox->SetLineWidth(2);
209 myTBox->SetX1(userxlow);
210 myTBox->SetY1(userylow);
211 myTBox->SetX2(userxhigh);
212 myTBox->SetY2(useryhigh);
213 myTBox->DrawClone(
"l");
217 if (fabs(fabs(xlow)-fabs(xhigh)) > 0.01) {
260 if (
label.CompareTo(
"Work in Progress",TString::kIgnoreCase))
264 if (!
label.CompareTo(
"Internal"))
270 else if (!
label.CompareTo(
"Preliminary"))
272 else if (
label ==
"")
289 TString jetAlgo = jetAlgoIn;
290 std::vector<TString> returnvals;
293 if (jetAlgo.Contains(
"EMTopo") || jetAlgo.Contains(
"TopoEM"))
296 jetAlgo.ReplaceAll(
"EMTopo",
"");
297 jetAlgo.ReplaceAll(
"TopoEM",
"");
299 else if (jetAlgo.Contains(
"LCTopo") || jetAlgo.Contains(
"TopoLC"))
302 jetAlgo.ReplaceAll(
"LCTopo",
"");
303 jetAlgo.ReplaceAll(
"TopoLC",
"");
305 else if (jetAlgo.Contains(
"EMPFlow"))
308 jetAlgo.ReplaceAll(
"EMPFlow",
"");
310 else if (jetAlgo.Contains(
"TrackCaloCluster"))
313 jetAlgo.ReplaceAll(
"TrackCaloCluster",
"");
317 printf(
"Failed to parse calib for: %s\n",jetAlgoIn.Data());
318 returnvals.push_back(
"");
323 if (jetAlgo.BeginsWith(
"AntiKt"))
325 type =
"anti-#it{k}_{t}";
326 jetAlgo.ReplaceAll(
"AntiKt",
"");
328 else if (jetAlgo.BeginsWith(
"CamKt"))
330 type =
"Cambridge-Aachen k_{t}";
331 jetAlgo.ReplaceAll(
"CamKt",
"");
333 else if (jetAlgo.BeginsWith(
"Kt"))
336 jetAlgo.ReplaceAll(
"Kt",
"");
340 printf(
"Failed to parse type for: %s\n",jetAlgoIn.Data());
341 returnvals.push_back(
"");
348 if (!jet::utils::getTypeObjFromString<int>(jetAlgo,jetR))
350 printf(
"Failed to get radius parameter for: %s\n",jetAlgoIn.Data());
351 returnvals.push_back(
"");
356 printf(
"Got unexpected radius parameter of %d for: %s\n",jetR,jetAlgoIn.Data());
357 returnvals.push_back(
"");
361 returnvals.push_back(
type);
362 returnvals.push_back( Form(
"#font[52]{R} = %s",jetR>9?Form(
"%.1f",jetR/10.):Form(
"0.%d",jetR)));
363 returnvals.push_back(
calib);
374 TString jetAlgo = jetAlgoIn;
375 jetAlgo.ReplaceAll(
"Trimmed",
";Trimmed").ReplaceAll(
"Filtered",
";Filtered");
378 std::vector<TString> jetAlgoStrings = jet::utils::vectorize<TString>(jetAlgo,
";");
379 if (jetAlgoStrings.size() != 2)
381 printf(
"Failed to split large-R jet definition: %s\n",jetAlgoIn.Data());
386 TString jetDefPart =
GetJetDesc(jetAlgoStrings.at(0)).at(0)+
" "+
GetJetDesc(jetAlgoStrings.at(0)).at(1)+
" jets, "+
GetJetDesc(jetAlgoStrings.at(0)).at(2);
387 if (jetDefPart ==
"")
390 jetDefPart.ReplaceAll(
"+JES",
"+JES+JMS");
393 TString jetSubPart =
"";
394 TString trimOrFilter =
"";
395 if (jetAlgoStrings.at(1).Contains(
"Trimmed"))
396 trimOrFilter =
"Trimmed";
397 else if (jetAlgoStrings.at(1).Contains(
"Filtered"))
398 trimOrFilter =
"Filtered";
402 if (trimOrFilter ==
"Trimmed")
404 jetAlgoStrings.at(1).ReplaceAll(
"Trimmed",
"");
406 if (jetAlgoStrings.at(1).BeginsWith(
"PtFrac"))
408 jetAlgoStrings.at(1).ReplaceAll(
"PtFrac",
"");
409 const char* temp = jetAlgoStrings.at(1).Data();
412 if (TString(temp[
index]).IsDigit())
413 pTfrac += TString(temp[
index]);
419 printf(
"Found PtFrac but not an associated value: %s\n",jetAlgoIn.Data());
422 jetAlgoStrings.at(1).Replace(0,pTfrac.Length(),
"");
426 if (jetAlgoStrings.at(1).BeginsWith(
"SmallR"))
428 jetAlgoStrings.at(1).ReplaceAll(
"SmallR",
"");
429 const char* temp = jetAlgoStrings.at(1).Data();
432 if (TString(temp[
index]).IsDigit())
433 smallR += TString(temp[
index]);
439 printf(
"Found SmallR but not an associated value: %s\n",jetAlgoIn.Data());
442 jetAlgoStrings.at(1).Replace(0,smallR.Length(),
"");
445 if (jetAlgoStrings.at(1) !=
"")
447 printf(
"Substructure information remains (%s): %s\n",jetAlgoStrings.at(1).Data(),jetAlgoIn.Data());
451 jetSubPart = Form(
"Trimmed (#it{f}_{cut} = %.2f, #font[52]{R}_{sub} = %.1f)%s",
float(jet::utils::getTypeObjFromString<int>(pTfrac))/100.,
float(jet::utils::getTypeObjFromString<int>(smallR))/100.,
optHelper.
IsPublicFormat() ?
", #it{p}_{T}^{jet} > 150 GeV" :
"");
454 if (jetSubPart ==
"")
456 printf(
"Failed to parse substructure information: %s\n",jetAlgoIn.Data());
460 return Form(
"#splitline{%s}{%s}",jetDefPart.Data(),jetSubPart.Data());
469 else if (TString(provider->
getJetDef().c_str()).Contains(
"Trimmed"))
482 if (
config.Contains(
"_HbbTagging"))
484 else if (
config.Contains(
"_WZTagging"))
486 else if (
config.Contains(
"_TopTagging"))
497 if (
release.BeginsWith(
"2011_"))
502 else if (
release.BeginsWith(
"2012_"))
507 else if (
release.BeginsWith(
"2015_Prerec"))
509 type =
"Prerec 2015";
512 else if (
release.BeginsWith(
"2015_"))
517 else if (
release.BeginsWith(
"2015_TLA"))
522 else if (
release.BeginsWith(
"2015_ICHEP"))
527 else if (
release.BeginsWith(
"2016_Moriond") ||
release.BeginsWith(
"rel21_Moriond2018"))
532 else if (
release.BeginsWith(
"rel21_Summer2018")||
release.BeginsWith(
"rel21_Fall2018"))
534 type =
"Data 2015-2017";
537 else if (
release.BeginsWith(
"rel21_Moriond2018"))
539 type =
"Data 2015+2016";
542 else if (
release.BeginsWith(
"rel21_Spring2019") ||
release.BeginsWith(
"rel21_Summer2019") ||
release.BeginsWith(
"rel21_Fall2020"))
544 type =
"Data 2015-2017";
547 if (
type ==
"" || sqrtS ==
"")
549 printf(
"Could not parse year information from release: %s\n",
release.Data());
554 if (bunchspacing !=
"") {
555 DrawText(Form(
"%s, #sqrt{#it{s}} = %s, %s ns",
type.Data(),sqrtS.Data(),bunchspacing.Data()),kBlack,yPos);
557 DrawText(Form(
"%s, #sqrt{#it{s}} = %s",
type.Data(),sqrtS.Data()),kBlack,yPos);
565 TString scenario =
"Nominal";
566 if (
config.Contains(
"StrongerCorrelations"))
567 scenario =
"Stronger Correlations";
568 else if (
config.Contains(
"WeakerCorrelations"))
569 scenario =
"Weaker Correlations";
570 else if (
config.Contains(
"_3NP_"))
572 TString scenarioNum =
"UNKNOWN";
573 std::vector<TString>
tokens = jet::utils::vectorize<TString>(
config,
"_./");
574 for (
size_t iToken = 0; iToken <
tokens.size(); ++iToken)
575 if (
tokens.at(iToken).BeginsWith(
"Scenario"))
576 scenarioNum =
tokens.at(iToken).ReplaceAll(
"Scenario",
"");
578 scenario = Form(
"Rep_{str.red}^{%s,JES}",scenarioNum.Data());
581 if (scenario !=
"Nominal")
596 static TH1* PThisto = NULL;
615 std::getline(
ss, token,
'_');
616 std::cout <<
"Year: " << token << std::endl;
617 int year = token ==
"rel21" ? 2017 : std::stoi(token);
624 if (
jetType ==
"AntiKt4LCTopo")
626 else if (
jetType ==
"AntiKt6LCTopo")
628 else if (
jetType ==
"AntiKt4EMTopo")
630 else if (
jetType ==
"AntiKt6EMTopo")
634 printf(
"Unrecognized jet type for PT fraction: %s\n",
jetType.Data());
638 std::cout <<
"Using pT file " <<
filename << std::endl;
639 TFile* PTfile =
new TFile(
filename,
"READ");
640 if (!PTfile || PTfile->IsZombie())
642 printf(
"Failed to open PT fraction file\n");
645 PThisto =
dynamic_cast<TH1*
>(PTfile->Get(
histName));
648 printf(
"Failed to retrieve PT fraction histo: %s\n",
histName.Data());
651 PThisto->SetDirectory(0);
654 return PThisto->Interpolate(
jet.pt()/1.e3);
667 if (
release.BeginsWith(
"2011_"))
673 else if (
release.BeginsWith(
"2012_") or
release.BeginsWith(
"2015_Prerec"))
676 sigmaMu = 5.593*1.11;
679 else if (
release.BeginsWith(
"2015_Moriond") ||
release.BeginsWith(
"2015_ICHEP") ||
release.BeginsWith(
"2015_TLA"))
685 else if (
release.BeginsWith(
"2016_") ||
release.BeginsWith(
"rel21_Moriond2018") ||
release.BeginsWith(
"rel21_Summer2018") ||
release.BeginsWith(
"rel21_Fall2018") ||
release.BeginsWith(
"rel21_Spring2019") ||
release.BeginsWith(
"rel21_Summer2019") ||
release.BeginsWith(
"rel21_Fall2020") )
696 printf(
"Unexpected year for setPileupShiftsForYear in release: %s\n",
release.Data());
707 printf(
"WARNING: empty vector passed to getQuadratureSumUncertainty\n");
712 if (compIndices.size() == 1 && (compIndices.at(0) == 8888 || compIndices.at(0) == 9999))
714 if (compIndices.at(0) == 8888)
719 else if (compIndices.size() == 1 && (compIndices.at(0) == 6666 || compIndices.at(0) == 7777))
722 if (scaleVars.size() != 1)
723 printf(
"WARNING: cannot parse multiple scale variable resolutions at once, using index 0");
727 if (compIndices.at(0) == 6666)
735 const double inverted = compIndices.at(0) < 0 ? -1 : 1;
739 unc = factor*localUnc*inverted;
743 for (
size_t iComp = 0; iComp < compIndices.size(); ++iComp)
745 if (compIndices.at(iComp) == 8888 || compIndices.at(iComp) == 9999)
continue;
746 if (compIndices.at(iComp) == 6666 || compIndices.at(iComp) == 7777)
continue;
752 const double inverted = compIndices.at(iComp) < 0 ? -1 : 1;
754 unc += factor*factor*localUnc*localUnc*inverted;
771 std::vector<TString> provNames;
779 const std::vector<TString> subComponents = jet::utils::vectorize<TString>(
compName,
",");
781 for (
size_t iSubComp = 0; iSubComp < subComponents.size(); ++iSubComp)
784 const bool beginWild = subComponents.at(iSubComp).BeginsWith(
"#");
785 const bool endWild = subComponents.at(iSubComp).EndsWith(
"#");
786 const bool midWild = !beginWild && !endWild && subComponents.at(iSubComp).Contains(
"#");
787 const bool ALLCOMP = !subComponents.at(iSubComp).CompareTo(
"total",TString::kIgnoreCase) || !subComponents.at(iSubComp).CompareTo(
"#");
788 const bool CALOWEIGHT = !subComponents.at(iSubComp).CompareTo(
"caloweight",TString::kIgnoreCase);
789 const bool TAWEIGHT = !subComponents.at(iSubComp).CompareTo(
"taweight",TString::kIgnoreCase);
790 const bool NOMRESMC = !subComponents.at(iSubComp).CompareTo(
"nominalresmc",TString::kIgnoreCase);
791 const bool NOMRESDATA = !subComponents.at(iSubComp).CompareTo(
"nominalresdata",TString::kIgnoreCase);
792 const bool inverted = subComponents.at(iSubComp).BeginsWith(
"INV__");
793 const TString toFind = midWild ? subComponents.at(iSubComp) : TString(subComponents.at(iSubComp)).ReplaceAll(
"#",
"").ReplaceAll(
"INV__",
"");
796 std::vector<TString> tokensToFind;
797 if (midWild) tokensToFind = jet::utils::vectorize<TString>(toFind,
"#");
798 if (midWild && tokensToFind.size() != 2)
800 printf(
"Only one middle-wildcard is currently supported\n");
801 printf(
"Cannot handle string: %s\n",toFind.Data());
806 bool foundIndex =
false;
807 for (
size_t iProvComp = 0; iProvComp < provNames.size(); ++iProvComp)
847 if ( ( provNames.at(iProvComp).BeginsWith(tokensToFind.at(0),TString::kIgnoreCase) || (namePrefix !=
"" && provNames.at(iProvComp).BeginsWith(namePrefix+tokensToFind.at(0),TString::kIgnoreCase)) ) && provNames.at(iProvComp).EndsWith(tokensToFind.at(1),TString::kIgnoreCase))
854 else if (!beginWild && !endWild)
857 if (!provNames.at(iProvComp).CompareTo(toFind,TString::kIgnoreCase) || ( namePrefix !=
"" && !provNames.at(iProvComp).CompareTo(namePrefix+toFind,TString::kIgnoreCase) ) )
865 else if (beginWild && !endWild)
868 if (provNames.at(iProvComp).EndsWith(toFind,TString::kIgnoreCase))
875 else if (!beginWild && endWild)
878 if (provNames.at(iProvComp).BeginsWith(toFind,TString::kIgnoreCase) || ( namePrefix !=
"" && provNames.at(iProvComp).BeginsWith(namePrefix+toFind,TString::kIgnoreCase) ) )
889 if (provNames.at(iProvComp).Contains(toFind,TString::kIgnoreCase))
898 printf(
"WARNING: Failed to find match for sub/component: %s\n",toFind.Data());
905 printf(
"Failed to find any indices for component: %s\n",
compName.Data());
914 std::vector< std::vector<int> >
indices;
917 for (
size_t iComp = 0; iComp <
compNames.size(); ++iComp)
921 for (
size_t iComp = 0; iComp <
indices.size(); ++iComp)
923 printf(
"Parsed component named: %s\n",
compNames.at(iComp).Data());
924 for (
size_t iIndex = 0; iIndex <
indices.at(iComp).
size(); ++iIndex)
927 else if (
indices.at(iComp).at(iIndex) < 0)
930 printf(
"\t %d: SPECIAL\n",
indices.at(iComp).at(iIndex));
938 void MakeUncertaintyPlots(
const TString&
outFile,TCanvas*
canvas,
const std::vector<JetUncertaintiesTool*>& providers,
const std::vector< std::vector< std::vector<int> > >& compSetIndices,
const std::vector< std::vector<TString> >& labelNames,TH1D* frame,
const double fixedValue,
const std::vector<double>& scanBins,
const bool fixedIsEta,
const float mOverPt,
const bool doComparison,
const bool doCompareOnly,
const bool mOverPtIsMass)
956 std::vector<TH1D*> totalHists;
957 std::vector<TGraphErrors*> totalGraphs;
958 std::vector< std::vector<TGraphErrors*> > compGraphs;
972 IsBjet(*
jet) =
false;
982 size_t indexHelper = 0;
985 for (
size_t iProv = 0; iProv < providers.size(); ++iProv)
1011 std::cout <<
"Fixed LargeRJetTruthLabel" << std::endl;
1027 totalHists.push_back(
new TH1D(Form(
"Total_%zu_hist",iProv),
"",scanBins.size()-1,&scanBins[0]));
1028 TH1D* totalHist = totalHists.back();
1029 totalHist->SetFillColor(590);
1030 totalHist->SetLineWidth(0);
1033 totalGraphs.push_back(
new TGraphErrors());
1034 TGraphErrors* totalGraph = totalGraphs.back();
1035 totalGraph->SetName(Form(
"Total_%zu_graph",iProv));
1036 totalGraph->SetLineStyle(1);
1037 totalGraph->SetLineWidth(2);
1038 totalGraph->SetLineColor(kBlack);
1044 int PTindex =
static_cast<int>(allIndices.size());
1046 if (TString(provider->
getComponentName(iComp).c_str()).Contains(
"PunchThrough",TString::kIgnoreCase))
1053 std::vector<TGraphErrors*> provCompGraphs;
1056 for (
size_t iComp = 0; iComp < compSetIndices.at(iProv).size(); ++iComp)
1059 provCompGraphs.push_back(
new TGraphErrors());
1060 TGraphErrors* compGraph = provCompGraphs.back();
1061 compGraph->SetName(labelNames.at(iProv).at(iComp));
1062 compGraph->SetLineStyle(indexHelper+1);
1063 compGraph->SetLineColor(indexHelper+2 < 5 ? indexHelper+2 : indexHelper+3 < 13 ? indexHelper+3 : indexHelper+4);
1064 if (indexHelper+3 == 10) compGraph->SetLineColor(kYellow-9);
1065 compGraph->SetLineWidth(doComparison?3:4);
1072 for (
int iScan = 1; iScan < frame->GetNbinsX()+2; ++iScan)
1074 const double binValue = iScan == 1 ? frame->GetBinLowEdge(iScan)+1.e-3 : iScan == frame->GetNbinsX()+1 ? frame->GetBinLowEdge(iScan)-1.e-3 : frame->GetBinLowEdge(iScan);
1079 const double mass = mOverPtIsMass ? mOverPt*1.e3 : mOverPt*
pt;
1093 bool isZero =
false;
1095 if (
pt > 1.5e6) isZero =
true;
1107 for (
size_t iComp = 0; iComp < compSetIndices.at(iProv).
size(); ++iComp)
1111 TGraphErrors* compGraph = provCompGraphs.at(iComp);
1113 compGraph->SetPoint(iScan-1,binValue,compUnc);
1118 totalGraph->SetPoint(iScan-1,binValue,totalUnc);
1123 compGraphs.push_back(provCompGraphs);
1126 for (
int iScan = 1; iScan < frame->GetNbinsX()+1; ++iScan)
1128 const double binValue = frame->GetBinCenter(iScan);
1133 const double mass = mOverPtIsMass ? mOverPt*1.e3 : mOverPt*
pt;
1146 bool isZero =
false;
1148 if (
pt > 1.5e6) isZero =
true;
1165 for (
size_t iProv = 0; iProv < providers.size(); ++iProv)
1167 TH1D* totalHist = totalHists.at(iProv);
1170 TH1D* rebinnedTotal =
new TH1D(Form(
"Rebinned_%s",totalHist->GetName()),
"",rebinnedBins.size()-1,&rebinnedBins[0]);
1171 rebinnedTotal->SetFillColor(590);
1172 rebinnedTotal->SetLineWidth(0);
1173 for(
int iBin = 1; iBin < rebinnedTotal->GetNbinsX()+1; ++iBin)
1174 rebinnedTotal->SetBinContent(iBin,totalHist->Interpolate(rebinnedTotal->GetBinCenter(iBin)));
1175 delete totalHists[iProv];
1176 totalHists[iProv] = rebinnedTotal;
1184 else canvas->SetLogx(
false);
1190 frame->GetXaxis()->SetRangeUser(
xrange.first,
xrange.second);
1193 else if (fixedIsEta) frame->GetXaxis()->SetRangeUser(17,3.0
e3);
1194 else frame->GetXaxis()->SetRangeUser(-4.5,4.5);
1199 frame->GetYaxis()->SetRangeUser(0,
maxYuser);
1209 TH1D* comparisonHist = 0;
1210 TGraphErrors * comparisonGraph = 0;
1212 comparisonHist = totalHists.at(providers.size()-1);
1213 totalHists.pop_back();
1214 comparisonGraph = totalGraphs.at(providers.size()-1);
1215 totalGraphs.pop_back();
1221 if (doCompareOnly) {
1223 totalGraphs.at(
index)->SetLineColor(1000+
index);
1224 totalGraphs.at(
index)->SetLineStyle(1);
1225 totalGraphs.at(
index)->SetLineWidth(2);
1226 totalHists.at(
index)->SetLineColor(1000+
index);
1227 totalHists.at(
index)->SetLineStyle(1);
1228 totalHists.at(
index)->SetLineWidth(2);
1229 totalGraphs.at(
index)->Draw(
"l same");
1232 totalHists.at(0)->Draw(
"histF same");
1233 else if ((providers.size() == 2) && doComparison) {
1249 comparisonGraph->SetLineWidth(6);
1254 comparisonHist->SetLineColor(kGreen+3);
1255 comparisonHist->SetFillColor(kTeal+5);
1259 comparisonHist->SetLineColor(kTeal+5);
1260 comparisonHist->SetFillColor(kTeal-9);
1263 comparisonHist->Draw(
"histF same");
1264 totalHists.at(0)->Draw(
"histF same");
1268 if (!doCompareOnly) {
1269 for (
size_t iProv = 0; iProv < providers.size(); ++iProv)
1272 if (iProv == providers.size()-1)
continue;
1274 comparisonGraph->SetLineColor(comparisonHist->GetLineColor());
1275 comparisonGraph->Draw(
"l same");
1276 totalGraphs.at(0)->Draw(
"l same");
1278 for (
size_t iComp = 0; iComp < compGraphs.at(iProv).
size(); ++iComp)
1279 compGraphs.at(iProv).at(iComp)->Draw(
"l same");
1287 for (
size_t i=0;
i<providers.size();
i++) {
1288 const TString thisconfname = providers.at(
i)->getConfigFile().c_str();
1289 if (!(thisconfname.Contains(
"_2012/")))
sign =
false;
1291 bool sameRelease =
true;
1292 const TString release0 = providers.at(0)->getRelease();
1293 for (
size_t i=1;
i<providers.size(); ++
i)
1294 if (providers.at(
i)->getRelease() != release0)
1295 sameRelease =
false;
1299 if (providers.size() == 1 || (providers.size()==2 && doComparison) ||
sign || sameRelease)
1317 if (providers.size() == 1 || (providers.size()==2 && doComparison) ||
sign || sameRelease)
1320 DrawText(fixedIsEta?Form(
"#eta = %.1f, m = %.0f GeV",
fixedValue,mOverPt):Form(
"#it{p}_{T}^{jet} = %.0f GeV",
fixedValue),kBlack,TString(providers.at(0)->getJetDef().c_str()).Contains(
"Trimmed") ? 0.74 : 0.805);
1322 DrawText(fixedIsEta?Form(
"#eta = %.1f, m/p_{T} = %.2f",
fixedValue,mOverPt):Form(
"#it{p}_{T}^{jet} = %.0f GeV",
fixedValue),kBlack,TString(providers.at(0)->getJetDef().c_str()).Contains(
"Trimmed") ? 0.74 : 0.805);
1324 DrawText(fixedIsEta?Form(
"#eta = %.1f",
fixedValue):Form(
"#it{p}_{T}^{jet} = %.0f GeV",
fixedValue),kBlack,TString(providers.at(0)->getJetDef().c_str()).Contains(
"Trimmed") ? 0.74 : 0.805);
1330 double legx=0.41, legy=0.78,
dy = 0.045;
1333 else if (TString(providers.at(0)->getJetDef().c_str()).Contains(
"Trimmed"))
1336 if (doCompareOnly) {
1337 for (
size_t i=0;
i < totalGraphs.size();
i++) {
1338 const TString
title = labelNames.at(
i).at(0);
1342 if ((providers.size() == 1 || (providers.size() == 2 && doComparison)) &&
optHelper.
DrawTotal()) {
1347 const TString
title = labelNames.at(providers.size()-1).at(0);
1356 for (
size_t iProv = 0; iProv < providers.size(); ++iProv)
1357 for (
size_t iComp = 0; iComp < compGraphs.at(iProv).
size(); ++iComp)
1359 const TGraphErrors* compGraph = compGraphs.at(iProv).at(iComp);
1360 const TString
label = compGraph->GetName();
1361 if (
label.Contains(
"#splitline"))
1378 frame->Draw(
"axis same");
1394 for (
size_t iSet = 0; iSet < compGraphs.size(); ++iSet)
1396 for (
size_t iComp = 0 ; iComp < compGraphs.at(iSet).
size(); ++iComp)
1398 compGraphs.at(iSet).at(iComp)->Write();
1405 for (
size_t iProv = 0; iProv < providers.size(); ++iProv)
1407 if (doComparison && iProv == providers.size()-1)
continue;
1409 delete totalHists.at(iProv);
1410 delete totalGraphs.at(iProv);
1412 for (
size_t iComp = 0; iComp < compGraphs.at(iProv).
size(); ++iComp)
1413 delete compGraphs.at(iProv).at(iComp);
1415 delete comparisonHist;
1416 delete comparisonGraph;
1420 void MakeUncertaintyPlots(
const TString&
outFile,TCanvas*
canvas,
const std::vector<JetUncertaintiesTool*>& providers,
const std::vector< std::vector<TString> >& compSetComponents,
const std::vector< std::vector<TString> >& labelNames,
const bool doComparison,
const bool doCompareOnly)
1433 TH1D* frameEtaScan =
new TH1D(
"frameEtaScan",
"",etaScanValues.size()-1,&etaScanValues[0]);
1434 TH1D* framePtScan =
new TH1D(
"framePtScan",
"",ptScanValues.size()-1,&ptScanValues[0]);
1436 TString yAxisVar =
"";
1446 yAxisVar =
"#it{p}_{T}";
1451 yAxisVar =
"#it{p}_{T}";
1459 yAxisVar =
"D_{12}";
1462 yAxisVar =
"D_{23}";
1465 yAxisVar =
"#tau_{21}";
1468 yAxisVar =
"#tau_{21}^{wta}";
1471 yAxisVar =
"#tau_{32}";
1474 yAxisVar =
"#tau_{32}^{wta}";
1492 Form(
"Fractional J%sS uncertainty",yAxisVar.Data())
1494 Form(
"Uncertainty on #sigma(%s)/%s",yAxisVar.Data(),yAxisVar.Data())
1495 :
"Unknown scale type";
1496 frameEtaScan->GetXaxis()->SetTitleOffset(1.4);
1498 frameEtaScan->GetXaxis()->SetTitle(
"#eta");
1499 frameEtaScan->GetYaxis()->SetTitle(yAxisLabel.Data());
1500 framePtScan->GetXaxis()->SetTitleOffset(1.4);
1502 framePtScan->GetXaxis()->SetTitle(
"#it{p}_{T}^{jet} [GeV]");
1503 framePtScan->GetYaxis()->SetTitle(yAxisLabel.Data());
1504 framePtScan->GetXaxis()->SetMoreLogLabels();
1507 for (
int iBin = 1; iBin <= frameEtaScan->GetNbinsX(); ++iBin)
1508 frameEtaScan->SetBinContent(iBin,-1);
1509 for (
int iBin = 1; iBin <= framePtScan->GetNbinsX(); ++iBin)
1510 framePtScan->SetBinContent(iBin,-1);
1514 std::vector< std::vector< std::vector<int> > > compSetIndices;
1515 for (
size_t iProv = 0; iProv < providers.size(); ++iProv)
1521 for (
size_t iFixed = 0; iFixed < etaValuesForPtScan.size(); ++iFixed)
1522 MakeUncertaintyPlots(
outFile,
canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.at(iFixed),ptScanValues,
true,mOverPtValuesForPtScan.at(0),doComparison, doCompareOnly,
false);
1523 for (
size_t iFixed = 0; iFixed < ptValuesForEtaScan.size(); ++iFixed)
1524 MakeUncertaintyPlots(
outFile,
canvas,providers,compSetIndices,labelNames,frameEtaScan,ptValuesForEtaScan.at(iFixed),etaScanValues,
false,mOverPtValuesForPtScan.at(0),doComparison, doCompareOnly,
false);
1525 if (massValuesForPtScan.size())
1527 for (
size_t iFixed = 0; iFixed < massValuesForPtScan.size(); ++iFixed)
1528 MakeUncertaintyPlots(
outFile,
canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.size() ? etaValuesForPtScan.at(0) : 0,ptScanValues,
true,massValuesForPtScan.at(iFixed),doComparison,doCompareOnly,
true);
1530 if (mOverPtValuesForPtScan.size() > 1)
1532 for (
size_t iFixed = 0; iFixed < mOverPtValuesForPtScan.size(); ++iFixed)
1533 MakeUncertaintyPlots(
outFile,
canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.size() ? etaValuesForPtScan.at(0) : 0,ptScanValues,
true,mOverPtValuesForPtScan.at(iFixed),doComparison,doCompareOnly,
false);
1538 if (massValuesForPtScan.size())
1540 for (
size_t iFixed = 0; iFixed < massValuesForPtScan.size(); ++iFixed)
1541 MakeUncertaintyPlots(
outFile,
canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.at(0),ptScanValues,
true,massValuesForPtScan.at(iFixed),doComparison,doCompareOnly,
true);
1545 for (
size_t iFixed = 0; iFixed < mOverPtValuesForPtScan.size(); ++iFixed)
1546 MakeUncertaintyPlots(
outFile,
canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.at(0),ptScanValues,
true,mOverPtValuesForPtScan.at(iFixed),doComparison, doCompareOnly,
false);
1552 delete frameEtaScan;
1560 printf(
"Expected arguments:\n");
1561 printf(
"\t1. Output file (ps, pdf, eps)\n");
1562 printf(
"\t2. Jet definition(s), semicolon delimited\n");
1563 printf(
"\t3. MC type(s), semicolon delimited (one for all configs, or one per config)\n");
1564 printf(
"\t4. Config file(s), semicolon delimited\n");
1565 printf(
"\t5. Component list, special formatting (one for all configs, or one per config):\n");
1566 printf(
"\t\tComma-delimited means combine components\n");
1567 printf(
"\t\tSemicolon-delimited means new component\n");
1568 printf(
"\t\tAmpersand-delimited means new config\n");
1569 printf(
"\t\tTOTAL to get the total uncertainty as one term\n");
1570 printf(
"\t\t# is wildcard, so InSitu# is everything starting with InSitu\n");
1571 printf(
"\t6. Component labels, special formatting (one for all configs, or one per config)\n");
1572 printf(
"\t\tSemicolon-delimited for each component label\n");
1573 printf(
"\t\tAmpersand-delimited for each config\n");
1574 printf(
"\t7. Options (optional argument), semi-colon delimited, examples:\n");
1575 printf(
"\t\tisDijet=false\n");
1576 printf(
"\t\tisLargeR=false\n");
1580 std::vector<TString>
jetDefs = jet::utils::vectorize<TString>(
argv[2],
";");
1581 std::vector<TString> mcTypes = jet::utils::vectorize<TString>(
argv[3],
";");
1582 std::vector<TString> configs = jet::utils::vectorize<TString>(
argv[4],
";");
1583 std::vector<TString> compSets = jet::utils::vectorize<TString>(
argv[5],
"@");
1584 std::vector<TString> labelSets = jet::utils::vectorize<TString>(
argv[6],
"@");
1588 StatusCode::enableFailure();
1590 bool doComparison =
false;
1591 bool compareJetDefs =
false;
1592 TString compareMCType =
"";
1593 TString totalLabel =
"";
1594 TString otherJetDef =
"";
1596 if (doCompConfig !=
"") {
1597 doComparison =
true;
1598 std::vector<TString> comparisons = jet::utils::vectorize<TString>(doCompConfig,
"&");
1599 if (comparisons.size() < 3)
1601 printf(
"Failed to parse comparison request: %s\n",doCompConfig.Data());
1604 doCompConfig = comparisons.at(0);
1605 compareMCType = comparisons.at(1);
1606 totalLabel = comparisons.at(2).Strip(TString::kBoth,
'"');
1607 configs.push_back(doCompConfig);
1608 mcTypes.push_back(compareMCType);
1609 compSets.push_back(
"");
1610 labelSets.push_back(totalLabel);
1611 if (comparisons.size()>3)
1613 compareJetDefs =
true;
1614 jetDefs.push_back(comparisons.at(3));
1619 if (doCompareOnly) {
1627 for (
size_t item = 0;
item < compareconfigs.size();
item++) {
1628 std::vector<TString> comparisons = jet::utils::vectorize<TString>(compareconfigs.at(
item),
"&");
1629 doCompConfig = comparisons.at(0);
1630 compareMCType = comparisons.at(1);
1631 totalLabel = comparisons.at(2).Strip(TString::kBoth,
'"');
1632 configs.push_back(doCompConfig);
1633 mcTypes.push_back(compareMCType);
1634 compSets.push_back(
"");
1635 labelSets.push_back(totalLabel);
1636 if (comparisons.size()>3)
jetDefs.push_back(comparisons.at(3));
1642 if (mcTypes.size() != 1 && mcTypes.size() != configs.size())
1644 printf(
"Expected either 1 MC type for all configs, or 1 MC type per config\n");
1645 printf(
"Instead, got %zu MC types and %zu configs\n",mcTypes.size(),configs.size());
1649 else if (mcTypes.size() == 1 && configs.size() != 1)
1650 for (
size_t iConfig = 1; iConfig < configs.size(); ++iConfig)
1651 mcTypes.push_back(mcTypes.at(0));
1654 if (compSets.size() != labelSets.size())
1656 printf(
"Expected matching numbers of component lists and labels\n");
1657 printf(
"Instead, got %zu component lists and %zu labels\n",compSets.size(),labelSets.size());
1662 if (compSets.size() != 1 && compSets.size() != configs.size())
1664 printf(
"Expected either 1 component list for all configs, or 1 component list per config\n");
1665 printf(
"Instead, got %zu component lists and %zu configs\n",compSets.size(),configs.size());
1669 else if (compSets.size() == 1 && configs.size() != 1)
1670 for (
size_t iConfig = 1; iConfig < configs.size(); ++iConfig)
1672 compSets.push_back(compSets.at(0));
1673 labelSets.push_back(labelSets.at(0));
1678 std::vector< std::vector<TString> > compSetComponents;
1679 std::vector< std::vector<TString> > labelNames;
1680 for (
size_t iSet = 0; iSet < compSets.size(); ++iSet)
1682 compSetComponents.push_back(jet::utils::vectorize<TString>(compSets.at(iSet),
";"));
1683 labelNames.push_back(jet::utils::vectorize<TString>(labelSets.at(iSet),
";"));
1689 gStyle->SetPalette(1);
1690 TCanvas*
canvas =
new TCanvas(
"canvas");
1691 canvas->SetMargin(0.12,0.04,0.15,0.04);
1692 canvas->SetFillStyle(4000);
1694 canvas->SetFrameBorderMode(0);
1705 system(Form(
"mkdir -p %s",TString(
outFile).ReplaceAll(
outFile.EndsWith(
".eps")?
".eps":
".png",
"").Data()));
1710 if (!(
jetDefs.size() == configs.size() &&
jetDefs.size() != 1) || (doComparison &&
jetDefs.size() != 1 && !compareJetDefs))
1712 std::cout <<
"Going to process for multiple jet types!" << std::endl;
1714 for (
size_t iJetDef = 0; iJetDef <
jetDefs.size(); ++iJetDef)
1717 std::cout <<
"Running for jet type " <<
jetDef << std::endl;
1720 std::vector<JetUncertaintiesTool*> providers;
1721 for (
size_t iConfig = 0; iConfig < configs.size(); ++iConfig)
1727 if (providers.back()->setProperty(
"JetDefinition",
jetDef.Data()).isFailure())
1729 printf(
"Failed to set JetDefinition to %s\n",
jetDef.Data());
1732 if (providers.back()->setProperty(
"MCType",mcTypes.at(iConfig).Data()).isFailure())
1734 printf(
"Failed to set MCType to %s\n",mcTypes.at(iConfig).Data());
1737 if (providers.back()->setProperty(
"ConfigFile",configs.at(iConfig).Data()).isFailure())
1739 printf(
"Failed to set ConfigFile to %s\n",configs.at(iConfig).Data());
1753 if (providers.back()->setProperty(
"AnalysisFile",analysisFile.Data()).isFailure())
1755 printf(
"Failed to set AnalysisFile to %s\n",analysisFile.Data());
1773 if (providers.back()->setProperty(
"Path",
optHelper.
GetPath().Data()).isFailure())
1786 printf(
"Failed to set VariablesToShift\n");
1792 if (providers.back()->initialize().isFailure())
1794 printf(
"Failed to initialize tool for config: %s\n",configs.at(iConfig).Data());
1803 for (
size_t iProv = 0; iProv < providers.size(); ++iProv)
1804 delete providers.at(iProv);
1811 std::vector<JetUncertaintiesTool*> providers;
1814 for (
size_t iJetDef = 0; iJetDef <
jetDefs.size(); ++iJetDef)
1817 const TString
config = configs.at(iJetDef);
1823 if (providers.back()->setProperty(
"JetDefinition",
jetDef.Data()).isFailure())
1825 printf(
"Failed to set JetDefinition to %s\n",
jetDef.Data());
1828 if (providers.back()->setProperty(
"MCType",mcTypes.at(iJetDef).Data()).isFailure())
1830 printf(
"Failed to set MCType to %s\n",mcTypes.at(iJetDef).Data());
1833 if (providers.back()->setProperty(
"ConfigFile",configs.at(iJetDef).Data()).isFailure())
1835 printf(
"Failed to set ConfigFile to %s\n",configs.at(iJetDef).Data());
1849 if (providers.back()->setProperty(
"AnalysisFile",analysisFile.Data()).isFailure())
1851 printf(
"Failed to set AnalysisFile to %s\n",analysisFile.Data());
1870 if (providers.back()->setProperty(
"Path",
optHelper.
GetPath().Data()).isFailure())
1883 printf(
"Failed to set VariablesToShift\n");
1889 if (providers.back()->initialize().isFailure())
1891 printf(
"Failed to initialize tool for config: %s\n",configs.at(iJetDef).Data());
1900 for (
size_t iProv = 0; iProv < providers.size(); ++iProv)
1901 delete providers.at(iProv);