MINT2
HyperPlotStyle.cpp
Go to the documentation of this file.
1 #include "Mint/HyperPlotStyle.h"
2 
3 
5 
7 
8 }
9 
10 
12 
13  int ncontours = 100;
14  palette_pulls = new int [ncontours];
15  Double_t stops[4] = { 0.00, 0.45, 0.55, 1.00 };
16  Double_t red [4] = { 0.00, 1.00, 1.00, 1.00 };
17  Double_t green[4] = { 0.00, 1.00, 1.00, 0.00 };
18  Double_t blue [4] = { 1.00, 1.00, 1.00, 0.00 };
19  int FI = TColor::CreateGradientColorTable(4, stops, red, green, blue, ncontours);
20  for (int i=0;i<ncontours;i++) palette_pulls[i] = FI+i;
21 
22 }
23 
24 void HyperPlotStyle::setPalette(TString name){
25 
26  if (name == "pulls"){
27  gStyle->SetNumberContours(100);
28  gStyle->SetPalette(100, palette_pulls);
29  }
30  else{
31  gStyle->SetPalette(57);
32  }
33 
34  //kDeepSea=51, kGreyScale=52, kDarkBodyRadiator=53,
35  //kBlueYellow= 54, kRainBow=55, kInvertedDarkBodyRadiator=56,
36  //kBird=57, kCubehelix=58, kGreenRedViolet=59,
37  //kBlueRedYellow=60, kOcean=61, kColorPrintableOnGrey=62,
38  //kAlpine=63, kAquamarine=64, kArmy=65,
39  //kAtlantic=66, kAurora=67, kAvocado=68,
40  //kBeach=69, kBlackBody=70, kBlueGreenYellow=71,
41  //kBrownCyan=72, kCMYK=73, kCandy=74,
42  //kCherry=75, kCoffee=76, kDarkRainBow=77,
43  //kDarkTerrain=78, kFall=79, kFruitPunch=80,
44  //kFuchsia=81, kGreyYellow=82, kGreenBrownTerrain=83,
45  //kGreenPink=84, kIsland=85, kLake=86,
46  //kLightTemperature=87, kLightTerrain=88, kMint=89,
47  //kNeon=90, kPastel=91, kPearl=92,
48  //kPigeon=93, kPlum=94, kRedBlue=95,
49  //kRose=96, kRust=97, kSandyTerrain=98,
50  //kSienna=99, kSolar=100, kSouthWest=101,
51  //kStarryNight=102, kSunset=103, kTemperatureMap=104,
52  //kThermometer=105, kValentine=106, kVisibleSpectrum=107,
53  //kWaterMelon=108, kCool=109, kCopper=110,
54  //kGistEarth=111 kViridis=112
55 
56 
57 }
58 
60 
61  makePalettes();
62  LHCbStyle();
63 
64 }
65 
66 //This is just copied from LHCb style
67 void HyperPlotStyle::LHCbStyle(Bool_t colzPlot, Int_t NCont){
68 
69  colzPlot = true;
70  NCont++;
71 
72  // define names for colours
73  //Int_t black = 1;
74  //Int_t red = 2;
75  //Int_t green = 3;
76  //Int_t blue = 4;
77  //Int_t yellow = 5;
78  //Int_t magenta= 6;
79  //Int_t cyan = 7;
80  //Int_t purple = 9;
81 
82 
84  // PURPOSE:
85  //
86  // This macro defines a standard style for (black-and-white)
87  // "publication quality" LHCb ROOT plots.
88  //
89  // USAGE:
90  //
91  // Include the lines
92  // gROOT->ProcessLine(".L lhcbstyle.C");
93  // lhcbStyle();
94  // at the beginning of your root macro.
95  //
96  // Example usage is given in myPlot.C
97  //
98  // COMMENTS:
99  //
100  // Font:
101  //
102  // The font is chosen to be 132, this is Times New Roman (like the text of
103  // your document) with precision 2.
104  //
105  // "Landscape histograms":
106  //
107  // The style here is designed for more or less square plots.
108  // For longer histograms, or canvas with many pads, adjustements are needed.
109  // For instance, for a canvas with 1x5 histograms:
110  // TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800);
111  // c1->Divide(1,5);
112  // Adaptions like the following will be needed:
113  // gStyle->SetTickLength(0.05,"x");
114  // gStyle->SetTickLength(0.01,"y");
115  // gStyle->SetLabelSize(0.15,"x");
116  // gStyle->SetLabelSize(0.1,"y");
117  // gStyle->SetStatW(0.15);
118  // gStyle->SetStatH(0.5);
119  //
120  // Authors: Thomas Schietinger, Andrew Powell, Chris Parkes, Niels Tuning
121  // Maintained by Editorial board member (currently Niels)
123 
124  // Use times new roman, precision 2
125  Int_t lhcbFont = 132; // Old LHCb style: 62;
126  // Line thickness
127  Double_t lhcbWidth = 2.00; // Old LHCb style: 3.00;
128  // Text size
129  Double_t lhcbTSize = 0.06;
130 
131  // use plain black on white colors
132  gROOT->SetStyle("Plain");
133  TStyle *lhcbStyle= new TStyle("lhcbStyle","LHCb plots style");
134 
135  //lhcbStyle->SetErrorX(0); // don't suppress the error bar along X
136 
137  lhcbStyle->SetFillColor(1);
138  lhcbStyle->SetFillStyle(1001); // solid
139  lhcbStyle->SetFrameFillColor(0);
140  lhcbStyle->SetFrameBorderMode(0);
141  lhcbStyle->SetPadBorderMode(0);
142  lhcbStyle->SetPadColor(0);
143  lhcbStyle->SetCanvasBorderMode(0);
144  lhcbStyle->SetCanvasColor(0);
145  lhcbStyle->SetStatColor(0);
146  lhcbStyle->SetLegendBorderSize(0);
147  lhcbStyle->SetLegendFont(132);
148 
149  // If you want the usual gradient palette (blue -> red)
150  lhcbStyle->SetPalette(1);
151  // If you want colors that correspond to gray scale in black and white:
152  //int colors[8] = {0,5,7,3,6,2,4,1};
153  //lhcbStyle->SetPalette(8,colors);
154 
155  // set the paper & margin sizes
156  lhcbStyle->SetPaperSize(20,26);
157  lhcbStyle->SetPadTopMargin(0.05);
158  lhcbStyle->SetPadRightMargin(0.05); // increase for colz plots
159  lhcbStyle->SetPadBottomMargin(0.16);
160  lhcbStyle->SetPadLeftMargin(0.14);
161 
162  // use large fonts
163  lhcbStyle->SetTextFont(lhcbFont);
164  lhcbStyle->SetTextSize(lhcbTSize);
165  lhcbStyle->SetLabelFont(lhcbFont,"x");
166  lhcbStyle->SetLabelFont(lhcbFont,"y");
167  lhcbStyle->SetLabelFont(lhcbFont,"z");
168  lhcbStyle->SetLabelSize(lhcbTSize,"x");
169  lhcbStyle->SetLabelSize(lhcbTSize,"y");
170  lhcbStyle->SetLabelSize(lhcbTSize,"z");
171  lhcbStyle->SetTitleFont(lhcbFont);
172  lhcbStyle->SetTitleFont(lhcbFont,"x");
173  lhcbStyle->SetTitleFont(lhcbFont,"y");
174  lhcbStyle->SetTitleFont(lhcbFont,"z");
175  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"x");
176  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"y");
177  lhcbStyle->SetTitleSize(1.2*lhcbTSize,"z");
178 
179  // use medium bold lines and thick markers
180  lhcbStyle->SetLineWidth(lhcbWidth);
181  lhcbStyle->SetFrameLineWidth(lhcbWidth);
182  lhcbStyle->SetHistLineWidth(lhcbWidth);
183  lhcbStyle->SetFuncWidth(lhcbWidth);
184  lhcbStyle->SetGridWidth(lhcbWidth);
185  lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
186  //lhcbStyle->SetMarkerStyle(20);
187  lhcbStyle->SetMarkerStyle(8);
188  //lhcbStyle->SetMarkerSize(1.0);
189  lhcbStyle->SetMarkerSize(0.5); //Sam found these too big
190 
191  // label offsets
192  lhcbStyle->SetLabelOffset(0.010,"X");
193  lhcbStyle->SetLabelOffset(0.010,"Y");
194 
195  // by default, do not display histogram decorations:
196  lhcbStyle->SetOptStat(0);
197  //lhcbStyle->SetOptStat("emr"); // show only nent -e , mean - m , rms -r
198  // full opts at http://root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat
199  lhcbStyle->SetStatFormat("6.3g"); // specified as c printf options
200  lhcbStyle->SetOptTitle(0);
201  lhcbStyle->SetOptFit(0);
202  //lhcbStyle->SetOptFit(1011); // order is probability, Chi2, errors, parameters
203  //titles
204  lhcbStyle->SetTitleOffset(0.95,"X");
205  lhcbStyle->SetTitleOffset(0.95,"Y");
206  lhcbStyle->SetTitleOffset(1.2,"Z");
207  lhcbStyle->SetTitleFillColor(0);
208  lhcbStyle->SetTitleStyle(0);
209  lhcbStyle->SetTitleBorderSize(0);
210  lhcbStyle->SetTitleFont(lhcbFont,"title");
211  lhcbStyle->SetTitleX(0.0);
212  lhcbStyle->SetTitleY(1.0);
213  lhcbStyle->SetTitleW(1.0);
214  lhcbStyle->SetTitleH(0.05);
215 
216  // look of the statistics box:
217  lhcbStyle->SetStatBorderSize(0);
218  lhcbStyle->SetStatFont(lhcbFont);
219  lhcbStyle->SetStatFontSize(0.05);
220  lhcbStyle->SetStatX(0.9);
221  lhcbStyle->SetStatY(0.9);
222  lhcbStyle->SetStatW(0.25);
223  lhcbStyle->SetStatH(0.15);
224 
225  // put tick marks on top and RHS of plots
226  lhcbStyle->SetPadTickX(1);
227  lhcbStyle->SetPadTickY(1);
228 
229  // histogram divisions: only 5 in x to avoid label overlaps
230  lhcbStyle->SetNdivisions(505,"x");
231  lhcbStyle->SetNdivisions(510,"y");
232 
233  gROOT->SetStyle("lhcbStyle");
234  gROOT->ForceStyle();
235 
236  // add LHCb label
237  TPaveText* lhcbName = new TPaveText(gStyle->GetPadLeftMargin() + 0.05,
238  0.87 - gStyle->GetPadTopMargin(),
239  gStyle->GetPadLeftMargin() + 0.20,
240  0.95 - gStyle->GetPadTopMargin(),
241  "BRNDC");
242  lhcbName->AddText("LHCb");
243  lhcbName->SetFillColor(0);
244  lhcbName->SetTextAlign(12);
245  lhcbName->SetBorderSize(0);
246 
247  TText *lhcbLabel = new TText();
248  lhcbLabel->SetTextFont(lhcbFont);
249  lhcbLabel->SetTextColor(1);
250  lhcbLabel->SetTextSize(lhcbTSize);
251  lhcbLabel->SetTextAlign(12);
252 
253  TLatex *lhcbLatex = new TLatex();
254  lhcbLatex->SetTextFont(lhcbFont);
255  lhcbLatex->SetTextColor(1);
256  lhcbLatex->SetTextSize(lhcbTSize);
257  lhcbLatex->SetTextAlign(12);
258 
259  std::cout << "-------------------------" << std::endl;
260  std::cout << "Set LHCb Style - Feb 2012" << std::endl;
261  std::cout << "-------------------------" << std::endl;
262 
263 }
264 
266 
267 
268 }
269 
270 
271 
272 
static void setPalette(TString name)
static int * palette_pulls
static void makePalettes()
static void init()
static void LHCbStyle(Bool_t colzPlot=kFALSE, Int_t NCont=25)