File indexing completed on 2024-04-06 12:32:29
0001 #include <fstream>
0002 #include <TFile.h>
0003 #include <TString.h>
0004 #include <TCanvas.h>
0005
0006
0007
0008 using namespace std;
0009
0010 void prn(TString s0, TString s1) {
0011 std::cout << "\t>> " << s0 << ": " << s1 << std::endl;
0012 }
0013
0014 void prn(TString s0, double d) {
0015 std::cout << "\t>> " << s0 << ": " << d << std::endl;
0016 }
0017
0018
0019 void ProcessRelVal(TFile &ref_file, TFile &val_file, ifstream &recstr, const int nHist1, const int nHist2, const int nHits2D, const int nProfInd, const int nHistTot, TString ref_vers, TString val_vers, int harvest = 0, bool bRBX = false);
0020
0021 void RelValMacro(TString ref_vers = "218", TString val_vers = "218", TString rfname, TString vfname, TString InputStream = "InputRelVal.txt", int harvest = 0) {
0022
0023 ifstream RelValStream;
0024
0025 RelValStream.open(InputStream);
0026
0027 TFile Ref_File(rfname);
0028 TFile Val_File(vfname);
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 const int SH_nHistTot = 154;
0044 const int SH_nHist1 = 54;
0045 const int SH_nHist2 = 0;
0046 const int SH_nHist2D = 100;
0047 const int SH_nProfInd = 0;
0048
0049 ProcessRelVal(Ref_File, Val_File, RelValStream, SH_nHist1, SH_nHist2, SH_nHist2D, SH_nProfInd, SH_nHistTot, ref_vers, val_vers, harvest, false, true);
0050
0051 Ref_File.Close();
0052 Val_File.Close();
0053
0054 return;
0055 }
0056
0057 void ProcessRelVal(TFile &ref_file, TFile &val_file, ifstream &recstr, const int nHist1, const int nHist2, const int nHist2D, const int nProfInd, const int nHistTot, TString ref_vers, TString val_vers, int harvest, bool bRBX, bool bHD = false) {
0058
0059 TString RefHistDir, ValHistDir;
0060
0061 if (bRBX) {
0062 if (harvest == 11) {
0063 RefHistDir = "DQMData/Run 1/NoiseRatesV/Run summary/NoiseRatesTask";
0064 ValHistDir = "DQMData/Run 1/NoiseRatesV/Run summary/NoiseRatesTask";
0065 } else if (harvest == 10) {
0066 RefHistDir = "DQMData/NoiseRatesV/NoiseRatesTask";
0067 ValHistDir = "DQMData/Run 1/NoiseRatesV/Run summary/NoiseRatesTask";
0068 } else if (harvest == 1) {
0069 RefHistDir = "DQMData/Run 1/NoiseRatesV/Run summary/NoiseRatesTask";
0070 ValHistDir = "DQMData/NoiseRatesV/NoiseRatesTask";
0071 } else {
0072 RefHistDir = "DQMData/NoiseRatesV/NoiseRatesTask";
0073 ValHistDir = "DQMData/NoiseRatesV/NoiseRatesTask";
0074 }
0075 } else if (bHD) {
0076 if (harvest == 11) {
0077 RefHistDir = "DQMData/Run 2/HcalHitsV/Run summary/SimHitsValidationHcal";
0078 ValHistDir = "DQMData/Run 2/HcalHitsV/Run summary/SimHitsValidationHcal";
0079 } else if (harvest == 10) {
0080 RefHistDir = "DQMData/HcalDigisV/HcalDigiTask";
0081 ValHistDir = "DQMData/Run 1/HcalDigisV/Run summary/HcalDigiTask";
0082 } else if (harvest == 1) {
0083 RefHistDir = "DQMData/Run 1/HcalDigisV/Run summary/HcalDigiTask";
0084 ValHistDir = "DQMData/HcalDigisV/HcalDigiTask";
0085 } else {
0086 RefHistDir = "DQMData/HcalDigisV/HcalDigiTask";
0087 ValHistDir = "DQMData/HcalDigisV/HcalDigiTask";
0088 }
0089 } else {
0090 if (harvest == 11) {
0091 RefHistDir = "DQMData/Run 1/HcalRecHitsV/Run summary/HcalRecHitTask";
0092 ValHistDir = "DQMData/Run 1/HcalRecHitsV/Run summary/HcalRecHitTask";
0093 } else if (harvest == 10) {
0094 RefHistDir = "DQMData/HcalRecHitsV/HcalRecHitTask";
0095 ValHistDir = "DQMData/Run 1/HcalRecHitsV/Run summary/HcalRecHitTask";
0096 } else if (harvest == 1) {
0097 RefHistDir = "DQMData/Run 1/HcalRecHitsV/Run summary/HcalRecHitTask";
0098 ValHistDir = "DQMData/HcalRecHitsV/HcalRecHitTask";
0099 } else {
0100 RefHistDir = "DQMData/HcalRecHitsV/HcalRecHitTask";
0101 ValHistDir = "DQMData/HcalRecHitsV/HcalRecHitTask";
0102 }
0103 }
0104
0105 TCanvas* myc = 0;
0106 TLegend* leg = 0;
0107 TPaveText* ptchi2 = 0;
0108 TPaveStats *ptstats_r = 0;
0109 TPaveStats *ptstats_v = 0;
0110
0111 TH1F * ref_hist1[nHist1];
0112 TH2F * ref_hist2[nHist2];
0113 TProfile * ref_prof[nProfInd];
0114 TH1D * ref_fp[nProfInd];
0115 TH2F * ref_hist2D[nHist2D];
0116
0117 TH1F * val_hist1[nHist1];
0118 TH2F * val_hist2[nHist2];
0119 TProfile * val_prof[nProfInd];
0120 TH1D * val_fp[nProfInd];
0121 TH2F * val_hist2D[nHist2D];
0122
0123 int i;
0124 int DrawSwitch;
0125 TString StatSwitch, Chi2Switch, LogSwitch, DimSwitch;
0126 int RefCol, ValCol;
0127 TString HistName, HistName2;
0128 char xAxisTitle[200];
0129 int nRebin;
0130 float xAxisMin, xAxisMax, yAxisMin, yAxisMax;
0131 TString OutLabel, ProfileLabel;
0132 string xTitleCheck;
0133
0134 float hmax = 0;
0135
0136 int nh1 = 0;
0137 int nh2 = 0;
0138 int npr = 0;
0139 int npi = 0;
0140 int n2D = 0;
0141
0142 for (i = 0; i < nHistTot; i++) {
0143
0144
0145
0146
0147
0148
0149 recstr >> HistName >> DrawSwitch;
0150 prn("HistName", HistName);
0151
0152
0153 recstr >> OutLabel >> nRebin;
0154 recstr >> xAxisMin >> xAxisMax >> yAxisMin >> yAxisMax;
0155 recstr >> DimSwitch >> StatSwitch >> Chi2Switch >> LogSwitch;
0156 recstr >> RefCol >> ValCol;
0157 recstr.getline(xAxisTitle, 200);
0158
0159
0160 if (DrawSwitch == 0) {
0161 if (DimSwitch == "TM")
0162 recstr >> ProfileLabel;
0163 continue;
0164 }
0165
0166
0167
0168
0169 Float_t r, g, b;
0170 Float_t saturation = 1;
0171 Float_t lightness = 0.5;
0172 Float_t maxHue = 280;
0173 Float_t minHue = 0;
0174 Int_t maxPretty = 50;
0175 Float_t hue;
0176
0177 for (int j = 0; j < maxPretty; j++) {
0178 hue = maxHue - (j + 1)*((maxHue - minHue) / maxPretty);
0179 TColor::HLStoRGB(hue, lightness, saturation, r, g, b);
0180 TColor *color = (TColor*) (gROOT->GetListOfColors()->At(j + 51));
0181 color->SetRGB(r, g, b);
0182 }
0183 gStyle->SetPalette(1);
0184
0185
0186
0187 if (DimSwitch == "PRwide") {
0188 gStyle->SetPadLeftMargin(0.06);
0189 gStyle->SetPadRightMargin(0.03);
0190 myc = new TCanvas("myc", "", 1200, 600);
0191 } else myc = new TCanvas("myc", "", 800, 600);
0192 myc->SetGrid();
0193
0194 xTitleCheck = xAxisTitle;
0195 xTitleCheck = xTitleCheck.substr(1, 7);
0196
0197
0198 if (LogSwitch == "Log") myc->SetLogy(1);
0199 else myc->SetLogy(0);
0200
0201
0202 if (LogSwitch == "Log" && DimSwitch == "2D"){
0203 myc->SetLogy(0);
0204 myc->SetLogz(1);
0205 }
0206
0207 if (DimSwitch == "1D") {
0208
0209 ref_file.cd(RefHistDir);
0210 ref_hist1[nh1] = (TH1F*) gDirectory->Get(HistName);
0211
0212 val_file.cd(ValHistDir);
0213 val_hist1[nh1] = (TH1F*) gDirectory->Get(HistName);
0214
0215
0216 ref_hist1[nh1]->GetXaxis()->SetLabelSize(0.04);
0217 val_hist1[nh1]->GetXaxis()->SetLabelSize(0.04);
0218 ref_hist1[nh1]->GetYaxis()->SetLabelSize(0.04);
0219 val_hist1[nh1]->GetYaxis()->SetLabelSize(0.04);
0220 ref_hist1[nh1]->GetXaxis()->SetTitleSize(0.045);
0221 val_hist1[nh1]->GetXaxis()->SetTitleSize(0.045);
0222
0223 ref_hist1[nh1]->GetXaxis()->SetTickLength(-0.015);
0224 val_hist1[nh1]->GetXaxis()->SetTickLength(-0.015);
0225 ref_hist1[nh1]->GetYaxis()->SetTickLength(-0.015);
0226 val_hist1[nh1]->GetYaxis()->SetTickLength(-0.015);
0227
0228 ref_hist1[nh1]->GetXaxis()->SetLabelOffset(0.012);
0229 val_hist1[nh1]->GetXaxis()->SetLabelOffset(0.012);
0230 ref_hist1[nh1]->GetYaxis()->SetLabelOffset(0.012);
0231 val_hist1[nh1]->GetYaxis()->SetLabelOffset(0.012);
0232
0233 ref_hist1[nh1]->GetXaxis()->SetTitleOffset(0.8);
0234 val_hist1[nh1]->GetXaxis()->SetTitleOffset(0.8);
0235
0236
0237
0238 if (nRebin != 1) {
0239 ref_hist1[nh1]->Rebin(nRebin);
0240 val_hist1[nh1]->Rebin(nRebin);
0241 }
0242
0243
0244 ref_hist1[nh1]->SetStats(kTRUE);
0245 val_hist1[nh1]->SetStats(kTRUE);
0246
0247 if (StatSwitch != "Stat" && StatSwitch != "Statrv") {
0248 ref_hist1[nh1]->SetStats(kFALSE);
0249 val_hist1[nh1]->SetStats(kFALSE);
0250 }
0251
0252
0253
0254 if (xAxisMin == 0) xAxisMin = ref_hist1[nh1]->GetXaxis()->GetXmin();
0255 if (xAxisMax < 0) xAxisMax = ref_hist1[nh1]->GetXaxis()->GetXmax();
0256
0257 if (xAxisMax > 0 || xAxisMin != 0) {
0258 ref_hist1[nh1]->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax);
0259 val_hist1[nh1]->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax);
0260 }
0261
0262 if (yAxisMin != 0) ref_hist1[nh1]->SetMinimum(yAxisMin);
0263 if (yAxisMax > 0) ref_hist1[nh1]->SetMaximum(yAxisMax);
0264 else if (ref_hist1[nh1]->GetMaximum() < val_hist1[nh1]->GetMaximum() &&
0265 val_hist1[nh1]->GetMaximum() > 0) {
0266 if (LogSwitch == "Log") ref_hist1[nh1]->SetMaximum(2 * val_hist1[nh1]->GetMaximum());
0267 else ref_hist1[nh1]->SetMaximum(1.05 * val_hist1[nh1]->GetMaximum());
0268 }
0269
0270
0271 if (xTitleCheck != "NoTitle") ref_hist1[nh1]->GetXaxis()->SetTitle(xAxisTitle);
0272
0273
0274 ref_hist1[nh1]->SetTitle("");
0275 ref_hist1[nh1]->SetLineColor(RefCol);
0276 ref_hist1[nh1]->SetLineStyle(1);
0277 ref_hist1[nh1]->SetMarkerSize(0.02);
0278 if (StatSwitch != "Stat" && StatSwitch != "Statrv") ref_hist1[nh1]->SetLineWidth(2);
0279
0280 val_hist1[nh1]->SetTitle("");
0281 val_hist1[nh1]->SetLineColor(ValCol);
0282 val_hist1[nh1]->SetLineStyle(2);
0283 val_hist1[nh1]->SetMarkerSize(0.02);
0284 if (StatSwitch != "Stat" && StatSwitch != "Statrv") val_hist1[nh1]->SetLineWidth(2);
0285
0286
0287 TLegend *leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC");
0288 leg->SetBorderSize(2);
0289 leg->SetFillStyle(1001);
0290 leg->AddEntry(ref_hist1[nh1], "CMSSW_" + ref_vers, "l");
0291 leg->AddEntry(val_hist1[nh1], "CMSSW_" + val_vers, "l");
0292
0293 if (Chi2Switch == "Chi2") {
0294
0295 ref_hist1[nh1]->SetFillColor(40);
0296 ref_hist1[nh1]->Draw("hist");
0297 val_hist1[nh1]->SetLineStyle(1);
0298 if (StatSwitch == "Statrv") val_hist1[nh1]->Draw("sames e0");
0299 else val_hist1[nh1]->Draw("same e0");
0300
0301
0302 const float NCHI2MIN = 0.01;
0303
0304 float pval;
0305 stringstream mystream;
0306 char tempbuff[30];
0307
0308 pval = ref_hist1[nh1]->Chi2Test(val_hist1[nh1]);
0309
0310 sprintf(tempbuff, "Chi2 p-value: %6.3E%c", pval, '\0');
0311 mystream << tempbuff;
0312
0313 ptchi2 = new TPaveText(0.05, 0.92, 0.35, 0.99, "NDC");
0314
0315 if (pval > NCHI2MIN) ptchi2->SetFillColor(kGreen);
0316 else ptchi2->SetFillColor(kRed);
0317
0318 ptchi2->SetTextSize(0.03);
0319 ptchi2->AddText(mystream.str().c_str());
0320 ptchi2->Draw();
0321 } else {
0322
0323 ref_hist1[nh1]->Draw("hist");
0324 if (StatSwitch == "Statrv") val_hist1[nh1]->Draw("hist sames");
0325 else val_hist1[nh1]->Draw("hist same");
0326 }
0327
0328
0329 if (StatSwitch == "Stat" || StatSwitch == "Statrv") {
0330 ptstats_r = new TPaveStats(0.85, 0.86, 0.98, 0.98, "brNDC");
0331 ptstats_r->SetTextColor(RefCol);
0332 ref_hist1[nh1]->GetListOfFunctions()->Add(ptstats_r);
0333 ptstats_r->SetParent(ref_hist1[nh1]->GetListOfFunctions());
0334 ptstats_v = new TPaveStats(0.85, 0.74, 0.98, 0.86, "brNDC");
0335 ptstats_v->SetTextColor(ValCol);
0336 val_hist1[nh1]->GetListOfFunctions()->Add(ptstats_v);
0337 ptstats_v->SetParent(val_hist1[nh1]->GetListOfFunctions());
0338
0339 ptstats_r->Draw();
0340 ptstats_v->Draw();
0341 }
0342
0343 leg->Draw();
0344
0345 myc->SaveAs(OutLabel);
0346 nh1++;
0347 } else if (DimSwitch == "PR" || DimSwitch == "PRwide") {
0348
0349
0350 ref_file.cd(RefHistDir);
0351 ref_prof[npi] = (TProfile*) gDirectory->Get(HistName);
0352
0353 val_file.cd(ValHistDir);
0354 val_prof[npi] = (TProfile*) gDirectory->Get(HistName);
0355
0356
0357 ref_prof[npi]->GetXaxis()->SetLabelSize(0.04);
0358 val_prof[npi]->GetXaxis()->SetLabelSize(0.04);
0359 ref_prof[npi]->GetYaxis()->SetLabelSize(0.04);
0360 val_prof[npi]->GetYaxis()->SetLabelSize(0.04);
0361 ref_prof[npi]->GetXaxis()->SetTitleSize(0.045);
0362 val_prof[npi]->GetXaxis()->SetTitleSize(0.045);
0363
0364 ref_prof[npi]->GetXaxis()->SetTickLength(-0.015);
0365 val_prof[npi]->GetXaxis()->SetTickLength(-0.015);
0366 ref_prof[npi]->GetYaxis()->SetTickLength(-0.015);
0367 val_prof[npi]->GetYaxis()->SetTickLength(-0.015);
0368
0369 ref_prof[npi]->GetXaxis()->SetLabelOffset(0.02);
0370 val_prof[npi]->GetXaxis()->SetLabelOffset(0.02);
0371 ref_prof[npi]->GetYaxis()->SetLabelOffset(0.02);
0372 val_prof[npi]->GetYaxis()->SetLabelOffset(0.02);
0373
0374 ref_prof[npi]->GetXaxis()->SetTitleOffset(1.3);
0375 val_prof[npi]->GetXaxis()->SetTitleOffset(1.3);
0376
0377
0378
0379 leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC");
0380 leg->SetBorderSize(2);
0381 leg->SetFillStyle(1001);
0382
0383
0384 if (DimSwitch == "PR") {
0385 ref_prof[npi]->SetTitle("");
0386 ref_prof[npi]->SetErrorOption("");
0387
0388 val_prof[npi]->SetTitle("");
0389 val_prof[npi]->SetErrorOption("");
0390
0391 ref_prof[npi]->GetXaxis()->SetTitle(xAxisTitle);
0392
0393 if (StatSwitch != "Stat" && StatSwitch != "Statrv") {
0394 ref_prof[npi]->SetStats(kFALSE);
0395 val_prof[npi]->SetStats(kFALSE);
0396 }
0397
0398 ref_prof[npi]->SetLineColor(41);
0399 ref_prof[npi]->SetLineStyle(1);
0400 ref_prof[npi]->SetLineWidth(1);
0401 ref_prof[npi]->SetMarkerColor(41);
0402 ref_prof[npi]->SetMarkerStyle(21);
0403 ref_prof[npi]->SetMarkerSize(0.8);
0404
0405 val_prof[npi]->SetLineColor(43);
0406 val_prof[npi]->SetLineStyle(1);
0407 val_prof[npi]->SetLineWidth(1);
0408 val_prof[npi]->SetMarkerColor(43);
0409 val_prof[npi]->SetMarkerStyle(22);
0410 val_prof[npi]->SetMarkerSize(1.0);
0411
0412 if (ref_prof[npi]->GetMaximum() < val_prof[npi]->GetMaximum() &&
0413 val_prof[npi]->GetMaximum() > 0) {
0414 if (LogSwitch == "Log") ref_prof[npi]->SetMaximum(2 * val_prof[npi]->GetMaximum());
0415 else ref_prof[npi]->SetMaximum(1.05 * val_prof[npi]->GetMaximum());
0416 }
0417
0418 ref_prof[npi]->Draw("hist pl");
0419 val_prof[npi]->Draw("hist pl same");
0420
0421 leg->AddEntry(ref_prof[npi], "CMSSW_" + ref_vers, "pl");
0422 leg->AddEntry(val_prof[npi], "CMSSW_" + val_vers, "pl");
0423 } else if (DimSwitch == "PRwide") {
0424
0425 TString temp = HistName + "_px_v";
0426 ref_fp[npi] = ref_prof[npi]->ProjectionX();
0427 val_fp[npi] = val_prof[npi]->ProjectionX(temp.Data());
0428
0429 ref_fp[npi]->SetTitle("");
0430 val_fp[npi]->SetTitle("");
0431
0432 ref_fp[npi]->GetXaxis()->SetTitle(xAxisTitle);
0433
0434 if (StatSwitch != "Stat" && StatSwitch != "Statrv") {
0435 ref_fp[npi]->SetStats(kFALSE);
0436 val_fp[npi]->SetStats(kFALSE);
0437 }
0438
0439 int nbins = ref_fp[npi]->GetNbinsX();
0440 for (int j = 1; j < nbins; j++) {
0441 ref_fp[npi]->SetBinError(j, 0.);
0442 val_fp[npi]->SetBinError(j, 0.);
0443 }
0444 ref_fp[npi]->SetLineWidth(0);
0445 ref_fp[npi]->SetLineColor(0);
0446 ref_fp[npi]->SetLineStyle(1);
0447 ref_fp[npi]->SetMarkerColor(2);
0448 ref_fp[npi]->SetMarkerStyle(20);
0449 ref_fp[npi]->SetMarkerSize(0.5);
0450
0451 val_fp[npi]->SetLineWidth(0);
0452 val_fp[npi]->SetLineColor(0);
0453 val_fp[npi]->SetLineStyle(2);
0454 val_fp[npi]->SetMarkerColor(4);
0455 val_fp[npi]->SetMarkerStyle(22);
0456 val_fp[npi]->SetMarkerSize(0.5);
0457
0458 if (ref_fp[npi]->GetMaximum() < val_fp[npi]->GetMaximum() &&
0459 val_fp[npi]->GetMaximum() > 0) {
0460 if (LogSwitch == "Log") ref_fp[npi]->SetMaximum(2 * val_fp[npi]->GetMaximum());
0461 else ref_fp[npi]->SetMaximum(1.05 * val_fp[npi]->GetMaximum());
0462 }
0463
0464 ref_fp[npi]->Draw("p9");
0465 val_fp[npi]->Draw("p9same");
0466
0467 leg->AddEntry(ref_fp[npi], "CMSSW_" + ref_vers, "lp");
0468 leg->AddEntry(val_fp[npi], "CMSSW_" + val_vers, "lp");
0469
0470 }
0471
0472 leg->Draw("");
0473
0474 myc->SaveAs(OutLabel);
0475
0476 npi++;
0477 } else if (DimSwitch == "TM") {
0478
0479 recstr >> HistName2;
0480
0481 ref_file.cd(RefHistDir);
0482
0483 ref_hist2[nh2] = (TH2F*) gDirectory->Get(HistName);
0484 ref_prof[npi] = (TProfile*) gDirectory->Get(HistName2);
0485
0486 ref_hist2[nh2]->SetMarkerStyle(21);
0487 ref_prof[npi] ->SetMarkerStyle(21);
0488 ref_hist2[nh2]->SetMarkerSize(0.02);
0489 ref_prof[npi] ->SetMarkerSize(0.02);
0490
0491 val_file.cd(ValHistDir);
0492
0493 val_hist2[nh2] = (TH2F*) gDirectory->Get(HistName);
0494 val_prof[npi] = (TProfile*) gDirectory->Get(HistName2);
0495
0496 val_hist2[nh2]->SetMarkerStyle(21);
0497 val_prof[npi] ->SetMarkerStyle(21);
0498 val_hist2[nh2]->SetMarkerSize(0.02);
0499 val_prof[npi] ->SetMarkerSize(0.02);
0500
0501
0502 ref_hist2[nh2]->GetXaxis()->SetLabelSize(0.04);
0503 val_hist2[nh2]->GetXaxis()->SetLabelSize(0.04);
0504 ref_hist2[nh2]->GetYaxis()->SetLabelSize(0.04);
0505 val_hist2[nh2]->GetYaxis()->SetLabelSize(0.04);
0506 ref_hist2[nh2]->GetXaxis()->SetTitleSize(0.045);
0507 val_hist2[nh2]->GetXaxis()->SetTitleSize(0.045);
0508
0509 ref_hist2[nh2]->GetXaxis()->SetTickLength(-0.015);
0510 val_hist2[nh2]->GetXaxis()->SetTickLength(-0.015);
0511 ref_hist2[nh2]->GetYaxis()->SetTickLength(-0.015);
0512 val_hist2[nh2]->GetYaxis()->SetTickLength(-0.015);
0513
0514 ref_hist2[nh2]->GetXaxis()->SetLabelOffset(0.02);
0515 val_hist2[nh2]->GetXaxis()->SetLabelOffset(0.02);
0516 ref_hist2[nh2]->GetYaxis()->SetLabelOffset(0.02);
0517 val_hist2[nh2]->GetYaxis()->SetLabelOffset(0.02);
0518
0519 ref_hist2[nh2]->GetXaxis()->SetTitleOffset(1.3);
0520 val_hist2[nh2]->GetXaxis()->SetTitleOffset(1.3);
0521
0522
0523
0524
0525 if (xAxisMin == 0) xAxisMin = ref_hist2[nh2]->GetXaxis()->GetXmin();
0526 if (xAxisMax < 0) xAxisMax = ref_hist2[nh2]->GetXaxis()->GetXmax();
0527
0528 if (xAxisMax > 0 || xAxisMin != 0) {
0529 ref_hist2[nh2]->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax);
0530 val_hist2[nh2]->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax);
0531 }
0532
0533 if (yAxisMin != 0) ref_hist2[nh2]->SetMinimum(yAxisMin);
0534 if (yAxisMax > 0) ref_hist2[nh2]->SetMaximum(yAxisMax);
0535 else if (ref_hist2[nh2]->GetMaximum() < val_hist2[nh2]->GetMaximum() &&
0536 val_hist2[nh2]->GetMaximum() > 0) {
0537 if (LogSwitch == "Log") ref_hist2[nh2]->SetMaximum(2 * val_hist2[nh2]->GetMaximum());
0538 else ref_hist2[nh2]->SetMaximum(1.05 * val_hist2[nh2]->GetMaximum());
0539 }
0540
0541
0542 if (yAxisMax > 0 || yAxisMin != 0) {
0543 ref_hist2[nh2]->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax);
0544 val_hist2[nh2]->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax);
0545 }
0546
0547
0548 leg = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC");
0549 leg->SetBorderSize(2);
0550 leg->SetFillStyle(1001);
0551
0552 ref_hist2[nh2]->GetXaxis()->SetTitle(xAxisTitle);
0553 ref_hist2[nh2]->SetStats(kFALSE);
0554
0555 ref_hist2[nh2]->SetTitle("");
0556 val_hist2[nh2]->SetTitle("");
0557
0558 ref_hist2[nh2]->SetMarkerColor(RefCol);
0559 ref_hist2[nh2]->Draw();
0560 ref_prof[npi]->SetLineColor(41);
0561 ref_prof[npi]->Draw("same");
0562
0563 val_hist2[nh2]->SetMarkerColor(ValCol);
0564 val_hist2[nh2]->Draw("same");
0565 val_prof[npi]->SetLineColor(45);
0566 val_prof[npi]->Draw("same");
0567
0568 leg->AddEntry(ref_prof[npi], "CMSSW_" + ref_vers, "pl");
0569 leg->AddEntry(val_prof[npi], "CMSSW_" + val_vers, "pl");
0570
0571 leg->Draw("");
0572
0573 myc->SaveAs(OutLabel);
0574
0575 npi++;
0576 nh2++;
0577 i++;
0578 } else if (DimSwitch == "2D") {
0579
0580 myc->SetGrid(0, 0);
0581
0582
0583 ref_file.cd(RefHistDir);
0584 ref_hist2D[n2D] = (TH2F*) gDirectory->Get(HistName);
0585
0586 val_file.cd(ValHistDir);
0587 val_hist2D[n2D] = (TH2F*) gDirectory->Get(HistName);
0588
0589 ref_hist2D[n2D]->SetStats(kFALSE);
0590 val_hist2D[n2D]->SetStats(kFALSE);
0591
0592
0593 ref_hist2D[n2D]->GetXaxis()->SetLabelSize(0.04);
0594 val_hist2D[n2D]->GetXaxis()->SetLabelSize(0.04);
0595 ref_hist2D[n2D]->GetYaxis()->SetLabelSize(0.04);
0596 val_hist2D[n2D]->GetYaxis()->SetLabelSize(0.04);
0597 ref_hist2D[n2D]->GetXaxis()->SetTitleSize(0.045);
0598 val_hist2D[n2D]->GetXaxis()->SetTitleSize(0.045);
0599
0600 ref_hist2D[n2D]->GetXaxis()->SetTickLength(-0.015);
0601 val_hist2D[n2D]->GetXaxis()->SetTickLength(-0.015);
0602 ref_hist2D[n2D]->GetYaxis()->SetTickLength(-0.015);
0603 val_hist2D[n2D]->GetYaxis()->SetTickLength(-0.015);
0604
0605 ref_hist2D[n2D]->GetXaxis()->SetLabelOffset(0.02);
0606 val_hist2D[n2D]->GetXaxis()->SetLabelOffset(0.02);
0607 ref_hist2D[n2D]->GetYaxis()->SetLabelOffset(0.02);
0608 val_hist2D[n2D]->GetYaxis()->SetLabelOffset(0.02);
0609
0610 ref_hist2D[n2D]->GetXaxis()->SetTitleOffset(1.0);
0611 val_hist2D[n2D]->GetXaxis()->SetTitleOffset(1.0);
0612
0613 ref_hist2D[n2D]->SetTitle("");
0614 val_hist2D[n2D]->SetTitle("");
0615
0616
0617 if (n2D == 1) {
0618 ref_hist2D[n2D]->GetXaxis()->SetRangeUser(-29., 28.);
0619 val_hist2D[n2D]->GetXaxis()->SetRangeUser(-29., 28.);
0620 }
0621
0622
0623
0624
0625
0626 ref_hist2D[n2D]->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax);
0627 val_hist2D[n2D]->GetXaxis()->SetRangeUser(xAxisMin, xAxisMax);
0628
0629
0630
0631 ref_hist2D[n2D]->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax);
0632 val_hist2D[n2D]->GetYaxis()->SetRangeUser(yAxisMin, yAxisMax);
0633
0634
0635 TLegend *leg1 = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC");
0636 leg1->SetBorderSize(2);
0637 leg1->SetFillStyle(1001);
0638 leg1->AddEntry(ref_hist2D[n2D], "CMSSW_" + ref_vers, "l");
0639
0640 if (xTitleCheck != "NoTitle") ref_hist2D[n2D]->GetXaxis()->SetTitle(xAxisTitle);
0641 ref_hist2D[n2D]->Draw("colz");
0642 leg1->Draw();
0643 myc->SaveAs("ref_" + OutLabel);
0644
0645
0646 TLegend *leg2 = new TLegend(0.50, 0.91, 0.84, 0.99, "", "brNDC");
0647 leg2->SetBorderSize(2);
0648 leg2->SetFillStyle(1001);
0649 leg2->AddEntry(val_hist2D[n2D], "CMSSW_" + val_vers, "l");
0650
0651 if (xTitleCheck != "NoTitle") val_hist2D[n2D]->GetXaxis()->SetTitle(xAxisTitle);
0652 val_hist2D[n2D]->Draw("colz");
0653 leg2->Draw();
0654 myc->SaveAs("val_" + OutLabel);
0655
0656 n2D++;
0657 }
0658
0659
0660 if (myc) delete myc;
0661 if (leg) delete leg;
0662 if (ptchi2) delete ptchi2;
0663 if (ptstats_r) delete ptstats_r;
0664 if (ptstats_v) delete ptstats_v;
0665 }
0666 return;
0667 }