ATLAS Offline Software
Macros | Functions
InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h File Reference
#include <vector>
#include <string>
#include <string.h>
#include <TStyle.h>
#include <TLatex.h>
#include <TMarker.h>
#include <TROOT.h>
Include dependency graph for InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:

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, bool pre=false, float textsize=0.05)
 
void DrawTitleLatex (const char *chartitle, float x, float y, int color=1, float textsize=0.04)
 
void DrawLegendLatex (const char *chartitle, int markertype, float x, float y, int color=1, float textsize=0.034)
 
void GetCoreParameters (const TH1 *hist, double &mean, double &mean_error, double &rms, double &rms_error, double &nentries)
 
TH1DrawHisto (const char *name, const char *options="", int color=1, int marker=20, float offset=0)
 
TH1DrawOneResidualDist (std::string name, int color, int marker, float offset)
 
TH1DrawOneResidualProfile (std::string name, int color, int marker, float offset)
 

Macro Definition Documentation

◆ def_Official

#define def_Official   false

◆ def_Preliminary

#define def_Preliminary   false

Function Documentation

◆ DrawATLASLabel()

void DrawATLASLabel ( float  x,
float  y,
bool  pre = false,
float  textsize = 0.05 
)
inline

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

85  {
86  TLatex ATLASLabel;
87  ATLASLabel.SetNDC();
88  ATLASLabel.SetTextFont(72);
89  ATLASLabel.SetTextSize(textsize);
90  //if(pre)
91  //ATLASLabel.DrawLatex(x,y,"ATLAS");
92  //ATLASLabel.DrawLatex(x,y-0.05,"work in progress");
93  //else ATLASLabel.DrawLatex(x,y,"ATLAS");
94 }

◆ DrawHisto()

TH1* DrawHisto ( const char *  name,
const char *  options = "",
int  color = 1,
int  marker = 20,
float  offset = 0 
)

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

178  {
179  TH1F *histo = (TH1F *)gDirectory->Get(name);
180  if(!histo) return 0;
181  histo->SetDirectory(gROOT);
182  histo->UseCurrentStyle();
183  histo->SetLineColor(color);
184  //histo->SetFillColor(color);
185  histo->SetMarkerColor(color);
186  histo->SetMarkerSize(1.8);
187  histo->SetMarkerStyle(marker);
188  histo->Draw(options);
189  if(offset == 0) DrawTitleLatex(histo->GetTitle(), 0.2, 0.85);
190  //DrawLegendLatex(histo->GetTitle(), marker, 0.7, 0.85 - offset ,color);
191  return histo;
192 
193 }

◆ DrawLegendLatex()

void DrawLegendLatex ( const char *  chartitle,
int  markertype,
float  x,
float  y,
int  color = 1,
float  textsize = 0.034 
)
inline

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

131  {
132 
133  TMarker *markerdot = new TMarker(x - 0.5 * textsize, y + 0.3 * textsize, markertype);
134  markerdot->SetNDC();
135  markerdot->SetMarkerColor(color);
136  markerdot->SetMarkerSize(40 * textsize);
137  markerdot->Draw(); // cannot use DrawMarker because it does not SetNDC()
138  //delete markerdot;
139 
140  DrawTitleLatex(chartitle, x, y, color, textsize);
141 }

◆ DrawOneResidualDist()

TH1* DrawOneResidualDist ( std::string  name,
int  color,
int  marker,
float  offset 
)

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

195  {
196  double mean;
197  double mean_error;
198  double rms;
199  double rms_error;
200  double nentries;
201 
202  std::string options = "P";
203  if(offset != 0) options = "Psame";
204  TH1 *histo = DrawHisto(name.c_str(),options.c_str(),color,marker,offset);
205  GetCoreParameters(histo, mean, mean_error, rms, rms_error, nentries);
206  histo->Scale(1/histo->GetEntries());
207  histo->GetYaxis()->SetTitle("Fraction of pixel clusters");
208  histo->GetXaxis()->SetTitle("Residual [#mum]");
209  std::ostringstream LegendString1;
210  LegendString1.flags(std::ios::fixed);
211  LegendString1 << name << " - ";
212  int precision = 1-int(log10(rms_error));
213  if(precision < 0) precision = 0;
214  LegendString1.precision(precision);
215  LegendString1 << "RMS: " << rms << " #pm " << rms_error << " #mum" << " - ";
216  precision = 1-int(log10(mean_error));
217  if(precision < 0) precision = 0;
218  LegendString1.precision(precision);
219  LegendString1 << "Mean: " << mean << " #pm " << mean_error << " #mum" << " - ";
220  DrawLegendLatex(LegendString1.str().c_str(), marker, 0.7, 0.85 - offset ,color);
221 }

