ATLAS Offline Software
Functions | Variables
MakeCorrelationMatrixPlots.cxx File Reference
#include "JetUncertainties/JetUncertaintiesTool.h"
#include "JetUncertainties/Helpers.h"
#include "../testingMacros/atlasstyle/AtlasStyle.C"
#include "../testingMacros/atlasstyle/AtlasLabels.C"
#include "TString.h"
#include "TCanvas.h"
#include "TH2D.h"
#include "TFile.h"
#include <vector>
#include "CxxUtils/checker_macros.h"

Go to the source code of this file.

Functions

double relativeMetric (const double numerator, const double denominator)
 
void DrawLabels (const TH2D *histo, const double fixedValue1, const double fixedValue2, const JetUncertaintiesTool *uncTool, const JetUncertaintiesTool *uncToolDiff=nullptr, const double mean=0, const double extremum=0, const int extremeX=-1, const int extremeY=-1)
 
void FormatHisto (TH2D *histo)
 
void PlotCorrelationHistos (const TString &outFile, TCanvas *canvas, TFile *outHistFile, const std::vector< JetUncertaintiesTool * > &providers, const std::vector< TH2D * > &corrMats, const double fixedValue1, const double fixedValue2)
 
void MakeCorrelationPlots (const TString &outFile, TCanvas *canvas, TFile *outHistFile, const std::vector< JetUncertaintiesTool * > &providers, const std::vector< std::pair< double, double > > &fixedEta, const std::vector< std::pair< double, double > > &fixedPt)
 
int main ATLAS_NOT_THREAD_SAFE (int argc, char *argv[])
 

Variables

 ATLAS_NO_CHECK_FILE_THREAD_SAFETY
 
const double fixedRangeDiff = 0
 
const bool addExtremumInfo = true
 
const bool addScenarioInfo = false
 
const bool makeGrid = true
 
const bool minRepStyle = false
 
const bool testJER = false
 
bool useRelativeMetric = true
 
int iEPS = 0
 

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

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

Definition at line 327 of file MakeCorrelationMatrixPlots.cxx.

