Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-21 23:14:22

0001 #ifndef _Common_
0002 #define _Common_
0003 
0004 #include "TString.h"
0005 #include "TColor.h"
0006 #include "TStyle.h"
0007 #include "TFile.h"
0008 #include "TGraphErrors.h"
0009 #include "TCanvas.h"
0010 #include "TLegend.h"
0011 #include "TMarker.h"
0012 #include "TAxis.h"
0013 #include "TH1F.h"
0014 #include "TF1.h"
0015 
0016 #include <iostream>
0017 #include <vector>
0018 #include <algorithm>
0019 
0020 namespace {
0021   void setupStyle() {
0022     gStyle->SetOptStat(0);
0023     gStyle->SetPadTickX(1);
0024     gStyle->SetPadTickY(1);
0025   }
0026 };  // namespace
0027 
0028 enum ArchEnum { SNB, KNL, SKL, LNXG, LNXS };
0029 
0030 namespace {
0031   ArchEnum ARCH;
0032   void setupARCHEnum(const TString& arch) {
0033     if (arch.Contains("SNB"))
0034       ARCH = SNB;
0035     else if (arch.Contains("KNL"))
0036       ARCH = KNL;
0037     else if (arch.Contains("SKL"))
0038       ARCH = SKL;
0039     else if (arch.Contains("LNX-S"))
0040       ARCH = LNXS;
0041     else if (arch.Contains("LNX-G"))
0042       ARCH = LNXG;
0043     else {
0044       std::cerr << arch.Data() << " is not an allowed architecture! Exiting... " << std::endl;
0045       exit(1);
0046     }
0047   }
0048 };  // namespace
0049 
0050 struct ArchOpts {
0051   Int_t vumin;
0052   Int_t vumax;
0053 
0054   Int_t thmin;
0055   Int_t thmax;
0056 
0057   Double_t vutimemin;
0058   Double_t vutimemax;
0059 
0060   Double_t thtimemin;
0061   Double_t thtimemax;
0062 
0063   Double_t vuspeedupmin;
0064   Double_t vuspeedupmax;
0065 
0066   Double_t thspeedupmin;
0067   Double_t thspeedupmax;
0068 
0069   Double_t thmeiftimemin;
0070   Double_t thmeiftimemax;
0071 
0072   Double_t thmeifspeedupmin;
0073   Double_t thmeifspeedupmax;
0074 };
0075 
0076 namespace {
0077   ArchOpts arch_opt;
0078   void setupArch() {
0079     if (ARCH == SNB) {
0080       arch_opt.vumin = 1;
0081       arch_opt.vumax = 8;
0082 
0083       arch_opt.thmin = 1;
0084       arch_opt.thmax = 24;
0085 
0086       arch_opt.vutimemin = 0.;
0087       arch_opt.vutimemax = 0.5;
0088 
0089       arch_opt.thtimemin = 0.001;
0090       arch_opt.thtimemax = 1.;
0091 
0092       arch_opt.vuspeedupmin = 0.;
0093       arch_opt.vuspeedupmax = arch_opt.vumax;
0094 
0095       arch_opt.thspeedupmin = 0.;
0096       arch_opt.thspeedupmax = arch_opt.thmax;
0097 
0098       arch_opt.thmeiftimemin = 0.01;
0099       arch_opt.thmeiftimemax = 0.5;
0100 
0101       arch_opt.thmeifspeedupmin = 0.;
0102       arch_opt.thmeifspeedupmax = arch_opt.thmax;
0103     } else if (ARCH == KNL) {
0104       arch_opt.vumin = 1;
0105       arch_opt.vumax = 16;
0106 
0107       arch_opt.thmin = 1;
0108       arch_opt.thmax = 256;
0109 
0110       arch_opt.vutimemin = 0.;
0111       arch_opt.vutimemax = 1.5;
0112 
0113       arch_opt.thtimemin = 0.001;
0114       arch_opt.thtimemax = 1.;
0115 
0116       arch_opt.vuspeedupmin = 0.;
0117       arch_opt.vuspeedupmax = arch_opt.vumax;
0118 
0119       arch_opt.thspeedupmin = 0.;
0120       arch_opt.thspeedupmax = 80.;
0121 
0122       arch_opt.thmeiftimemin = 0.001;
0123       arch_opt.thmeiftimemax = arch_opt.thtimemax;
0124 
0125       arch_opt.thmeifspeedupmin = 0.;
0126       arch_opt.thmeifspeedupmax = arch_opt.thspeedupmax;
0127     } else if (ARCH == SKL) {
0128       arch_opt.vumin = 1;
0129       arch_opt.vumax = 16;
0130 
0131       arch_opt.thmin = 1;
0132       arch_opt.thmax = 64;
0133 
0134       arch_opt.vutimemin = 0.;
0135       arch_opt.vutimemax = 0.25;
0136 
0137       arch_opt.thtimemin = 0.0001;
0138       arch_opt.thtimemax = 1.;
0139 
0140       arch_opt.vuspeedupmin = 0.;
0141       arch_opt.vuspeedupmax = arch_opt.vumax;
0142 
0143       arch_opt.thspeedupmin = 0.;
0144       arch_opt.thspeedupmax = arch_opt.thmax / 2;
0145 
0146       arch_opt.thmeiftimemin = 0.001;
0147       arch_opt.thmeiftimemax = arch_opt.thtimemax;
0148 
0149       arch_opt.thmeifspeedupmin = 0.;
0150       arch_opt.thmeifspeedupmax = arch_opt.thspeedupmax;
0151     } else if (ARCH == LNXG) {
0152       arch_opt.vumin = 1;
0153       arch_opt.vumax = 16;
0154 
0155       arch_opt.thmin = 1;
0156       arch_opt.thmax = 64;
0157 
0158       arch_opt.vutimemin = 0.;
0159       arch_opt.vutimemax = 0.25;
0160 
0161       arch_opt.thtimemin = 0.0001;
0162       arch_opt.thtimemax = 1.;
0163 
0164       arch_opt.vuspeedupmin = 0.;
0165       arch_opt.vuspeedupmax = arch_opt.vumax;
0166 
0167       arch_opt.thspeedupmin = 0.;
0168       arch_opt.thspeedupmax = arch_opt.thmax / 2;
0169 
0170       arch_opt.thmeiftimemin = 0.001;
0171       arch_opt.thmeiftimemax = arch_opt.thtimemax;
0172 
0173       arch_opt.thmeifspeedupmin = 0.;
0174       arch_opt.thmeifspeedupmax = arch_opt.thspeedupmax;
0175     } else if (ARCH == LNXS) {
0176       arch_opt.vumin = 1;
0177       arch_opt.vumax = 16;
0178 
0179       arch_opt.thmin = 1;
0180       arch_opt.thmax = 64;
0181 
0182       arch_opt.vutimemin = 0.;
0183       arch_opt.vutimemax = 0.25;
0184 
0185       arch_opt.thtimemin = 0.0001;
0186       arch_opt.thtimemax = 1.;
0187 
0188       arch_opt.vuspeedupmin = 0.;
0189       arch_opt.vuspeedupmax = arch_opt.vumax;
0190 
0191       arch_opt.thspeedupmin = 0.;
0192       arch_opt.thspeedupmax = arch_opt.thmax / 2;
0193 
0194       arch_opt.thmeiftimemin = 0.001;
0195       arch_opt.thmeiftimemax = arch_opt.thtimemax;
0196 
0197       arch_opt.thmeifspeedupmin = 0.;
0198       arch_opt.thmeifspeedupmax = arch_opt.thspeedupmax;
0199     } else {
0200       std::cerr << "How did this happen?? You did not specify one of the allowed ARCHs!" << std::endl;
0201       exit(1);
0202     }
0203   }
0204 };  // namespace
0205 
0206 enum SuiteEnum { full, forPR, forConf, val };
0207 
0208 namespace {
0209   SuiteEnum SUITE;
0210   void setupSUITEEnum(const TString& suite) {
0211     if (suite.Contains("full"))
0212       SUITE = full;
0213     else if (suite.Contains("forPR"))
0214       SUITE = forPR;
0215     else if (suite.Contains("forConf"))
0216       SUITE = forConf;
0217     else if (suite.Contains("val"))
0218       SUITE = val;
0219     else {
0220       std::cerr << suite.Data() << " is not an allowed validation suite! Exiting... " << std::endl;
0221       exit(1);
0222     }
0223   }
0224 };  // namespace
0225 
0226 struct BuildOpts {
0227   BuildOpts() {}
0228   BuildOpts(const TString& name, const Color_t color, const TString& label) : name(name), color(color), label(label) {}
0229 
0230   TString name;
0231   Color_t color;
0232   TString label;
0233 };
0234 typedef std::vector<BuildOpts> BOVec;
0235 typedef std::map<TString, BuildOpts> BOMap;
0236 
0237 namespace {
0238   BOVec builds;
0239   UInt_t nbuilds;
0240   void setupBuilds(const Bool_t isBenchmark, const Bool_t includeCMSSW) {
0241     // tmp map to fill builds vector
0242     BOMap buildsMap;
0243     buildsMap["BH"] = {"BH", kBlue, "Best Hit"};
0244     buildsMap["STD"] = {"STD", kGreen + 1, "Standard"};
0245     buildsMap["CE"] = {"CE", kRed, "Clone Engine"};
0246     buildsMap["FV"] = {"FV", kMagenta, "Full Vector"};
0247     buildsMap["CMSSW"] = {"CMSSW", kBlack, "CMSSW"};
0248 
0249     // KPM: Consult ./xeon_scripts/common-variables.sh to match routines to suite
0250     if (SUITE == full) {
0251       builds.emplace_back(buildsMap["BH"]);
0252       builds.emplace_back(buildsMap["STD"]);
0253       builds.emplace_back(buildsMap["CE"]);
0254       builds.emplace_back(buildsMap["FV"]);
0255     } else if (SUITE == forPR) {
0256       if (isBenchmark) {
0257         builds.emplace_back(buildsMap["BH"]);
0258         builds.emplace_back(buildsMap["CE"]);
0259       } else {
0260         builds.emplace_back(buildsMap["STD"]);
0261         builds.emplace_back(buildsMap["CE"]);
0262       }
0263     } else if (SUITE == forConf) {
0264       builds.emplace_back(buildsMap["CE"]);
0265       builds.back().label = "mkFit";  // change label in legend for conference
0266     } else if (SUITE == val) {
0267       if (isBenchmark) {
0268         std::cout << "INFO: val mode has an empty set for isBenchmark" << std::endl;
0269       } else {
0270         builds.emplace_back(buildsMap["STD"]);
0271         builds.emplace_back(buildsMap["CE"]);
0272       }
0273     } else {
0274       std::cerr << "How did this happen?? You did not specify one of the allowed SUITEs!" << std::endl;
0275       exit(1);
0276     }
0277 
0278     // always check for adding in CMSSW --> never true for isBenchmark
0279     if (includeCMSSW)
0280       builds.emplace_back(buildsMap["CMSSW"]);
0281 
0282     // set nbuilds
0283     nbuilds = builds.size();
0284   }
0285 
0286 };  // namespace
0287 
0288 void GetMinMaxHist(const TH1F* hist, Double_t& min, Double_t& max) {
0289   for (auto ibin = 1; ibin <= hist->GetNbinsX(); ibin++) {
0290     const auto content = hist->GetBinContent(ibin);
0291 
0292     if (content < min && content != 0.0)
0293       min = content;
0294     if (content > max)
0295       max = content;
0296   }
0297 }
0298 
0299 void SetMinMaxHist(TH1F* hist, const Double_t min, const Double_t max, const Bool_t isLogy) {
0300   hist->SetMinimum(isLogy ? min / 2.0 : min / 1.05);
0301   hist->SetMaximum(isLogy ? max * 2.0 : max * 1.05);
0302 }
0303 
0304 #endif