ATLAS Offline Software
Loading...
Searching...
No Matches
AtlasStyle.h File Reference
#include <vector>
#include <string>
#include <string_view>
#include <cmath>
#include <TStyle.h>
#include <TLatex.h>
#include <TMarker.h>
#include <TROOT.h>
Include dependency graph for InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/AtlasStyle.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define def_Preliminary   false
#define def_Official   false

Functions

void SetAtlasStyle ()
void DrawATLASLabel (float x, float y, float textsize=0.05, bool Preliminary=true)
void DrawTitleLatex (std::string_view chartitle, float x, float y, int color=1, float textsize=0.04)
void DrawLegendLatex (std::string_view chartitle, int markertype, float x, float y, int color=1, float textsize=0.03)
void GetCoreParameters (const TH1 *hist, double &mean, double &mean_error, double &rms, double &rms_error, double &nentries)

Macro Definition Documentation

◆ def_Official

#define def_Official   false

◆ def_Preliminary

#define def_Preliminary   false

Function Documentation

◆ DrawATLASLabel()

void DrawATLASLabel ( float x,
float y,
float textsize = 0.05,
bool Preliminary = true )
inline

Definition at line 86 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/AtlasStyle.h.

86 {
87 TLatex l; //l.SetTextAlign(12);
88 l.SetTextSize(textsize);
89 l.SetNDC();
90 l.SetTextFont(72);
91 l.SetTextColor(1);
92
93 double delx = 0.115*696*gPad->GetWh()/(472*gPad->GetWw());
94
95 l.DrawLatex(x,y,"ATLAS");
96 if (Preliminary) {
97 TLatex p;
98 p.SetNDC();
99 p.SetTextFont(42);
100 p.SetTextColor(1);
101 p.DrawLatex(x+delx,y,"Preliminary");
102 // p.DrawLatex(x,y,"#sqrt{s}=900GeV");
103 }
104}
#define y
#define x
l
Printing final latex table to .tex output file.

◆ DrawLegendLatex()

void DrawLegendLatex ( std::string_view chartitle,
int markertype,
float x,
float y,
int color = 1,
float textsize = 0.03 )
inline

Definition at line 134 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/AtlasStyle.h.

138 {
139
140 TMarker *markerdot = new TMarker(x - 0.4 * textsize, y + 0.2 * textsize, markertype);
141 markerdot->SetNDC();
142 markerdot->SetMarkerColor(color);
143 markerdot->SetMarkerSize(25 * textsize);
144 markerdot->Draw(); // cannot use DrawMarker because it does not SetNDC()
145 //delete markerdot;
146
147 DrawTitleLatex(chartitle, x, y, color, textsize);
148}
void DrawTitleLatex(std::string_view chartitle, float x, float y, int color=1, float textsize=0.04)

◆ DrawTitleLatex()

void DrawTitleLatex ( std::string_view chartitle,
float x,
float y,
int color = 1,
float textsize = 0.04 )
inline

Definition at line 108 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/AtlasStyle.h.

111 {
112 std::string left = std::string(chartitle);
113 std::vector<std::string> cuts;
114 std::string::size_type found = 0;
115 while(1){ // loop over the title, will exit with break
116 left = left.substr(found);
117 found = left.find(" - ");
118 if(found == std::string::npos){
119 cuts.push_back(std::move(left));
120 break;
121 }
122 cuts.push_back(left.substr(0,found));
123 found += 3; // take into account the delimiter " - "
124 }
125 TLatex TitleLabel;
126 TitleLabel.SetNDC();
127 TitleLabel.SetTextSize(textsize);
128 TitleLabel.SetTextColor(color);
129 for(unsigned int i = 0 ; i < cuts.size(); i++)
130 TitleLabel.DrawLatex(x,y-i*(1.25)*textsize,(cuts[i]).c_str());
131
132}

◆ GetCoreParameters()

void GetCoreParameters ( const TH1 * hist,
double & mean,
double & mean_error,
double & rms,
double & rms_error,
double & nentries )
inline

Definition at line 151 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/AtlasStyle.h.