328 {
329  if (argc != 7 && argc != 8 && argc != 9)
330  {
331  printf("Expected arguments:\n");
332  printf("\t1. Output file (ps, pdf, eps)\n");
333  printf("\t2. Jet definition(s), semicolon delimited\n");
334  printf("\t3. MC type\n");
335  printf("\t4. Config file(s), semicolon delimited\n");
336  printf("\t\tDifferences will be performed by left minus right\n");
337  printf("\t\tExample: A;B;C --> A,B,C,A-B,B-C\n");
338  printf("\t5. Fixed eta values to consider for pT correlations, semicolon delimited\n");
339  printf("\t Note: Comma-delimited pairs if specifying both eta1 and eta2\n");
340  printf("\t6. Fixed pT values to consider for eta correlations, semicolon delimited\n");
341  printf("\t Note: Comma-delimited pairs if specifying both pt1 and pt2\n");
342  printf("\t Note: Expected units are GeV, not MeV\n");
343  printf("\t7. Output histogram root file (OPTIONAL)\n");
344  printf("\t8. Whether to switch to relative differences (OPTIONAL, default \"false\")\n");
345  return 1;
346  }
347  TFile* outHistFile = nullptr;
348  TString outFile = argv[1];
349  std::vector<TString> jetDefs = jet::utils::vectorize<TString>(argv[2],";");
350  TString mcType = argv[3];
351  std::vector<TString> configs = jet::utils::vectorize<TString>(argv[4],";");
352  std::vector<TString> fixedEtaS = jet::utils::vectorize<TString>(argv[5],";");
353  std::vector<TString> fixedPtS = jet::utils::vectorize<TString>(argv[6],";");
354  if (argc > 7)
355  outHistFile = TFile::Open(argv[7],"RECREATE");
356  if (argc > 8)
358 
359 #ifdef XAOD_STANDALONE
360  StatusCode::enableFailure();
361 #endif // XAOD_STANDALONE
362 
363  if (configs.empty())
364  {
365  printf("Failed to find any configs: %s\n",argv[4]);
366  return 2;
367  }
368 
369  // Ensure we have to do something
370  if (fixedEtaS.empty() && fixedPtS.empty())
371  {
372  printf("No fixed pT or eta values were specified, nothing to do.\n");
373  return 2;
374  }
375 
376  // Convert fixed value singlets or pairs to pairs
377  std::vector< std::pair<double,double> > fixedEta;
378  std::vector< std::pair<double,double> > fixedPt;
379  if (makeGrid)
380  {
381  for (size_t iEta1 = 0; iEta1 < fixedEtaS.size(); ++iEta1)
382  for (size_t iEta2 = 0; iEta2 < fixedEtaS.size(); ++iEta2)
383  fixedEta.emplace_back(jet::utils::getTypeObjFromString<double>(fixedEtaS.at(iEta1)),jet::utils::getTypeObjFromString<double>(fixedEtaS.at(iEta2)));
384  }
385  else
386  {
387  for (size_t iEta = 0; iEta < fixedEtaS.size(); ++iEta)
388  {
389  std::vector<double> temp = jet::utils::vectorize<double>(fixedEtaS.at(iEta),",");
390  if (temp.size() == 1 && !makeGrid)
391  fixedEta.emplace_back(temp.at(0),temp.at(0));
392  else if (temp.size() == 2)
393  fixedEta.emplace_back(temp.at(0),temp.at(1));
394  else
395  {
396  printf("Specified a fixed eta term which is not 1 or 2 values: %s\n",fixedEtaS.at(iEta).Data());
397  printf("Unsure of how to interpret this term, exiting.\n");
398  return 3;
399  }
400  }
401  }
402 
403  if (makeGrid)
404  {
405  for (size_t iPt1 = 0; iPt1 < fixedPtS.size(); ++iPt1)
406  for (size_t iPt2 = 0; iPt2 < fixedPtS.size(); ++iPt2)
407  fixedPt.emplace_back(jet::utils::getTypeObjFromString<double>(fixedPtS.at(iPt1)),jet::utils::getTypeObjFromString<double>(fixedPtS.at(iPt2)));
408  }
409  else
410  {
411  for (size_t iPt = 0; iPt < fixedPtS.size(); ++iPt)
412  {
413  std::vector<double> temp = jet::utils::vectorize<double>(fixedPtS.at(iPt),",");
414  if (temp.size() == 1)
415  fixedPt.emplace_back(temp.at(0),temp.at(0));
416  else if (temp.size() == 2)
417  fixedPt.emplace_back(temp.at(0),temp.at(1));
418  else
419  {
420  printf("Specified a fixed pt term which is not 1 or 2 values: %s\n",fixedPtS.at(iPt).Data());
421  printf("Unsure of how to interpret this term, exiting.\n");
422  return 4;
423  }
424  }
425  }
426 
427  // Create the canvas
428  SetAtlasStyle();
429  gStyle->SetPalette(1);
430  TCanvas* canvas = new TCanvas("canvas");
431  canvas->SetMargin(0.12,0.15,minRepStyle?0.13:0.135,minRepStyle?0.18:0.115);
432  canvas->SetFillStyle(4000);
433  canvas->SetFillColor(0);
434  canvas->SetFrameBorderMode(0);
435  canvas->cd();
436 
437  // If this is not an eps, start the output
438  if (outFile != "NONE" && !outFile.EndsWith(".eps"))
439  canvas->Print(outFile+"[");
440 
441 
442  // Run once per jet type
443  for (size_t iJetDef = 0; iJetDef < jetDefs.size(); ++iJetDef)
444  {
445  const TString jetDef = jetDefs.at(iJetDef);
446 
447  // Create the providers
448  std::vector<JetUncertaintiesTool*> providers;
449  printf("Processing %zu config(s)...\n",configs.size());
450  for (size_t iConfig = 0; iConfig < configs.size(); ++iConfig)
451  {
452  // Make a new provider
453  providers.push_back(new JetUncertaintiesTool(Form("%s_%zu",jetDef.Data(),iConfig)));
454 
455  //Set properties
456  if (providers.back()->setProperty("JetDefinition",jetDef.Data()).isFailure())
457  {
458  printf("Failed to set JetDefinition to %s\n",jetDef.Data());
459  return 5;
460  }
461  if (providers.back()->setProperty("MCType",mcType.Data()).isFailure())
462  {
463  printf("Failed to set MCType to %s\n",mcType.Data());
464  return 6;
465  }
466  if (providers.back()->setProperty("ConfigFile",configs.at(iConfig).Data()).isFailure())
467  {
468  printf("Failed to set ConfigFile to %s\n",configs.at(iConfig).Data());
469  return 7;
470  }
471 
473  //if (IsDijet())
474  //{
475  // const TString dijetAnalysisFile = "../testingMacros/random_stuff/MJESForInclusiveJets_MC11b.root";
476  // if (providers.back()->setProperty("AnalysisFile",dijetAnalysisFile.Data()).isFailure())
477  // {
478  // printf("Failed to set AnalysisFile to %s\n",dijetAnalysisFile.Data());
479  // exit(7);
480  // }
481  //}
482 
483  // Set to use GeV
484  if (providers.back()->setScaleToGeV().isFailure())
485  {
486  printf("Failed to set tool scale to GeV for config: %s\n",configs.at(iConfig).Data());
487  return 8;
488  }
489 
490  // Done setting properties, initialize the tool
491  if (providers.back()->initialize().isFailure())
492  {
493  printf("Failed to initialize tool for config: %s\n",configs.at(iConfig).Data());
494  return 9;
495  }
496  }
497 
498  // Make the plots
499  MakeCorrelationPlots(outFile,canvas,outHistFile,providers,fixedEta,fixedPt);
500 
501  // Clean up
502  for (size_t iProv = 0; iProv < providers.size(); ++iProv)
503  delete providers.at(iProv);
504  providers.clear();
505  }
506 
507  // If this is not an eps, end the output
508  if (outFile != "NONE" && !outFile.EndsWith(".eps"))
509  canvas->Print(outFile+"]");
510 
511  // If an output histogram file exists, close it
512  if (outHistFile)
513  {
514  outHistFile->Close();
515  outHistFile = nullptr;
516  }
517 
518  return 0;
519 }

