Interval.h

Go to the documentation of this file.
00001 // @(#)root/tmva $Id: Interval.h 37986 2011-02-04 21:42:15Z pcanal $    
00002 // Author: Peter Speckmayer
00003 
00004 /**********************************************************************************
00005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00006  * Package: TMVA                                                                  *
00007  * Class  : Interval                                                              *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description:                                                                   *
00011  *    Generic range definition (used, eg, in genetic algorithm)                   *
00012  *                                                                                *
00013  * Authors (alphabetical):                                                        *
00014  *      Peter Speckmayer <speckmay@mail.cern.ch>  - CERN, Switzerland             *
00015  *                                                                                *
00016  * Copyright (c) 2005:                                                            *
00017  *      CERN, Switzerland                                                         * 
00018  *      MPI-K Heidelberg, Germany                                                 * 
00019  *                                                                                *
00020  * Redistribution and use in source and binary forms, with or without             *
00021  * modification, are permitted according to the terms listed in LICENSE           *
00022  * (http://tmva.sourceforge.net/LICENSE)                                          *
00023  **********************************************************************************/
00024 
00025 #ifndef ROOT_TMVA_Interval
00026 #define ROOT_TMVA_Interval
00027 
00028 //////////////////////////////////////////////////////////////////////////////
00029 //                                                                          //
00030 // Interval                                                                 //
00031 //                                                                          //
00032 // Interval definition, continuous and discrete                             //
00033 //                                                                          //
00034 // Interval(min,max)  : a continous interval [min,max]                      //
00035 // Interval(min,max,n): a "discrete interval" [min,max], i.e the n numbers: //
00036 //          min, min+step, min+2*step,...., min+(n-1)*step, min+n*step=max  //
00037 //   e.g.: Interval(1,5,5)=1,2,3,4,5                                        //
00038 //         Interval(.5,1.,6)= .5, .6., .7, .8, .9, 1.0                      //
00039 //                                                                          //
00040 //  Note: **bin** counting starts from ZERO unlike in ROOT histograms       //
00041 //                                                                          //
00042 //    Example:   Interval(.5,1.,6)                                          //
00043 //                                                                          //
00044 //             [ min                           max ]                        //
00045 //         ------------------------------------------------------------     //
00046 //                |     |     |     |     |     |                           //
00047 //               .5    .6    .7    .8    .9    1.0                          //
00048 //                                                                          //
00049 //         bin    0     1     2     3     4     5                           //
00050 //                                                                          //
00051 //                                                                          //
00052 //////////////////////////////////////////////////////////////////////////////
00053 #ifndef ROOT_Rtypes                                                         
00054 #include "Rtypes.h"
00055 #endif
00056 
00057 class TRandom3;
00058 
00059 namespace TMVA {
00060 
00061    class MsgLogger;
00062    
00063    class Interval {
00064 
00065    public:
00066 
00067       Interval( Double_t min, Double_t max, Int_t nbins = 0 );
00068       Interval( const Interval& other );
00069       virtual ~Interval();
00070 
00071       // accessors
00072       Double_t GetMin()   const { return fMin; }
00073       Double_t GetMax()   const { return fMax; }
00074       Double_t GetWidth() const { return fMax - fMin; }
00075       Int_t    GetNbins() const { return fNbins; }
00076       Double_t GetMean()  const { return (fMax + fMin)/2; }
00077       Double_t GetRndm( TRandom3& )  const;
00078       Double_t GetElement( Int_t position ) const;      
00079       Double_t GetStepSize() const;
00080 
00081       void SetMax( Double_t m ) { fMax = m; }
00082       void SetMin( Double_t m ) { fMin = m; }
00083 
00084    private:
00085 
00086       Double_t fMin, fMax;    // the constraints of the Interval
00087       Int_t    fNbins;        // when >0 : number of bins (discrete interval); when =0 continuous interval
00088 
00089       static MsgLogger* fgLogger;   // message logger
00090       MsgLogger& Log() const { return *fgLogger; }          
00091 
00092       ClassDef(Interval,0)    // Interval definition, continous and discrete
00093    };
00094 
00095 } // namespace TMVA
00096 
00097 #endif

Generated on Tue Jul 5 14:27:30 2011 for ROOT_528-00b_version by  doxygen 1.5.1