CMS 3D CMS Logo

CMS_lumi.h
Go to the documentation of this file.
1 #ifndef _ALIGNMENT_OFFLINEVALIDATION_CMS_LUMI_H_
2 #define _ALIGNMENT_OFFLINEVALIDATION_CMS_LUMI_H_
3 
4 #include "TPad.h"
5 #include "TLatex.h"
6 #include "TLine.h"
7 #include "TBox.h"
8 #include <iostream>
9 
10 //
11 // Global variables
12 //
13 
14 TString cmsText = "CMS";
15 float cmsTextFont = 61; // default is helvetic-bold
16 
17 bool writeExtraText = false;
18 TString extraText = "Preliminary";
19 float extraTextFont = 52; // default is helvetica-italics
20 
21 // text sizes and text offsets with respect to the top frame
22 // in unit of the top margin size
23 float lumiTextSize = 0.6;
24 float lumiTextOffset = 0.2;
25 float cmsTextSize = 0.75;
26 float cmsTextOffset = 0.1; // only used in outOfFrame version
27 
28 float relPosX = 0.045;
29 float relPosY = 0.035;
30 float relExtraDY = 1.2;
31 
32 // ratio of "CMS" and extra text size
33 float extraOverCmsTextSize = 0.76;
34 
35 TString lumi_13TeV = "20.1 fb^{-1}";
36 TString lumi_8TeV = "19.7 fb^{-1}";
37 TString lumi_7TeV = "5.1 fb^{-1}";
38 TString lumi_sqrtS = "";
39 bool drawLogo = false;
40 
41 void CMS_lumi(TPad* pad, int iPeriod = 3, int iPosX = 10);
42 
43 void CMS_lumi(TPad* pad, int iPeriod, int iPosX) {
44  bool outOfFrame = false;
45  if (iPosX / 10 == 0) {
46  outOfFrame = true;
47  }
48  int alignY_ = 3;
49  int alignX_ = 2;
50  if (iPosX / 10 == 0)
51  alignX_ = 1;
52  if (iPosX == 0)
53  alignX_ = 1;
54  if (iPosX == 0)
55  alignY_ = 1;
56  if (iPosX / 10 == 1)
57  alignX_ = 1;
58  if (iPosX / 10 == 2)
59  alignX_ = 2;
60  if (iPosX / 10 == 3)
61  alignX_ = 3;
62  //if( iPosX == 0 ) relPosX = 0.12;
63  int align_ = 10 * alignX_ + alignY_;
64 
65  float H = pad->GetWh();
66  float W = pad->GetWw();
67  float l = pad->GetLeftMargin();
68  float t = pad->GetTopMargin();
69  float r = pad->GetRightMargin();
70  float b = pad->GetBottomMargin();
71  // float e = 0.025;
72 
73  pad->cd();
74 
75  TString lumiText;
76  if (iPeriod == 1) {
77  lumiText += lumi_7TeV;
78  lumiText += " (7 TeV)";
79  } else if (iPeriod == 2) {
80  lumiText += lumi_8TeV;
81  lumiText += " (8 TeV)";
82  } else if (iPeriod == 3) {
83  lumiText = lumi_8TeV;
84  lumiText += " (8 TeV)";
85  lumiText += " + ";
86  lumiText += lumi_7TeV;
87  lumiText += " (7 TeV)";
88  } else if (iPeriod == 4) {
89  lumiText += lumi_13TeV;
90  lumiText += " (#sqrt{s} = 13 TeV)";
91  } else if (iPeriod == 7) {
92  if (outOfFrame)
93  lumiText += "#scale[0.85]{";
94  lumiText += lumi_13TeV;
95  lumiText += " (13 TeV)";
96  lumiText += " + ";
97  lumiText += lumi_8TeV;
98  lumiText += " (8 TeV)";
99  lumiText += " + ";
100  lumiText += lumi_7TeV;
101  lumiText += " (7 TeV)";
102  if (outOfFrame)
103  lumiText += "}";
104  } else if (iPeriod == 12) {
105  lumiText += "8 TeV";
106  } else if (iPeriod == 0) {
107  lumiText += lumi_sqrtS;
108  }
109 
110  std::cout << lumiText << std::endl;
111 
112  TLatex latex;
113  latex.SetNDC();
114  latex.SetTextAngle(0);
115  latex.SetTextColor(kBlack);
116 
117  float extraTextSize = extraOverCmsTextSize * cmsTextSize;
118 
119  latex.SetTextFont(42);
120  latex.SetTextAlign(31);
121  latex.SetTextSize(lumiTextSize * t);
122  latex.DrawLatex(1 - r, 1 - t + lumiTextOffset * t, lumiText);
123 
124  if (outOfFrame) {
125  latex.SetTextFont(cmsTextFont);
126  latex.SetTextAlign(11);
127  latex.SetTextSize(cmsTextSize * t);
128  latex.DrawLatex(l, 1 - t + lumiTextOffset * t, cmsText);
129  }
130 
131  pad->cd();
132 
133  float posX_ = 0;
134  if (iPosX % 10 <= 1) {
135  posX_ = l + relPosX * (1 - l - r);
136  } else if (iPosX % 10 == 2) {
137  posX_ = l + 0.5 * (1 - l - r);
138  } else if (iPosX % 10 == 3) {
139  posX_ = 1 - r - relPosX * (1 - l - r);
140  }
141  float posY_ = 1 - t - relPosY * (1 - t - b);
142  if (!outOfFrame) {
143  if (drawLogo) {
144  posX_ = l + 0.045 * (1 - l - r) * W / H;
145  posY_ = 1 - t - 0.045 * (1 - t - b);
146  float xl_0 = posX_;
147  float yl_0 = posY_ - 0.15;
148  float xl_1 = posX_ + 0.15 * H / W;
149  float yl_1 = posY_;
150  TPad* pad_logo = new TPad("logo", "logo", xl_0, yl_0, xl_1, yl_1);
151  pad_logo->Draw();
152  pad_logo->cd();
153  pad_logo->Modified();
154  pad->cd();
155  } else {
156  latex.SetTextFont(cmsTextFont);
157  latex.SetTextSize(cmsTextSize * t);
158  latex.SetTextAlign(align_);
159  latex.DrawLatex(posX_, posY_, cmsText);
160  if (writeExtraText) {
161  latex.SetTextFont(extraTextFont);
162  latex.SetTextAlign(align_);
163  latex.SetTextSize(extraTextSize * t);
164  latex.DrawLatex(posX_, posY_ - relExtraDY * cmsTextSize * t, extraText);
165  }
166  }
167  } else if (writeExtraText) {
168  if (iPosX == 0) {
169  posX_ = l + relPosX * (1 - l - r);
170  posY_ = 1 - t + lumiTextOffset * t;
171  }
172  latex.SetTextFont(extraTextFont);
173  latex.SetTextSize(extraTextSize * t);
174  latex.SetTextAlign(align_);
175  latex.DrawLatex(posX_, posY_, extraText);
176  }
177  return;
178 }
179 
180 #endif
class-composition.H
H
Definition: class-composition.py:31
lumiTextSize
float lumiTextSize
Definition: CMS_lumi.h:23
extraText
TString extraText
Definition: CMS_lumi.h:18
gather_cfg.cout
cout
Definition: gather_cfg.py:144
relPosY
float relPosY
Definition: CMS_lumi.h:29
relPosX
float relPosX
Definition: CMS_lumi.h:28
cmsTextOffset
float cmsTextOffset
Definition: CMS_lumi.h:26
cmsText
TString cmsText
Definition: CMS_lumi.h:14
lumi_7TeV
TString lumi_7TeV
Definition: CMS_lumi.h:37
lumi_8TeV
TString lumi_8TeV
Definition: CMS_lumi.h:36
b
double b
Definition: hdecay.h:118
writeExtraText
bool writeExtraText
Definition: CMS_lumi.h:17
lumi_sqrtS
TString lumi_sqrtS
Definition: CMS_lumi.h:38
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
cmsTextSize
float cmsTextSize
Definition: CMS_lumi.h:25
alignCSCRings.r
r
Definition: alignCSCRings.py:93
relExtraDY
float relExtraDY
Definition: CMS_lumi.h:30
extraOverCmsTextSize
float extraOverCmsTextSize
Definition: CMS_lumi.h:33
CMS_lumi
void CMS_lumi(TPad *pad, int iPeriod=3, int iPosX=10)
Definition: CMS_lumi.h:43
drawLogo
bool drawLogo
Definition: CMS_lumi.h:39
lumi_13TeV
TString lumi_13TeV
Definition: CMS_lumi.h:35
extraTextFont
float extraTextFont
Definition: CMS_lumi.h:19
cmsTextFont
float cmsTextFont
Definition: CMS_lumi.h:15
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
lumiTextOffset
float lumiTextOffset
Definition: CMS_lumi.h:24