◆ DrawLabels()

void DrawLabels ( const TH2D *  histo,
const double  fixedValue1,
const double  fixedValue2,
const JetUncertaintiesTool uncTool,
const JetUncertaintiesTool uncToolDiff = nullptr,
const double  mean = 0,
const double  extremum = 0,
const int  extremeX = -1,
const int  extremeY = -1 
)

Definition at line 45 of file MakeCorrelationMatrixPlots.cxx.

46 {
47  // Create the tex making object
48  static TLatex* tex = []()
49  {
50  tex = new TLatex();
51  tex->SetNDC();
52  tex->SetTextSize(0.045);
53  tex->SetTextColor(kBlack);
54  return tex;
55  }();
56 
57  // Add the ATLAS label
58  ATLASLabel(0.13,minRepStyle?0.825:0.955,"",kBlack);
59 
60  // Determine the configuration type (data year, correlation scenario, reduction if applicable)
61  const TString config1 = uncTool->getConfigFile();
62  const TString config2 = uncToolDiff ? uncToolDiff->getConfigFile() : "";
63  const TString year = config1.Contains("_2011/") ? "2011"/*, #sqrt{s} = 7 TeV"*/ : config1.Contains("_2012/") ? "2012": config1.Contains("_2015/") ? "2015" : "UNKNOWN";
64  const TString jetDef = uncTool->getJetDef();
65  const TString scenario1 = config1.Contains("StrongerCorrelations") ? "stronger" : (config1.Contains("WeakerCorrelations") ? "weaker" : "nominal");
66  const TString scenario2 = config2.Contains("StrongerCorrelations") ? "stronger" : (config2.Contains("WeakerCorrelations") ? "weaker" : "nominal");
67  const TString scenarioDiff = Form("%s - %s correlation scenarios",scenario1.Data(),scenario2.Data());
68  const TString reduction1 = config1.Contains("_ByCategory") ? "category reduction" : (config1.Contains("NP") ? "global reduction" : "original");
69  const TString reduction2 = config2.Contains("_ByCategory") ? "category reduction" : (config2.Contains("NP") ? "global reduction" : "original");
70  const TString reductionDiff = Form("%s - %s",reduction1.Data(),reduction2.Data());
71 
72  TString configDescString;
73  if (uncToolDiff)
74  {
75  if (scenario1 == scenario2 && reduction1 == reduction2)
76  configDescString = "UNKNOWN COMPARISON TYPE";
77  else if (scenario1 == scenario2 && reduction1 != reduction2)
78  configDescString = Form("%s correlation scenario, %s",scenario1.Data(),reductionDiff.Data());
79  else if (scenario1 != scenario2 && reduction1 == reduction2)
80  configDescString = Form("%s%s",scenarioDiff.Data(),reduction1 == "original" ? "" : Form(", %s",reduction1.Data()));
81  else
82  configDescString = Form("%s, %s",scenarioDiff.Data(),reductionDiff.Data());
83  }
84  else
85  {
86  configDescString = Form("%s correlation scenario%s",scenario1.Data(),reduction1 == "original" ? "" : Form(", %s",reduction1.Data()));
87  }
88 
89 
90  // Add the configuration info
91  const TString fixedValString = TString(histo->GetXaxis()->GetTitle()).Contains("#it{p}") ? Form("(#eta^{jet1},#eta^{jet2}) = (%.1f,%.1f)",fixedValue1,fixedValue2) : Form("(#it{p}_{T}^{jet1},#it{p}_{T}^{jet2}) = (%ld,%ld) GeV",lround(fixedValue1),lround(fixedValue2));
92  //tex->DrawLatex(0.13,minRepStyle?0.95:0.91,Form("anti-k_{t} #it{R} = %s, %s+JES+GSC, Data %s, %s",jetDef.Contains("AntiKt4") ? "0.4" : jetDef.Contains("AntiKt6") ? "0.6" : "UNKNOWN", jetDef.Contains("EM") ? "EM" : jetDef.Contains("LC") ? "LCW" : "UNKNOWN", year.Data(),fixedValString.Data()));
93  if (minRepStyle)
94  {
95  const TString reductionString = "str.red"; //"evdm";
96  const TString selector = ""; //"#it{p}_{T}^{jet},";
97  const TString scenarioString = TString(histo->GetName()).BeginsWith("diff_")?Form("Correlation difference, Rep_{full}^{%sJES} - Rep_{%s}^{%sJES}, %s",selector.Data(),reductionString.Data(),selector.Data(),fixedValString.Data()):Form("Correlation matrix, Rep_{%s}^{%sJES}, %s",TString(histo->GetName()).Contains("_0_")?"full":reductionString.Data(),selector.Data(),fixedValString.Data());
98  tex->DrawLatex(0.13,0.8751,Form("anti-#it{k}_{t} #it{R} = %s, %s+JES %s",jetDef.Contains("AntiKt4") ? "0.4" : jetDef.Contains("AntiKt6") ? "0.6" : "UNKNOWN", jetDef.Contains("EM") ? "EM" : jetDef.Contains("LC") ? "LCW" : "UNKNOWN", year.Data()));
99  tex->DrawLatex(0.13,0.9305,scenarioString.Data());
100  }
101  else
102  {
103  tex->DrawLatex(0.48,0.960,Form("anti-#it{k}_{t} #it{R} = %s, %s+JES + #it{in situ}",jetDef.Contains("AntiKt4") ? "0.4" : jetDef.Contains("AntiKt6") ? "0.6" : "UNKNOWN", jetDef.Contains("EM") ? "EM" : jetDef.Contains("LC") ? "LCW" : "UNKNOWN"));
104  tex->DrawLatex(0.48,0.905,fixedValString.Data());
105  tex->DrawLatex(0.13,0.905,Form("Data %s, #sqrt{s} = %d TeV",year.Data(),year=="2012"?8:year=="2011"?7:year=="2015"||year=="2016"?13:0));
106  }
107 
108 
109  if (addScenarioInfo)
110  {
111  tex->DrawLatex(0.15,0.84,configDescString.Data());
112  tex->DrawLatex(0.15,0.79,TString(uncTool->getAnalysisFile().c_str()).Contains("Unknown") ? "unknown flavour composition" : TString(uncTool->getAnalysisFile().c_str()).Contains("InclusiveJets") ? "inclusive jets composition" : "Unexpected flavour composition file");
113  }
114 
115 
116  if (addExtremumInfo && extremeX > 0 && extremeY > 0)
117  {
118  if (TString(histo->GetXaxis()->GetTitle()).Contains("#it{p}"))
119  tex->DrawLatex(0.01,0.015,Form("Mean value %.2f, max %.2f at (%ld,%ld) GeV",round(100*mean)/100.,round(100*extremum)/100.,lround(histo->GetXaxis()->GetBinCenter(extremeX)),lround(histo->GetYaxis()->GetBinCenter(extremeY))));
120  else
121  tex->DrawLatex(0.01,0.015,Form("Mean value %.2f, max %.2f at (%.2f,%.2f)",round(100*mean)/100.,round(100*extremum)/100.,histo->GetXaxis()->GetBinCenter(extremeX),histo->GetYaxis()->GetBinCenter(extremeY)));
122  }
123 }

