Newer
Older
TB_Chris / Kepler / options / ResStudies / .svn / text-base / lhcbStyle.C.svn-base
  1. // all users - please change the name of this file to lhcbStyle.C
  2. // Commits to lhcbdocs svn of .C files are not allowed
  3. {
  4.  
  5. // define names for colours
  6. Int_t black = 1;
  7. Int_t red = 2;
  8. Int_t green = 3;
  9. Int_t blue = 4;
  10. Int_t yellow = 5;
  11. Int_t magenta= 6;
  12. Int_t cyan = 7;
  13. Int_t purple = 9;
  14.  
  15. ////////////////////////////////////////////////////////////////////
  16. // PURPOSE:
  17. //
  18. // This macro defines a standard style for (black-and-white)
  19. // "publication quality" LHCb ROOT plots.
  20. //
  21. // USAGE:
  22. //
  23. // Include the lines
  24. // gROOT->ProcessLine(".L lhcbstyle.C");
  25. // lhcbStyle();
  26. // at the beginning of your root macro.
  27. //
  28. // Example usage is given in myPlot.C
  29. //
  30. // COMMENTS:
  31. //
  32. // Font:
  33. //
  34. // The font is chosen to be 132, this is Times New Roman (like the text of
  35. // your document) with precision 2.
  36. //
  37. // "Landscape histograms":
  38. //
  39. // The style here is designed for more or less square plots.
  40. // For longer histograms, or canvas with many pads, adjustements are needed.
  41. // For instance, for a canvas with 1x5 histograms:
  42. // TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800);
  43. // c1->Divide(1,5);
  44. // Adaptions like the following will be needed:
  45. // gStyle->SetTickLength(0.05,"x");
  46. // gStyle->SetTickLength(0.01,"y");
  47. // gStyle->SetLabelSize(0.15,"x");
  48. // gStyle->SetLabelSize(0.1,"y");
  49. // gStyle->SetStatW(0.15);
  50. // gStyle->SetStatH(0.5);
  51. //
  52. // Authors: Thomas Schietinger, Andrew Powell, Chris Parkes, Niels Tuning
  53. // Maintained by Editorial board member (currently Niels)
  54. ///////////////////////////////////////////////////////////////////
  55.  
  56. // Use times new roman, precision 2
  57. Int_t lhcbFont = 132; // Old LHCb style: 62;
  58. // Line thickness
  59. Double_t lhcbWidth = 2.00; // Old LHCb style: 3.00;
  60. // Text size
  61. Double_t lhcbTSize = 0.06;
  62. // use plain black on white colors
  63. gROOT->SetStyle("Plain");
  64. TStyle *lhcbStyle= new TStyle("lhcbStyle","LHCb plots style");
  65. //lhcbStyle->SetErrorX(0); // don't suppress the error bar along X
  66.  
  67. lhcbStyle->SetFillColor(1);
  68. lhcbStyle->SetFillStyle(1001); // solid
  69. lhcbStyle->SetFrameFillColor(0);
  70. lhcbStyle->SetFrameBorderMode(0);
  71. lhcbStyle->SetPadBorderMode(0);
  72. lhcbStyle->SetPadColor(0);
  73. lhcbStyle->SetCanvasBorderMode(0);
  74. lhcbStyle->SetCanvasColor(0);
  75. lhcbStyle->SetStatColor(0);
  76. lhcbStyle->SetLegendBorderSize(0);
  77. lhcbStyle->SetLegendFont(132);
  78.  
  79. // If you want the usual gradient palette (blue -> red)
  80. lhcbStyle->SetPalette(1);
  81. // If you want colors that correspond to gray scale in black and white:
  82. int colors[8] = {0,5,7,3,6,2,4,1};
  83. // lhcbStyle->SetPalette(8,colors);
  84.  
  85. // set the paper & margin sizes
  86. lhcbStyle->SetPaperSize(20,26);
  87. lhcbStyle->SetPadTopMargin(0.05);
  88. lhcbStyle->SetPadRightMargin(0.05); // increase for colz plots
  89. lhcbStyle->SetPadBottomMargin(0.16);
  90. lhcbStyle->SetPadLeftMargin(0.14);
  91. // use large fonts
  92. lhcbStyle->SetTextFont(lhcbFont);
  93. lhcbStyle->SetTextSize(lhcbTSize);
  94. lhcbStyle->SetLabelFont(lhcbFont,"x");
  95. lhcbStyle->SetLabelFont(lhcbFont,"y");
  96. lhcbStyle->SetLabelFont(lhcbFont,"z");
  97. lhcbStyle->SetLabelSize(lhcbTSize,"x");
  98. lhcbStyle->SetLabelSize(lhcbTSize,"y");
  99. lhcbStyle->SetLabelSize(lhcbTSize,"z");
  100. lhcbStyle->SetTitleFont(lhcbFont);
  101. lhcbStyle->SetTitleFont(lhcbFont,"x");
  102. lhcbStyle->SetTitleFont(lhcbFont,"y");
  103. lhcbStyle->SetTitleFont(lhcbFont,"z");
  104. lhcbStyle->SetTitleSize(1.2*lhcbTSize,"x");
  105. lhcbStyle->SetTitleSize(1.2*lhcbTSize,"y");
  106. lhcbStyle->SetTitleSize(1.2*lhcbTSize,"z");
  107.  
  108. // use medium bold lines and thick markers
  109. lhcbStyle->SetLineWidth(lhcbWidth);
  110. lhcbStyle->SetFrameLineWidth(lhcbWidth);
  111. lhcbStyle->SetHistLineWidth(lhcbWidth);
  112. lhcbStyle->SetFuncWidth(lhcbWidth);
  113. lhcbStyle->SetGridWidth(lhcbWidth);
  114. lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
  115. lhcbStyle->SetMarkerStyle(20);
  116. lhcbStyle->SetMarkerSize(1.0);
  117.  
  118. // label offsets
  119. lhcbStyle->SetLabelOffset(0.010,"X");
  120. lhcbStyle->SetLabelOffset(0.010,"Y");
  121.  
  122. // by default, do not display histogram decorations:
  123. lhcbStyle->SetOptStat(0);
  124. //lhcbStyle->SetOptStat("emr"); // show only nent -e , mean - m , rms -r
  125. // full opts at http://root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat
  126. lhcbStyle->SetStatFormat("6.3g"); // specified as c printf options
  127. lhcbStyle->SetOptTitle(0);
  128. lhcbStyle->SetOptFit(0);
  129. //lhcbStyle->SetOptFit(1011); // order is probability, Chi2, errors, parameters
  130. //titles
  131. lhcbStyle->SetTitleOffset(0.95,"X");
  132. lhcbStyle->SetTitleOffset(0.95,"Y");
  133. lhcbStyle->SetTitleOffset(1.2,"Z");
  134. lhcbStyle->SetTitleFillColor(0);
  135. lhcbStyle->SetTitleStyle(0);
  136. lhcbStyle->SetTitleBorderSize(0);
  137. lhcbStyle->SetTitleFont(lhcbFont,"title");
  138. lhcbStyle->SetTitleX(0.0);
  139. lhcbStyle->SetTitleY(1.0);
  140. lhcbStyle->SetTitleW(1.0);
  141. lhcbStyle->SetTitleH(0.05);
  142. // look of the statistics box:
  143. lhcbStyle->SetStatBorderSize(0);
  144. lhcbStyle->SetStatFont(lhcbFont);
  145. lhcbStyle->SetStatFontSize(0.05);
  146. lhcbStyle->SetStatX(0.9);
  147. lhcbStyle->SetStatY(0.9);
  148. lhcbStyle->SetStatW(0.25);
  149. lhcbStyle->SetStatH(0.15);
  150.  
  151. // put tick marks on top and RHS of plots
  152. lhcbStyle->SetPadTickX(1);
  153. lhcbStyle->SetPadTickY(1);
  154.  
  155. // histogram divisions: only 5 in x to avoid label overlaps
  156. lhcbStyle->SetNdivisions(505,"x");
  157. lhcbStyle->SetNdivisions(510,"y");
  158. gROOT->SetStyle("lhcbStyle");
  159. gROOT->ForceStyle();
  160.  
  161. // add LHCb label
  162. lhcbName = new TPaveText(gStyle->GetPadLeftMargin() + 0.05,
  163. 0.87 - gStyle->GetPadTopMargin(),
  164. gStyle->GetPadLeftMargin() + 0.20,
  165. 0.95 - gStyle->GetPadTopMargin(),
  166. "BRNDC");
  167. lhcbName->AddText("LHCb");
  168. lhcbName->SetFillColor(0);
  169. lhcbName->SetTextAlign(12);
  170. lhcbName->SetBorderSize(0);
  171.  
  172. TText *lhcbLabel = new TText();
  173. lhcbLabel->SetTextFont(lhcbFont);
  174. lhcbLabel->SetTextColor(1);
  175. lhcbLabel->SetTextSize(lhcbTSize);
  176. lhcbLabel->SetTextAlign(12);
  177.  
  178. TLatex *lhcbLatex = new TLatex();
  179. lhcbLatex->SetTextFont(lhcbFont);
  180. lhcbLatex->SetTextColor(1);
  181. lhcbLatex->SetTextSize(lhcbTSize);
  182. lhcbLatex->SetTextAlign(12);
  183.  
  184. cout << "-------------------------" << endl;
  185. cout << "Set LHCb Style - Feb 2012" << endl;
  186. cout << "-------------------------" << endl;
  187. }
  188.  
  189.