152 {
153
154 nentries = 0.;
155 mean = 0.;
156 mean_error = 0.;
157 rms = 0.;
158 rms_error = 0.;
159
160 double axmin = hist->GetMean() - 3 * hist->GetRMS();
161 double axmax = hist->GetMean() + 3 * hist->GetRMS();
162 int nbins = hist->GetNbinsX();
163 int imean = 0;
164 hist->GetBinWithContent(hist->GetMean(), imean);
165 float binwidth = hist->GetBinWidth(imean);
166 if( fabs(axmax-axmin) < binwidth){
167 nentries = hist->GetEntries();
168 mean = hist->GetMean();
169 rms = binwidth/sqrt(12);
170 }else{
171 for (int i = 0 ; i < nbins; i++){
172 double value = hist->GetBinCenter(i+1);
173 double ientries = hist->GetBinContent(i+1);
174 if (value < axmin) continue;
175 if (value > axmax) break;
176 mean += value*ientries;
177 rms += value*value*ientries;
178 nentries += ientries;
179 }
180 if (nentries > 0) {
182 rms = sqrt(rms/nentries-mean*mean);
183 }
184 }
185
186 if (nentries > 0) {
187 mean_error = rms / sqrt(nentries);
188 if(nentries > 1) rms_error = rms / sqrt(2*(nentries-1));
189 }
190
191 return;
192}
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
bool binwidth
Definition listroot.cxx:58

◆ SetAtlasStyle()

void SetAtlasStyle ( )
inline

Definition at line 18 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/AtlasStyle.h.

18 {
19 TStyle *atlasStyle= new TStyle("ATLAS","Atlas style");
20
21 // use plain black on white colors
22 Int_t icol=0;
23 atlasStyle->SetFrameBorderMode(icol);
24 atlasStyle->SetCanvasBorderMode(icol);
25 atlasStyle->SetFrameFillColor(icol);
26 atlasStyle->SetPadBorderMode(icol);
27 atlasStyle->SetPadColor(icol);
28 atlasStyle->SetCanvasColor(icol);
29 atlasStyle->SetStatColor(icol);
30 //atlasStyle->SetFillColor(icol);
31
32 // set the paper & margin sizes
33 atlasStyle->SetPaperSize(20,26);
34 atlasStyle->SetPadTopMargin(0.05);
35 atlasStyle->SetPadRightMargin(0.05);
36 atlasStyle->SetPadBottomMargin(0.16);
37 atlasStyle->SetPadLeftMargin(0.12);
38
39 // use large fonts
40 //Int_t font=72;
41 Int_t font=42;
42 Double_t tsize=0.05;
43 atlasStyle->SetTextFont(font);
44
45
46 atlasStyle->SetTextSize(tsize);
47 atlasStyle->SetLabelFont(font,"x");
48 atlasStyle->SetTitleFont(font,"x");
49 atlasStyle->SetLabelFont(font,"y");
50 atlasStyle->SetTitleFont(font,"y");
51 atlasStyle->SetLabelFont(font,"z");
52 atlasStyle->SetTitleFont(font,"z");
53
54 atlasStyle->SetLabelSize(tsize,"x");
55 atlasStyle->SetTitleSize(tsize,"x");
56 atlasStyle->SetLabelSize(tsize,"y");
57 atlasStyle->SetTitleSize(tsize,"y");
58 atlasStyle->SetLabelSize(tsize,"z");
59 atlasStyle->SetTitleSize(tsize,"z");
60
61
62 //use bold lines and markers
63 atlasStyle->SetMarkerStyle(20);
64 atlasStyle->SetMarkerSize(1.2);
65 atlasStyle->SetHistLineWidth(2);
66 atlasStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
67
68 //get rid of X error bars and y error bar caps
69 //atlasStyle->SetErrorX(0.001);
70
71 //do not display any of the standard histogram decorations
72 atlasStyle->SetOptTitle(0);
73 //atlasStyle->SetOptStat(1111);
74 atlasStyle->SetOptStat(0);
75 //atlasStyle->SetOptFit(1111);
76 atlasStyle->SetOptFit(0);
77
78 // put tick marks on top and RHS of plots
79 atlasStyle->SetPadTickX(1);
80 atlasStyle->SetPadTickY(1);
81
82 gROOT->SetStyle("ATLAS");
83
84}