<commit_before>// @(#)root/hist:$Id$
// Author: <NAME>   18/05/95

#include <string.h>
#include <stdio.h>
#include <ctype.h>

#include "TH1.h"


//______________________________________________________________________________
Int_t TH1::AxisChoice( Option_t *axis) const
{
   // Choose an axis according to "axis".

   char achoice = toupper(axis[0]);
   if (achoice == 'X') return 1;
   if (achoice == 'Y') return 2;
   if (achoice == 'Z') return 3;
   return 0;
}


//______________________________________________________________________________
Int_t TH1::GetNdivisions( Option_t *axis) const
{
   // Return the number of divisions for "axis".

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetNdivisions();
   if (ax == 2) return fYaxis.GetNdivisions();
   if (ax == 3) return fZaxis.GetNdivisions();
   return 0;
}


//______________________________________________________________________________
Color_t TH1::GetAxisColor( Option_t *axis) const
{
   // Return the number of divisions for "axis".

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetAxisColor();
   if (ax == 2) return fYaxis.GetAxisColor();
   if (ax == 3) return fZaxis.GetAxisColor();
   return 0;
}


//______________________________________________________________________________
Color_t TH1::GetLabelColor( Option_t *axis) const
{
   // Return the "axis" label color.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetLabelColor();
   if (ax == 2) return fYaxis.GetLabelColor();
   if (ax == 3) return fZaxis.GetLabelColor();
   return 0;
}


