All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Axis.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // AID-GENERATED
3 // =========================================================================
4 // This class was generated by AID - Abstract Interface Definition
5 // DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
6 // =========================================================================
7 #ifndef GAUDICOMMONSVC_AXIS_H
8 #define GAUDICOMMONSVC_AXIS_H 1
9 
10 // This file is part of the AIDA library
11 // Copyright (C) 2002 by the AIDA team. All rights reserved.
12 // This library is free software and under the terms of the
13 // GNU Library General Public License described in the LGPL.txt
14 
15 #include "AIDA/IAxis.h"
16 
17 #include "TAxis.h"
18 
19 namespace Gaudi {
20 
29  class Axis : public AIDA::IAxis
30  {
31  public:
32 
33  static int toRootIndex(int index, int nbins) {
34  if (index==AIDA::IAxis::OVERFLOW_BIN) return nbins+1;
35  if (index==AIDA::IAxis::UNDERFLOW_BIN) return 0;
36  return index+1;
37  }
38 
39  static int toAidaIndex(int index, int bins) {
40  if ( index == bins + 1 ) return AIDA::IAxis::OVERFLOW_BIN ;
41  if ( index == 0 ) return AIDA::IAxis::UNDERFLOW_BIN ;
42  return index - 1 ;
43  }
44 
51  int rIndex(int index) const { return toRootIndex(index, bins());}
52 
59  int aIndex( int index ) const { return toAidaIndex(index, bins()); }
60 
61  public:
62 
63  Axis() = default;
64  explicit Axis ( TAxis * itaxi ) : taxis_(itaxi) {}
65 
66  void initialize (TAxis * itaxi , bool ) { taxis_ = itaxi; }
67 
73  bool isFixedBinning() const override
74  {
75  return 0 == taxis_ ? true : !taxis_->IsVariableBinSize() ;
76  }
77 
83  double lowerEdge() const override { return taxis().GetXmin();}
84 
90  double upperEdge() const override { return taxis().GetXmax();}
91 
97  int bins() const override { return taxis().GetNbins();}
98 
105  double binLowerEdge(int index) const override { return taxis().GetBinLowEdge(rIndex(index));}
112  double binUpperEdge(int index) const override { return taxis().GetBinUpEdge(rIndex(index));}
113 
120  double binWidth(int index) const override { return taxis().GetBinWidth(rIndex(index));}
121 
131  int coordToIndex(double coord) const override
132  {
133  return aIndex( taxis().FindBin(coord) );
134  }
135 
139  TAxis & taxis() const { return *me().taxis_;}
140 
141  private:
142 
143  Axis & me() const { return const_cast<Axis&>(*this);}
144 
145 
146  TAxis * taxis_ = nullptr;
147 
148  }; // class
149 
150 } // namespace Gaudi
151 
152 #endif // GAUDICOMMONSVC_AXIS_H
int aIndex(int index) const
Convert a ROOT bin number on the axis to the AIDA bin number.
Definition: Axis.h:59
static int toAidaIndex(int index, int bins)
Definition: Axis.h:39
Axis(TAxis *itaxi)
Definition: Axis.h:64
Axis & me() const
Definition: Axis.h:143
bool isFixedBinning() const override
Check if the IAxis has fixed binning, i.e.
Definition: Axis.h:73
Axis()=default
TAxis * taxis_
Definition: Axis.h:146
int coordToIndex(double coord) const override
Convert a coordinate on the axis to a bin number.
Definition: Axis.h:131
int bins() const override
The number of bins (excluding underflow and overflow) on the IAxis.
Definition: Axis.h:97
double binLowerEdge(int index) const override
Get the lower edge of the specified bin.
Definition: Axis.h:105
double binUpperEdge(int index) const override
Get the upper edge of the specified bin.
Definition: Axis.h:112
void initialize(TAxis *itaxi, bool)
Definition: Axis.h:66
double lowerEdge() const override
Get the lower edge of the IAxis.
Definition: Axis.h:83
static int toRootIndex(int index, int nbins)
Definition: Axis.h:33
double upperEdge() const override
Get the upper edge of the IAxis.
Definition: Axis.h:90
Helper functions to set/get the application return code.
Definition: __init__.py:1
An IAxis represents a binned histogram axis.
Definition: Axis.h:29
TAxis & taxis() const
Definition: Axis.h:139
double binWidth(int index) const override
Get the width of the specified bin.
Definition: Axis.h:120
int rIndex(int index) const
Convert a AIDA bin number on the axis to the ROOT bin number.
Definition: Axis.h:51