File indexing completed on 2024-04-06 11:56:58
0001
0002 #include "TCanvas.h"
0003 #include "TClass.h"
0004 #include "TDirectory.h"
0005 #include "TFile.h"
0006 #include "TGaxis.h"
0007 #include "TGraph.h"
0008 #include "TH1.h"
0009 #include "TH2.h"
0010 #include "TKey.h"
0011 #include "TLegend.h"
0012 #include "TObjString.h"
0013 #include "TObject.h"
0014 #include "TProfile.h"
0015 #include "TRatioPlot.h"
0016 #include "TStyle.h"
0017
0018
0019 #include <iostream>
0020
0021
0022 #include "Alignment/OfflineValidation/macros/CMS_lumi.h"
0023
0024
0025 TFile *sourceFile1, *sourceFile2;
0026
0027
0028 std::vector<TFile *> sourceFiles;
0029 Int_t def_colors[9] = {kBlack, kBlue, kRed, kMagenta, kGreen, kCyan, kViolet, kOrange, kGreen + 2};
0030
0031 std::pair<Double_t, Double_t> getExtrema(TObjArray *array);
0032 template <typename T>
0033 void MakeNicePlotStyle(T *hist);
0034 void MakeNiceProfile(TProfile *prof);
0035
0036
0037 void plot2Histograms(TH1 *h1, TH1 *h2, const TString &label1, const TString &label2);
0038 void plot2Profiles(TProfile *h1, TProfile *h2, const TString &label1, const TString &label2);
0039 void recurseOverKeys(TDirectory *target1, const std::vector<TString> &labels, bool isNorm, const TString &Rlabel);
0040 void recurseOverKeys(TDirectory *target1, const TString &label1, const TString &label2);
0041 void plotHistograms(std::vector<TH1 *> histos,
0042 const std::vector<TString> &labels,
0043 bool isNormalized = false,
0044 const TString &Rlabel = "");
0045 void plotHistogramsInv(std::vector<TH1 *> histos,
0046 std::vector<TH1 *> invHistos,
0047 const std::vector<TString> &labels,
0048 const TString &Rlabel = "");
0049
0050
0051 void loopAndPlot(TString namesandlabels, const TString &Rlabel = "", bool doNormalize = false)
0052
0053 {
0054 std::vector<TString> labels;
0055
0056 namesandlabels.Remove(TString::kTrailing, ',');
0057 TObjArray *nameandlabelpairs = namesandlabels.Tokenize(",");
0058 for (Int_t i = 0; i < nameandlabelpairs->GetEntries(); ++i) {
0059 TObjArray *aFileLegPair = TString(nameandlabelpairs->At(i)->GetName()).Tokenize("=");
0060 if (aFileLegPair->GetEntries() == 2) {
0061 sourceFiles.push_back(TFile::Open(aFileLegPair->At(0)->GetName(), "READ"));
0062 TObjString *s_label = (TObjString *)aFileLegPair->At(1);
0063 labels.push_back(s_label->String());
0064 } else {
0065 std::cout << "Please give file name and legend entry in the following form:\n"
0066 << " filename1=legendentry1,filename2=legendentry2\n";
0067 return;
0068 }
0069 }
0070
0071 recurseOverKeys(sourceFiles[0], labels, doNormalize, Rlabel);
0072
0073 for (const auto &file : sourceFiles) {
0074 file->Close();
0075 }
0076 }
0077
0078
0079 void recurseOverKeys(TDirectory *target1, const std::vector<TString> &labels, bool isNorm, const TString &Rlabel)
0080
0081 {
0082
0083 TString fullPath = target1->GetPath();
0084
0085
0086 TString prefixToRemove = "root://eoscms.cern.ch/";
0087 if (fullPath.BeginsWith(prefixToRemove)) {
0088 fullPath.Remove(0, prefixToRemove.Length());
0089 }
0090
0091 TString path((char *)strstr(fullPath.Data(), ":"));
0092 path.Remove(0, 2);
0093
0094 sourceFiles[0]->cd(path);
0095
0096 std::cout << path << std::endl;
0097
0098 TDirectory *current_sourcedir = gDirectory;
0099
0100 TKey *key;
0101 TIter nextkey(current_sourcedir->GetListOfKeys());
0102
0103 while ((key = (TKey *)nextkey())) {
0104 auto obj = key->ReadObj();
0105
0106
0107 if (obj->IsA()->InheritsFrom("TH1")) {
0108 if (obj->IsA()->InheritsFrom("TH2"))
0109 continue;
0110
0111
0112 std::vector<TH1 *> histos;
0113
0114 TH1 *htemp1 = (TH1 *)obj;
0115 TString histName = htemp1->GetName();
0116
0117 for (const auto &file : sourceFiles) {
0118 TH1 *htemp;
0119 if (path != "") {
0120 file->GetObject(path + "/" + histName, htemp);
0121 } else {
0122 file->GetObject(histName, htemp);
0123 }
0124 histos.push_back(htemp);
0125 }
0126
0127 if (histName == "CosPhi" or histName == "CosPhi3D") {
0128 TString histName2;
0129 if (histName == "CosPhi") {
0130 histName2 = "CosPhiInv";
0131 } else if (histName == "CosPhi3D") {
0132 histName2 = "CosPhiInv3D";
0133 }
0134 std::vector<TH1 *> invHistos;
0135 for (const auto &file : sourceFiles) {
0136 TH1 *htemp2;
0137 if (path != "") {
0138 file->GetObject(path + "/" + histName2, htemp2);
0139 } else {
0140 file->GetObject(histName2, htemp2);
0141 }
0142 invHistos.push_back(htemp2);
0143 }
0144 plotHistogramsInv(histos, invHistos, labels, Rlabel);
0145 }
0146
0147 plotHistograms(histos, labels, isNorm, Rlabel);
0148 } else if (obj->IsA()->InheritsFrom("TDirectory")) {
0149
0150
0151 std::cout << "Found subdirectory " << obj->GetName() << std::endl;
0152
0153
0154
0155
0156
0157
0158 if ((TString(obj->GetName())).Contains("Residuals"))
0159 continue;
0160
0161 recurseOverKeys((TDirectory *)obj, labels, isNorm, Rlabel);
0162
0163 }
0164 }
0165 }
0166
0167
0168 void plotHistograms(std::vector<TH1 *> histos,
0169 const std::vector<TString> &labels,
0170 bool isNormalized,
0171 const TString &Rlabel)
0172
0173 {
0174 TGaxis::SetMaxDigits(3);
0175
0176 int W = 800;
0177 int H = 800;
0178
0179 float T = 0.08 * H;
0180 float B = 0.12 * H;
0181 float L = 0.12 * W;
0182 float R = 0.04 * W;
0183
0184 auto c1 = new TCanvas(Form("c1_%s", histos[0]->GetName()), "A ratio example", W, H);
0185 c1->SetFillColor(0);
0186 c1->SetBorderMode(0);
0187 c1->SetFrameFillStyle(0);
0188 c1->SetFrameBorderMode(0);
0189 c1->SetLeftMargin(L / W + 0.05);
0190 c1->SetRightMargin(R / W);
0191 c1->SetTopMargin(T / H);
0192 c1->SetBottomMargin(B / H);
0193 c1->SetTickx(0);
0194 c1->SetTicky(0);
0195 c1->SetGrid();
0196 c1->cd();
0197
0198 gStyle->SetOptStat(0);
0199
0200 c1->SetTicks(0, 1);
0201
0202 TObjArray *array = new TObjArray(histos.size());
0203 int index = 0;
0204 for (const auto &histo : histos) {
0205 MakeNicePlotStyle<TH1>(histo);
0206
0207 if (isNormalized) {
0208 Double_t scale = 1. / histo->Integral();
0209 histo->Scale(scale);
0210 }
0211
0212 histo->SetLineColor(def_colors[index]);
0213 histo->SetMarkerColor(def_colors[index]);
0214 histo->SetMarkerStyle(20);
0215 array->Add(histo);
0216 index++;
0217 }
0218
0219 std::pair<Double_t, Double_t> extrema = getExtrema(array);
0220 delete array;
0221 float min = (extrema.first > 0) ? (extrema.first) * 0.7 : (extrema.first) * 1.3;
0222 histos[0]->GetYaxis()->SetRangeUser(min, extrema.second * 1.3);
0223
0224 TRatioPlot *rp{nullptr};
0225
0226 for (unsigned int i = 1; i < histos.size(); i++) {
0227 if (i == 1) {
0228 rp = new TRatioPlot(histos[0], histos[i]);
0229 rp->SetLeftMargin(0.15);
0230 rp->SetRightMargin(0.05);
0231 rp->SetSeparationMargin(0.01);
0232 rp->SetLowBottomMargin(0.35);
0233 rp->Draw();
0234 } else {
0235 rp->GetUpperPad()->cd();
0236 histos[i]->Draw("same");
0237 }
0238 }
0239
0240 if (!rp) {
0241 std::cerr << "TRatioPlot could not be initialized, exiting!" << std::endl;
0242 return;
0243 }
0244
0245 rp->GetUpperPad()->cd();
0246
0247
0248 TLegend *infoBox = new TLegend(0.65, 0.75, 0.95, 0.90, "");
0249 infoBox->SetShadowColor(0);
0250 infoBox->SetFillColor(kWhite);
0251 infoBox->SetTextSize(0.035);
0252
0253 for (unsigned int i = 0; i < histos.size(); i++) {
0254 if (i == 0) {
0255 infoBox->AddEntry(histos[i], labels[i], "L");
0256 } else {
0257 infoBox->AddEntry(histos[i], labels[i], "P");
0258 }
0259 }
0260 infoBox->Draw("same");
0261
0262 MakeNicePlotStyle<TGraph>(rp->GetLowerRefGraph());
0263 rp->GetLowerRefGraph()->GetYaxis()->SetTitle("ratio");
0264 rp->GetLowerRefGraph()->SetMinimum(0.);
0265 rp->GetLowerRefGraph()->SetMaximum(2.);
0266 rp->GetLowerRefGraph()->SetLineColor(def_colors[0]);
0267 rp->GetLowerRefGraph()->SetMarkerColor(def_colors[0]);
0268
0269
0270 for (unsigned int i = 1; i < histos.size(); i++) {
0271 auto c2 = new TCanvas(Form("c2_%s_%i", histos[i]->GetName(), i), "A ratio example 2", 800, 800);
0272 c2->cd();
0273 auto rp2 = new TRatioPlot(histos[0], histos[i]);
0274 rp2->Draw();
0275 TGraph *g = rp2->GetLowerRefGraph();
0276
0277 MakeNicePlotStyle<TGraph>(g);
0278 g->SetLineColor(def_colors[i]);
0279 g->SetMarkerColor(def_colors[i]);
0280
0281 c1->cd();
0282 rp->GetLowerPad()->cd();
0283 if (g)
0284 g->Draw("same");
0285 c1->Update();
0286 delete c2;
0287 }
0288
0289
0290
0291
0292 CMS_lumi(c1, 0, 3, Rlabel);
0293 c1->SaveAs(TString(histos[0]->GetName()) + ".png");
0294 delete c1;
0295 }
0296
0297
0298 void plotHistogramsInv(std::vector<TH1 *> histos,
0299 std::vector<TH1 *> invHistos,
0300 const std::vector<TString> &labels,
0301 const TString &Rlabel)
0302
0303 {
0304 TGaxis::SetMaxDigits(4);
0305
0306 int W = 800;
0307 int H = 800;
0308
0309 float T = 0.08 * H;
0310 float B = 0.12 * H;
0311 float L = 0.12 * W;
0312 float R = 0.04 * W;
0313
0314 auto c1 = new TCanvas(Form("c1_%s", histos[0]->GetName()), "A ratio example", W, H);
0315 c1->SetFillColor(0);
0316 c1->SetBorderMode(0);
0317 c1->SetFrameFillStyle(0);
0318 c1->SetFrameBorderMode(0);
0319 c1->SetLeftMargin(L / W + 0.05);
0320 c1->SetRightMargin(R / W);
0321 c1->SetTopMargin(T / H);
0322 c1->SetBottomMargin(B / H);
0323 c1->SetTickx(0);
0324 c1->SetTicky(0);
0325 c1->SetGrid();
0326 c1->cd();
0327
0328 gStyle->SetOptStat(0);
0329
0330 c1->SetTicks(0, 1);
0331
0332 TObjArray *array = new TObjArray(histos.size());
0333
0334 for (unsigned int i = 0; i < histos.size(); i++) {
0335 const Double_t bin1 = histos[i]->GetBinContent(1);
0336 const Double_t invBin1 = invHistos[i]->GetBinContent(invHistos[i]->GetNbinsX());
0337 if (bin1 != invBin1) {
0338 std::cout << "Something went wrong, inverted histograms are not mirrored" << std::endl;
0339 }
0340 MakeNicePlotStyle<TH1>(histos[i]);
0341 MakeNicePlotStyle<TH1>(invHistos[i]);
0342
0343 histos[i]->SetLineColor(def_colors[i]);
0344 histos[i]->SetMarkerColor(def_colors[i]);
0345 histos[i]->SetMarkerStyle(20);
0346
0347 invHistos[i]->SetLineColor(def_colors[i]);
0348 invHistos[i]->SetMarkerStyle(kOpenCross);
0349 invHistos[i]->SetMarkerSize(1.2);
0350 invHistos[i]->SetMarkerColor(def_colors[i]);
0351 invHistos[i]->GetXaxis()->SetTitle(histos[0]->GetXaxis()->GetTitle());
0352 array->Add(histos[i]);
0353 }
0354
0355 std::pair<Double_t, Double_t> extrema = getExtrema(array);
0356 delete array;
0357 float min = (extrema.first > 0) ? (extrema.first) * 0.7 : (extrema.first) * 1.3;
0358 histos[0]->GetYaxis()->SetRangeUser(min, extrema.second * 1.3);
0359
0360 TRatioPlot *rp{nullptr};
0361
0362 for (unsigned int i = 0; i < histos.size(); i++) {
0363 invHistos[i]->SetLineWidth(2);
0364 if (i == 0) {
0365 rp = new TRatioPlot(invHistos[0], histos[0]);
0366 rp->SetLeftMargin(0.15);
0367 rp->SetRightMargin(0.05);
0368 rp->SetSeparationMargin(0.01);
0369 rp->SetLowBottomMargin(0.35);
0370 rp->Draw("hist");
0371 } else {
0372 rp->GetUpperPad()->cd();
0373 invHistos[i]->Draw("same hist");
0374 histos[i]->Draw("same p0");
0375 }
0376 }
0377
0378 if (!rp) {
0379 std::cerr << "TRatioPlot could not be initialized, exiting!" << std::endl;
0380 return;
0381 }
0382
0383 rp->GetUpperPad()->cd();
0384
0385
0386 TLegend *infoBox = new TLegend(0.4, 0.75, 0.65, 0.90, "");
0387 infoBox->SetShadowColor(0);
0388 infoBox->SetFillColor(kWhite);
0389 infoBox->SetTextSize(0.035);
0390
0391 for (unsigned int i = 0; i < histos.size(); i++) {
0392 infoBox->AddEntry(histos[i], labels[i], "P");
0393 }
0394 infoBox->Draw("same");
0395
0396 MakeNicePlotStyle<TGraph>(rp->GetLowerRefGraph());
0397 rp->GetLowerRefGraph()->GetYaxis()->SetTitle("ratio");
0398 rp->GetLowerRefGraph()->SetMinimum(0.3);
0399 rp->GetLowerRefGraph()->SetMaximum(1.7);
0400 rp->GetLowerRefGraph()->SetLineColor(def_colors[0]);
0401 rp->GetLowerRefGraph()->SetMarkerColor(def_colors[0]);
0402
0403 for (unsigned int i = 1; i < histos.size(); i++) {
0404 TLine *line = new TLine(gPad->GetUxmin(), 1, gPad->GetUxmax(), 1);
0405 auto c2 = new TCanvas(Form("c2_%s_%i", histos[i]->GetName(), i), "A ratio example 2", 800, 800);
0406 c2->cd();
0407 auto rp2 = new TRatioPlot(invHistos[i], histos[i]);
0408 rp2->Draw();
0409 TGraph *g = rp2->GetLowerRefGraph();
0410
0411 MakeNicePlotStyle<TGraph>(g);
0412 g->SetLineColor(def_colors[i]);
0413 g->SetMarkerColor(def_colors[i]);
0414
0415
0416 c1->cd();
0417 rp->GetLowerPad()->cd();
0418 line->Draw("same");
0419 if (g)
0420 g->Draw("same P");
0421 c1->Update();
0422 delete c2;
0423 }
0424
0425 CMS_lumi(c1, 0, 3, Rlabel);
0426 c1->SaveAs(TString(histos[0]->GetName()) + "_mirrored.png");
0427 c1->SaveAs(TString(histos[0]->GetName()) + "_mirrored.pdf");
0428 delete c1;
0429 }
0430
0431
0432 void recurseOverKeys(TDirectory *target1, const TString &label1, const TString &label2)
0433
0434 {
0435
0436 TString path((char *)strstr(target1->GetPath(), ":"));
0437 path.Remove(0, 2);
0438
0439 sourceFile1->cd(path);
0440
0441 std::cout << path << std::endl;
0442
0443 TDirectory *current_sourcedir = gDirectory;
0444
0445 TKey *key;
0446 TIter nextkey(current_sourcedir->GetListOfKeys());
0447
0448 while ((key = (TKey *)nextkey())) {
0449 auto obj = key->ReadObj();
0450
0451
0452 if (obj->IsA()->InheritsFrom("TH1F")) {
0453
0454
0455 TH1F *htemp1, *htemp2;
0456
0457 htemp1 = (TH1F *)obj;
0458 TString histName = htemp1->GetName();
0459
0460 if (path != "") {
0461 sourceFile2->GetObject(path + "/" + histName, htemp2);
0462 } else {
0463 sourceFile2->GetObject(histName, htemp2);
0464 }
0465
0466
0467
0468 plot2Histograms(htemp1, htemp2, label1, label2);
0469
0470 } else if (obj->IsA()->InheritsFrom("TProfile")) {
0471
0472
0473 TProfile *htemp1, *htemp2;
0474
0475 htemp1 = (TProfile *)obj;
0476 TString histName = htemp1->GetName();
0477
0478 if (path != "") {
0479 sourceFile2->GetObject(path + "/" + histName, htemp2);
0480 } else {
0481 sourceFile2->GetObject(histName, htemp2);
0482 }
0483
0484 plot2Profiles(htemp1, htemp2, label1, label2);
0485 } else if (obj->IsA()->InheritsFrom("TDirectory")) {
0486
0487
0488 std::cout << "Found subdirectory " << obj->GetName() << std::endl;
0489
0490
0491
0492
0493
0494
0495 if ((TString(obj->GetName())).Contains("DQM") && !(TString(obj->GetName())).Contains("DQMData"))
0496 continue;
0497
0498 recurseOverKeys((TDirectory *)obj, label1, label2);
0499
0500 }
0501 }
0502 }
0503
0504
0505 void plot2Profiles(TProfile *h1, TProfile *h2, const TString &label1, const TString &label2)
0506
0507 {
0508 auto c1 = new TCanvas(Form("c1_%s", h1->GetName()), "example", 800, 800);
0509 c1->SetLeftMargin(0.15);
0510 c1->SetRightMargin(0.03);
0511 gStyle->SetOptStat(0);
0512
0513 h1->SetLineColor(kBlue);
0514 h2->SetLineColor(kRed);
0515
0516 h1->SetMarkerColor(kBlue);
0517 h2->SetMarkerColor(kRed);
0518
0519 h1->SetMarkerStyle(20);
0520 h2->SetMarkerStyle(21);
0521
0522 MakeNiceProfile(h1);
0523 MakeNiceProfile(h2);
0524
0525 TObjArray *array = new TObjArray(2);
0526 array->Add(h1);
0527 array->Add(h2);
0528
0529 std::pair<Double_t, Double_t> extrema = getExtrema(array);
0530
0531 delete array;
0532
0533 float min = (extrema.first > 0) ? (extrema.first) * 0.99 : (extrema.first) * 1.01;
0534
0535 h1->GetYaxis()->SetRangeUser(min, extrema.second * 1.01);
0536 h2->GetYaxis()->SetRangeUser(min, extrema.second * 1.01);
0537 c1->cd();
0538 h1->Draw();
0539 h2->Draw("same");
0540
0541 TLegend *infoBox = new TLegend(0.75, 0.75, 0.97, 0.90, "");
0542 infoBox->AddEntry(h1, label1, "PL");
0543 infoBox->AddEntry(h2, label2, "PL");
0544 infoBox->SetShadowColor(0);
0545 infoBox->SetFillColor(kWhite);
0546 infoBox->Draw("same");
0547
0548 c1->SaveAs(TString(h1->GetName()) + ".png");
0549 delete c1;
0550 }
0551
0552
0553 void plot2Histograms(TH1 *h1, TH1 *h2, const TString &label1, const TString &label2) {
0554
0555
0556 TGaxis::SetMaxDigits(3);
0557
0558 auto c1 = new TCanvas(Form("c1_%s", h1->GetName()), "A ratio example", 800, 800);
0559 gStyle->SetOptStat(0);
0560
0561 MakeNicePlotStyle<TH1>(h1);
0562 MakeNicePlotStyle<TH1>(h2);
0563
0564 h1->SetLineColor(kBlue);
0565 h2->SetLineColor(kRed);
0566
0567 TObjArray *array = new TObjArray(2);
0568 array->Add(h1);
0569 array->Add(h2);
0570
0571 std::pair<Double_t, Double_t> extrema = getExtrema(array);
0572
0573 delete array;
0574
0575 float min = (extrema.first > 0) ? (extrema.first) * 0.7 : (extrema.first) * 1.3;
0576
0577 h1->GetYaxis()->SetRangeUser(min, extrema.second * 1.3);
0578 h2->GetYaxis()->SetRangeUser(min, extrema.second * 1.3);
0579
0580 auto rp = new TRatioPlot(h1, h2);
0581 c1->SetTicks(0, 1);
0582 rp->Draw();
0583
0584
0585
0586
0587
0588
0589 rp->SetLeftMargin(0.15);
0590 rp->SetRightMargin(0.03);
0591 rp->SetSeparationMargin(0.01);
0592 rp->SetLowBottomMargin(0.35);
0593
0594 rp->GetUpperPad()->cd();
0595
0596 TLegend *infoBox = new TLegend(0.75, 0.75, 0.97, 0.90, "");
0597 infoBox->AddEntry(h1, label1, "L");
0598 infoBox->AddEntry(h2, label2, "L");
0599 infoBox->SetShadowColor(0);
0600 infoBox->SetFillColor(kWhite);
0601 infoBox->Draw("same");
0602
0603 MakeNicePlotStyle<TGraph>(rp->GetLowerRefGraph());
0604 rp->GetLowerRefGraph()->GetYaxis()->SetTitle("ratio");
0605 rp->GetLowerRefGraph()->SetMinimum(0.);
0606 rp->GetLowerRefGraph()->SetMaximum(2.);
0607 c1->Update();
0608
0609
0610
0611
0612 c1->SaveAs(TString(h1->GetName()) + ".png");
0613 delete c1;
0614 }
0615
0616
0617 template <typename T>
0618 void MakeNicePlotStyle(T *hist)
0619
0620 {
0621
0622 hist->SetLineWidth(2);
0623 hist->GetXaxis()->SetNdivisions(505);
0624 hist->GetXaxis()->CenterTitle(true);
0625 hist->GetYaxis()->CenterTitle(true);
0626 hist->GetXaxis()->SetTitleFont(42);
0627 hist->GetYaxis()->SetTitleFont(42);
0628 hist->GetXaxis()->SetTitleSize(0.05);
0629 hist->GetYaxis()->SetTitleSize(0.05);
0630 hist->GetXaxis()->SetTitleOffset(0.9);
0631 hist->GetYaxis()->SetTitleOffset(1.4);
0632 hist->GetXaxis()->SetLabelFont(42);
0633 hist->GetYaxis()->SetLabelFont(42);
0634 if (((TObject *)hist)->IsA()->InheritsFrom("TGraph")) {
0635 hist->GetYaxis()->SetLabelSize(.025);
0636
0637 } else {
0638 hist->GetYaxis()->SetLabelSize(.05);
0639 }
0640 hist->GetXaxis()->SetLabelSize(.05);
0641 }
0642
0643
0644 void MakeNiceProfile(TProfile *prof)
0645
0646 {
0647 prof->SetLineWidth(2);
0648 prof->GetXaxis()->SetNdivisions(505);
0649 prof->GetXaxis()->CenterTitle(true);
0650 prof->GetYaxis()->CenterTitle(true);
0651 prof->GetXaxis()->SetTitleFont(42);
0652 prof->GetYaxis()->SetTitleFont(42);
0653 prof->GetXaxis()->SetTitleSize(0.05);
0654 prof->GetYaxis()->SetTitleSize(0.05);
0655 prof->GetXaxis()->SetTitleOffset(0.9);
0656 prof->GetYaxis()->SetTitleOffset(1.4);
0657 prof->GetXaxis()->SetLabelFont(42);
0658 prof->GetYaxis()->SetLabelFont(42);
0659 prof->GetYaxis()->SetLabelSize(.05);
0660 prof->GetXaxis()->SetLabelSize(.05);
0661 }
0662
0663
0664 std::pair<Double_t, Double_t> getExtrema(TObjArray *array)
0665
0666 {
0667 Double_t theMaximum = (static_cast<TH1 *>(array->At(0)))->GetMaximum();
0668 Double_t theMinimum = (static_cast<TH1 *>(array->At(0)))->GetMinimum();
0669 for (Int_t i = 0; i < array->GetSize(); i++) {
0670 if ((static_cast<TH1 *>(array->At(i)))->GetMaximum() > theMaximum) {
0671 theMaximum = (static_cast<TH1 *>(array->At(i)))->GetMaximum();
0672 }
0673 if ((static_cast<TH1 *>(array->At(i)))->GetMinimum() < theMinimum) {
0674 theMinimum = (static_cast<TH1 *>(array->At(i)))->GetMinimum();
0675 }
0676 }
0677 return std::make_pair(theMinimum, theMaximum);
0678 }