The Gaudi Framework  v29r0 (ff2e7097)
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 {
21 
30  class Axis : public AIDA::IAxis
31  {
32  public:
33  static int toRootIndex( int index, int nbins )
34  {
35  if ( index == AIDA::IAxis::OVERFLOW_BIN ) return nbins + 1;
36  if ( index == AIDA::IAxis::UNDERFLOW_BIN ) return 0;
37  return index + 1;
38  }
39 
40  static int toAidaIndex( int index, int bins )
41  {
42  if ( index == bins + 1 ) return AIDA::IAxis::OVERFLOW_BIN;
43  if ( index == 0 ) return AIDA::IAxis::UNDERFLOW_BIN;
44  return index - 1;
45  }
46 
53  int rIndex( int index ) const { return toRootIndex( index, bins() ); }
54 
61  int aIndex( int index ) const { return toAidaIndex( index, bins() ); }
62 
63  public:
64  Axis() = default;
65  explicit Axis( TAxis* itaxi ) : taxis_( itaxi ) {}
66 
67  void initialize( TAxis* itaxi, bool ) { taxis_ = itaxi; }
68 
74  bool isFixedBinning() const override { return 0 == taxis_ ? true : !taxis_->IsVariableBinSize(); }
75 
81  double lowerEdge() const override { return taxis().GetXmin(); }
82 
88  double upperEdge() const override { return taxis().GetXmax(); }
89 
95  int bins() const override { return taxis().GetNbins(); }
96 
104  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 { return aIndex( taxis().FindBin( coord ) ); }
132 
136  TAxis& taxis() const { return *me().taxis_; }
137 
138  private:
139  Axis& me() const { return const_cast<Axis&>( *this ); }
140 
141  TAxis* taxis_ = nullptr;
142 
143  }; // class
144 
145 } // namespace Gaudi
146 
147 #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:61
static int toAidaIndex(int index, int bins)
Definition: Axis.h:40
Axis(TAxis *itaxi)
Definition: Axis.h:65
Axis & me() const
Definition: Axis.h:139
bool isFixedBinning() const override
Check if the IAxis has fixed binning, i.e.
Definition: Axis.h:74
Axis()=default
TAxis * taxis_
Definition: Axis.h:141
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:95
double binLowerEdge(int index) const override
Get the lower edge of the specified bin.
Definition: Axis.h:104
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:67
double lowerEdge() const override
Get the lower edge of the IAxis.
Definition: Axis.h:81
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:88
Helper functions to set/get the application return code.
Definition: __init__.py:1
An IAxis represents a binned histogram axis.
Definition: Axis.h:30
TAxis & taxis() const
Definition: Axis.h:136
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:53