File indexing completed on 2024-04-06 12:32:13
0001 #include "CMS_lumi.h"
0002 #include <iostream>
0003
0004 void CMS_lumi(TPad* pad, int iPeriod, int iPosX) {
0005 bool outOfFrame = false;
0006 if (iPosX / 10 == 0) {
0007 outOfFrame = true;
0008 }
0009 int alignY_ = 3;
0010 int alignX_ = 2;
0011 if (iPosX / 10 == 0)
0012 alignX_ = 1;
0013 if (iPosX == 0)
0014 alignX_ = 1;
0015 if (iPosX == 0)
0016 alignY_ = 1;
0017 if (iPosX / 10 == 1)
0018 alignX_ = 1;
0019 if (iPosX / 10 == 2)
0020 alignX_ = 2;
0021 if (iPosX / 10 == 3)
0022 alignX_ = 3;
0023 if (iPosX == 0)
0024 relPosX = 0.12;
0025 int align_ = 10 * alignX_ + alignY_;
0026
0027 float H = pad->GetWh();
0028 float W = pad->GetWw();
0029 float l = pad->GetLeftMargin();
0030 float t = pad->GetTopMargin();
0031 float r = pad->GetRightMargin();
0032 float b = pad->GetBottomMargin();
0033
0034
0035 pad->cd();
0036
0037 TString lumiText;
0038 if (iPeriod == 1) {
0039 lumiText += lumi_7TeV;
0040 lumiText += " (7 TeV)";
0041 } else if (iPeriod == 2) {
0042 lumiText += lumi_8TeV;
0043 lumiText += " (8 TeV)";
0044 } else if (iPeriod == 3) {
0045 lumiText = lumi_8TeV;
0046 lumiText += " (8 TeV)";
0047 lumiText += " + ";
0048 lumiText += lumi_7TeV;
0049 lumiText += " (7 TeV)";
0050 } else if (iPeriod == 4) {
0051 lumiText += lumi_13TeV;
0052 lumiText += " (13 TeV)";
0053 } else if (iPeriod == 7) {
0054 if (outOfFrame)
0055 lumiText += "#scale[0.85]{";
0056 lumiText += lumi_13TeV;
0057 lumiText += " (13 TeV)";
0058 lumiText += " + ";
0059 lumiText += lumi_8TeV;
0060 lumiText += " (8 TeV)";
0061 lumiText += " + ";
0062 lumiText += lumi_7TeV;
0063 lumiText += " (7 TeV)";
0064 if (outOfFrame)
0065 lumiText += "}";
0066 } else if (iPeriod == 12) {
0067 lumiText += "8 TeV";
0068 } else if (iPeriod == 0) {
0069 lumiText += lumi_sqrtS;
0070 }
0071
0072 std::cout << lumiText << endl;
0073
0074 TLatex latex;
0075 latex.SetNDC();
0076 latex.SetTextAngle(0);
0077 latex.SetTextColor(kBlack);
0078
0079 float extraTextSize = extraOverCmsTextSize * cmsTextSize;
0080
0081 latex.SetTextFont(42);
0082 latex.SetTextAlign(31);
0083 latex.SetTextSize(lumiTextSize * t);
0084 latex.DrawLatex(1 - r, 1 - t + lumiTextOffset * t, lumiText);
0085
0086 if (outOfFrame) {
0087 latex.SetTextFont(cmsTextFont);
0088 latex.SetTextAlign(11);
0089 latex.SetTextSize(cmsTextSize * t);
0090 latex.DrawLatex(l, 1 - t + lumiTextOffset * t, cmsText);
0091 }
0092
0093 pad->cd();
0094
0095 float posX_ = 0;
0096 if (iPosX % 10 <= 1) {
0097 posX_ = l + relPosX * (1 - l - r);
0098 } else if (iPosX % 10 == 2) {
0099 posX_ = l + 0.5 * (1 - l - r);
0100 } else if (iPosX % 10 == 3) {
0101 posX_ = 1 - r - relPosX * (1 - l - r);
0102 }
0103 float posY_ = 1 - t - relPosY * (1 - t - b);
0104 if (!outOfFrame) {
0105 if (drawLogo) {
0106 posX_ = l + 0.045 * (1 - l - r) * W / H;
0107 posY_ = 1 - t - 0.045 * (1 - t - b);
0108 float xl_0 = posX_;
0109 float yl_0 = posY_ - 0.15;
0110 float xl_1 = posX_ + 0.15 * H / W;
0111 float yl_1 = posY_;
0112 TASImage* CMS_logo = new TASImage("CMS-BW-label.png");
0113 TPad* pad_logo = new TPad("logo", "logo", xl_0, yl_0, xl_1, yl_1);
0114 pad_logo->Draw();
0115 pad_logo->cd();
0116 CMS_logo->Draw("X");
0117 pad_logo->Modified();
0118 pad->cd();
0119 } else {
0120 latex.SetTextFont(cmsTextFont);
0121 latex.SetTextSize(cmsTextSize * t);
0122 latex.SetTextAlign(align_);
0123 latex.DrawLatex(posX_, posY_, cmsText);
0124 if (writeExtraText) {
0125 latex.SetTextFont(extraTextFont);
0126 latex.SetTextAlign(align_);
0127 latex.SetTextSize(extraTextSize * t);
0128 latex.DrawLatex(posX_, posY_ - relExtraDY * cmsTextSize * t, extraText);
0129 }
0130 }
0131 } else if (writeExtraText) {
0132 if (iPosX == 0) {
0133 posX_ = l + relPosX * (1 - l - r);
0134 posY_ = 1 - t + lumiTextOffset * t;
0135 }
0136 latex.SetTextFont(extraTextFont);
0137 latex.SetTextSize(extraTextSize * t);
0138 latex.SetTextAlign(align_);
0139 latex.DrawLatex(posX_, posY_, extraText);
0140 }
0141 return;
0142 }