ATLAS Offline Software
Loading...
Searching...
No Matches
MakeUncertaintyPlots.cxx File Reference
#include "JetUncertainties/JetUncertaintiesTool.h"
#include "JetUncertainties/Helpers.h"
#include "JetUncertainties/UncertaintyEnum.h"
#include "xAODJet/Jet.h"
#include "xAODJet/JetContainer.h"
#include "xAODJet/JetAuxContainer.h"
#include "xAODEventInfo/EventInfo.h"
#include "xAODEventInfo/EventInfoContainer.h"
#include "xAODEventInfo/EventInfoAuxContainer.h"
#include "../testingMacros/atlasstyle/AtlasStyle.C"
#include "../testingMacros/atlasstyle/AtlasLabels.C"
#include "TString.h"
#include "TCanvas.h"
#include "TH1D.h"
#include "TGraphErrors.h"
#include "TColor.h"
#include "TBox.h"
#include "math.h"
#include <vector>
#include "OptionHelper.h"
#include <iostream>
#include <sstream>

Go to the source code of this file.

Macros

#define TESTLINE   printf("Reached line %d\n",__LINE__);

Functions

void applyPublicFormat (TGraph &graph)
void DrawText (TString txt, int col=kBlack, double y=0.88, double x=0.15, int align=12, double ts=0.042)
void DrawLineLabel (TString txt, double x, double y, int col, int ls, int lw)
void DrawLineLabel (TString txt, double x, double y, const TGraphErrors *h)
void DrawLineLabel (TString txt, double x, double y, const TH1 *h)
void DrawFillLabel (TString txt, double x, double y, TH1 *h, bool logX=optHelper.LogPt(), bool logY=false)
void DrawAtlasLabel (const TString &label=optHelper.GetATLASLabel(), const bool right=true)
std::vector< TString > GetJetDesc (const TString &jetAlgoIn)
TString GetLargeJetDesc (const TString &jetAlgoIn)
void DrawJetLabel (const JetUncertaintiesTool *provider, const double yPos)
TString getTagType (const JetUncertaintiesTool *provider)
void DrawYearLabel (const JetUncertaintiesTool *provider, const double yPos)
void DrawScenarioLabel (const JetUncertaintiesTool *provider, const double yPos)
double GetPunchthroughProb (const JetUncertaintiesTool *provider, const xAOD::Jet &jet)
void setPileupShiftsForYear (const JetUncertaintiesTool *provider, xAOD::EventInfo *eInfo, const xAOD::Jet *jet=NULL)
double getQuadratureSumUncertainty (const JetUncertaintiesTool *provider, const std::vector< int > &compIndices, const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const int PTindex)
std::vector< int > getComponentIndicesFromName (const JetUncertaintiesTool *provider, const TString &compName)
std::vector< std::vector< int > > getComponentIndicesFromNames (const JetUncertaintiesTool *provider, const std::vector< TString > &compNames)
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)
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)
int main (int argc, char *argv[])

Variables

static TBox * myTBox = new TBox()
float maxYuser = -1.
jet::OptionHelper optHelper
const bool debug = true

Macro Definition Documentation

◆ TESTLINE

#define TESTLINE   printf("Reached line %d\n",__LINE__);

Definition at line 38 of file MakeUncertaintyPlots.cxx.

Function Documentation

◆ applyPublicFormat()

void applyPublicFormat ( TGraph & graph)

Definition at line 56 of file MakeUncertaintyPlots.cxx.

57{
58 const TString name = graph.GetName();
59 if (name.Contains("Absolute") && name.Contains("JES"))
60 {
61 graph.SetLineColor(kRed);
62 graph.SetLineStyle(1);
63 }
64 else if (name.Contains("Relative") && name.Contains("JES"))
65 {
66 graph.SetLineColor(kMagenta);
67 graph.SetLineStyle(6);
68 }
69 else if (name.Contains("Flav. composition"))
70 {
71 graph.SetLineColor(kBlue);
72 graph.SetLineStyle(2);
73 if (!name.CompareTo("Flav. composition"))
74 graph.SetName(Form("%s, %s",name.Data(),optHelper.GetCompositionName().Data()));
75 }
76 else if (name.Contains("Flav. response"))
77 {
78 graph.SetLineColor(kGreen+1);
79 graph.SetLineStyle(3);
80 if (!name.CompareTo("Flav. response"))
81 graph.SetName(Form("%s, %s",name.Data(),optHelper.GetCompositionName().Data()));
82 }
83 else if (name.Contains("Pileup") || name.Contains("Pile-up"))
84 {
85 graph.SetLineColor(kGray+1);
86 graph.SetLineStyle(4);
87 }
88 else if (name.Contains("Punch-through"))
89 {
90 graph.SetLineColor(kOrange+7);
91 graph.SetLineStyle(5);
92 }
93 else if (name.Contains("nonclosure") || name.Contains("NonClosure"))
94 {
95 graph.SetLineColor(kCyan);
96 graph.SetLineStyle(7);
97 }
98 else if (name.Contains("Trigger data-derived"))
99 {
100 graph.SetLineColor(kOrange+7);
101 graph.SetLineStyle(5);
102 }
103 else
104 printf("Unexpected name for public format, not changing style of graph: %s\n",name.Data());
105}
jet::OptionHelper optHelper

◆ DrawAtlasLabel()

void DrawAtlasLabel ( const TString & label = optHelper.GetATLASLabel(),
const bool right = true )

Definition at line 254 of file MakeUncertaintyPlots.cxx.

255{
256 double xPos = 0.15;
257// double yPos = 0.850;
258 double yPos = 0.890;
259
260 if (label.CompareTo("Work in Progress",TString::kIgnoreCase))
261 {
262 if (right)
263 {
264 if (!label.CompareTo("Internal"))
265 {
266 xPos = 0.7;
267 if (optHelper.IsLargeR() && optHelper.IsPublicFormat())
268 xPos = 0.65;
269 }
270 else if (!label.CompareTo("Preliminary"))
271 xPos = 0.67;
272 else if (label == "")
273 xPos = 0.8;
274 else
275 xPos = 0.7;
276 }
277 ATLASLabel(xPos,yPos,label.Data(),kBlack);
278 }
279 else
280 {
281 ATLASLabel(right?0.75:xPos,yPos,"",kBlack);
282 DrawText(label,kBlack,yPos-0.038,right?0.75:xPos);
283 }
284
285}
void DrawText(TString txt, int col=kBlack, double y=0.88, double x=0.15, int align=12, double ts=0.042)
void ATLASLabel(Double_t x, Double_t y, char *text=NULL, Color_t color=1)
std::string label(const std::string &format, int i)
Definition label.h:19

◆ DrawFillLabel()

void DrawFillLabel ( TString txt,
double x,
double y,
TH1 * h,
bool logX = optHelper.LogPt(),
bool logY = false )

Definition at line 138 of file MakeUncertaintyPlots.cxx.

138 {
139
140/* static TPave *box = new TPave();
141// box->SetFillColor(590);
142 box->SetFillColor(h->GetFillColor());
143 box->SetLineColor(h->GetLineColor());
144 box->SetLineWidth(1);
145 box->SetLineColor(kBlack);
146 box->SetShadowColor(0);
147 box->SetX1NDC(x-0.02);
148 box->SetY1NDC(y-0.015);
149 box->SetX2NDC(x+0.02);
150 box->SetY2NDC(y+0.015);
151 box->Draw();
152*/
153 // Margin = (0.12,0.04,0.15,0.04)
154 double xlow = h->GetXaxis()->GetXmin();
155 double xhigh = h->GetXaxis()->GetXmax();
156
157 // YES THIS IS HACKY
158 y = y + 0.003; // ""
159 if (fabs(fabs(xlow)-fabs(xhigh)) > 0.01) {
160 x = x + 0.012; // Boxes in an ugly place otherwise.
161 }
162
163 double yhigh = maxYuser; // ""
164 // Now calculate user coordinates from sensible ratios given in function call :(
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;
168 if (logX) {
169 userxlow = exp(log(xlow) + fracxaxislow*(log(xhigh) - log(xlow)));
170 userxhigh = exp(log(xlow) + fracxaxishigh*(log(xhigh) - log(xlow)));
171 if (optHelper.fillShift().first != 0 || optHelper.fillShift().second != 0)
172 {
173 userxlow -= optHelper.fillShift().first;
174 userxhigh -= optHelper.fillShift().second;
175 }
176 else if (optHelper.IsLargeR())
177 {
178 userxlow -= 15;
179 userxhigh -= 15;
180 }
181 } else {
182 userxlow = xlow + fracxaxislow*(xhigh - xlow);
183 userxhigh = xlow + fracxaxishigh*(xhigh - xlow);
184 if (optHelper.fillShift().first != 0 || optHelper.fillShift().second != 0)
185 {
186 userxlow -= optHelper.fillShift().first;
187 userxhigh -= optHelper.fillShift().second;
188 }
189 if (optHelper.IsTLA())
190 {
191 userxlow -= 15;
192 userxhigh -= 15;
193 }
194 }
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;
198 if (logY) {
199 userylow = exp(fracyaxislow*(log(yhigh)));
200 useryhigh = exp(fracyaxishigh*(log(yhigh)));
201 } else {
202 userylow = fracyaxislow*yhigh;
203 useryhigh = fracyaxishigh*yhigh;
204 }
205
206 myTBox->SetFillColor(h->GetFillColor());
207 myTBox->SetLineColor(h->GetLineColor());
208 myTBox->SetLineWidth(2);
209 myTBox->SetX1(userxlow); //(80);
210 myTBox->SetY1(userylow); //(0.1*y-0.005);
211 myTBox->SetX2(userxhigh); //(110.0);
212 myTBox->SetY2(useryhigh); //(0.1*y);
213 myTBox->DrawClone("l");
214
215 // Undo shift
216 y = y - 0.003;
217 if (fabs(fabs(xlow)-fabs(xhigh)) > 0.01) {
218 x = x - 0.012;
219 }
220
221/*
222 static TPave *box = new TPave();
223 box->SetFillColor(590);
224 box->SetLineColor(h->GetLineColor()); box->SetLineWidth(1); box->SetLineColor(kBlack);
225 //box->SetFillStyle(1001);
226 //box->SetShadowColor(h->GetFillColor());
227 //box->SetFillColor(2);
228 //cout << box->GetFillColor() << endl;
229 box->DrawPave(x-0.02,y-0.015,x+0.02,y+0.015,1,"ndc");//h->GetLineWidth(),"ndc");
230 //box->DrawBox(100,0.04,200,0.05);
231 // double xc[4] = {x-0.02,x+0.02,x+0.02,x-0.02};
232 //double yc[4] = {y-0.015,x-0.015,y+0.015,x+0.015};
233 //gPad->SetFillColor(590);
234 //gPad->PaintFillArea(4,xc,yc);
235 //double x1 = gPad->GetX1(), xden=(gPad->GetX2()-gPad->GetX1());
236 //double y1 = gPad->GetY1(), yden=(gPad->GetY2()-gPad->GetY1());
237 //box->DrawBox((x-0.02)*xden+x1,(y-0.015)*yden+y1,(x+0.02)*xden+x1,(y+0.015)*yden+y1);
238 //cout << (x-0.02)*xden+x1 << endl;
239*/
240
241
242 /*
243 No, we do not have such functions, but the conversion is easy
244 double u = (x-gPad->GetX1())/(gpad->GetX2()-gPad->GetX1());
245 where
246 x is your user coordinate
247 u will be the corresponding NDC coordinate
248 */
249 DrawText(txt,kBlack,y,x+0.032,12,0.036);
250}
static TBox * myTBox
float maxYuser
#define y
#define x
Header file for AthHistogramAlgorithm.