//______________________________________________________________________________
Style_t TH1::GetLabelFont( Option_t *axis) const
{
   // Return the "axis" label font.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetLabelFont();
   if (ax == 2) return fYaxis.GetLabelFont();
   if (ax == 3) return fZaxis.GetLabelFont();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetLabelOffset( Option_t *axis) const
{
   // Return the "axis" label offset.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetLabelOffset();
   if (ax == 2) return fYaxis.GetLabelOffset();
   if (ax == 3) return fZaxis.GetLabelOffset();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetLabelSize( Option_t *axis) const
{
   // Return the "axis" label size.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetLabelSize();
   if (ax == 2) return fYaxis.GetLabelSize();
   if (ax == 3) return fZaxis.GetLabelSize();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetTickLength( Option_t *axis) const
{
   // Return the "axis" tick length.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetTickLength();
   if (ax == 2) return fYaxis.GetTickLength();
   if (ax == 3) return fZaxis.GetTickLength();
   return 0;
}


//______________________________________________________________________________
Style_t TH1::GetTitleFont( Option_t *axis) const
{
   // Return the "axis" title font.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetTitleFont();
   if (ax == 2) return fYaxis.GetTitleFont();
   if (ax == 3) return fZaxis.GetTitleFont();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetTitleOffset( Option_t *axis) const
{
   // Return the "axis" title offset.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetTitleOffset();
   if (ax == 2) return fYaxis.GetTitleOffset();
   if (ax == 3) return fZaxis.GetTitleOffset();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetTitleSize( Option_t *axis) const
{
   // Return the "axis" title size.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetTitleSize();
   if (ax == 2) return fYaxis.GetTitleSize();
   if (ax == 3) return fZaxis.GetTitleSize();
   return 0;
}


//______________________________________________________________________________
void TH1::SetNdivisions(Int_t n, Option_t *axis)
{
   // Set the number of divisions to draw an axis.
   //  ndiv      : Number of divisions.
   //
   //       n = N1 + 100*N2 + 10000*N3
   //       N1=number of primary divisions.
   //       N2=number of secondary divisions.
   //       N3=number of 3rd divisions.
   //           e.g.:
   //           nndi=0 --> no tick marks.
   //           nndi=2 --> 2 divisions, one tick mark in the middle
   //                      of the axis.
   // axis specifies which axis ("x","y","z"), default = "x"
   // if axis="xyz" set all 3 axes

   TString opt = axis;
   opt.ToLower();

   if (opt.Contains("x")) fXaxis.SetNdivisions(n);
   if (opt.Contains("y")) fYaxis.SetNdivisions(n);
   if (opt.Contains("z")) fZaxis.SetNdivisions(n);
}


//______________________________________________________________________________
void TH1::SetAxisColor(Color_t color, Option_t *axis)
{
   // Set color to draw the axis line and tick marks.
   // axis specifies which axis ("x","y","z"), default = "x"
   // if axis="xyz" set all 3 axes

   TString opt = axis;
   opt.ToLower();

   if (opt.Contains("x")) fXaxis.SetAxisColor(color);
   if (opt.Contains("y")) fYaxis.SetAxisColor(color);
   if (opt.Contains("z")) fZaxis.SetAxisColor(color);
}


//______________________________________________________________________________
void TH1::SetAxisRange(Axis_t xmin, Axis_t xmax, Option_t *axis)
{
   // Set the "axis" range.

   Int_t ax = AxisChoice(axis);
   TAxis *theAxis = 0;
   if (ax == 1) theAxis = GetXaxis();
   if (ax == 2) theAxis = GetYaxis();
   if (ax == 3) theAxis = GetZaxis();
   if (ax > fDimension) {
      SetMinimum(xmin);<commit_msg>Fix forward_null. coverity CID 11808<commit_after>// @(#)root/hist:$Id$
// Author: <NAME>   18/05/95

#include <string.h>
#include <stdio.h>
#include <ctype.h>

#include "TH1.h"


//______________________________________________________________________________
Int_t TH1::AxisChoice( Option_t *axis) const
{
   // Choose an axis according to "axis".

   char achoice = toupper(axis[0]);
   if (achoice == 'X') return 1;
   if (achoice == 'Y') return 2;
   if (achoice == 'Z') return 3;
   return 0;
}


//______________________________________________________________________________
Int_t TH1::GetNdivisions( Option_t *axis) const
{
   // Return the number of divisions for "axis".

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetNdivisions();
   if (ax == 2) return fYaxis.GetNdivisions();
   if (ax == 3) return fZaxis.GetNdivisions();
   return 0;
}


//______________________________________________________________________________
Color_t TH1::GetAxisColor( Option_t *axis) const
{
   // Return the number of divisions for "axis".

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetAxisColor();
   if (ax == 2) return fYaxis.GetAxisColor();
   if (ax == 3) return fZaxis.GetAxisColor();
   return 0;
}


//______________________________________________________________________________
Color_t TH1::GetLabelColor( Option_t *axis) const
{
   // Return the "axis" label color.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetLabelColor();
   if (ax == 2) return fYaxis.GetLabelColor();
   if (ax == 3) return fZaxis.GetLabelColor();
   return 0;
}


//______________________________________________________________________________
Style_t TH1::GetLabelFont( Option_t *axis) const
{
   // Return the "axis" label font.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetLabelFont();
   if (ax == 2) return fYaxis.GetLabelFont();
   if (ax == 3) return fZaxis.GetLabelFont();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetLabelOffset( Option_t *axis) const
{
   // Return the "axis" label offset.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetLabelOffset();
   if (ax == 2) return fYaxis.GetLabelOffset();
   if (ax == 3) return fZaxis.GetLabelOffset();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetLabelSize( Option_t *axis) const
{
   // Return the "axis" label size.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetLabelSize();
   if (ax == 2) return fYaxis.GetLabelSize();
   if (ax == 3) return fZaxis.GetLabelSize();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetTickLength( Option_t *axis) const
{
   // Return the "axis" tick length.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetTickLength();
   if (ax == 2) return fYaxis.GetTickLength();
   if (ax == 3) return fZaxis.GetTickLength();
   return 0;
}


//______________________________________________________________________________
Style_t TH1::GetTitleFont( Option_t *axis) const
{
   // Return the "axis" title font.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetTitleFont();
   if (ax == 2) return fYaxis.GetTitleFont();
   if (ax == 3) return fZaxis.GetTitleFont();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetTitleOffset( Option_t *axis) const
{
   // Return the "axis" title offset.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetTitleOffset();
   if (ax == 2) return fYaxis.GetTitleOffset();
   if (ax == 3) return fZaxis.GetTitleOffset();
   return 0;
}


//______________________________________________________________________________
Float_t TH1::GetTitleSize( Option_t *axis) const
{
   // Return the "axis" title size.

   Int_t ax = AxisChoice(axis);
   if (ax == 1) return fXaxis.GetTitleSize();
   if (ax == 2) return fYaxis.GetTitleSize();
   if (ax == 3) return fZaxis.GetTitleSize();
   return 0;
}


//______________________________________________________________________________
void TH1::SetNdivisions(Int_t n, Option_t *axis)
{
   // Set the number of divisions to draw an axis.
   //  ndiv      : Number of divisions.
   //
   //       n = N1 + 100*N2 + 10000*N3
   //       N1=number of primary divisions.
   //       N2=number of secondary divisions.
   //       N3=number of 3rd divisions.
   //           e.g.:
   //           nndi=0 --> no tick marks.
   //           nndi=2 --> 2 divisions, one tick mark in the middle
   //                      of the axis.
   // axis specifies which axis ("x","y","z"), default = "x"
   // if axis="xyz" set all 3 axes

   TString opt = axis;
   opt.ToLower();

   if (opt.Contains("x")) fXaxis.SetNdivisions(n);
   if (opt.Contains("y")) fYaxis.SetNdivisions(n);
   if (opt.Contains("z")) fZaxis.SetNdivisions(n);
}


//______________________________________________________________________________
void TH1::SetAxisColor(Color_t color, Option_t *axis)
{
   // Set color to draw the axis line and tick marks.
   // axis specifies which axis ("x","y","z"), default = "x"
   // if axis="xyz" set all 3 axes

   TString opt = axis;
   opt.ToLower();

   if (opt.Contains("x")) fXaxis.SetAxisColor(color);
   if (opt.Contains("y")) fYaxis.SetAxisColor(color);
   if (opt.Contains("z")) fZaxis.SetAxisColor(color);
}


//______________________________________________________________________________
void TH1::SetAxisRange(Axis_t xmin, Axis_t xmax, Option_t *axis)
{
   // Set the "axis" range.

   Int_t ax = AxisChoice(axis);
   TAxis *theAxis = 0;
   if (ax == 1) theAxis = GetXaxis();
   if (ax == 2) theAxis = GetYaxis();
   if (ax == 3) theAxis = GetZaxis();
   if (!theAxis) return;
   if (ax > fDimension) {
      SetMinimum(xmin);
{'fraction_non_alphanumeric': 0.12867834665759484, 'fraction_numerical': 0.015733968361966322, 'mean_word_length': 3.7491922455573508, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4500625', 'n_tokens_mistral': 3782, 'n_tokens_neox': 3569, 'n_words': 1010}