◆ DrawOneResidualProfile()

TH1* DrawOneResidualProfile ( std::string  name,
int  color,
int  marker,
float  offset 
)

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

223  {
224  std::string options = "P";
225  if(offset != 0) options = "Psame";
226  TH1 *histo = DrawHisto(name.c_str(),options.c_str(),color,marker,offset);
227  histo->GetYaxis()->SetTitle("RMS of residuals [#mum]");
228  //histo->GetXaxis()->SetTitle("Residual [#mum]");
229  std::ostringstream LegendString1;
230  DrawLegendLatex(name.c_str(), marker, 0.6, 0.9 - offset ,color);
231 }

◆ DrawTitleLatex()

void DrawTitleLatex ( const char *  chartitle,
float  x,
float  y,
int  color = 1,
float  textsize = 0.04 
)
inline

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

100  {
101  char null = '\0';
102  TLatex TitleLabel;
103  TitleLabel.SetNDC();
104  TitleLabel.SetTextSize(textsize);
105  TitleLabel.SetTextColor(color);
106 
107  int i = 2; // understand this if you can...
108  int offset = 0;
109  int counter = 0;
110  char swap[100];
111  for(int i = 2; ; i++ ){ // will exit at the end of the string...
112  if(chartitle[i-2] == ' ' && chartitle[i-1] == '-' && chartitle[i] == ' '){
113  strncpy(swap, chartitle + offset, (i-2 - offset)*sizeof(char));
114  swap[(i-2 - offset)] = null ;
115  TitleLabel.DrawLatex(x, y-counter*(1.25)*textsize, swap);
116  offset = i+1;
117  counter++;
118  }else if(chartitle[i] == null ){
119  TitleLabel.DrawLatex(x, y-counter*(1.25)*textsize, chartitle + offset);
120  break;
121 
122  }
123  }
124 }

◆ GetCoreParameters()

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

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

145  {
146 
147  nentries = 0.;
148  mean = 0.;
149  mean_error = 0.;
150  rms = 0.;
151  rms_error = 0.;
152 
153  double axmin = hist->GetMean() - 3 * hist->GetRMS();
154  double axmax = hist->GetMean() + 3 * hist->GetRMS();
155  int nbins = hist->GetNbinsX();
156 
157  for (int i = 0 ; i < nbins; i++){
158  double value = hist->GetBinCenter(i+1);
159  double ientries = hist->GetBinContent(i+1);
160  if (value <= axmin) continue;
161  if (value >= axmax) break;
162  mean += value*ientries;
163  rms += value*value*ientries;
164  nentries += ientries;
165  }
166 
167  if (nentries > 0) {
168  mean = mean/nentries;
169  rms = sqrt(rms/nentries-mean*mean);
170  mean_error = rms / sqrt(nentries);
171  if(nentries > 1) rms_error = rms / sqrt(2*(nentries-1));
172  }
173 
174  return;
175 }

◆ SetAtlasStyle()

void SetAtlasStyle ( )
inline

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