◆ DrawJetLabel()

void DrawJetLabel ( const JetUncertaintiesTool * provider,
const double yPos )

Definition at line 463 of file MakeUncertaintyPlots.cxx.

464{
465 if (optHelper.IsLargeR())
466 {
467 DrawText(GetLargeJetDesc(provider->getJetDef().c_str()),kBlack,yPos);
468 }
469 else if (TString(provider->getJetDef().c_str()).Contains("Trimmed"))
470 {
471 DrawText(GetLargeJetDesc(provider->getJetDef().c_str()),kBlack,yPos-0.035);
472 }
473 else
474 //DrawText(GetJetDesc(provider->getJetDef().c_str())+" + #it{in situ} correction",kBlack,yPos);
475 //DrawText(GetJetDesc(provider->getJetDef().c_str()).at(0)+" "+GetJetDesc(provider->getJetDef().c_str()).at(1)+", "+GetJetDesc(provider->getJetDef().c_str()).at(2)+" + #it{in situ}",kBlack,yPos);
476 DrawText(GetJetDesc(provider->getJetDef().c_str()).at(0)+" "+GetJetDesc(provider->getJetDef().c_str()).at(1)+", "+GetJetDesc(provider->getJetDef().c_str()).at(2),kBlack,yPos);
477}
std::vector< TString > GetJetDesc(const TString &jetAlgoIn)
TString GetLargeJetDesc(const TString &jetAlgoIn)
virtual std::string getJetDef() const

◆ DrawLineLabel() [1/3]

void DrawLineLabel ( TString txt,
double x,
double y,
const TGraphErrors * h )

Definition at line 130 of file MakeUncertaintyPlots.cxx.

130 {
131 DrawLineLabel(txt,x,y,h->GetLineColor(),h->GetLineStyle(),h->GetLineWidth());
132}
void DrawLineLabel(TString txt, double x, double y, int col, int ls, int lw)

◆ DrawLineLabel() [2/3]

void DrawLineLabel ( TString txt,
double x,
double y,
const TH1 * h )

Definition at line 134 of file MakeUncertaintyPlots.cxx.

134 {
135 DrawLineLabel(txt,x,y,h->GetLineColor(),h->GetLineStyle(),h->GetLineWidth());
136}

◆ DrawLineLabel() [3/3]

void DrawLineLabel ( TString txt,
double x,
double y,
int col,
int ls,
int lw )

Definition at line 125 of file MakeUncertaintyPlots.cxx.

125 {
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);
128}
l
Printing final latex table to .tex output file.

◆ DrawScenarioLabel()

void DrawScenarioLabel ( const JetUncertaintiesTool * provider,
const double yPos )

Definition at line 561 of file MakeUncertaintyPlots.cxx.

562{
563 const TString config = provider->getConfigFile().c_str();
564
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_"))
571 {
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","");
577
578 scenario = Form("Rep_{str.red}^{%s,JES}",scenarioNum.Data());
579 }
580
581 if (scenario != "Nominal")
582 DrawText(scenario,kBlack,config.Contains("_3NP")?yPos-0.01:yPos);
583}
virtual std::string getConfigFile() const
bool vectorize(const TString &str, const TString &sep, std::vector< T > &result)

◆ DrawText()

void DrawText ( TString txt,
int col = kBlack,
double y = 0.88,
double x = 0.15,
int align = 12,
double ts = 0.042 )

Definition at line 114 of file MakeUncertaintyPlots.cxx.

115{
116 static TLatex *tex = new TLatex();
117 tex->SetNDC();
118 tex->SetTextFont(42);
119 tex->SetTextSize(ts);
120 tex->SetTextAlign(align);
121 tex->SetTextColor(col);
122 tex->DrawLatex(x,y,txt);
123}
int ts
Definition globals.cxx:24

◆ DrawYearLabel()

void DrawYearLabel ( const JetUncertaintiesTool * provider,
const double yPos )

Definition at line 491 of file MakeUncertaintyPlots.cxx.

492{
493 const TString release = provider->getRelease();
494
495 TString type = "";
496 TString sqrtS = "";
497 if (release.BeginsWith("2011_"))
498 {
499 type = "Data 2011";
500 sqrtS = "7 TeV";
501 }
502 else if (release.BeginsWith("2012_"))
503 {
504 type = "Data 2012";
505 sqrtS = "8 TeV";
506 }
507 else if (release.BeginsWith("2015_Prerec"))
508 {
509 type = "Prerec 2015";
510 sqrtS = "13 TeV";
511 }
512 else if (release.BeginsWith("2015_"))
513 {
514 type = "Data 2015";
515 sqrtS = "13 TeV";
516 }
517 else if (release.BeginsWith("2015_TLA"))
518 {
519 type = "Data 2015";
520 sqrtS = "13 TeV";
521 }
522 else if (release.BeginsWith("2015_ICHEP"))
523 {
524 type = "Data 2015";
525 sqrtS = "13 TeV";
526 }
527 else if (release.BeginsWith("2016_Moriond") || release.BeginsWith("rel21_Moriond2018"))
528 {
529 type = "Data 2016";
530 sqrtS = "13 TeV";
531 }
532 else if (release.BeginsWith("rel21_Summer2018")|| release.BeginsWith("rel21_Fall2018"))
533 {
534 type = "Data 2015-2017";
535 sqrtS = "13 TeV";
536 }
537 else if (release.BeginsWith("rel21_Moriond2018"))
538 {
539 type = "Data 2015+2016";
540 sqrtS = "13 TeV";
541 }
542 else if (release.BeginsWith("rel21_Spring2019") || release.BeginsWith("rel21_Summer2019") || release.BeginsWith("rel21_Fall2020"))
543 {
544 type = "Data 2015-2017";
545 sqrtS = "13 TeV";
546 }
547 if (type == "" || sqrtS == "")
548 {
549 printf("Could not parse year information from release: %s\n",release.Data());
550 exit(-1);
551 }
552 //DrawText(Form("%s, #sqrt{#it{s}} = %s",type.Data(),sqrtS.Data()),kBlack,yPos);
553 const TString bunchspacing = optHelper.GetBunchSpacing();
554 if (bunchspacing != "") {
555 DrawText(Form("%s, #sqrt{#it{s}} = %s, %s ns",type.Data(),sqrtS.Data(),bunchspacing.Data()),kBlack,yPos);
556 } else
557 DrawText(Form("%s, #sqrt{#it{s}} = %s",type.Data(),sqrtS.Data()),kBlack,yPos);
558
559}
virtual std::string getRelease() const
static std::string release
Definition computils.h:50

◆ getComponentIndicesFromName()

std::vector< int > getComponentIndicesFromName ( const JetUncertaintiesTool * provider,
const TString & compName )

Definition at line 767 of file MakeUncertaintyPlots.cxx.

