KaliVeda
Toolkit for HIC analysis
KVValueRange.h
1 
4 #ifndef __KVVALUERANGE_H
5 #define __KVVALUERANGE_H
6 
7 #include "KVBase.h"
8 
17 template< typename ValueType >
18 class KVValueRange : public KVBase {
19  ValueType fMin;
20  ValueType fMax;
21  ValueType fSize;
22 
23 public:
24  KVValueRange() : KVBase("KVValueRange", "Templated range of values") {}
25  KVValueRange(ValueType min, ValueType max)
26  : KVBase("KVValueRange", "Templated range of values"),
27  fMin(min), fMax(max), fSize(fMax - fMin)
28  {}
30  : KVBase()
31  {
32  r.Copy(*this);
33  }
34  void Copy(TObject& o) const
35  {
36  KVBase::Copy(o);
37  KVValueRange& vr = static_cast<KVValueRange&>(o);
38  vr.fMin = fMin;
39  vr.fMax = fMax;
40  vr.fSize = fSize;
41  }
42  ROOT_COPY_ASSIGN_OP(KVValueRange)
43  ValueType Min() const
44  {
45  return fMin;
46  }
47  ValueType Max() const
48  {
49  return fMax;
50  }
51  ValueType Size() const
52  {
53  return fSize;
54  }
55  ValueType Random() const
56  {
57  return gRandom->Uniform(fMin, fMax);
58  }
59  ValueType ValueIofN(Int_t i, Int_t n) const
60  {
63 
64  i >= n ? i = n - 1 : (i < 0 ? i = 0 : 1);
65  return fMin + i * fSize / (n - 1.);
66  }
67 
68  TString GetExpression(const TString& obs_name)
69  {
72  return Form("%g #leq %s #leq %g", Min(), obs_name.Data(), Max());
73  }
74 
75  Bool_t Contains(ValueType V) const
76  {
78  return !(V < fMin) && !(V > fMax);
79  }
80 
81  ClassDef(KVValueRange, 1) //Range of values specified by minimum, maximum
82 };
83 #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:142
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:18
ValueType Max() const
Definition: KVValueRange.h:47
void Copy(TObject &o) const
Definition: KVValueRange.h:34
Bool_t Contains(ValueType V) const
Definition: KVValueRange.h:75
ValueType fMax
Definition: KVValueRange.h:20
TString GetExpression(const TString &obs_name)
Definition: KVValueRange.h:68
KVValueRange(ValueType min, ValueType max)
Definition: KVValueRange.h:25
ValueType ValueIofN(Int_t i, Int_t n) const
Definition: KVValueRange.h:59
ValueType fMin
Definition: KVValueRange.h:19
ValueType Random() const
Definition: KVValueRange.h:55
ValueType Min() const
Definition: KVValueRange.h:43
ValueType fSize
Definition: KVValueRange.h:21
KVValueRange(const KVValueRange &r)
Definition: KVValueRange.h:29
ValueType Size() const
Definition: KVValueRange.h:51
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)