KaliVeda
Toolkit for HIC analysis
KVValueRange.h
1 
4 #ifndef __KVVALUERANGE_H
5 #define __KVVALUERANGE_H
6 
7 #include "KVBase.h"
8 #include "TRandom.h"
9 
18 template< typename ValueType >
19 class KVValueRange : public KVBase {
20  ValueType fMin;
21  ValueType fMax;
22  ValueType fSize;
23 
24 public:
25  KVValueRange() : KVBase("KVValueRange", "Templated range of values") {}
26  KVValueRange(ValueType min, ValueType max)
27  : KVBase("KVValueRange", "Templated range of values"),
28  fMin(min), fMax(max), fSize(fMax - fMin)
29  {}
31  : KVBase()
32  {
33  r.Copy(*this);
34  }
35  void Copy(TObject& o) const
36  {
37  KVBase::Copy(o);
38  KVValueRange& vr = static_cast<KVValueRange&>(o);
39  vr.fMin = fMin;
40  vr.fMax = fMax;
41  vr.fSize = fSize;
42  }
43  ROOT_COPY_ASSIGN_OP(KVValueRange)
44  ValueType Min() const
45  {
46  return fMin;
47  }
48  ValueType Max() const
49  {
50  return fMax;
51  }
52  ValueType Size() const
53  {
54  return fSize;
55  }
56  ValueType Random() const
57  {
58  return gRandom->Uniform(fMin, fMax);
59  }
60  ValueType ValueIofN(Int_t i, Int_t n) const
61  {
64 
65  i >= n ? i = n - 1 : (i < 0 ? i = 0 : 1);
66  return fMin + i * fSize / (n - 1.);
67  }
68 
69  TString GetExpression(const TString& obs_name)
70  {
73  return Form("%g #leq %s #leq %g", Min(), obs_name.Data(), Max());
74  }
75 
76  Bool_t Contains(ValueType V) const
77  {
79  return !(V < fMin) && !(V > fMax);
80  }
81 
82  ClassDef(KVValueRange, 1) //Range of values specified by minimum, maximum
83 };
84 #endif
int Int_t
ROOT::R::TRInterface & r
bool Bool_t
#define ClassDef(name, id)
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
Base class for KaliVeda framework.
Definition: KVBase.h:139
void Copy(TObject &) const override
Make a copy of this object.
Definition: KVBase.cpp:373
Range of values specified by minimum, maximum.
Definition: KVValueRange.h:19
ValueType Max() const
Definition: KVValueRange.h:48
void Copy(TObject &o) const
Definition: KVValueRange.h:35
Bool_t Contains(ValueType V) const
Definition: KVValueRange.h:76
ValueType fMax
Definition: KVValueRange.h:21
TString GetExpression(const TString &obs_name)
Definition: KVValueRange.h:69
KVValueRange(ValueType min, ValueType max)
Definition: KVValueRange.h:26
ValueType ValueIofN(Int_t i, Int_t n) const
Definition: KVValueRange.h:60
ValueType fMin
Definition: KVValueRange.h:20
ValueType Random() const
Definition: KVValueRange.h:56
ValueType Min() const
Definition: KVValueRange.h:44
ValueType fSize
Definition: KVValueRange.h:22
KVValueRange(const KVValueRange &r)
Definition: KVValueRange.h:30
ValueType Size() const
Definition: KVValueRange.h:52
virtual void Copy(TObject &object) const
virtual Double_t Uniform(Double_t x1, Double_t x2)
const char * Data() const
const Int_t n
double min(double x, double y)
double max(double x, double y)