768{
769 // Map of name to index won't work as we need to worry about wildcard component names
770 // So build a vector
771 std::vector<TString> provNames;
772 for (size_t iComp = 0; iComp < provider->getNumComponents(); ++iComp)
773 provNames.push_back(provider->getComponentName(iComp));
774
775 // Get the name prefix, if it exists
776 const TString namePrefix = optHelper.GetNamePrefix();
777
778 // Now parse component name to index/indices
779 const std::vector<TString> subComponents = jet::utils::vectorize<TString>(compName,",");
780 std::vector<int> indices;
781 for (size_t iSubComp = 0; iSubComp < subComponents.size(); ++iSubComp)
782 {
783 // Check for wildcards
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__","");
794
795 // Treat the more difficult mid-wild case
796 std::vector<TString> tokensToFind;
797 if (midWild) tokensToFind = jet::utils::vectorize<TString>(toFind,"#");
798 if (midWild && tokensToFind.size() != 2)
799 {
800 printf("Only one middle-wildcard is currently supported\n");
801 printf("Cannot handle string: %s\n",toFind.Data());
802 exit(-1);
803 }
804
805 // Find the component index
806 bool foundIndex = false;
807 for (size_t iProvComp = 0; iProvComp < provNames.size(); ++iProvComp)
808 {
809 // Skip components which are not 4-vec scales or pt-scales
810 //if (!provider->getComponentScalesFourVec(iProvComp) && !provider->getComponentScalesPt(iProvComp))
811 // continue;
812
813 if (ALLCOMP)
814 {
815 foundIndex = true;
816 indices.push_back(iProvComp);
817 }
818 else if (CALOWEIGHT)
819 {
820 foundIndex = true;
821 indices.push_back(8888);
822 break;
823 }
824 else if (TAWEIGHT)
825 {
826 foundIndex = true;
827 indices.push_back(9999);
828 break;
829 }
830 else if (NOMRESMC)
831 {
832 foundIndex = true;
833 indices.push_back(6666);
834 break;
835 }
836 else if (NOMRESDATA)
837 {
838 foundIndex = true;
839 indices.push_back(7777);
840 break;
841 }
842 else if (midWild)
843 {
844 // There is a wildcard in the middle of the name
845 // Check if the string starts with the first token and ends with the last token
846 // We already ensured there are only two tokens
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))
848 {
849 // The wildcard may cover many components, so keep looping to make sure we find them all
850 foundIndex = true;
851 indices.push_back(iProvComp);
852 }
853 }
854 else if (!beginWild && !endWild)
855 {
856 // Direct name equalitty (no wildcards)
857 if (!provNames.at(iProvComp).CompareTo(toFind,TString::kIgnoreCase) || ( namePrefix != "" && !provNames.at(iProvComp).CompareTo(namePrefix+toFind,TString::kIgnoreCase) ) )
858 {
859 // There can only be one component with a given name, so break out if we find it
860 foundIndex = true;
861 indices.push_back(iProvComp);
862 break;
863 }
864 }
865 else if (beginWild && !endWild)
866 {
867 // The start of the name is a wildcard
868 if (provNames.at(iProvComp).EndsWith(toFind,TString::kIgnoreCase))
869 {
870 // The wildcard may cover many components, so keep looping to make sure we find them all
871 foundIndex = true;
872 indices.push_back(iProvComp);
873 }
874 }
875 else if (!beginWild && endWild)
876 {
877 // The end of the name is a wildcard
878 if (provNames.at(iProvComp).BeginsWith(toFind,TString::kIgnoreCase) || ( namePrefix != "" && provNames.at(iProvComp).BeginsWith(namePrefix+toFind,TString::kIgnoreCase) ) )
879 {
880 // The wildcard may cover many components, so keep looping to make sure we find them all
881 foundIndex = true;
882 indices.push_back(iProvComp);
883 }
884 }
885 else
886 {
887 // There are wildcards at the start and end of the name
888 // Look for the desired substring within the name
889 if (provNames.at(iProvComp).Contains(toFind,TString::kIgnoreCase))
890 {
891 // The wildcards may cover many components, so keep looping to make sure we find them all
892 foundIndex = true;
893 indices.push_back(iProvComp);
894 }
895 }
896 }
897 if (!foundIndex)
898 printf("WARNING: Failed to find match for sub/component: %s\n",toFind.Data());
899 else if (inverted)
900 indices.back() *= -1;
901 }
902
903 if (!indices.size() && !optHelper.IgnoreNoMatch())
904 {
905 printf("Failed to find any indices for component: %s\n",compName.Data());
906 exit(-1);
907 }
908
909 return indices;
910}
virtual size_t getNumComponents() const
virtual std::string getComponentName(const size_t index) const
std::pair< long int, long int > indices

◆ getComponentIndicesFromNames()

std::vector< std::vector< int > > getComponentIndicesFromNames ( const JetUncertaintiesTool * provider,
const std::vector< TString > & compNames )

Definition at line 912 of file MakeUncertaintyPlots.cxx.

913{
914 std::vector< std::vector<int> > indices;
915
916 // Now parse all of the names to provider indices
917 for (size_t iComp = 0; iComp < compNames.size(); ++iComp)
918 indices.push_back(getComponentIndicesFromName(provider,compNames.at(iComp)));
919
920 if (debug)
921 for (size_t iComp = 0; iComp < indices.size(); ++iComp)
922 {
923 printf("Parsed component named: %s\n",compNames.at(iComp).Data());
924 for (size_t iIndex = 0; iIndex < indices.at(iComp).size(); ++iIndex)
925 if (indices.at(iComp).at(iIndex) >= 0 && indices.at(iComp).at(iIndex) < static_cast<int>(provider->getNumComponents()))
926 printf("\t %d: %s\n",indices.at(iComp).at(iIndex),provider->getComponentName(indices.at(iComp).at(iIndex)).c_str());
927 else if (indices.at(iComp).at(iIndex) < 0)
928 printf("\t %d: INVERTED %s\n",indices.at(iComp).at(iIndex)*-1,provider->getComponentName(indices.at(iComp).at(iIndex)*-1).c_str());
929 else
930 printf("\t %d: SPECIAL\n",indices.at(iComp).at(iIndex));
931 }
932
933 return indices;
934}
const bool debug
std::vector< int > getComponentIndicesFromName(const JetUncertaintiesTool *provider, const TString &compName)

◆ GetJetDesc()

std::vector< TString > GetJetDesc ( const TString & jetAlgoIn)

Definition at line 287 of file MakeUncertaintyPlots.cxx.

288{
289 TString jetAlgo = jetAlgoIn;
290 std::vector<TString> returnvals;
291
292 TString calib = "";
293 if (jetAlgo.Contains("EMTopo") || jetAlgo.Contains("TopoEM"))
294 {
295 calib = "EM+JES";
296 jetAlgo.ReplaceAll("EMTopo","");
297 jetAlgo.ReplaceAll("TopoEM","");
298 }
299 else if (jetAlgo.Contains("LCTopo") || jetAlgo.Contains("TopoLC"))
300 {
301 calib = "LCW+JES";
302 jetAlgo.ReplaceAll("LCTopo","");
303 jetAlgo.ReplaceAll("TopoLC","");
304 }
305 else if (jetAlgo.Contains("EMPFlow"))
306 {
307 calib = "PFlow+JES";
308 jetAlgo.ReplaceAll("EMPFlow","");
309 }
310 else if (jetAlgo.Contains("TrackCaloCluster"))
311 {
312 calib = "TCC+JES";
313 jetAlgo.ReplaceAll("TrackCaloCluster","");
314 }
315 if (calib == "")
316 {
317 printf("Failed to parse calib for: %s\n",jetAlgoIn.Data());
318 returnvals.push_back("");
319 return returnvals;
320 }
321
322 TString type = "";
323 if (jetAlgo.BeginsWith("AntiKt"))
324 {
325 type = "anti-#it{k}_{t}";
326 jetAlgo.ReplaceAll("AntiKt","");
327 }
328 else if (jetAlgo.BeginsWith("CamKt"))
329 {
330 type = "Cambridge-Aachen k_{t}";
331 jetAlgo.ReplaceAll("CamKt","");
332 }
333 else if (jetAlgo.BeginsWith("Kt"))
334 {
335 type = "k_{t}";
336 jetAlgo.ReplaceAll("Kt","");
337 }
338 if (type == "")
339 {
340 printf("Failed to parse type for: %s\n",jetAlgoIn.Data());
341 returnvals.push_back("");
342 return returnvals;
343 }
344
345 // AntiKt4LCTopo --> AntiKt4 --> 4
346 // Hopefully all that's left is the radius parameter
347 int jetR = 0;
348 if (!jet::utils::getTypeObjFromString<int>(jetAlgo,jetR))
349 {
350 printf("Failed to get radius parameter for: %s\n",jetAlgoIn.Data());
351 returnvals.push_back("");
352 return returnvals;
353 }
354 if (jetR <= 0)
355 {
356 printf("Got unexpected radius parameter of %d for: %s\n",jetR,jetAlgoIn.Data());
357 returnvals.push_back("");
358 return returnvals;
359 }
360
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);
364 //returnvals.push_back(Form("%s %s ",type.Data(),calib.Data()));
365// return Form("%s #font[52]{R} = %s, %s",type.Data(),jetR>9?Form("%.1f",jetR/10.):Form("0.%d",jetR),calib.Data());
366 return returnvals;
367}
bool getTypeObjFromString(const std::string &str, T &obj)

◆ GetLargeJetDesc()

TString GetLargeJetDesc ( const TString & jetAlgoIn)

Definition at line 369 of file MakeUncertaintyPlots.cxx.

370{
371 // First get the substructure techniques information
372 // Example: AntiKt10LCTopoTrimmedPtFrac5SmallR30
373 // Want to split into "AntiKt10LCTopo" and "TrimmedPtFrac5SmallR30"
374 TString jetAlgo = jetAlgoIn;
375 jetAlgo.ReplaceAll("Trimmed",";Trimmed").ReplaceAll("Filtered",";Filtered");
376
377 // Split it
378 std::vector<TString> jetAlgoStrings = jet::utils::vectorize<TString>(jetAlgo,";");
379 if (jetAlgoStrings.size() != 2)
380 {
381 printf("Failed to split large-R jet definition: %s\n",jetAlgoIn.Data());
382 return "";
383 }
384
385 // Get the pure jet part
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 == "")
388 return "";
389 // Overwrite the "+JES" as this is not applicable for large-R
390 jetDefPart.ReplaceAll("+JES","+JES+JMS");
391
392 // Now get the substructure part
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";
399
400 // Get trimming info
401 // TODO make this more general
402 if (trimOrFilter == "Trimmed")
403 {
404 jetAlgoStrings.at(1).ReplaceAll("Trimmed","");
405 TString pTfrac = "";
406 if (jetAlgoStrings.at(1).BeginsWith("PtFrac"))
407 {
408 jetAlgoStrings.at(1).ReplaceAll("PtFrac","");
409 const char* temp = jetAlgoStrings.at(1).Data();
410 for (int index = 0; index < jetAlgoStrings.at(1).Length(); ++index)
411 {
412 if (TString(temp[index]).IsDigit())
413 pTfrac += TString(temp[index]);
414 else
415 break;
416 }
417 if (pTfrac == "")
418 {
419 printf("Found PtFrac but not an associated value: %s\n",jetAlgoIn.Data());
420 return "";
421 }
422 jetAlgoStrings.at(1).Replace(0,pTfrac.Length(),"");
423 }
424
425 TString smallR = "";
426 if (jetAlgoStrings.at(1).BeginsWith("SmallR"))
427 {
428 jetAlgoStrings.at(1).ReplaceAll("SmallR","");
429 const char* temp = jetAlgoStrings.at(1).Data();
430 for (int index = 0; index < jetAlgoStrings.at(1).Length(); ++index)
431 {
432 if (TString(temp[index]).IsDigit())
433 smallR += TString(temp[index]);
434 else
435 break;
436 }
437 if (smallR == "")
438 {
439 printf("Found SmallR but not an associated value: %s\n",jetAlgoIn.Data());
440 return "";
441 }
442 jetAlgoStrings.at(1).Replace(0,smallR.Length(),"");
443 }
444
445 if (jetAlgoStrings.at(1) != "")
446 {
447 printf("Substructure information remains (%s): %s\n",jetAlgoStrings.at(1).Data(),jetAlgoIn.Data());
448 return "";
449 }
450
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" : "");
452 }
453
454 if (jetSubPart == "")
455 {
456 printf("Failed to parse substructure information: %s\n",jetAlgoIn.Data());
457 return "";
458 }
459
460 return Form("#splitline{%s}{%s}",jetDefPart.Data(),jetSubPart.Data());
461}
Definition index.py:1