17  {
18  TStyle *atlasStyle= new TStyle("ATLAS","Atlas style");
19 
20  // use plain black on white colors
21  Int_t icol=0;
22  atlasStyle->SetFrameBorderMode(icol);
23  atlasStyle->SetFrameFillColor(icol);
24  atlasStyle->SetCanvasBorderMode(icol);
25  atlasStyle->SetPadBorderMode(icol);
26  atlasStyle->SetPadColor(icol);
27  atlasStyle->SetCanvasColor(icol);
28  atlasStyle->SetStatColor(icol);
29  //atlasStyle->SetFillColor(icol);
30 
31  // set the paper & margin sizes
32  atlasStyle->SetPaperSize(20,26);
33  atlasStyle->SetPadTopMargin(0.05);
34  atlasStyle->SetPadRightMargin(0.05);
35  atlasStyle->SetPadBottomMargin(0.16);
36  atlasStyle->SetPadLeftMargin(0.12);
37 
38  // use large fonts
39  //Int_t font=72;
40  Int_t font=42;
41  Double_t tsize=0.05;
42  atlasStyle->SetTextFont(font);
43 
44 
45  atlasStyle->SetTextSize(tsize);
46  atlasStyle->SetLabelFont(font,"x");
47  atlasStyle->SetTitleFont(font,"x");
48  atlasStyle->SetLabelFont(font,"y");
49  atlasStyle->SetTitleFont(font,"y");
50  atlasStyle->SetLabelFont(font,"z");
51  atlasStyle->SetTitleFont(font,"z");
52 
53  atlasStyle->SetLabelSize(tsize,"x");
54  atlasStyle->SetTitleSize(tsize,"x");
55  atlasStyle->SetLabelSize(tsize,"y");
56  atlasStyle->SetTitleSize(tsize,"y");
57  atlasStyle->SetLabelSize(tsize,"z");
58  atlasStyle->SetTitleSize(tsize,"z");
59 
60 
61  //use bold lines and markers
62  atlasStyle->SetMarkerStyle(20);
63  atlasStyle->SetMarkerSize(1.2);
64  atlasStyle->SetHistLineWidth(2);
65  atlasStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
66 
67  //get rid of X error bars and y error bar caps
68  //atlasStyle->SetErrorX(0.001);
69 
70  //do not display any of the standard histogram decorations
71  atlasStyle->SetOptTitle(0);
72  //atlasStyle->SetOptStat(1111);
73  atlasStyle->SetOptStat(0);
74  //atlasStyle->SetOptFit(1111);
75  atlasStyle->SetOptFit(0);
76 
77  // put tick marks on top and RHS of plots
78  atlasStyle->SetPadTickX(1);
79  atlasStyle->SetPadTickY(1);
80 
81  gROOT->SetStyle("ATLAS");
82 
83 }
color
Definition: jFexInputByteStreamTool.cxx:25
mean
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="")
Definition: dependence.cxx:254
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
plotmaker.hist
hist
Definition: plotmaker.py:148
atlasStyleMacro.atlasStyle
atlasStyle
Definition: atlasStyleMacro.py:8
athena.value
value
Definition: athena.py:122
x
#define x
DrawLegendLatex
void DrawLegendLatex(const char *chartitle, int markertype, float x, float y, int color=1, float textsize=0.034)
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:127
python.Include.marker
string marker
Definition: Include.py:21
atlasStyleMacro.icol
int icol
Definition: atlasStyleMacro.py:13
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
PlotCalibFromCool.nentries
nentries
Definition: PlotCalibFromCool.py:798
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:92
DrawTitleLatex
void DrawTitleLatex(const char *chartitle, float x, float y, int color=1, float textsize=0.04)
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:97
GetCoreParameters
void GetCoreParameters(const TH1 *hist, double &mean, double &mean_error, double &rms, double &rms_error, double &nentries)
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:144
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
SH::MetaObject::swap
void swap(MetaObject &a, MetaObject &b)
standard swap
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
y
#define y
TH1F
Definition: rootspy.cxx:320
DeMoStatus.ATLASLabel
def ATLASLabel(x, y, text="")
ATLASLabel copied from atlastyle package, as import does not work for unknown reasons.
Definition: DeMoStatus.py:51
TH1
Definition: rootspy.cxx:268
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
plotBeamSpotMon.font
font
Definition: plotBeamSpotMon.py:80
atlasStyleMacro.tsize
float tsize
Definition: atlasStyleMacro.py:37
test_pyathena.counter
counter
Definition: test_pyathena.py:15
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
DrawHisto
TH1 * DrawHisto(const char *name, const char *options="", int color=1, int marker=20, float offset=0)
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:178