◆ FormatHisto()

void FormatHisto ( TH2D *  histo)

Definition at line 125 of file MakeCorrelationMatrixPlots.cxx.

126 {
127  histo->SetTitleSize(0.06,"z");
128  histo->SetLabelSize(0.04,"z");
129  histo->SetTitleOffset(1.225,"x");
130  histo->SetTitleOffset(1.05,"y");
131  histo->SetTitleOffset(0.76,"z");
132  histo->SetLabelOffset(0.002,"x");
133  histo->GetXaxis()->SetMoreLogLabels();
134 }

◆ MakeCorrelationPlots()

void MakeCorrelationPlots ( const TString &  outFile,
TCanvas *  canvas,
TFile *  outHistFile,
const std::vector< JetUncertaintiesTool * > &  providers,
const std::vector< std::pair< double, double > > &  fixedEta,
const std::vector< std::pair< double, double > > &  fixedPt 
)

Definition at line 254 of file MakeCorrelationMatrixPlots.cxx.

255 {
256  const TString release = providers.at(0)->getRelease();
257  const double minPtVal = release.EndsWith("TLA") ? 75 : 17;
258  const double maxPtVal = testJER ? 1500 : release.EndsWith("TLA") ? 1000 : (release.BeginsWith("2011") || release.BeginsWith("2012")) ? 2500 : 3000;
259  const double minEtaVal = 0;
260  const double maxEtaVal = release.EndsWith("TLA") ? 2.8 : 4.5;
261 
262  // First the pT correlation plots
263  canvas->SetLogx(true);
264  canvas->SetLogy(true);
265  for (size_t iFixed = 0; iFixed < fixedEta.size(); ++iFixed)
266  {
267  const double etaVal1 = fixedEta.at(iFixed).first;
268  const double etaVal2 = fixedEta.at(iFixed).second;
269 
270  printf("Processing (eta1,eta2) = (%.2f,%.2f)\n",etaVal1,etaVal2);
271 
272  // Make the initial histograms
273  std::vector<TH2D*> corrPt;
274  for (size_t iProv = 0; iProv < providers.size(); ++iProv)
275  {
276  corrPt.push_back(providers.at(iProv)->getPtCorrelationMatrix(100,minPtVal,maxPtVal,etaVal1,etaVal2));
277  corrPt.back()->GetXaxis()->SetTitle("#it{p}_{T}^{jet} [GeV]");
278  corrPt.back()->GetYaxis()->SetTitle(corrPt.back()->GetXaxis()->GetTitle());
279 
280  // Switch to 1-corr if Sasha's requested metric
281  if (useRelativeMetric)
282  for (int binX = 1; binX <= corrPt.back()->GetNbinsX(); ++binX)
283  for (int binY = 1; binY <= corrPt.back()->GetNbinsY(); ++binY)
284  if (corrPt.back()->GetBinContent(binX,binY) > -100) {
285  corrPt.back()->SetBinContent(binX,binY,1-corrPt.back()->GetBinContent(binX,binY));
286  }
287  }
288 
289  // Now plot them and the difference histograms
290  PlotCorrelationHistos(outFile,canvas,outHistFile,providers,corrPt,etaVal1,etaVal2);
291 
292  }
293 
294  // Now the eta correlation plots
295  canvas->SetLogx(false);
296  canvas->SetLogy(false);
297  for (size_t iFixed = 0; iFixed < fixedPt.size(); ++iFixed)
298  {
299  const double ptVal1 = fixedPt.at(iFixed).first;
300  const double ptVal2 = fixedPt.at(iFixed).second;
301 
302  printf("Processing (pT1,pT2) = (%.0f,%.0f)\n",ptVal1,ptVal2);
303 
304  // Make the initial histograms
305  std::vector<TH2D*> corrEta;
306  for (size_t iProv = 0; iProv < providers.size(); ++iProv)
307  {
308  corrEta.push_back(providers.at(iProv)->getEtaCorrelationMatrix(round(10*(maxEtaVal-minEtaVal)),minEtaVal,maxEtaVal,ptVal1,ptVal2));
309  corrEta.back()->GetXaxis()->SetTitle("#eta^{jet}");
310  corrEta.back()->GetYaxis()->SetTitle(corrEta.back()->GetXaxis()->GetTitle());
311 
312  // Switch to 1-corr if Sasha's requested metric
313  if (useRelativeMetric)
314  for (int binX = 1; binX <= corrEta.back()->GetNbinsX(); ++binX)
315  for (int binY = 1; binY <= corrEta.back()->GetNbinsY(); ++binY)
316  if (corrEta.back()->GetBinContent(binX,binY) > -100)
317  corrEta.back()->SetBinContent(binX,binY,1-corrEta.back()->GetBinContent(binX,binY));
318  }
319 
320  // Now plot them and the difference histograms
321  PlotCorrelationHistos(outFile,canvas,outHistFile,providers,corrEta,ptVal1,ptVal2);
322  }
323 }