◆ GetPunchthroughProb()

double GetPunchthroughProb ( const JetUncertaintiesTool * provider,
const xAOD::Jet & jet )

Definition at line 594 of file MakeUncertaintyPlots.cxx.

595{
596 static TH1* PThisto = NULL;
597 static TString jetType = "";
598
599 if (PThisto == NULL || jetType == "" || jetType != provider->getJetDef())
600 {
601 if (PThisto)
602 {
603 delete PThisto;
604 PThisto = NULL;
605 }
606
607 const TString config = provider->getConfigFile();
608 TString filename;
609 jetType = provider->getJetDef();
610 TString histName = "";
611 // All Run 2 analyses should use this option.
612 const TString release = provider->getRelease();
613 std::istringstream ss(release.Data());
614 std::string token;
615 std::getline(ss, token, '_');
616 std::cout << "Year: " << token << std::endl;
617 int year = token == "rel21" ? 2017 : std::stoi(token);
618 if (year > 2012) {
619 filename = optHelper.GetInputsDir()+"/PTprob.root";
620 histName = "h_PT_pT_EMJES4_norm";
621 } else {
622 filename = optHelper.GetInputsDir()+"/PTprob_2012.root";
623
624 if (jetType == "AntiKt4LCTopo")
625 histName = "h_PT_pT_LCJES4_norm";
626 else if (jetType == "AntiKt6LCTopo")
627 histName = "h_PT_pT_LCJES6_norm";
628 else if (jetType == "AntiKt4EMTopo")
629 histName = "h_PT_pT_EMJES4_norm";
630 else if (jetType == "AntiKt6EMTopo")
631 histName = "h_PT_pT_EMJES6_norm";
632 else
633 {
634 printf("Unrecognized jet type for PT fraction: %s\n",jetType.Data());
635 exit(100);
636 }
637 }
638 std::cout << "Using pT file " << filename << std::endl;
639 TFile* PTfile = new TFile(filename,"READ");
640 if (!PTfile || PTfile->IsZombie())
641 {
642 printf("Failed to open PT fraction file\n");
643 exit(101);
644 }
645 PThisto = dynamic_cast<TH1*>(PTfile->Get(histName));
646 if (!PThisto)
647 {
648 printf("Failed to retrieve PT fraction histo: %s\n",histName.Data());
649 exit(102);
650 }
651 PThisto->SetDirectory(0);
652 }
653
654 return PThisto->Interpolate(jet.pt()/1.e3);
655}
static Double_t ss

◆ getQuadratureSumUncertainty()

double getQuadratureSumUncertainty ( const JetUncertaintiesTool * provider,
const std::vector< int > & compIndices,
const xAOD::Jet & jet,
const xAOD::EventInfo & eInfo,
const int PTindex )

Definition at line 704 of file MakeUncertaintyPlots.cxx.

705{
706 if (compIndices.size() == 0 && !optHelper.IgnoreNoMatch())
707 printf("WARNING: empty vector passed to getQuadratureSumUncertainty\n");
708 //for (size_t iComp = 0; iComp < compIndices.size(); ++iComp)
709 // printf("Component %zu/%zu (%zu)\n",iComp,compIndices.size(),compIndices.at(iComp));
710
711 double unc = 0;
712 if (compIndices.size() == 1 && (compIndices.at(0) == 8888 || compIndices.at(0) == 9999)) // SPECIAL: calorimeter or TA weight
713 {
714 if (compIndices.at(0) == 8888)
715 unc = provider->getNormalizedCaloMassWeight(jet)/10.;
716 else
717 unc = provider->getNormalizedTAMassWeight(jet)/10.;
718 }
719 else if (compIndices.size() == 1 && (compIndices.at(0) == 6666 || compIndices.at(0) == 7777)) // SPECIAL: nominal MC or data resolution
720 {
721 std::vector<jet::CompScaleVar::TypeEnum> scaleVars = optHelper.GetScaleVars();
722 if (scaleVars.size() != 1)
723 printf("WARNING: cannot parse multiple scale variable resolutions at once, using index 0");
724
725 jet::JetTopology::TypeEnum topology = optHelper.GetTopology();
726
727 if (compIndices.at(0) == 6666)
728 unc = provider->getNominalResolutionMC(jet,scaleVars.at(0),topology);
729 else
730 unc = provider->getNominalResolutionData(jet,scaleVars.at(0),topology);
731 }
732 else if (compIndices.size() == 1 && !optHelper.AbsValue())
733 {
734 const double factor = abs(compIndices.at(0)) != PTindex ? 1 : GetPunchthroughProb(provider,jet);
735 const double inverted = compIndices.at(0) < 0 ? -1 : 1;
736 double localUnc = 0;
737 for (size_t iScaleVar = 0; iScaleVar < optHelper.GetScaleVars().size(); ++iScaleVar)
738 if (provider->getValidUncertainty(abs(compIndices.at(0)),localUnc,jet,eInfo,optHelper.GetScaleVars().at(iScaleVar)))
739 unc = factor*localUnc*inverted;
740 }
741 else
742 {
743 for (size_t iComp = 0; iComp < compIndices.size(); ++iComp)
744 {
745 if (compIndices.at(iComp) == 8888 || compIndices.at(iComp) == 9999) continue;
746 if (compIndices.at(iComp) == 6666 || compIndices.at(iComp) == 7777) continue;
747
748 const double factor = compIndices.at(iComp) != PTindex ? 1 : GetPunchthroughProb(provider,jet);
749 double localUnc = 0;
750 for (size_t iScaleVar = 0; iScaleVar < optHelper.GetScaleVars().size(); ++iScaleVar)
751 {
752 const double inverted = compIndices.at(iComp) < 0 ? -1 : 1;
753 if (provider->getValidUncertainty(abs(compIndices.at(iComp)),localUnc,jet,eInfo,optHelper.GetScaleVars().at(iScaleVar)))
754 unc += factor*factor*localUnc*localUnc*inverted;
755 }
756 }
757 if (unc > 0)
758 unc = sqrt(unc);
759 else if (optHelper.AbsValue())
760 unc = sqrt(-unc);
761 else
762 unc = -sqrt(-unc);
763 }
764 return unc;
765}
double GetPunchthroughProb(const JetUncertaintiesTool *provider, const xAOD::Jet &jet)
virtual double getNominalResolutionMC(const xAOD::Jet &jet, const jet::CompScaleVar::TypeEnum smearType, const jet::JetTopology::TypeEnum topology=jet::JetTopology::UNKNOWN) const
virtual double getNormalizedTAMassWeight(const xAOD::Jet &jet) const
virtual bool getValidUncertainty(size_t index, double &unc, const xAOD::Jet &jet) const
virtual double getNormalizedCaloMassWeight(const xAOD::Jet &jet) const
virtual double getNominalResolutionData(const xAOD::Jet &jet, const jet::CompScaleVar::TypeEnum smearType, const jet::JetTopology::TypeEnum topology=jet::JetTopology::UNKNOWN) const

◆ getTagType()

TString getTagType ( const JetUncertaintiesTool * provider)

Definition at line 479 of file MakeUncertaintyPlots.cxx.

480{
481 const TString config = provider->getConfigFile().c_str();
482 if (config.Contains("_HbbTagging"))
483 return "Hbb";
484 else if (config.Contains("_WZTagging"))
485 return "W/Z";
486 else if (config.Contains("_TopTagging"))
487 return "Top";
488 return "UNKNOWN";
489}

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 1556 of file MakeUncertaintyPlots.cxx.

