Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:26

0001 // -*- C++ -*-
0002 // AID-GENERATED
0003 // =========================================================================
0004 // This class was generated by AID - Abstract Interface Definition
0005 // DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
0006 // =========================================================================
0007 #ifndef GAUDICOMMONSVC_AXIS_H
0008 #define GAUDICOMMONSVC_AXIS_H 1
0009 
0010 //  This file is part of the AIDA library
0011 //  Copyright (C) 2002 by the AIDA team.  All rights reserved.
0012 //  This library is free software and under the terms of the
0013 //  GNU Library General Public License described in the LGPL.txt
0014 
0015 #include "AIDA/IAxis.h"
0016 
0017 #include "TAxis.h"
0018 
0019 namespace Gaudi {
0020 
0021   /**
0022    * An IAxis represents a binned histogram axis. A 1D Histogram would have
0023    * one Axis representing the X axis, while a 2D Histogram would have two
0024    * axes representing the X and Y Axis.
0025    *
0026    * @author The AIDA team (http://aida.freehep.org/)
0027    *
0028    */
0029   class Axis : public AIDA::IAxis {
0030   public:
0031     static int toRootIndex( int index, int nbins ) {
0032       if ( index == AIDA::IAxis::OVERFLOW_BIN ) return nbins + 1;
0033       if ( index == AIDA::IAxis::UNDERFLOW_BIN ) return 0;
0034       return index + 1;
0035     }
0036 
0037     static int toAidaIndex( int index, int bins ) {
0038       if ( index == bins + 1 ) return AIDA::IAxis::OVERFLOW_BIN;
0039       if ( index == 0 ) return AIDA::IAxis::UNDERFLOW_BIN;
0040       return index - 1;
0041     }
0042 
0043     /**
0044      * Convert a AIDA bin number on the axis to the ROOT bin number.
0045      * @param index TheAIDA bin number
0046      * @return      The corresponding ROOT bin number.
0047      *
0048      */
0049     int rIndex( int index ) const { return toRootIndex( index, bins() ); }
0050 
0051     /**
0052      * Convert a ROOT bin number on the axis to the AIDA bin number.
0053      * @param index The ROOT bin number: 1 to bins() for the in-range bins or bins()+1 for OVERFLOW or 0 for UNDERFLOW.
0054      * @return      The corresponding AIDA bin number.
0055      *
0056      */
0057     int aIndex( int index ) const { return toAidaIndex( index, bins() ); }
0058 
0059   public:
0060     Axis() = default;
0061     explicit Axis( TAxis* itaxi ) : taxis_( itaxi ) {}
0062 
0063     void initialize( TAxis* itaxi, bool ) { taxis_ = itaxi; }
0064 
0065     /**
0066      * Check if the IAxis has fixed binning, i.e. if all the bins have the same width.
0067      * @return <code>true</code> if the binning is fixed, <code>false</code> otherwise.
0068      *
0069      */
0070     bool isFixedBinning() const override { return 0 == taxis_ ? true : !taxis_->IsVariableBinSize(); }
0071 
0072     /**
0073      * Get the lower edge of the IAxis.
0074      * @return The IAxis's lower edge.
0075      *
0076      */
0077     double lowerEdge() const override { return taxis().GetXmin(); }
0078 
0079     /**
0080      * Get the upper edge of the IAxis.
0081      * @return The IAxis's upper edge.
0082      *
0083      */
0084     double upperEdge() const override { return taxis().GetXmax(); }
0085 
0086     /**
0087      * The number of bins (excluding underflow and overflow) on the IAxis.
0088      * @return The IAxis's number of bins.
0089      *
0090      */
0091     int bins() const override { return taxis().GetNbins(); }
0092 
0093     /**
0094      * Get the lower edge of the specified bin.
0095      * @param index The bin number: 0 to bins()-1 for the in-range bins or OVERFLOW or UNDERFLOW.
0096      * @return      The lower edge of the corresponding bin; for the underflow bin this is
0097      * <tt>Double.NEGATIVE_INFINITY</tt>.
0098      *
0099      */
0100     double binLowerEdge( int index ) const override { return taxis().GetBinLowEdge( rIndex( index ) ); }
0101     /**
0102      * Get the upper edge of the specified bin.
0103      * @param index The bin number: 0 to bins()-1 for the in-range bins or OVERFLOW or UNDERFLOW.
0104      * @return      The upper edge of the corresponding bin; for the overflow bin this is
0105      * <tt>Double.POSITIVE_INFINITY</tt>.
0106      *
0107      */
0108     double binUpperEdge( int index ) const override { return taxis().GetBinUpEdge( rIndex( index ) ); }
0109 
0110     /**
0111      * Get the width of the specified bin.
0112      * @param index The bin number: 0 to bins()-1) for the in-range bins or OVERFLOW or UNDERFLOW.
0113      * @return      The width of the corresponding bin.
0114      *
0115      */
0116     double binWidth( int index ) const override { return taxis().GetBinWidth( rIndex( index ) ); }
0117 
0118     /**
0119      * Convert a coordinate on the axis to a bin number.
0120      * If the coordinate is less than the lowerEdge UNDERFLOW is returned; if the coordinate is greater or
0121      * equal to the upperEdge OVERFLOW is returned.
0122      * @param coord The coordinate to be converted.
0123      * @return      The corresponding bin number.
0124      *
0125      */
0126 
0127     int coordToIndex( double coord ) const override { return aIndex( taxis().FindBin( coord ) ); }
0128 
0129     /**
0130      *
0131      */
0132     TAxis& taxis() const { return *me().taxis_; }
0133 
0134   private:
0135     Axis& me() const { return const_cast<Axis&>( *this ); }
0136 
0137     TAxis* taxis_ = nullptr;
0138 
0139   }; // class
0140 
0141 } // namespace Gaudi
0142 
0143 #endif // GAUDICOMMONSVC_AXIS_H