◆ PlotCorrelationHistos()

void PlotCorrelationHistos ( const TString &  outFile,
TCanvas *  canvas,
TFile *  outHistFile,
const std::vector< JetUncertaintiesTool * > &  providers,
const std::vector< TH2D * > &  corrMats,
const double  fixedValue1,
const double  fixedValue2 
)

Definition at line 136 of file MakeCorrelationMatrixPlots.cxx.

137 {
138  // First make the difference histograms
139  // Must be now as colz bug fixes axis range once draw is called
140  std::vector<TH2D*> corrMatDiffs;
141  std::vector< std::pair<JetUncertaintiesTool*,JetUncertaintiesTool*> > diffProviders;
142  for (size_t iHisto = 0; iHisto + 1 < corrMats.size(); ++iHisto)
143  {
144  // Take the difference
145  TH2D* diff = new TH2D(*corrMats.at(iHisto));
146  diff->SetName(Form("diff_%s",diff->GetName()));
147 
148  // Subtract, watching for kinematic limits and relative metric
149  for (int binX = 1; binX <= diff->GetNbinsX(); ++binX)
150  for (int binY = 1; binY <= diff->GetNbinsY(); ++binY)
151  if (corrMats.at(iHisto)->GetBinContent(binX,binY) < -100)
152  diff->SetBinContent(binX,binY,corrMats.at(iHisto)->GetBinContent(binX,binY));
153  else if (useRelativeMetric)
154  diff->SetBinContent(binX,binY,relativeMetric(corrMats.at(iHisto)->GetBinContent(binX,binY),corrMats.at(iHisto+1)->GetBinContent(binX,binY)));
155  else
156  diff->SetBinContent(binX,binY,corrMats.at(iHisto)->GetBinContent(binX,binY) - corrMats.at(iHisto+1)->GetBinContent(binX,binY));
157 
158  //diff->Add(corrMats.at(iHisto+1),-1);
159  //for (int binX = 1; binX <= diff->GetNbinsX(); ++binX)
160  // for (int binY = 1; binY <= diff->GetNbinsY(); ++binY)
161  // if (corrMats.at(iHisto)->GetBinContent(binX,binY) < -100)
162  // diff->SetBinContent(binX,binY,corrMats.at(iHisto)->GetBinContent(binX,binY));
163 
164  // Now store
165  corrMatDiffs.push_back(diff);
166  diffProviders.emplace_back(providers.at(iHisto),providers.at(iHisto+1));
167  }
168 
169  // Now make the initial plots
170  for (size_t iHisto = 0; iHisto < corrMats.size(); ++iHisto)
171  {
172  TH2D* histo = corrMats.at(iHisto);
173  histo->GetZaxis()->SetTitle("correlation");
174  histo->GetZaxis()->SetRangeUser(0.0,1.0);
176  histo->Draw("colz");
177  DrawLabels(histo,fixedValue1,fixedValue2,providers.at(iHisto));
178 
179  if (outFile != "NONE" && !outFile.EndsWith(".eps"))
180  canvas->Print(outFile);
181  else if (outFile != "NONE")
182  canvas->Print(TString(outFile).ReplaceAll(".eps",Form("-%d.eps",++iEPS)));
183 
184  if (outHistFile)
185  {
186  outHistFile->cd();
187  histo->Write(histo->GetName());
188  canvas->cd();
189  }
190  }
191 
192  // Now make the difference plots
193  for (size_t iHisto = 0; iHisto < corrMatDiffs.size(); ++iHisto)
194  {
195  TH2D* histo = corrMatDiffs.at(iHisto);
196 
197  // Determine the maximum difference
198  // Matrix is not necessarily symmetric (only symmetric if fixed1 == fixed2)
199  // Be careful to ignore kinematic limits (set outside scale on purpose)
200  double meanDiff = 0;
201  double maxDiff = 0;
202  int maxX = -1;
203  int maxY = -1;
204  unsigned long long numValidBins = 0;
205  for (int binX = 1; binX <= histo->GetNbinsX(); ++binX)
206  for (int binY = 1; binY <= histo->GetNbinsY(); ++binY)
207  {
208  // Check kinematic limits
209  if (histo->GetBinContent(binX,binY) < -100)
210  continue;
211 
212  // Adjust the mean and max
213  meanDiff += histo->GetBinContent(binX,binY);
214  numValidBins++;
215  if (fabs(histo->GetBinContent(binX,binY)) > fabs(maxDiff))
216  {
217  maxDiff = histo->GetBinContent(binX,binY);
218  maxX = binX;
219  maxY = binY;
220  }
221  }
222  //meanDiff /= histo->GetNbinsX()*histo->GetNbinsY();
223  meanDiff /= numValidBins;
224 
225  // Set the range to the maximum (rounded up to nearest multiple of 5) if requested
226  if (fixedRangeDiff < 1.e-3)
227  {
228  const double maxDiffRounded = static_cast<int>(fabs(maxDiff)*20+1)/20.;
229  histo->GetZaxis()->SetRangeUser(-maxDiffRounded,maxDiffRounded);
230  }
231  else
232  histo->GetZaxis()->SetRangeUser(-fixedRangeDiff,fixedRangeDiff);
233 
234  // Now plot
235  histo->GetZaxis()->SetTitle("correlation difference");
237  histo->Draw("colz");
238  DrawLabels(histo,fixedValue1,fixedValue2,diffProviders.at(iHisto).first,diffProviders.at(iHisto).second,meanDiff,maxDiff,maxX,maxY);
239 
240  if (outFile != "NONE" && !outFile.EndsWith(".eps"))
241  canvas->Print(outFile);
242  else if (outFile != "NONE")
243  canvas->Print(TString(outFile).ReplaceAll(".eps",Form("-%d.eps",++iEPS)));
244 
245  if (outHistFile && corrMatDiffs.size() == 1)
246  {
247  outHistFile->cd();
248  histo->Write(histo->GetName());
249  canvas->cd();
250  }
251  }
252 }

