42 Box(
const vector<double>& min,
const vector<double>& max,
43 const double value = 0.0,
const double error = 1.0):
44 fMin(min), fMax(max), fVal(value), fError(error)
50 {
return (fMin == b.fMin) && (fMax == b.fMax)
51 && (fVal == b.fVal) && (fError == b.fError); }
54 const vector<double>& GetMin()
const {
return fMin; }
56 const vector<double>& GetMax()
const {
return fMax; }
58 double GetVal()
const {
return fVal; }
60 double GetError()
const {
return fError; }
63 void AddVal(
const double value) { fVal += value; }
65 friend class BoxContainer;
66 friend ostream&
operator <<(ostream& os,
const Box& b);
85 BoxContainer(
const Box& b): fBox(b) {}
94 vector<double>::const_iterator boxit = b2.fMin.begin();
95 vector<double>::const_iterator bigit = b1.fMax.begin();
96 while ( isIn && boxit != b2.fMin.end() )
98 if ( (*boxit) >= (*bigit) ) isIn =
false;
103 boxit = b2.fMax.begin();
104 bigit = b1.fMin.begin();
105 while ( isIn && boxit != b2.fMax.end() )
107 if ( (*boxit) <= (*bigit) ) isIn =
false;
122 AreaComparer(vector<double>::iterator iter):
125 fLimit(8 *
std::numeric_limits<double>::
epsilon())
130 if (
fabs(value- (*fIter)) < fLimit )
132 fThereIsArea =
false;
137 bool IsThereArea() {
return fThereIsArea; }
141 vector<double>::iterator fIter;
152 void DivideBox(
const vector<double>& min,
const vector<double>& max,
153 const vector<double>& bmin,
const vector<double>& bmax,
154 const unsigned int size,
const unsigned int n,
155 list<Box>&
l,
const double val,
const double error)
157 vector<double> boxmin(min);
158 vector<double> boxmax(max);
162 if ( for_each(boxmin.begin(), boxmin.end(), AreaComparer(boxmax.begin())).IsThereArea() )
163 l.push_back(Box(boxmin, boxmax));
169 if ( for_each(boxmin.begin(), boxmin.end(), AreaComparer(boxmax.begin())).IsThereArea() )
170 l.push_back(Box(boxmin, boxmax, val, error));
173 DivideBox(boxmin, boxmax, bmin, bmax, size, n-1, l, val, error);
177 if ( for_each(boxmin.begin(), boxmin.end(), AreaComparer(boxmax.begin())).IsThereArea() )
178 l.push_back(Box(boxmin, boxmax));
184 void PushBack(Box&
box) { fProxy.push_back(box); }
185 list<Box>::iterator
Begin() {
return fProxy.begin(); }
186 list<Box>::iterator
End() {
return fProxy.end(); }
187 void Remove(list<Box>::iterator it) { fProxy.erase(it); }
188 list<Box>& GetList() {
return fProxy; }
194 SparseData::SparseData(vector<double>& min, vector<double>& max)
199 Box originalBox(min, max);
200 fList =
new ProxyListBox();
201 fList->PushBack(originalBox);
204 SparseData::SparseData(
const unsigned int dim,
double min[],
double max[])
209 vector<double> minv(min,min+dim);
210 vector<double> maxv(max,max+dim);
211 Box originalBox(minv, maxv);
212 fList =
new ProxyListBox();
213 fList->PushBack(originalBox);
216 SparseData::~SparseData()
219 unsigned int SparseData::NPoints()
const 222 return fList->GetList().size();
225 unsigned int SparseData::NDim()
const 228 return fList->Begin()->GetMin().size();
232 const double content,
const double error)
239 Box littleBox(min, max);
240 list<Box>::iterator it;
243 it = std::find_if(fList->Begin(), fList->End(), BoxContainer(littleBox));
244 if ( it != fList->End() )
248 cout <<
"SparseData::Add -> FAILED! box not found! " << endl;
249 cout << littleBox << endl;
255 it->AddVal( content );
260 littleBox.GetMin(), littleBox.GetMax(),
261 it->GetMin().size(), it->GetMin().size() - 1,
262 fList->GetList(), content, error );
268 void SparseData::GetPoint(
const unsigned int i,
269 std::vector<double>& min, std::vector<double>&max,
270 double& content,
double& error)
275 unsigned int counter = 0;
276 list<Box>::iterator it = fList->Begin();
277 while ( it != fList->End() && counter != i ) {
282 if ( (it == fList->End()) || (counter != i) )
283 throw std::out_of_range(
"SparseData::GetPoint");
287 content = it->GetVal();
288 error = it->GetError();
291 void SparseData::PrintList()
const 294 copy(fList->Begin(), fList->End(), ostream_iterator<Box>(cout,
"\n------\n"));
298 void SparseData::GetBinData(
BinData& bd)
const 302 list<Box>::iterator it = fList->Begin();
303 const unsigned int dim = it->GetMin().size();
307 for ( ; it != fList->End(); ++it )
309 vector<double>
mid(dim);
311 for (
unsigned int i = 0; i < dim; ++i)
313 mid[i] = ((it->GetMax()[i] - it->GetMin()[i]) /2) + it->GetMin()[i];
316 bd.
Add(&mid[0], it->GetVal(), it->GetError());
320 void SparseData::GetBinDataIntegral(
BinData& bd)
const 325 list<Box>::iterator it = fList->Begin();
327 bd.
Initialize(fList->GetList().size(), it->GetMin().size());
329 for ( ; it != fList->End(); ++it )
332 bd.
Add(&(it->GetMin()[0]), it->GetVal(), it->GetError());
338 void SparseData::GetBinDataNoZeros(
BinData& bd)
const 343 list<Box>::iterator it = fList->Begin();
344 const unsigned int dim = it->GetMin().size();
348 for ( ; it != fList->End(); ++it )
351 if ( it->GetVal() == 0 )
continue;
352 vector<double>
mid(dim);
354 for (
unsigned int i = 0; i < dim; ++i)
356 mid[i] = ((it->GetMax()[i] - it->GetMin()[i]) /2) + it->GetMin()[i];
359 bd.
Add(&mid[0], it->GetVal(), it->GetError());
367 copy(b.GetMin().begin(), b.GetMin().end(), ostream_iterator<double>(os,
" "));
369 copy(b.GetMax().begin(), b.GetMax().end(), ostream_iterator<double>(os,
" "));
370 os <<
"val: " << b.GetVal();
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t mid
Namespace for new ROOT classes and functions.
void DivideBox(const vector< double > &min, const vector< double > &max, const vector< double > &bmin, const vector< double > &bmax, const unsigned int size, const unsigned int n, list< Box > &l, const double val, const double error)
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
void AddBinUpEdge(const double *xup)
add the bin width data, a pointer to an array with the bin upper edge information.
TRObject operator()(const T1 &t1) const
void Initialize(unsigned int newPoints, unsigned int dim=1, ErrorType err=kValueError)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
void Add(double x, double y)
add one dim data with only coordinate and values
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Bool_t operator==(const TDatime &d1, const TDatime &d2)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
ostream & operator<<(ostream &os, const ROOT::Fit::Box &b)