File indexing completed on 2024-04-06 11:56:56
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
0046 enum AlignObj { IDEALAlign, RUN1Align, CRUZETAlign, CRAFTAlign, Coll0TAlign };
0047
0048 class TkAlStyle {
0049 public:
0050
0051 static void set(const PublicationStatus status,
0052 const Era era = NONE,
0053 const TString customTitle = "",
0054 const TString customRightTitle = "");
0055 static void set(const TString customTitle);
0056 static PublicationStatus status() { return publicationStatus_; }
0057
0058 static TString toTString(const PublicationStatus status);
0059 static TString toTString(const Era era);
0060 static TString toTString(const AlignObj obj);
0061
0062 static int color(const AlignObj obj);
0063 static int style(const AlignObj obj);
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 static void drawStandardTitle() {
0076 standardTitle()->Draw("same");
0077 standardRightTitle()->Draw("same");
0078 }
0079 static void drawStandardTitle(const Era era) {
0080 standardTitle()->Draw("same");
0081 standardRightTitle(era)->Draw("same");
0082 }
0083 static PublicationStatus toStatus(std::string _status);
0084
0085
0086
0087
0088
0089
0090 static TPaveText* standardTitle(PublicationStatus status) { return title(header(status)); }
0091 static TPaveText* standardTitle() { return standardTitle(publicationStatus_); }
0092
0093 static TPaveText* standardRightTitle(const Era era) { return righttitle(rightheader(era)); }
0094 static TPaveText* standardRightTitle() { return standardRightTitle(era_); }
0095
0096
0097
0098 static TPaveText* customTitle(const TString& txt) { return title(txt); }
0099 static TPaveText* customRightTitle(const TString& txt) { return righttitle(txt); }
0100
0101 static TString legendheader;
0102 static TString legendoptions;
0103 static double textSize;
0104
0105
0106
0107
0108 static TLegend* legend(const int nEntries, const double relWidth = 0.5) { return legendTR(nEntries, relWidth); }
0109 static TLegend* legend(TString position, const int nEntries, const double relWidth = 0.5) {
0110 position.ToLower();
0111 if (!(position.Contains("top") || position.Contains("bottom")))
0112 position += "top";
0113 if (!(position.Contains("left") || position.Contains("right")))
0114 position += "right";
0115 TLegend* leg = nullptr;
0116 if (position.Contains("top") && position.Contains("right")) {
0117 leg = legendTR(nEntries, relWidth);
0118 } else if (position.Contains("top") && position.Contains("left")) {
0119 leg = legendTL(nEntries, relWidth);
0120 } else if (position.Contains("bottom") && position.Contains("right")) {
0121 leg = legendBR(nEntries, relWidth);
0122 } else if (position.Contains("bottom") && position.Contains("left")) {
0123 leg = legendBL(nEntries, relWidth);
0124 } else {
0125 leg = legendTR(nEntries, relWidth);
0126 }
0127
0128 return leg;
0129 }
0130
0131 static TLegend* legendTL(const int nEntries, const double relWidth = 0.5) {
0132 return legend(nEntries, relWidth, true, true);
0133 }
0134 static TLegend* legendTR(const int nEntries, const double relWidth = 0.5) {
0135 return legend(nEntries, relWidth, false, true);
0136 }
0137 static TLegend* legendBL(const int nEntries, const double relWidth = 0.5) {
0138 return legend(nEntries, relWidth, true, false);
0139 }
0140 static TLegend* legendBR(const int nEntries, const double relWidth = 0.5) {
0141 return legend(nEntries, relWidth, false, false);
0142 }
0143
0144
0145
0146
0147
0148 static TPaveText* label(const int nEntries, const double relWidth = 0.5) { return labelTR(nEntries, relWidth); }
0149
0150 static TPaveText* label(TString position, const int nEntries, const double relWidth = 0.5) {
0151 position.ToLower();
0152 if (!(position.Contains("top") || position.Contains("bottom")))
0153 position += "top";
0154 if (!(position.Contains("left") || position.Contains("right")))
0155 position += "right";
0156 TPaveText* label = nullptr;
0157 if (position.Contains("top") && position.Contains("right")) {
0158 label = labelTR(nEntries, relWidth);
0159 } else if (position.Contains("top") && position.Contains("left")) {
0160 label = labelTL(nEntries, relWidth);
0161 } else if (position.Contains("bottom") && position.Contains("right")) {
0162 label = labelBR(nEntries, relWidth);
0163 } else if (position.Contains("bottom") && position.Contains("left")) {
0164 label = labelBL(nEntries, relWidth);
0165 } else {
0166 label = labelTR(nEntries, relWidth);
0167 }
0168
0169 return label;
0170 }
0171
0172
0173 static TPaveText* labelTL(const int nEntries, const double relWidth = 0.5) {
0174 return label(nEntries, relWidth, true, true);
0175 }
0176 static TPaveText* labelTR(const int nEntries, const double relWidth = 0.5) {
0177 return label(nEntries, relWidth, false, true);
0178 }
0179 static TPaveText* labelBL(const int nEntries, const double relWidth = 0.5) {
0180 return label(nEntries, relWidth, true, false);
0181 }
0182 static TPaveText* labelBR(const int nEntries, const double relWidth = 0.5) {
0183 return label(nEntries, relWidth, false, false);
0184 }
0185
0186 static double lineHeight() { return lineHeight_; }
0187
0188 private:
0189 static PublicationStatus publicationStatus_;
0190 static Era era_;
0191 static TString customTitle_;
0192 static TString customRightTitle_;
0193 static double lineHeight_;
0194 static double margin_;
0195
0196
0197 static TString applyCMS(const TString& txt);
0198 static TPaveText* title(const TString& txt);
0199 static TPaveText* righttitle(const TString& txt);
0200
0201
0202
0203 static TString header(const PublicationStatus status);
0204 static TString rightheader(const Era era);
0205
0206
0207 static void setXCoordinatesL(const double relWidth, double& x0, double& x1);
0208 static void setXCoordinatesR(const double relWidth, double& x0, double& x1);
0209 static void setYCoordinatesT(const int nEntries, double& y0, double& y1);
0210 static void setYCoordinatesB(const int nEntries, double& y0, double& y1);
0211
0212 static TLegend* legend(const int nEntries, const double relWidth, const bool left, const bool top);
0213 static TPaveText* label(const int nEntries, const double relWidth, const bool leftt, const bool top);
0214 };
0215
0216 #endif