00001
00002
00003
00004 #include <string.h>
00005 #include <stdio.h>
00006 #include <ctype.h>
00007
00008 #include "TH1.h"
00009
00010
00011
00012 Int_t TH1::AxisChoice( Option_t *axis) const
00013 {
00014
00015
00016 char achoice = toupper(axis[0]);
00017 if (achoice == 'X') return 1;
00018 if (achoice == 'Y') return 2;
00019 if (achoice == 'Z') return 3;
00020 return 0;
00021 }
00022
00023
00024
00025 Int_t TH1::GetNdivisions( Option_t *axis) const
00026 {
00027
00028
00029 Int_t ax = AxisChoice(axis);
00030 if (ax == 1) return fXaxis.GetNdivisions();
00031 if (ax == 2) return fYaxis.GetNdivisions();
00032 if (ax == 3) return fZaxis.GetNdivisions();
00033 return 0;
00034 }
00035
00036
00037
00038 Color_t TH1::GetAxisColor( Option_t *axis) const
00039 {
00040
00041
00042 Int_t ax = AxisChoice(axis);
00043 if (ax == 1) return fXaxis.GetAxisColor();
00044 if (ax == 2) return fYaxis.GetAxisColor();
00045 if (ax == 3) return fZaxis.GetAxisColor();
00046 return 0;
00047 }
00048
00049
00050
00051 Color_t TH1::GetLabelColor( Option_t *axis) const
00052 {
00053
00054
00055 Int_t ax = AxisChoice(axis);
00056 if (ax == 1) return fXaxis.GetLabelColor();
00057 if (ax == 2) return fYaxis.GetLabelColor();
00058 if (ax == 3) return fZaxis.GetLabelColor();
00059 return 0;
00060 }
00061
00062
00063
00064 Style_t TH1::GetLabelFont( Option_t *axis) const
00065 {
00066
00067
00068 Int_t ax = AxisChoice(axis);
00069 if (ax == 1) return fXaxis.GetLabelFont();
00070 if (ax == 2) return fYaxis.GetLabelFont();
00071 if (ax == 3) return fZaxis.GetLabelFont();
00072 return 0;
00073 }
00074
00075
00076
00077 Float_t TH1::GetLabelOffset( Option_t *axis) const
00078 {
00079
00080
00081 Int_t ax = AxisChoice(axis);
00082 if (ax == 1) return fXaxis.GetLabelOffset();
00083 if (ax == 2) return fYaxis.GetLabelOffset();
00084 if (ax == 3) return fZaxis.GetLabelOffset();
00085 return 0;
00086 }
00087
00088
00089
00090 Float_t TH1::GetLabelSize( Option_t *axis) const
00091 {
00092
00093
00094 Int_t ax = AxisChoice(axis);
00095 if (ax == 1) return fXaxis.GetLabelSize();
00096 if (ax == 2) return fYaxis.GetLabelSize();
00097 if (ax == 3) return fZaxis.GetLabelSize();
00098 return 0;
00099 }
00100
00101
00102
00103 Float_t TH1::GetTickLength( Option_t *axis) const
00104 {
00105
00106
00107 Int_t ax = AxisChoice(axis);
00108 if (ax == 1) return fXaxis.GetTickLength();
00109 if (ax == 2) return fYaxis.GetTickLength();
00110 if (ax == 3) return fZaxis.GetTickLength();
00111 return 0;
00112 }
00113
00114
00115
00116 Style_t TH1::GetTitleFont( Option_t *axis) const
00117 {
00118
00119
00120 Int_t ax = AxisChoice(axis);
00121 if (ax == 1) return fXaxis.GetTitleFont();
00122 if (ax == 2) return fYaxis.GetTitleFont();
00123 if (ax == 3) return fZaxis.GetTitleFont();
00124 return 0;
00125 }
00126
00127
00128
00129 Float_t TH1::GetTitleOffset( Option_t *axis) const
00130 {
00131
00132
00133 Int_t ax = AxisChoice(axis);
00134 if (ax == 1) return fXaxis.GetTitleOffset();
00135 if (ax == 2) return fYaxis.GetTitleOffset();
00136 if (ax == 3) return fZaxis.GetTitleOffset();
00137 return 0;
00138 }
00139
00140
00141
00142 Float_t TH1::GetTitleSize( Option_t *axis) const
00143 {
00144
00145
00146 Int_t ax = AxisChoice(axis);
00147 if (ax == 1) return fXaxis.GetTitleSize();
00148 if (ax == 2) return fYaxis.GetTitleSize();
00149 if (ax == 3) return fZaxis.GetTitleSize();
00150 return 0;
00151 }
00152
00153
00154
00155 void TH1::SetNdivisions(Int_t n, Option_t *axis)
00156 {
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 TString opt = axis;
00172 opt.ToLower();
00173
00174 if (opt.Contains("x")) fXaxis.SetNdivisions(n);
00175 if (opt.Contains("y")) fYaxis.SetNdivisions(n);
00176 if (opt.Contains("z")) fZaxis.SetNdivisions(n);
00177 }
00178
00179
00180
00181 void TH1::SetAxisColor(Color_t color, Option_t *axis)
00182 {
00183
00184
00185
00186
00187 TString opt = axis;
00188 opt.ToLower();
00189
00190 if (opt.Contains("x")) fXaxis.SetAxisColor(color);
00191 if (opt.Contains("y")) fYaxis.SetAxisColor(color);
00192 if (opt.Contains("z")) fZaxis.SetAxisColor(color);
00193 }
00194
00195
00196
00197 void TH1::SetAxisRange(Axis_t xmin, Axis_t xmax, Option_t *axis)
00198 {
00199
00200
00201 Int_t ax = AxisChoice(axis);
00202 TAxis *theAxis = 0;
00203 if (ax == 1) theAxis = GetXaxis();
00204 if (ax == 2) theAxis = GetYaxis();
00205 if (ax == 3) theAxis = GetZaxis();
00206 if (!theAxis) return;
00207 if (ax > fDimension) {
00208 SetMinimum(xmin);
00209 SetMaximum(xmax);
00210 return;
00211 }
00212 Int_t bin1 = theAxis->FindFixBin(xmin);
00213 Int_t bin2 = theAxis->FindFixBin(xmax);
00214 theAxis->SetRange(bin1, bin2);
00215 }
00216
00217
00218
00219 void TH1::SetLabelColor(Color_t color, Option_t *axis)
00220 {
00221
00222
00223
00224
00225 TString opt = axis;
00226 opt.ToLower();
00227
00228 if (opt.Contains("x")) fXaxis.SetLabelColor(color);
00229 if (opt.Contains("y")) fYaxis.SetLabelColor(color);
00230 if (opt.Contains("z")) fZaxis.SetLabelColor(color);
00231 }
00232
00233
00234
00235 void TH1::SetLabelFont(Style_t font, Option_t *axis)
00236 {
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 TString opt = axis;
00247 opt.ToLower();
00248
00249 if (opt.Contains("x")) fXaxis.SetLabelFont(font);
00250 if (opt.Contains("y")) fYaxis.SetLabelFont(font);
00251 if (opt.Contains("z")) fZaxis.SetLabelFont(font);
00252 }
00253
00254
00255
00256 void TH1::SetLabelOffset(Float_t offset, Option_t *axis)
00257 {
00258
00259
00260
00261
00262
00263 TString opt = axis;
00264 opt.ToLower();
00265
00266 if (opt.Contains("x")) fXaxis.SetLabelOffset(offset);
00267 if (opt.Contains("y")) fYaxis.SetLabelOffset(offset);
00268 if (opt.Contains("z")) fZaxis.SetLabelOffset(offset);
00269 }
00270
00271
00272
00273 void TH1::SetLabelSize(Float_t size, Option_t *axis)
00274 {
00275
00276
00277
00278
00279
00280 TString opt = axis;
00281 opt.ToLower();
00282
00283 if (opt.Contains("x")) fXaxis.SetLabelSize(size);
00284 if (opt.Contains("y")) fYaxis.SetLabelSize(size);
00285 if (opt.Contains("z")) fZaxis.SetLabelSize(size);
00286 }
00287
00288
00289
00290 void TH1::SetTickLength(Float_t length, Option_t *axis)
00291 {
00292
00293
00294
00295
00296 TString opt = axis;
00297 opt.ToLower();
00298
00299 if (opt.Contains("x")) fXaxis.SetTickLength(length);
00300 if (opt.Contains("y")) fYaxis.SetTickLength(length);
00301 if (opt.Contains("z")) fZaxis.SetTickLength(length);
00302 }
00303
00304
00305
00306 void TH1::SetTitleFont(Style_t font, Option_t *axis)
00307 {
00308
00309
00310
00311
00312
00313
00314
00315
00316 TString opt = axis;
00317 opt.ToLower();
00318
00319 if (opt.Contains("x")) fXaxis.SetTitleFont(font);
00320 if (opt.Contains("y")) fYaxis.SetTitleFont(font);
00321 if (opt.Contains("z")) fZaxis.SetTitleFont(font);
00322 }
00323
00324
00325
00326 void TH1::SetTitleOffset(Float_t offset, Option_t *axis)
00327 {
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337 TString opt = axis;
00338 opt.ToLower();
00339
00340 if (opt.Contains("x")) fXaxis.SetTitleOffset(offset);
00341 if (opt.Contains("y")) fYaxis.SetTitleOffset(offset);
00342 if (opt.Contains("z")) fZaxis.SetTitleOffset(offset);
00343 }
00344
00345
00346
00347 void TH1::SetTitleSize(Float_t size, Option_t *axis)
00348 {
00349
00350
00351
00352
00353
00354
00355
00356 TString opt = axis;
00357 opt.ToLower();
00358
00359 if (opt.Contains("x")) fXaxis.SetTitleSize(size);
00360 if (opt.Contains("y")) fYaxis.SetTitleSize(size);
00361 if (opt.Contains("z")) fZaxis.SetTitleSize(size);
00362 }