File indexing completed on 2025-01-30 10:21:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT_Fit_DataRange
0014 #define ROOT_Fit_DataRange
0015
0016 #include <vector>
0017 #include <utility>
0018
0019 namespace ROOT {
0020
0021 namespace Fit {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class DataRange {
0036
0037 public:
0038
0039 typedef std::vector<std::pair<double,double> > RangeSet;
0040 typedef std::vector< RangeSet > RangeIntervals;
0041
0042
0043
0044
0045 explicit DataRange (unsigned int dim = 1) :
0046 fRanges ( std::vector<RangeSet> (dim) )
0047 {}
0048
0049
0050
0051
0052 DataRange(double xmin, double xmax);
0053
0054
0055
0056
0057 DataRange(double xmin, double xmax, double ymin, double ymax);
0058
0059
0060
0061 DataRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
0062
0063
0064
0065 unsigned int NDim() const { return fRanges.size(); }
0066
0067
0068
0069
0070
0071 unsigned int Size(unsigned int icoord = 0) const {
0072 return icoord < fRanges.size() ? fRanges[icoord].size() : 0;
0073 }
0074
0075
0076
0077
0078
0079
0080 bool IsSet() const {
0081 for (unsigned int icoord = 0; icoord < fRanges.size(); ++icoord)
0082 if (!fRanges[icoord].empty()) return true;
0083 return false;
0084 }
0085
0086
0087
0088
0089 const RangeSet & Ranges(unsigned int icoord = 0) const {
0090
0091 return fRanges.at(icoord);
0092 }
0093
0094
0095
0096
0097
0098 std::pair<double, double> operator() (unsigned int icoord = 0,unsigned int irange = 0) const;
0099
0100
0101
0102
0103
0104 void GetRange(unsigned int irange, unsigned int icoord, double & xmin, double & xmax) const {
0105 if (Size(icoord)<= irange) GetInfRange(xmin,xmax);
0106 else {
0107 xmin = fRanges[icoord][irange].first;
0108 xmax = fRanges[icoord][irange].second;
0109 }
0110 }
0111
0112
0113
0114
0115 void GetRange(unsigned int icoord, double & xmin, double & xmax) const {
0116 if (Size(icoord) == 0) GetInfRange(xmin,xmax);
0117 else {
0118 xmin = fRanges[icoord].front().first;
0119 xmax = fRanges[icoord].front().second;
0120 }
0121 }
0122
0123
0124
0125 void GetRange(double & xmin, double & xmax,unsigned int irange = 0) const { GetRange(irange,0,xmin,xmax); }
0126
0127
0128
0129 void GetRange(double & xmin, double & xmax, double & ymin, double & ymax,unsigned int irange = 0) const {
0130 GetRange(irange,0,xmin,xmax); GetRange(irange,1,ymin,ymax);
0131 }
0132
0133
0134
0135 void GetRange(double & xmin, double & xmax, double & ymin, double & ymax, double & zmin, double & zmax,unsigned int irange=0) const {
0136 GetRange(irange,0,xmin,xmax); GetRange(irange,1,ymin,ymax); GetRange(irange,2,zmin,zmax);
0137 }
0138
0139
0140
0141 void GetRange(double * xmin, double * xmax, unsigned int irange = 0) const {
0142 for (unsigned int i = 0; i < fRanges.size(); ++i)
0143 GetRange(irange,i,xmin[i],xmax[i]);
0144 }
0145
0146
0147
0148
0149 ~DataRange () {}
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159 void AddRange(unsigned int icoord , double xmin, double xmax );
0160
0161
0162
0163
0164 void AddRange(double xmin, double xmax ) { AddRange(0,xmin,xmax); }
0165
0166
0167
0168 void AddRange(double xmin, double xmax, double ymin, double ymax ) { AddRange(0,xmin,xmax); AddRange(1,ymin,ymax); }
0169
0170
0171
0172
0173 void AddRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax ) {
0174 AddRange(0,xmin,xmax); AddRange(1,ymin,ymax); AddRange(2,zmin,zmax); }
0175
0176
0177
0178
0179
0180
0181 void SetRange(unsigned int icoord , double xmin, double xmax );
0182
0183
0184
0185
0186 void SetRange(double xmin, double xmax ) { SetRange(0,xmin,xmax); }
0187
0188
0189
0190 void SetRange(double xmin, double xmax, double ymin, double ymax ) { SetRange(0,xmin,xmax); SetRange(1,ymin,ymax); }
0191
0192
0193
0194
0195 void SetRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax ) {
0196 SetRange(0,xmin,xmax); SetRange(1,ymin,ymax); SetRange(2,zmin,zmax); }
0197
0198
0199
0200
0201 void Clear (unsigned int icoord = 0 );
0202
0203
0204
0205
0206 bool IsInside(double x, unsigned int icoord = 0) const;
0207
0208
0209
0210
0211 bool IsInside(const double *x) const {
0212 bool ret = true;
0213 for (unsigned int idim = 0; idim < fRanges.size(); ++idim) {
0214 ret &= IsInside(x[idim],idim);
0215 if (!ret) return ret;
0216 }
0217 return ret;
0218 }
0219
0220 protected:
0221
0222
0223
0224
0225 void CleanRangeSet(unsigned int icoord, double xmin, double xmax);
0226
0227
0228 static void GetInfRange(double &x1, double &x2);
0229
0230 private:
0231
0232 RangeIntervals fRanges;
0233
0234
0235 };
0236
0237 }
0238
0239 }
0240
0241
0242 #endif