◆ relativeMetric()

double relativeMetric ( const double  numerator,
const double  denominator 
)

Definition at line 31 of file MakeCorrelationMatrixPlots.cxx.

32 {
33  if (fabs(denominator) < 1.e-3)
34  {
35  if (fabs(numerator) < 1.e-3)
36  return 1;
37  else {
38  std::cout << "Setting error code in steering" << std::endl;
39  return JESUNC_ERROR_CODE;
40  }
41  }
42  return sqrt(numerator/denominator);
43 }

Variable Documentation

◆ addExtremumInfo

const bool addExtremumInfo = true

Definition at line 22 of file MakeCorrelationMatrixPlots.cxx.

◆ addScenarioInfo

const bool addScenarioInfo = false

Definition at line 23 of file MakeCorrelationMatrixPlots.cxx.

◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY

ATLAS_NO_CHECK_FILE_THREAD_SAFETY

Definition at line 19 of file MakeCorrelationMatrixPlots.cxx.

◆ fixedRangeDiff

const double fixedRangeDiff = 0

Definition at line 21 of file MakeCorrelationMatrixPlots.cxx.

◆ iEPS

int iEPS = 0

Definition at line 29 of file MakeCorrelationMatrixPlots.cxx.

◆ makeGrid

const bool makeGrid = true