1557{
1558 if (argc != 7 && argc != 8)
1559 {
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");
1577 exit(1);
1578 }
1579 TString outFile = argv[1];
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],"@");
1585 if (argc == 8) optHelper.Initialize(jet::utils::vectorize<TString>(argv[7],";"));
1586 else optHelper.Initialize(std::vector<TString>());
1587
1588 StatusCode::enableFailure();
1589
1590 bool doComparison = false;
1591 bool compareJetDefs = false;
1592 TString compareMCType = "";
1593 TString totalLabel = "";
1594 TString otherJetDef = "";
1595 TString doCompConfig = optHelper.DoCompare();
1596 if (doCompConfig != "") {
1597 doComparison = true;
1598 std::vector<TString> comparisons = jet::utils::vectorize<TString>(doCompConfig,"&");
1599 if (comparisons.size() < 3)
1600 {
1601 printf("Failed to parse comparison request: %s\n",doCompConfig.Data());
1602 exit(1);
1603 }
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)
1612 {
1613 compareJetDefs = true;
1614 jetDefs.push_back(comparisons.at(3));
1615 }
1616 }
1617
1618 bool doCompareOnly = optHelper.CompareOnly();
1619 if (doCompareOnly) {
1620 // If we are doing only the comparison we don't want anything with individual components
1621 // just three big lines. So clear anything that is here now.
1622 configs.clear();
1623 mcTypes.clear();
1624 compSets.clear();
1625 labelSets.clear();
1626 std::vector<TString> compareconfigs = optHelper.GetCompareVals();
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));
1637 }
1638
1639 }
1640
1641 // One MC type for all configs or one MC type per config
1642 if (mcTypes.size() != 1 && mcTypes.size() != configs.size())
1643 {
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());
1646 exit(2);
1647 }
1648 // One MC type for all configs, then duplicate
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));
1652
1653 // Equal numbers of component lists and labels
1654 if (compSets.size() != labelSets.size())
1655 {
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());
1658 exit(4);
1659 }
1660
1661 // One component list for all configs or one component list per config
1662 if (compSets.size() != 1 && compSets.size() != configs.size())
1663 {
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());
1666 exit(3);
1667 }
1668 // One component list for all configs, then duplicate
1669 else if (compSets.size() == 1 && configs.size() != 1)
1670 for (size_t iConfig = 1; iConfig < configs.size(); ++iConfig)
1671 {
1672 compSets.push_back(compSets.at(0));
1673 labelSets.push_back(labelSets.at(0));
1674 }
1675
1676
1677 // Split the component sets and labels further
1678 std::vector< std::vector<TString> > compSetComponents;
1679 std::vector< std::vector<TString> > labelNames;
1680 for (size_t iSet = 0; iSet < compSets.size(); ++iSet)
1681 {
1682 compSetComponents.push_back(jet::utils::vectorize<TString>(compSets.at(iSet),";"));
1683 labelNames.push_back(jet::utils::vectorize<TString>(labelSets.at(iSet),";"));
1684 }
1685
1686
1687 // Create the canvas
1688 SetAtlasStyle();
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);
1693 canvas->SetFillColor(0);
1694 canvas->SetFrameBorderMode(0);
1695 canvas->cd();
1696
1697 // Ensure we don't have debugging enabled
1698 if (optHelper.GetDumpFile() == "")
1699 {
1700 // If this is not an eps, start the output
1701 if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png"))
1702 canvas->Print(outFile+"[");
1703 // Otherwise, make a folder for the eps files
1704 else
1705 system(Form("mkdir -p %s",TString(outFile).ReplaceAll(outFile.EndsWith(".eps")?".eps":".png","").Data()));
1706
1707 }
1708
1709 // Run once per jet type
1710 if (!(jetDefs.size() == configs.size() && jetDefs.size() != 1) || (doComparison && jetDefs.size() != 1 && !compareJetDefs))
1711 {
1712 std::cout << "Going to process for multiple jet types!" << std::endl;
1713
1714 for (size_t iJetDef = 0; iJetDef < jetDefs.size(); ++iJetDef)
1715 {
1716 const TString jetDef = jetDefs.at(iJetDef);
1717 std::cout << "Running for jet type " << jetDef << std::endl;
1718
1719 // Create the providers
1720 std::vector<JetUncertaintiesTool*> providers;
1721 for (size_t iConfig = 0; iConfig < configs.size(); ++iConfig)
1722 {
1723 // Make a new provider
1724 providers.push_back(new JetUncertaintiesTool(Form("%s_%zu",jetDef.Data(),iConfig)));
1725
1726 //Set properties
1727 if (providers.back()->setProperty("JetDefinition",jetDef.Data()).isFailure())
1728 {
1729 printf("Failed to set JetDefinition to %s\n",jetDef.Data());
1730 exit(4);
1731 }
1732 if (providers.back()->setProperty("MCType",mcTypes.at(iConfig).Data()).isFailure())
1733 {
1734 printf("Failed to set MCType to %s\n",mcTypes.at(iConfig).Data());
1735 exit(5);
1736 }
1737 if (providers.back()->setProperty("ConfigFile",configs.at(iConfig).Data()).isFailure())
1738 {
1739 printf("Failed to set ConfigFile to %s\n",configs.at(iConfig).Data());
1740 exit(6);
1741 }
1742 if (providers.back()->setProperty("IsData",optHelper.GetIsData()).isFailure())
1743 {
1744 printf("Failed to set IsData to %s\n",optHelper.GetIsData() ? "true" : "false");
1745 exit(7);
1746 }
1747
1748 // Check if we want to change topology from unknown to dijet
1749 const TString analysisFile = optHelper.GetCompositionPath();
1750
1751 if (analysisFile) {
1752
1753 if (providers.back()->setProperty("AnalysisFile",analysisFile.Data()).isFailure())
1754 {
1755 printf("Failed to set AnalysisFile to %s\n",analysisFile.Data());
1756 exit(7);
1757 }
1758 }
1759
1760 // Check if we want to set the CalibArea
1761 if (optHelper.GetCalibArea() != "")
1762 {
1763 if (providers.back()->setProperty("CalibArea",optHelper.GetCalibArea().Data()).isFailure())
1764 {
1765 printf("Failed to set CalibArea to %s\n",optHelper.GetCalibArea().Data());
1766 exit(7);
1767 }
1768 }
1769
1770 // Check if we want to set the Path
1771 if (optHelper.GetPath() != "")
1772 {
1773 if (providers.back()->setProperty("Path",optHelper.GetPath().Data()).isFailure())
1774 {
1775 printf("Failed to set Path to %s\n",optHelper.GetPath().Data());
1776 exit(7);
1777 }
1778 }
1779
1780
1781 // Set filters if specified
1782 if (optHelper.VariablesToShift().size())
1783 {
1784 if (providers.back()->setProperty("VariablesToShift",optHelper.VariablesToShift()).isFailure())
1785 {
1786 printf("Failed to set VariablesToShift\n");
1787 exit(8);
1788 }
1789 }
1790
1791 // Done setting properties, initialize the tool
1792 if (providers.back()->initialize().isFailure())
1793 {
1794 printf("Failed to initialize tool for config: %s\n",configs.at(iConfig).Data());
1795 exit(9);
1796 }
1797 }
1798
1799 // Make the plots
1800 MakeUncertaintyPlots(outFile,canvas,providers,compSetComponents,labelNames,doComparison,doCompareOnly);
1801
1802 // Clean up
1803 for (size_t iProv = 0; iProv < providers.size(); ++iProv)
1804 delete providers.at(iProv);
1805 providers.clear();
1806 }
1807 }
1808 else
1809 {
1810 // Create the providers
1811 std::vector<JetUncertaintiesTool*> providers;
1812
1813 // Special case of different jet collections being compared
1814 for (size_t iJetDef = 0; iJetDef < jetDefs.size(); ++iJetDef)
1815 {
1816 const TString jetDef = jetDefs.at(iJetDef);
1817 const TString config = configs.at(iJetDef);
1818
1819 //Make a new provider
1820 providers.push_back(new JetUncertaintiesTool(Form("%s_%zu",jetDef.Data(),iJetDef)));
1821
1822 //Set properties
1823 if (providers.back()->setProperty("JetDefinition",jetDef.Data()).isFailure())
1824 {
1825 printf("Failed to set JetDefinition to %s\n",jetDef.Data());
1826 exit(4);
1827 }
1828 if (providers.back()->setProperty("MCType",mcTypes.at(iJetDef).Data()).isFailure())
1829 {
1830 printf("Failed to set MCType to %s\n",mcTypes.at(iJetDef).Data());
1831 exit(5);
1832 }
1833 if (providers.back()->setProperty("ConfigFile",configs.at(iJetDef).Data()).isFailure())
1834 {
1835 printf("Failed to set ConfigFile to %s\n",configs.at(iJetDef).Data());
1836 exit(6);
1837 }
1838 if (providers.back()->setProperty("IsData",optHelper.GetIsData()).isFailure())
1839 {
1840 printf("Failed to set IsData to %s\n",optHelper.GetIsData() ? "true" : "false");
1841 exit(7);
1842 }
1843
1844 // Check if we want to change topology from unknown to dijet
1845 const TString analysisFile = optHelper.GetCompositionPath();
1846
1847 if (analysisFile) {
1848
1849 if (providers.back()->setProperty("AnalysisFile",analysisFile.Data()).isFailure())
1850 {
1851 printf("Failed to set AnalysisFile to %s\n",analysisFile.Data());
1852 exit(7);
1853 }
1854 }
1855
1856
1857 // Check if we want to set the CalibArea
1858 if (optHelper.GetCalibArea() != "")
1859 {
1860 if (providers.back()->setProperty("CalibArea",optHelper.GetCalibArea().Data()).isFailure())
1861 {
1862 printf("Failed to set CalibArea to %s\n",optHelper.GetCalibArea().Data());
1863 exit(7);
1864 }
1865 }
1866
1867 // Check if we want to set the Path
1868 if (optHelper.GetPath() != "")
1869 {
1870 if (providers.back()->setProperty("Path",optHelper.GetPath().Data()).isFailure())
1871 {
1872 printf("Failed to set Path to %s\n",optHelper.GetPath().Data());
1873 exit(7);
1874 }
1875 }
1876
1877
1878 // Set filters if specified
1879 if (optHelper.VariablesToShift().size())
1880 {
1881 if (providers.back()->setProperty("VariablesToShift",optHelper.VariablesToShift()).isFailure())
1882 {
1883 printf("Failed to set VariablesToShift\n");
1884 exit(8);
1885 }
1886 }
1887
1888 // Done setting properties, initialize the tool
1889 if (providers.back()->initialize().isFailure())
1890 {
1891 printf("Failed to initialize tool for config: %s\n",configs.at(iJetDef).Data());
1892 exit(9);
1893 }
1894 }
1895
1896 // Make the plots
1897 MakeUncertaintyPlots(outFile,canvas,providers,compSetComponents,labelNames,doComparison,doCompareOnly);
1898
1899 // Clean up
1900 for (size_t iProv = 0; iProv < providers.size(); ++iProv)
1901 delete providers.at(iProv);
1902 providers.clear();
1903 }
1904
1905 // Ensure we don't have debugging enabled
1906 if (optHelper.GetDumpFile() == "")
1907 {
1908 // If this is not an eps, end the output
1909 if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png"))
1910 canvas->Print(outFile+"]");
1911 }
1912
1913 return 0;
1914}
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)
outFile
Comment Out Those You do not wish to run.

◆ MakeUncertaintyPlots() [1/2]

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 )

Definition at line 938 of file MakeUncertaintyPlots.cxx.

