Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Interval.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Peter Speckmayer
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : Interval *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Generic range definition (used, eg, in genetic algorithm) *
12  * *
13  * Authors (alphabetical): *
14  * Peter Speckmayer <speckmay@mail.cern.ch> - CERN, Switzerland *
15  * *
16  * Copyright (c) 2005: *
17  * CERN, Switzerland *
18  * MPI-K Heidelberg, Germany *
19  * *
20  * Redistribution and use in source and binary forms, with or without *
21  * modification, are permitted according to the terms listed in LICENSE *
22  * (http://tmva.sourceforge.net/LICENSE) *
23  **********************************************************************************/
24 
25 #ifndef ROOT_TMVA_Interval
26 #define ROOT_TMVA_Interval
27 
28 //////////////////////////////////////////////////////////////////////////////
29 // //
30 // Interval //
31 // //
32 // Interval definition, continuous and discrete //
33 // //
34 // Interval(min,max) : a continous interval [min,max] //
35 // Interval(min,max,n): a "discrete interval" [min,max], i.e the n numbers: //
36 // min, min+step, min+2*step,...., min+(n-1)*step, min+n*step=max //
37 // e.g.: Interval(1,5,5)=1,2,3,4,5 //
38 // Interval(.5,1.,6)= .5, .6., .7, .8, .9, 1.0 //
39 // //
40 // Note: **bin** counting starts from ZERO unlike in ROOT histograms //
41 // //
42 // Example: Interval(.5,1.,6) //
43 // //
44 // [ min max ] //
45 // ------------------------------------------------------------ //
46 // | | | | | | //
47 // .5 .6 .7 .8 .9 1.0 //
48 // //
49 // bin 0 1 2 3 4 5 //
50 // //
51 // //
52 //////////////////////////////////////////////////////////////////////////////
53 #include "Rtypes.h"
54 
55 class TRandom3;
56 
57 namespace TMVA {
58 
59  class MsgLogger;
60 
61  class Interval {
62 
63  public:
64 
65  Interval( Double_t min, Double_t max, Int_t nbins = 0 );
66  Interval( const Interval& other );
67  virtual ~Interval();
68 
69  // accessors
70  // accessors
71  virtual Double_t GetMin() const { return fMin; }
72  virtual Double_t GetMax() const { return fMax; }
73  virtual Double_t GetWidth() const;
74  virtual Int_t GetNbins() const { return fNbins; }
75  virtual Double_t GetMean() const;
76  virtual Double_t GetRndm( TRandom3& ) const;
77  virtual Double_t GetElement( Int_t position ) const;
78  virtual Double_t GetStepSize(Int_t iBin=0) const;
79 
80  void SetMax( Double_t m ) { fMax = m; }
81  void SetMin( Double_t m ) { fMin = m; }
82 
83  virtual void Print( std::ostream& os ) const;
84 
85  protected:
86 
87  Double_t fMin, fMax; // the constraints of the Interval
88  Int_t fNbins; // when >0 : number of bins (discrete interval); when ==0 continuous interval
89 
90  private:
91  MsgLogger& Log() const;
92 
93  ClassDef(Interval,0); // Interval definition, continous and discrete
94  };
95 
96 } // namespace TMVA
97 
98 #endif