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;
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; }
199 Box originalBox(min, max);
200 fList =
new ProxyListBox();
201 fList->PushBack(originalBox);
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);
222 return fList->GetList().size();
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 );
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();
294 copy(
fList->Begin(),
fList->End(), ostream_iterator<Box>(cout,
"\n------\n"));
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());
325 list<Box>::iterator it =
fList->Begin();
329 for ( ; it !=
fList->End(); ++it )
332 bd.
Add(&(it->GetMin()[0]), it->GetVal(), it->GetError());
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();
Bool_t operator==(const TDatime &d1, const TDatime &d2)
TRObject operator()(const T1 &t1) const
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
void AddBinUpEdge(const double *xup)
add the bin width data, a pointer to an array with the bin upper edge information.
void Add(double x, double y)
add one dim data with only coordinate and values
void Initialize(unsigned int newPoints, unsigned int dim=1, ErrorType err=kValueError)
void Add(std::vector< double > &min, std::vector< double > &max, const double content, const double error=1.0)
unsigned int NDim() const
void GetPoint(const unsigned int i, std::vector< double > &min, std::vector< double > &max, double &content, double &error)
unsigned int NPoints() const
void GetBinDataNoZeros(BinData &) const
void GetBinData(BinData &) const
SparseData(std::vector< double > &min, std::vector< double > &max)
void GetBinDataIntegral(BinData &) const
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
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)
ostream & operator<<(ostream &os, const ROOT::Fit::Box &b)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Namespace for new ROOT classes and functions.