939{
940 static const SG::AuxElement::Accessor<int> Nsegments("GhostMuonSegmentCount");
941 static const SG::AuxElement::Accessor<char> IsBjet("IsBjet");
942 static const SG::AuxElement::Accessor<float> minDR("MinDR");
943 static const SG::AuxElement::Accessor<int> NJets("Njet");
944
945 // Combined mass helpers
948 static const SG::AuxElement::Accessor<float> scaleTAMoment("JetTrackAssistedMassCalibrated");
953
954 // Make TGraphs per provider per component
955 // Also make total TGraph and TH1D per provider
956 std::vector<TH1D*> totalHists;
957 std::vector<TGraphErrors*> totalGraphs;
958 std::vector< std::vector<TGraphErrors*> > compGraphs;
959
960 // Build a jet container and a jet for us to manipulate later
964 jets->setStore(new xAOD::JetAuxContainer());
965 jets->push_back(new xAOD::Jet());
966 xAOD::Jet* jet = jets->at(0);
967
968 // Add Nsegments information
969 // 25 segments is about average for jets receiving a correction
970 // This is modulated by the probability of punchthrough
971 Nsegments(*jet) = optHelper.IgnorePT()?0:25;
972 IsBjet(*jet) = false;
973 minDR(*jet) = 1;
974
975 // Build an EventInfo object for us to manipulate later
977 eInfos->setStore(new xAOD::EventInfoAuxContainer());
978 eInfos->push_back(new xAOD::EventInfo());
979 xAOD::EventInfo* eInfo = eInfos->at(0);
980 if (optHelper.GetNjetFlavour() != -1) NJets(*eInfo) = optHelper.GetNjetFlavour();
981
982 size_t indexHelper = 0;
983
984 // Get the provider
985 for (size_t iProv = 0; iProv < providers.size(); ++iProv)
986 {
987 const JetUncertaintiesTool* provider = providers.at(iProv);
988
989 // Set the pileup values for the year (so long as this isn't the special jet-dependent case)
990 if (!optHelper.IsEtaDepPileup())
991 setPileupShiftsForYear(provider,eInfo);
992 // Now catch the special case, where we want to set with respect to the central region for all jets
993 // (specifically early 2015 data where eta-intercalibration done with mu=0 data for forward region)
994 else
995 {
996 jet->setJetP4(xAOD::JetFourMom_t(100.e3,0.,0.,0.));
997 setPileupShiftsForYear(provider,eInfo,jet);
998 }
999
1000 // Fix the jet flavour if relevant
1001 if (optHelper.FixedTruthLabel())
1002 {
1003 jet->setAttribute("PartonTruthLabelID",optHelper.FixedTruthLabel());
1004 std::cout << "Fixed PartonTruthLabelID to " << optHelper.FixedTruthLabel() << std::endl;
1005 }
1006
1007 // Fix the large-R jet truth label if relevant
1008 if (optHelper.FixedLargeRJetTruthLabel() != LargeRJetTruthLabel::UNKNOWN)
1009 {
1010 jet->setAttribute(optHelper.TruthLabelMoment().Data(),LargeRJetTruthLabel::enumToInt(optHelper.FixedLargeRJetTruthLabel()));
1011 std::cout << "Fixed LargeRJetTruthLabel" << std::endl;
1012 }
1013 // Fix the Large-R jet tag accept if relevant
1014 // TODO: enable when available
1015 // if (optHelper.FixedLargeRJetTagAccept() != TagResult::UNKNOWN)
1016 // {
1017 // if (optHelper.FixedLargeRJetTagResultName() == "")
1018 // {
1019 // std::cout << "Unable to determine largeR jet tag result name, exiting for safety" << std::endl;
1020 // exit(1);
1021 // }
1022 // jet->setAttribute(optHelper.FixedLargeRJetTagResultName().Data(),optHelper.FixedLargeRJetTagAccept());
1023 // std::cout << "Fixed tag result to " << optHelper.FixedLargeRJetTagAccept() << " for name " << optHelper.FixedLargeRJetTagResultName().Data() << std::endl;
1024 // }
1025
1026 // One totalHist per provider
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);
1031
1032 // One totalGraph per provider
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);
1039
1040 // One list of all indices per provider
1041 const std::vector<int> allIndices = getComponentIndicesFromName(provider,"total");
1042
1043 // Find the punch-through index, if applicable
1044 int PTindex = static_cast<int>(allIndices.size());
1045 for (size_t iComp = 0; iComp < provider->getNumComponents(); ++iComp)
1046 if (TString(provider->getComponentName(iComp).c_str()).Contains("PunchThrough",TString::kIgnoreCase))
1047 {
1048 PTindex = iComp;
1049 break;
1050 }
1051
1052 // One vector of comp graphs per provider
1053 std::vector<TGraphErrors*> provCompGraphs;
1054
1055 // Now get the components
1056 for (size_t iComp = 0; iComp < compSetIndices.at(iProv).size(); ++iComp)
1057 {
1058 // One graph per component per provider
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);
1066 if (optHelper.IsPublicFormat() && !optHelper.IsLargeR())
1067 applyPublicFormat(*compGraph);
1068 indexHelper++;
1069 }
1070
1071 // Now run over the scan grid
1072 for (int iScan = 1; iScan < frame->GetNbinsX()+2; ++iScan)
1073 {
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);
1075
1076 // Build the jet to work with
1077 const double pt = (fixedIsEta ? binValue : fixedValue)*1.e3;
1078 const double eta = (fixedIsEta ? fixedValue : binValue);
1079 const double mass = mOverPtIsMass ? mOverPt*1.e3 : mOverPt*pt;
1080 jet->setJetP4(xAOD::JetFourMom_t(pt,eta,0,mass));
1081
1082 // Combined mass helpers
1083 scaleCalo.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1084 scaleTA.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1085 scaleCombQCD.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1086 scaleCombWZ.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1087 scaleCombHbb.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1088 scaleCombTop.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1089 scaleTAMoment(*jet) = mass ;
1090
1091
1092 // Kinematic cut when comparing large-R pre-recs
1093 bool isZero = false;
1094 if (optHelper.DoCompare() && TString(provider->getRelease().c_str()).Contains("2015_Prerec_"))
1095 if (pt > 1.5e6) isZero = true;
1096
1097
1098 // Fix the TagScaleFactor to start at 1 to start with for scale factor uncertainties
1099 std::vector<jet::CompScaleVar::TypeEnum> scaleVars = optHelper.GetScaleVars();
1100 if (optHelper.TagScaleFactorName() != "")
1101 {
1102 jet->setAttribute(optHelper.TagScaleFactorName().Data(),1.0);
1103 //std::cout << "Set " << optHelper.TagScaleFactorName().Data() << " to 1.0" << std::endl;
1104 }
1105
1106 // Fill components
1107 for (size_t iComp = 0; iComp < compSetIndices.at(iProv).size(); ++iComp)
1108 {
1109
1110 // Get the uncertainty for the component, quad-sum of sub-components if applicable
1111 TGraphErrors* compGraph = provCompGraphs.at(iComp);
1112 const double compUnc = !isZero ? getQuadratureSumUncertainty(provider,compSetIndices.at(iProv).at(iComp),*jet,*eInfo,PTindex) : 0;
1113 compGraph->SetPoint(iScan-1,binValue,compUnc);
1114 }
1115
1116 // Fill the total uncertainty graph
1117 const double totalUnc = !isZero ? getQuadratureSumUncertainty(provider,allIndices,*jet,*eInfo,PTindex) : 0;
1118 totalGraph->SetPoint(iScan-1,binValue,totalUnc);
1119
1120 }
1121
1122 // Add the vector of comp graphs to the total vector
1123 compGraphs.push_back(provCompGraphs);
1124
1125 // Now build the total uncertainty histo (bin centers instead of edges)
1126 for (int iScan = 1; iScan < frame->GetNbinsX()+1; ++iScan)
1127 {
1128 const double binValue = frame->GetBinCenter(iScan);
1129
1130 // Build the jet to work with
1131 const double pt = (fixedIsEta ? binValue : fixedValue)*1.e3;
1132 const double eta = (fixedIsEta ? fixedValue : binValue);
1133 const double mass = mOverPtIsMass ? mOverPt*1.e3 : mOverPt*pt;
1134 jet->setJetP4(xAOD::JetFourMom_t(pt,eta,0,mass));
1135
1136 // Combined mass helpers
1137 scaleCalo.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1138 scaleTA.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1139 scaleCombQCD.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1140 scaleCombWZ.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1141 scaleCombHbb.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1142 scaleCombTop.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass));
1143 scaleTAMoment(*jet) = mass ;
1144
1145 // Kinematic cut when comparing large-R pre-recs
1146 bool isZero = false;
1147 if (optHelper.DoCompare() && TString(provider->getRelease().c_str()).Contains("2015_Prerec_"))
1148 if (pt > 1.5e6) isZero = true;
1149
1150 totalHist->SetBinContent(iScan,!isZero ? getQuadratureSumUncertainty(provider,allIndices,*jet,*eInfo,PTindex) : 0);
1151 }
1152 }
1153
1154 // Clean up the jet and EventInfo
1155 //delete eInfo;
1156 //eInfos->clear();
1157 delete eInfos;
1158 //delete jet;
1159 //jets->clear();
1160 delete jets;
1161
1162 // Convert total graph to finer binning if this is an eta scan
1163 if (!fixedIsEta)
1164 {
1165 for (size_t iProv = 0; iProv < providers.size(); ++iProv)
1166 {
1167 TH1D* totalHist = totalHists.at(iProv);
1168
1169 std::vector<double> rebinnedBins = jet::utils::getUniformBins(720,-4.5,4.5);
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;
1177 }
1178 }
1179
1180 // Make the plot
1181 canvas->cd();
1182 canvas->Clear();
1183 if (fixedIsEta && optHelper.LogPt()) canvas->SetLogx(true);
1184 else canvas->SetLogx(false);
1185 frame->Draw("");
1186
1187 std::pair<double,double> xrange = optHelper.xAxisRange();
1188 if ((xrange.first > 0 or xrange.second > 0) and (xrange.first < xrange.second ) )
1189 {
1190 frame->GetXaxis()->SetRangeUser(xrange.first,xrange.second);
1191 }
1192 else if (optHelper.IsLargeR()) frame->GetXaxis()->SetRangeUser(200,3.e3);
1193 else if (fixedIsEta) frame->GetXaxis()->SetRangeUser(17,3.0e3);
1194 else frame->GetXaxis()->SetRangeUser(-4.5,4.5);
1195
1196 if (optHelper.IsLargeR())
1197 {
1198 maxYuser = optHelper.AxisMax();
1199 frame->GetYaxis()->SetRangeUser(0,maxYuser);
1200 }
1201 else
1202 {
1203 maxYuser = optHelper.AxisMax();
1204 frame->GetYaxis()->SetRangeUser(optHelper.AxisMin(),maxYuser);
1205 }
1206
1207 // If we want a comparison, that config was stored as last
1208 // item in the providers. Pop it off and store it.
1209 TH1D* comparisonHist = 0;
1210 TGraphErrors * comparisonGraph = 0;
1211 if (doComparison) {
1212 comparisonHist = totalHists.at(providers.size()-1);
1213 totalHists.pop_back();
1214 comparisonGraph = totalGraphs.at(providers.size()-1);
1215 totalGraphs.pop_back();
1216 }
1217 // Changed to have consistent style between plots (Steven, 11/02/2016)
1218 //TH1D * backHist = 0; TH1D * frontHist = 0;
1219 //TGraphErrors * backGraph = 0; TGraphErrors * frontGraph = 0;
1220
1221 if (doCompareOnly) {
1222 for (size_t index=0; index < providers.size(); index++) {
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"); // was c
1230 }
1231 } else if (providers.size() == 1 && optHelper.DrawTotal())
1232 totalHists.at(0)->Draw("histF same");
1233 else if ((providers.size() == 2) && doComparison) {
1234 //if (comparisonHist->GetMaximum() > totalHists.at(0)->GetMaximum()) {
1235 // backHist = comparisonHist;
1236 // frontHist = totalHists.at(0);
1237 // backGraph = comparisonGraph;
1238 // frontGraph = totalGraphs.at(0);
1239 //} else {
1240 // backHist = totalHists.at(0);
1241 // frontHist = comparisonHist;
1242 // backGraph = totalGraphs.at(0);
1243 // frontGraph = comparisonGraph;
1244 //}
1245 // Changed to have consistent style between plots (Steven, 11/02/2016)
1246 if (optHelper.IsTLA())
1247 {
1248 //comparisonHist->SetFillStyle(3345);
1249 comparisonGraph->SetLineWidth(6);
1250 }
1251
1252 if (optHelper.IsTLA())
1253 {
1254 comparisonHist->SetLineColor(kGreen+3);
1255 comparisonHist->SetFillColor(kTeal+5);
1256 }
1257 else
1258 {
1259 comparisonHist->SetLineColor(kTeal+5); //backHist->SetLineColor(kTeal+5);
1260 comparisonHist->SetFillColor(kTeal-9); //backHist->SetFillColor(kTeal-9);
1261 }
1262
1263 comparisonHist->Draw("histF same"); //backHist->Draw("histF same");
1264 totalHists.at(0)->Draw("histF same"); //frontHist->Draw("histF same");
1265
1266 }
1267
1268 if (!doCompareOnly) {
1269 for (size_t iProv = 0; iProv < providers.size(); ++iProv)
1270 {
1271 if (doComparison) {
1272 if (iProv == providers.size()-1) continue;
1273 // Changed to have consistent style between plots (Steven, 11/02/2016)
1274 comparisonGraph->SetLineColor(comparisonHist->GetLineColor()); //backGraph->SetLineColor(kTeal+5);
1275 comparisonGraph->Draw("l same"); //backGraph->Draw("c same"); // was c
1276 totalGraphs.at(0)->Draw("l same"); //frontGraph->Draw("c same"); // was c
1277 } else if (optHelper.DrawTotal()) totalGraphs.at(iProv)->Draw("l same"); // was c
1278 for (size_t iComp = 0; iComp < compGraphs.at(iProv).size(); ++iComp)
1279 compGraphs.at(iProv).at(iComp)->Draw("l same");
1280 }
1281 }
1282
1283 // Add labels
1284 if (optHelper.DoATLASLabel()) DrawAtlasLabel();
1285
1286 bool sign = true;
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;
1290 }
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;
1296 if (optHelper.IsLargeR())
1297 {
1298 DrawJetLabel(providers.at(0),0.83);
1299 if (providers.size() == 1 || (providers.size()==2 && doComparison) || sign || sameRelease)
1300 DrawYearLabel(providers.at(0),0.92);
1301 //DrawText(Form("|#eta| = %.1f, M/#it{p}_{T}^{jet} = %.2f%s",fixedValue,mOverPt,optHelper.SpecifyTagger()?Form(", %s tagged",getTagType(providers.at(0)).Data()):""),kBlack,0.75);
1302 if (mOverPtIsMass)
1303 DrawText(Form("|#eta_{jet}| < 2, m = %.0f GeV%s",mOverPt,optHelper.SpecifyTagger()?Form(", %s tagged",getTagType(providers.at(0)).Data()):""),kBlack,0.73);
1304 else
1305 DrawText(Form("|#eta_{jet}| < 2, m_{jet}/#it{p}_{T}^{jet} = %.2f%s",mOverPt,optHelper.SpecifyTagger()?Form(", %s tagged",getTagType(providers.at(0)).Data()):""),kBlack,0.73);
1306 }
1307 else
1308 {
1309/* DrawJetLabel(providers.at(0),0.905);
1310 if (providers.size() == 1 || (providers.size()==2 && doComparison))
1311 DrawYearLabel(providers.at(0),0.860);
1312 DrawText(fixedIsEta?Form("#eta = %.1f",fixedValue):Form("#it{p}_{T}^{jet} = %.0f GeV",fixedValue),kBlack,0.815);
1313 DrawScenarioLabel(providers.at(0),0.77); */
1314
1315
1316 DrawJetLabel(providers.at(0),0.855);//0.905);
1317 if (providers.size() == 1 || (providers.size()==2 && doComparison) || sign || sameRelease)
1318 DrawYearLabel(providers.at(0),0.910);//0.860);
1319 if (mOverPtIsMass)
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);
1321 else if (optHelper.GetFixedMoverPtVals().size() > 1)
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);
1323 else
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);
1325 DrawScenarioLabel(providers.at(0),0.76); // 0.77
1326
1327 }
1328
1329 // Add legend
1330 double legx=0.41, legy=0.78, dy = 0.045; //dy=0.070;
1331 if (optHelper.IsLargeR())
1332 legy = 0.68;
1333 else if (TString(providers.at(0)->getJetDef().c_str()).Contains("Trimmed"))
1334 legy = 0.73;
1335
1336 if (doCompareOnly) {
1337 for (size_t i=0; i < totalGraphs.size(); i++) {
1338 const TString title = labelNames.at(i).at(0);
1339 DrawLineLabel(title,legx,legy-=dy,totalHists.at(i));
1340 }
1341 }
1342 if ((providers.size() == 1 || (providers.size() == 2 && doComparison)) && optHelper.DrawTotal()) {
1343 if (fixedIsEta) DrawFillLabel(optHelper.TotalUncName(),legx,legy,totalHists.at(0));
1344 else DrawFillLabel(optHelper.TotalUncName(),legx,legy,totalHists.at(0),false);
1345 }
1346 if (doComparison) {
1347 const TString title = labelNames.at(providers.size()-1).at(0);
1348 if (optHelper.IsTLA())
1349 DrawLineLabel(title,legx,legy-=dy,comparisonGraph);
1350 else
1351 {
1352 if (fixedIsEta) DrawFillLabel(title,legx,legy-=dy,comparisonHist);
1353 else DrawFillLabel(title,legx,legy-=dy,comparisonHist, false);
1354 }
1355 }
1356 for (size_t iProv = 0; iProv < providers.size(); ++iProv)
1357 for (size_t iComp = 0; iComp < compGraphs.at(iProv).size(); ++iComp)
1358 {
1359 const TGraphErrors* compGraph = compGraphs.at(iProv).at(iComp);
1360 const TString label = compGraph->GetName(); //labelNames.at(iProv).at(iComp);
1361 if (label.Contains("#splitline"))
1362 {
1363 legy -= 0.35*dy;
1364 DrawLineLabel(label,legx,legy-=dy,compGraph);
1365 legy -= 0.35*dy;
1366 }
1367 else if (optHelper.IsLargeR() && !optHelper.IsPublicFormat())
1368 DrawLineLabel(label,legx-0.125+0.3*(iComp%2),legy-=(dy*((iComp+1)%2)),compGraph);
1369 else if (optHelper.IsLargeR())
1370 DrawLineLabel(label,legx,legy-=(dy+0.005),compGraph);
1371 else if (optHelper.TwoColumnLegend())
1372 DrawLineLabel(label,legx-0.125+0.3*(iComp%2),legy-=(dy*((iComp+1)%2)),compGraph);
1373 else
1374 DrawLineLabel(label,legx,legy-=dy,compGraph);
1375 }
1376
1377 // Write the plot
1378 frame->Draw("axis same");
1379
1380 // Ensure we don't have debugging enabled
1381 if (optHelper.GetDumpFile() == "")
1382 {
1383 if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png"))
1384 canvas->Print(outFile);
1385 else
1386 canvas->Print(TString(outFile).ReplaceAll(outFile.EndsWith(".eps")?".eps":".png",Form("/fig_%s_%s.%s",fixedIsEta?"eta":"pt",fixedIsEta?Form("%.1f",fixedValue):Form("%.0f",fixedValue),outFile.EndsWith(".eps")?"eps":"png")));
1387 }
1388 else
1389 {
1390 // Debug mode, just write out the graphs
1391 printf("Preparing to dump to file: %s\n",optHelper.GetDumpFile().Data());
1392 TFile* dumpFile = TFile::Open(optHelper.GetDumpFile(),"NEW");
1393 dumpFile->cd();
1394 for (size_t iSet = 0; iSet < compGraphs.size(); ++iSet)
1395 {
1396 for (size_t iComp = 0 ; iComp < compGraphs.at(iSet).size(); ++iComp)
1397 {
1398 compGraphs.at(iSet).at(iComp)->Write();
1399 }
1400 }
1401 dumpFile->Close();
1402 }
1403
1404 // Free graphs/hists
1405 for (size_t iProv = 0; iProv < providers.size(); ++iProv)
1406 {
1407 if (doComparison && iProv == providers.size()-1) continue;
1408 else {
1409 delete totalHists.at(iProv);
1410 delete totalGraphs.at(iProv);
1411 }
1412 for (size_t iComp = 0; iComp < compGraphs.at(iProv).size(); ++iComp)
1413 delete compGraphs.at(iProv).at(iComp);
1414 }
1415 delete comparisonHist;
1416 delete comparisonGraph;
1417
1418}
Scalar eta() const
pseudorapidity method
@ Data
Definition BaseObject.h:11
void DrawJetLabel(const JetUncertaintiesTool *provider, const double yPos)
void DrawYearLabel(const JetUncertaintiesTool *provider, const double yPos)
double getQuadratureSumUncertainty(const JetUncertaintiesTool *provider, const std::vector< int > &compIndices, const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const int PTindex)
void applyPublicFormat(TGraph &graph)
void DrawFillLabel(TString txt, double x, double y, TH1 *h, bool logX=optHelper.LogPt(), bool logY=false)
void setPileupShiftsForYear(const JetUncertaintiesTool *provider, xAOD::EventInfo *eInfo, const xAOD::Jet *jet=NULL)
TString getTagType(const JetUncertaintiesTool *provider)
void DrawAtlasLabel(const TString &label=optHelper.GetATLASLabel(), const bool right=true)
void DrawScenarioLabel(const JetUncertaintiesTool *provider, const double yPos)
int sign(int a)
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.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
JetFourMomAccessor is an extension of JetAttributeAccessor::AccessorWrapper<xAOD::JetFourMom_t> Acces...
Tool for accessing xAOD files outside of Athena.
A relatively simple transient store for objects created in analysis.
Definition TStore.h:45
void xrange(TH1 *h, bool symmetric)
int enumToInt(const TypeEnum type)
TestStore store
Definition TestStore.cxx:23
TString getJetScaleString(const TypeEnum type)
std::vector< double > getUniformBins(const size_t numBins, const double minVal, const double maxVal)
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".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17

