Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plot_commons.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plot_commons.h
1 /* Header file with useful functions for plotting */
2 
3 /*------------------------------------------*/
4 /*------------Create Histogram--------------*/
5 /*------------------------------------------*/
9 /*------------------------------------------*/
10 TH2F* make_TH2D_xylog( int x_nbins, int x_min, int x_max, int y_nbins, int y_min, int y_max )
11 {
12  TH2F* hnew = new TH2F("hnew", "", x_nbins, x_min, x_max, y_nbins, y_min, y_max );
13  TAxis *xaxis = hnew->GetXaxis();
14  TAxis *yaxis = hnew->GetYaxis();
15  int xbins = xaxis->GetNbins();
16  int ybins = yaxis->GetNbins();
17 
18  Axis_t xmin = xaxis->GetXmin();
19  Axis_t xmax = xaxis->GetXmax();
20  Axis_t xwidth = (xmax - xmin ) / xbins;
21  Axis_t *new_xbins = new Axis_t[xbins + 1];
22 
23  Axis_t ymin = yaxis->GetXmin();
24  Axis_t ymax = yaxis->GetXmax();
25  Axis_t ywidth = (ymax - ymin) / ybins;
26  Axis_t *new_ybins = new Axis_t[ybins + 1];
27 
28  for( int i =0; i <= xbins; i++)
29  {
30  new_xbins[i] = TMath::Power( 10, xmin + i*xwidth);
31  }
32  xaxis->Set(xbins, new_xbins);
33 
34  for( int i =0; i <= ybins; i++)
35  {
36  new_ybins[i] = TMath::Power( 10, ymin + i*ywidth);
37  }
38  yaxis->Set(ybins, new_ybins);
39 
40  return hnew;
41 }