Definition at line 24 of file MakeCorrelationMatrixPlots.cxx.

◆ minRepStyle

const bool minRepStyle = false

Definition at line 25 of file MakeCorrelationMatrixPlots.cxx.

◆ testJER

const bool testJER = false

Definition at line 26 of file MakeCorrelationMatrixPlots.cxx.

◆ useRelativeMetric

bool useRelativeMetric = true

Definition at line 28 of file MakeCorrelationMatrixPlots.cxx.

minRepStyle
const bool minRepStyle
Definition: MakeCorrelationMatrixPlots.cxx:25
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
addExtremumInfo
const bool addExtremumInfo
Definition: MakeCorrelationMatrixPlots.cxx:22
PlotCorrelationHistos
void PlotCorrelationHistos(const TString &outFile, TCanvas *canvas, TFile *outHistFile, const std::vector< JetUncertaintiesTool * > &providers, const std::vector< TH2D * > &corrMats, const double fixedValue1, const double fixedValue2)
Definition: MakeCorrelationMatrixPlots.cxx:136
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
SetAtlasStyle
void SetAtlasStyle()
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:17
Data
@ Data
Definition: BaseObject.h:11
DrawLabels
void DrawLabels(const TH2D *histo, const double fixedValue1, const double fixedValue2, const JetUncertaintiesTool *uncTool, const JetUncertaintiesTool *uncToolDiff=nullptr, const double mean=0, const double extremum=0, const int extremeX=-1, const int extremeY=-1)
Definition: MakeCorrelationMatrixPlots.cxx:45
iEPS
int iEPS
Definition: MakeCorrelationMatrixPlots.cxx:29
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
fixedRangeDiff
const double fixedRangeDiff
Definition: MakeCorrelationMatrixPlots.cxx:21
python.AtlRunQueryAMI.year
year
Definition: AtlRunQueryAMI.py:226
useRelativeMetric
bool useRelativeMetric
Definition: MakeCorrelationMatrixPlots.cxx:28
JESUNC_ERROR_CODE
#define JESUNC_ERROR_CODE
Definition: Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:23
Trk::binY
@ binY
Definition: BinningType.h:48
CalculateHighPtTerm.jetDef
dictionary jetDef
Definition: ICHEP2016/CalculateHighPtTerm.py:28
JetUncertaintiesTool::getConfigFile
virtual std::string getConfigFile() const
Definition: JetUncertaintiesTool.h:70
JetUncertaintiesTool
Definition: JetUncertaintiesTool.h:44
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
DeMoAtlasDataLoss.canvas
dictionary canvas
Definition: DeMoAtlasDataLoss.py:187
MakeCorrelationPlots
void MakeCorrelationPlots(const TString &outFile, TCanvas *canvas, TFile *outHistFile, const std::vector< JetUncertaintiesTool * > &providers, const std::vector< std::pair< double, double > > &fixedEta, const std::vector< std::pair< double, double > > &fixedPt)
Definition: MakeCorrelationMatrixPlots.cxx:254
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
addScenarioInfo
const bool addScenarioInfo
Definition: MakeCorrelationMatrixPlots.cxx:23
Trk::binX
@ binX
Definition: BinningType.h:47
ReadTripsProbsFromCool.denominator
denominator
Definition: ReadTripsProbsFromCool.py:96
ParseInputs.jetDefs
list jetDefs
Definition: Final2012/ParseInputs.py:102
DQPostProcessTest.outFile
outFile
Comment Out Those You do not wish to run.
Definition: DQPostProcessTest.py:37
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
testJER
const bool testJER
Definition: MakeCorrelationMatrixPlots.cxx:26
JetUncertaintiesTool::getAnalysisFile
virtual std::string getAnalysisFile() const
Definition: JetUncertaintiesTool.h:72
python.selector.AtlRunQuerySelectorLhcOlc.selector
selector
Definition: AtlRunQuerySelectorLhcOlc.py:611
DeMoStatus.ATLASLabel
def ATLASLabel(x, y, text="")
ATLASLabel copied from atlastyle package, as import does not work for unknown reasons.
Definition: DeMoStatus.py:51
relativeMetric
double relativeMetric(const double numerator, const double denominator)
Definition: MakeCorrelationMatrixPlots.cxx:31
FormatHisto
void FormatHisto(TH2D *histo)
Definition: MakeCorrelationMatrixPlots.cxx:125
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:77
JetUncertaintiesTool::getJetDef
virtual std::string getJetDef() const
Definition: JetUncertaintiesTool.h:68
jet::utils::getTypeObjFromString< bool >
bool getTypeObjFromString< bool >(const std::string &str, bool &obj)
Definition: Reconstruction/Jet/JetUncertainties/Root/Helpers.cxx:33
makeGrid
const bool makeGrid
Definition: MakeCorrelationMatrixPlots.cxx:24