KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVValueRange.h
Go to the documentation of this file.
1 
4 #ifndef __KVVALUERANGE_H
5 #define __KVVALUERANGE_H
6 
7 #include "KVBase.h"
8 
16 template< typename ValueType >
17 class KVValueRange : public KVBase {
18  ValueType fMin;
19  ValueType fMax;
20  ValueType fSize;
21 
22 public:
23  KVValueRange() : KVBase("KVValueRange", "Templated range of values") {}
24  KVValueRange(ValueType min, ValueType max)
25  : KVBase("KVValueRange", "Templated range of values"),
26  fMin(min), fMax(max), fSize(fMax - fMin)
27  {}
29  : KVBase()
30  {
31  r.Copy(*this);
32  }
33  void Copy(TObject& o) const
34  {
35  KVBase::Copy(o);
36  KVValueRange& vr = static_cast<KVValueRange&>(o);
37  vr.fMin = fMin;
38  vr.fMax = fMax;
39  vr.fSize = fSize;
40  }
41  ROOT_COPY_ASSIGN_OP(KVValueRange)
42  ValueType Min() const
43  {
44  return fMin;
45  }
46  ValueType Max() const
47  {
48  return fMax;
49  }
50  ValueType Size() const
51  {
52  return fSize;
53  }
54  ValueType Random() const
55  {
56  return gRandom->Uniform(fMin, fMax);
57  }
58  ValueType ValueIofN(Int_t i, Int_t n) const
59  {
62 
63  i >= n ? i = n - 1 : (i < 0 ? i = 0 : 1);
64  return fMin + i * fSize / (n - 1.);
65  }
66 
67  TString GetExpression(const TString& obs_name)
68  {
70  return Form("%g #leq %s #leq %g", Min(), obs_name.Data(), Max());
71  }
72 
73  ClassDef(KVValueRange, 1) //Range of values specified by minimum, maximum
74 };
75 #endif
int Int_t
ROOT::R::TRInterface & r
#define ClassDef(name, id)
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
Base class for KaliVeda framework.
Definition: KVBase.h:141
virtual void Copy(TObject &) const
Make a copy of this object.
Definition: KVBase.cpp:394
Range of values specified by minimum, maximum.
Definition: KVValueRange.h:17
ValueType Max() const
Definition: KVValueRange.h:46
void Copy(TObject &o) const
Make a copy of this object.
Definition: KVValueRange.h:33
ValueType fMax
Definition: KVValueRange.h:19
TString GetExpression(const TString &obs_name)
Definition: KVValueRange.h:67
KVValueRange(ValueType min, ValueType max)
Definition: KVValueRange.h:24
ValueType ValueIofN(Int_t i, Int_t n) const
Definition: KVValueRange.h:58
ValueType fMin
Definition: KVValueRange.h:18
ValueType Random() const
Definition: KVValueRange.h:54
ValueType Min() const
Definition: KVValueRange.h:42
ValueType fSize
Definition: KVValueRange.h:20
KVValueRange(const KVValueRange &r)
Definition: KVValueRange.h:28
ValueType Size() const
Definition: KVValueRange.h:50
virtual void Copy(TObject &object) const
virtual Double_t Uniform(Double_t x1, Double_t x2)
const char * Data() const
const Int_t n