KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVValueRange.h
1
3
4#ifndef __KVVALUERANGE_H
5#define __KVVALUERANGE_H
6
7#include "KVBase.h"
8
17template< typename ValueType >
18class KVValueRange : public KVBase {
19 ValueType fMin;
20 ValueType fMax;
21 ValueType fSize;
22
23public:
24 KVValueRange() : KVBase("KVValueRange", "Templated range of values") {}
25 KVValueRange(ValueType min, ValueType max)
26 : KVBase("KVValueRange", "Templated range of values"),
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.
ValueType Max() const
void Copy(TObject &o) const
Bool_t Contains(ValueType V) const
ValueType fMax
TString GetExpression(const TString &obs_name)
KVValueRange(ValueType min, ValueType max)
ValueType ValueIofN(Int_t i, Int_t n) const
ValueType fMin
ValueType Random() const
ValueType Min() const
ValueType fSize
KVValueRange(const KVValueRange &r)
ValueType Size() const
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)