File indexing completed on 2023-03-17 10:40:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef ALIGNMENT_OFFLINEVALIDATION_TKAL_STYLE_H
0018 #define ALIGNMENT_OFFLINEVALIDATION_TKAL_STYLE_H
0019
0020 #include "TColor.h"
0021 #include "TError.h"
0022 #include "TLegend.h"
0023 #include "TPaveText.h"
0024 #include "TString.h"
0025 #include "TStyle.h"
0026 #include <iostream>
0027 #include <string>
0028 #include <algorithm>
0029
0030
0031 enum PublicationStatus {
0032 NO_STATUS,
0033 INTERNAL,
0034 INTERNAL_SIMULATION,
0035 PRELIMINARY,
0036 PUBLIC,
0037 SIMULATION,
0038 UNPUBLISHED,
0039 CUSTOM
0040 };
0041
0042
0043 enum Era { NONE, CRUZET15, CRAFT15, COLL0T15 };
0044
0045 class TkAlStyle {
0046 public:
0047
0048 static void set(const PublicationStatus status,
0049 const Era era = NONE,
0050 const TString customTitle = "",
0051 const TString customRightTitle = "");
0052 static void set(const TString customTitle);
0053 static PublicationStatus status() { return publicationStatus_; }
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 static void drawStandardTitle() {
0066 standardTitle()->Draw("same");
0067 standardRightTitle()->Draw("same");
0068 }
0069 static void drawStandardTitle(const Era era) {
0070 standardTitle()->Draw("same");
0071 standardRightTitle(era)->Draw("same");
0072 }
0073 static PublicationStatus toStatus(std::string _status);
0074
0075
0076
0077
0078
0079
0080 static TPaveText* standardTitle(PublicationStatus status) { return title(header(status)); }
0081 static TPaveText* standardTitle() { return standardTitle(publicationStatus_); }
0082
0083 static TPaveText* standardRightTitle(const Era era) { return righttitle(rightheader(era)); }
0084 static TPaveText* standardRightTitle() { return standardRightTitle(era_); }
0085
0086
0087
0088 static TPaveText* customTitle(const TString& txt) { return title(txt); }
0089 static TPaveText* customRightTitle(const TString& txt) { return righttitle(txt); }
0090
0091 static TString legendheader;
0092 static TString legendoptions;
0093 static double textSize;
0094
0095
0096
0097
0098 static TLegend* legend(const int nEntries, const double relWidth = 0.5) { return legendTR(nEntries, relWidth); }
0099 static TLegend* legend(TString position, const int nEntries, const double relWidth = 0.5) {
0100 position.ToLower();
0101 if (!(position.Contains("top") || position.Contains("bottom")))
0102 position += "top";
0103 if (!(position.Contains("left") || position.Contains("right")))
0104 position += "right";
0105 TLegend* leg = nullptr;
0106 if (position.Contains("top") && position.Contains("right")) {
0107 leg = legendTR(nEntries, relWidth);
0108 } else if (position.Contains("top") && position.Contains("left")) {
0109 leg = legendTL(nEntries, relWidth);
0110 } else if (position.Contains("bottom") && position.Contains("right")) {
0111 leg = legendBR(nEntries, relWidth);
0112 } else if (position.Contains("bottom") && position.Contains("left")) {
0113 leg = legendBL(nEntries, relWidth);
0114 } else {
0115 leg = legendTR(nEntries, relWidth);
0116 }
0117
0118 return leg;
0119 }
0120
0121 static TLegend* legendTL(const int nEntries, const double relWidth = 0.5) {
0122 return legend(nEntries, relWidth, true, true);
0123 }
0124 static TLegend* legendTR(const int nEntries, const double relWidth = 0.5) {
0125 return legend(nEntries, relWidth, false, true);
0126 }
0127 static TLegend* legendBL(const int nEntries, const double relWidth = 0.5) {
0128 return legend(nEntries, relWidth, true, false);
0129 }
0130 static TLegend* legendBR(const int nEntries, const double relWidth = 0.5) {
0131 return legend(nEntries, relWidth, false, false);
0132 }
0133
0134
0135
0136
0137
0138 static TPaveText* label(const int nEntries, const double relWidth = 0.5) { return labelTR(nEntries, relWidth); }
0139
0140 static TPaveText* label(TString position, const int nEntries, const double relWidth = 0.5) {
0141 position.ToLower();
0142 if (!(position.Contains("top") || position.Contains("bottom")))
0143 position += "top";
0144 if (!(position.Contains("left") || position.Contains("right")))
0145 position += "right";
0146 TPaveText* label = nullptr;
0147 if (position.Contains("top") && position.Contains("right")) {
0148 label = labelTR(nEntries, relWidth);
0149 } else if (position.Contains("top") && position.Contains("left")) {
0150 label = labelTL(nEntries, relWidth);
0151 } else if (position.Contains("bottom") && position.Contains("right")) {
0152 label = labelBR(nEntries, relWidth);
0153 } else if (position.Contains("bottom") && position.Contains("left")) {
0154 label = labelBL(nEntries, relWidth);
0155 } else {
0156 label = labelTR(nEntries, relWidth);
0157 }
0158
0159 return label;
0160 }
0161
0162
0163 static TPaveText* labelTL(const int nEntries, const double relWidth = 0.5) {
0164 return label(nEntries, relWidth, true, true);
0165 }
0166 static TPaveText* labelTR(const int nEntries, const double relWidth = 0.5) {
0167 return label(nEntries, relWidth, false, true);
0168 }
0169 static TPaveText* labelBL(const int nEntries, const double relWidth = 0.5) {
0170 return label(nEntries, relWidth, true, false);
0171 }
0172 static TPaveText* labelBR(const int nEntries, const double relWidth = 0.5) {
0173 return label(nEntries, relWidth, false, false);
0174 }
0175
0176 static double lineHeight() { return lineHeight_; }
0177
0178 private:
0179 static PublicationStatus publicationStatus_;
0180 static Era era_;
0181 static TString customTitle_;
0182 static TString customRightTitle_;
0183 static double lineHeight_;
0184 static double margin_;
0185
0186
0187 static TString applyCMS(const TString& txt);
0188 static TPaveText* title(const TString& txt);
0189 static TPaveText* righttitle(const TString& txt);
0190
0191
0192
0193 static TString header(const PublicationStatus status);
0194 static TString rightheader(const Era era);
0195
0196
0197 static void setXCoordinatesL(const double relWidth, double& x0, double& x1);
0198 static void setXCoordinatesR(const double relWidth, double& x0, double& x1);
0199 static void setYCoordinatesT(const int nEntries, double& y0, double& y1);
0200 static void setYCoordinatesB(const int nEntries, double& y0, double& y1);
0201
0202 static TLegend* legend(const int nEntries, const double relWidth, const bool left, const bool top);
0203 static TPaveText* label(const int nEntries, const double relWidth, const bool leftt, const bool top);
0204 };
0205
0206 #endif