| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# Axis.h

Go to the documentation of this file.

    00001 // -*- C++ -*-
    00002 // AID-GENERATED
    00003 // =========================================================================
    00004 // This class was generated by AID - Abstract Interface Definition
    00005 // DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
    00006 // =========================================================================
    00007 #ifndef GAUDISVC__IAXIS_H
    00008 #define GAUDISVC__IAXIS_H 1
    00009
    00010 //  This file is part of the AIDA library
    00011 //  Copyright (C) 2002 by the AIDA team.  All rights reserved.
    00012 //  This library is free software and under the terms of the
    00013 //  GNU Library General Public License described in the LGPL.txt
    00014
    00015 #include "AIDA/IAxis.h"
    00016
    00017 #include "TAxis.h"
    00018
    00019 namespace Gaudi {
    00020
    00029   class Axis  : public AIDA::IAxis {
    00030   public:
    00031
    00032     typedef Axis self;
    00033
    00034     static int toRootIndex(int index, int nbins) {
    00035       if (index==AIDA::IAxis::OVERFLOW_BIN) return nbins+1;
    00036       if (index==AIDA::IAxis::UNDERFLOW_BIN) return 0;
    00037       return index+1;
    00038     }
    00039
    00040     static int toAidaIndex(int index, int bins) {
    00041       if ( index == bins + 1 ) return AIDA::IAxis::OVERFLOW_BIN ;
    00042       if ( index == 0 ) return AIDA::IAxis::UNDERFLOW_BIN ;
    00043       return index - 1 ;
    00044     }
    00045
    00052     int rIndex(int index) const { return toRootIndex(index, bins());}
    00053
    00060     int aIndex( int index ) const { return toAidaIndex(index, bins()); }
    00061
    00062   public:
    00063
    00064     Axis() : taxis_(0), fixed_(true)  {}
    00065
    00066     explicit Axis(TAxis * itaxi, bool isfixed=true) : taxis_(itaxi), fixed_(isfixed){}
    00067
    00068     void initialize(TAxis * itaxi, bool isfixed=true) {
    00069       taxis_ = itaxi;
    00070       fixed_ = isfixed;
    00071     }
    00072
    00074     virtual ~Axis()    {}
    00075
    00081     virtual bool isFixedBinning() const { return fixed_;}
    00082
    00088     virtual double lowerEdge() const { return taxis().GetXmin();}
    00089
    00095     virtual double upperEdge() const { return taxis().GetXmax();}
    00096
    00102     virtual int bins() const { return taxis().GetNbins();}
    00103
    00110     virtual double binLowerEdge(int index) const { return taxis().GetBinLowEdge(rIndex(index));}
    00117     virtual double binUpperEdge(int index) const { return taxis().GetBinUpEdge(rIndex(index));}
    00118
    00125     virtual double binWidth(int index) const { return taxis().GetBinWidth(rIndex(index));}
    00126
    00136     virtual int coordToIndex(double coord) const
    00137     {
    00138       return aIndex( taxis().FindBin(coord) );
    00139     }
    00140
    00144     TAxis & taxis() const { return *me().taxis_;}
    00145
    00146   private:
    00147
    00148   private:
    00149
    00150     self & me() const { return const_cast<self&>(*this);}
    00151
    00152
    00153     TAxis * taxis_;
    00154     bool fixed_;
    00155
    00156
    00157   }; // class
    00158
    00159 } // namespace Gaudi
    00160
    00161 #endif /* ifndef AIDA_IAXIS_H */