◆ MakeUncertaintyPlots() [2/2]

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 )

Definition at line 1420 of file MakeUncertaintyPlots.cxx.

1421{
1422 // Central values for scans
1423 const std::vector<double> ptValuesForEtaScan = optHelper.GetFixedPtVals();
1424 const std::vector<double> etaValuesForPtScan = optHelper.GetFixedEtaVals();
1425 const std::vector<double> mOverPtValuesForPtScan = optHelper.GetFixedMoverPtVals();
1426 const std::vector<double> massValuesForPtScan = optHelper.GetFixedMassVals();
1427
1428 // Scan ranges: all recently moved to 10x the bins
1429 const std::vector<double> etaScanValues = optHelper.GetEtaBins();
1430 const std::vector<double> ptScanValues = optHelper.GetPtBins();
1431
1432 // Create the frames
1433 TH1D* frameEtaScan = new TH1D("frameEtaScan","",etaScanValues.size()-1,&etaScanValues[0]);
1434 TH1D* framePtScan = new TH1D("framePtScan","",ptScanValues.size()-1,&ptScanValues[0]);
1435
1436 TString yAxisVar = "";
1437 if (optHelper.GetScaleVars().size() == 1)
1438 {
1439 switch (optHelper.GetScaleVars().at(0))
1440 {
1442 yAxisVar = "E";
1443 break;
1446 yAxisVar = "#it{p}_{T}"; // JER is evaluated on pT
1447 break;
1451 yAxisVar = "#it{p}_{T}";
1452 break;
1456 yAxisVar = "M";
1457 break;
1459 yAxisVar = "D_{12}";
1460 break;
1462 yAxisVar = "D_{23}";
1463 break;
1465 yAxisVar = "#tau_{21}";
1466 break;
1468 yAxisVar = "#tau_{21}^{wta}";
1469 break;
1471 yAxisVar = "#tau_{32}";
1472 break;
1474 yAxisVar = "#tau_{32}^{wta}";
1475 break;
1477 yAxisVar = "D_{2}";
1478 break;
1480 yAxisVar = "C_{2}";
1481 break;
1483 yAxisVar = "Qw";
1484 break;
1485 default:
1486 yAxisVar = "?";
1487 }
1488 }
1489
1490 const TString yAxisLabel = optHelper.GetScaleVars().size() != 1 ? "Unknown" :
1491 jet::CompScaleVar::isScaleType(optHelper.GetScaleVars().at(0)) ?
1492 Form("Fractional J%sS uncertainty",yAxisVar.Data())
1493 : jet::CompScaleVar::isResolutionType(optHelper.GetScaleVars().at(0)) ?
1494 Form("Uncertainty on #sigma(%s)/%s",yAxisVar.Data(),yAxisVar.Data())
1495 : "Unknown scale type";
1496 frameEtaScan->GetXaxis()->SetTitleOffset(1.4);
1497 frameEtaScan->GetYaxis()->SetTitleOffset(optHelper.GetScaleVars().size() == 1 && jet::CompScaleVar::isScaleType(optHelper.GetScaleVars().at(0))?1.25:1.125);
1498 frameEtaScan->GetXaxis()->SetTitle("#eta");
1499 frameEtaScan->GetYaxis()->SetTitle(yAxisLabel.Data());
1500 framePtScan->GetXaxis()->SetTitleOffset(1.4);
1501 framePtScan->GetYaxis()->SetTitleOffset(optHelper.GetScaleVars().size() == 1 && jet::CompScaleVar::isScaleType(optHelper.GetScaleVars().at(0))?1.25:1.125);
1502 framePtScan->GetXaxis()->SetTitle("#it{p}_{T}^{jet} [GeV]");
1503 framePtScan->GetYaxis()->SetTitle(yAxisLabel.Data());
1504 framePtScan->GetXaxis()->SetMoreLogLabels();
1505
1506 // Fill frame histograms with -1 so line is drawn outside of frame
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);
1511
1512
1513 // Convert components to indices
1514 std::vector< std::vector< std::vector<int> > > compSetIndices;
1515 for (size_t iProv = 0; iProv < providers.size(); ++iProv)
1516 compSetIndices.push_back(getComponentIndicesFromNames(providers.at(iProv),compSetComponents.at(iProv)));
1517
1518 // Create a plot per fixed value
1519 if (!optHelper.IsLargeR())
1520 {
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())
1526 {
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);
1529 }
1530 if (mOverPtValuesForPtScan.size() > 1)
1531 {
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);
1534 }
1535 }
1536 else
1537 {
1538 if (massValuesForPtScan.size())
1539 {
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);
1542 }
1543 else
1544 {
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);
1547 }
1548 }
1549
1550
1551 delete framePtScan;
1552 delete frameEtaScan;
1553}
if(febId1==febId2)
std::vector< std::vector< int > > getComponentIndicesFromNames(const JetUncertaintiesTool *provider, const std::vector< TString > &compNames)
bool isScaleType(const TypeEnum type)
bool isResolutionType(const TypeEnum type)

