ROOT logo
// @(#)root/tmva $Id: Interval.h 29195 2009-06-24 10:39:49Z brun $    
// Author: Peter Speckmayer

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : Interval                                                              *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *    Generic range definition (used, eg, in genetic algorithm)                   *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Peter Speckmayer <speckmay@mail.cern.ch>  - CERN, Switzerland             *
 *                                                                                *
 * Copyright (c) 2005:                                                            *
 *      CERN, Switzerland                                                         * 
 *      MPI-K Heidelberg, Germany                                                 * 
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/

#ifndef ROOT_TMVA_Interval
#define ROOT_TMVA_Interval

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// Interval                                                             //
//                                                                      //
// Interval definition, continuous and discrete                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif

class TRandom3;

namespace TMVA {

   class MsgLogger;
   
   class Interval {

   public:

      Interval( Double_t min, Double_t max, Int_t nbins = 0 );
      Interval( const Interval& other );
      virtual ~Interval();

      // accessors
      Double_t GetMin()   const { return fMin; }
      Double_t GetMax()   const { return fMax; }
      Double_t GetWidth() const { return fMax - fMin; }
      Int_t    GetNbins() const { return fNbins; }
      Double_t GetMean()  const { return (fMax + fMin)/2; }
      Double_t GetRndm( TRandom3& )  const;
      Double_t GetElement( Int_t position ) const;      

      void SetMax( Double_t m ) { fMax = m; }
      void SetMin( Double_t m ) { fMin = m; }

   private:

      Double_t fMin, fMax;    // the constraints of the Interval
      Int_t    fNbins;        // when >0 : number of bins (discrete interval); when =0 continuous interval

      mutable MsgLogger* fLogger;   // message logger
      MsgLogger& Log() const { return *fLogger; }          

      ClassDef(Interval,0)    // Interval definition, continous and discrete
   };

} // namespace TMVA

#endif
 Interval.h:1
 Interval.h:2
 Interval.h:3
 Interval.h:4
 Interval.h:5
 Interval.h:6
 Interval.h:7
 Interval.h:8
 Interval.h:9
 Interval.h:10
 Interval.h:11
 Interval.h:12
 Interval.h:13
 Interval.h:14
 Interval.h:15
 Interval.h:16
 Interval.h:17
 Interval.h:18
 Interval.h:19
 Interval.h:20
 Interval.h:21
 Interval.h:22
 Interval.h:23
 Interval.h:24
 Interval.h:25
 Interval.h:26
 Interval.h:27
 Interval.h:28
 Interval.h:29
 Interval.h:30
 Interval.h:31
 Interval.h:32
 Interval.h:33
 Interval.h:34
 Interval.h:35
 Interval.h:36
 Interval.h:37
 Interval.h:38
 Interval.h:39
 Interval.h:40
 Interval.h:41
 Interval.h:42
 Interval.h:43
 Interval.h:44
 Interval.h:45
 Interval.h:46
 Interval.h:47
 Interval.h:48
 Interval.h:49
 Interval.h:50
 Interval.h:51
 Interval.h:52
 Interval.h:53
 Interval.h:54
 Interval.h:55
 Interval.h:56
 Interval.h:57
 Interval.h:58
 Interval.h:59
 Interval.h:60
 Interval.h:61
 Interval.h:62
 Interval.h:63
 Interval.h:64
 Interval.h:65
 Interval.h:66
 Interval.h:67
 Interval.h:68
 Interval.h:69
 Interval.h:70
 Interval.h:71
 Interval.h:72
 Interval.h:73
 Interval.h:74
 Interval.h:75
 Interval.h:76
 Interval.h:77
 Interval.h:78
 Interval.h:79