◆ setPileupShiftsForYear()

void setPileupShiftsForYear ( const JetUncertaintiesTool * provider,
xAOD::EventInfo * eInfo,
const xAOD::Jet * jet = NULL )

Definition at line 657 of file MakeUncertaintyPlots.cxx.

658{
659
660 static const SG::AuxElement::Accessor<float> mu("averageInteractionsPerCrossing");
661 static const SG::AuxElement::Accessor<float> NPV("NPV");
662
663 float sigmaMu = 0;
664 float sigmaNPV = 0;
665
666 const TString release = provider->getRelease();
667 if (release.BeginsWith("2011_"))
668 {
669 // Dag, night of Febuary 4/5, 2013
670 sigmaMu = 3.0;
671 sigmaNPV = 3.0;
672 }
673 else if (release.BeginsWith("2012_") or release.BeginsWith("2015_Prerec"))
674 {
675 // Craig Sawyer, Jan 22 2013
676 sigmaMu = 5.593*1.11;
677 sigmaNPV = 3.672;
678 }
679 else if (release.BeginsWith("2015_Moriond") || release.BeginsWith("2015_ICHEP") || release.BeginsWith("2015_TLA"))
680 {
681 // Kate, Jan 31 2016
682 sigmaMu = 1.9;
683 sigmaNPV = 2.9;
684 }
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") )
686 {
687 // Kate, Nov 2016
688 // via Eric Corrigan's pileup studies
689 // Scaling term taken from
690 // https://indico.cern.ch/event/437993/contributions/1925644/attachments/1138739/1630981/spagan_MuRescaling.pdf
691 sigmaMu = 5.35;
692 sigmaNPV = 3.49;
693 }
694 else
695 {
696 printf("Unexpected year for setPileupShiftsForYear in release: %s\n",release.Data());
697 exit(-1);
698 }
699
700 mu(*eInfo) = (jet?provider->getRefMu(*jet):provider->getRefMu())+sigmaMu;
701 NPV(*eInfo) = (jet?provider->getRefNPV(*jet):provider->getRefNPV())+sigmaNPV;
702}
virtual float getRefNPV() const
virtual float getRefMu() const

Variable Documentation

◆ debug

const bool debug = true

Definition at line 53 of file MakeUncertaintyPlots.cxx.

◆ maxYuser

float maxYuser = -1.

Definition at line 49 of file MakeUncertaintyPlots.cxx.

◆ myTBox

TBox* myTBox = new TBox()
static

Definition at line 47 of file MakeUncertaintyPlots.cxx.

◆ optHelper

jet::OptionHelper optHelper

Definition at line 52 of file MakeUncertaintyPlots.cxx.