41 Box(
const vector<double>&
min,
const vector<double>&
max,
42 const double value = 0.0,
const double error = 1.0):
43 fMin(min), fMax(max), fVal(value), fError(error)
49 {
return (fMin == b.fMin) && (fMax == b.fMax)
50 && (fVal == b.fVal) && (fError == b.fError); }
53 const vector<double>& GetMin()
const {
return fMin; }
55 const vector<double>& GetMax()
const {
return fMax; }
57 double GetVal()
const {
return fVal; }
59 double GetError()
const {
return fError; }
62 void AddVal(
const double value) { fVal +=
value; }
64 friend class BoxContainer;
65 friend ostream&
operator <<(ostream& os,
const Box& b);
84 BoxContainer(
const Box& b): fBox(b) {}
93 vector<double>::const_iterator boxit = b2.fMin.begin();
94 vector<double>::const_iterator bigit = b1.fMax.begin();
95 while ( isIn && boxit != b2.fMin.end() )
97 if ( (*boxit) >= (*bigit) ) isIn =
false;
102 boxit = b2.fMax.begin();
103 bigit = b1.fMin.begin();
104 while ( isIn && boxit != b2.fMax.end() )
106 if ( (*boxit) <= (*bigit) ) isIn =
false;
121 AreaComparer(vector<double>::iterator
iter):
129 if (
fabs(value- (*fIter)) < fLimit )
131 fThereIsArea =
false;
136 bool IsThereArea() {
return fThereIsArea; }
140 vector<double>::iterator fIter;
152 const vector<double>& bmin,
const vector<double>& bmax,
153 const unsigned int size,
const unsigned int n,
154 list<Box>&
l,
const double val,
const double error)
156 vector<double> boxmin(min);
157 vector<double> boxmax(max);
161 if ( for_each(boxmin.begin(), boxmin.end(), AreaComparer(boxmax.begin())).IsThereArea() )
162 l.push_back(Box(boxmin, boxmax));
168 if ( for_each(boxmin.begin(), boxmin.end(), AreaComparer(boxmax.begin())).IsThereArea() )
169 l.push_back(Box(boxmin, boxmax, val, error));
172 DivideBox(boxmin, boxmax, bmin, bmax, size, n-1, l, val, error);
176 if ( for_each(boxmin.begin(), boxmin.end(), AreaComparer(boxmax.begin())).IsThereArea() )
177 l.push_back(Box(boxmin, boxmax));
183 void PushBack(Box& box) { fProxy.push_back(box); }
184 list<Box>::iterator
Begin() {
return fProxy.begin(); }
185 list<Box>::iterator
End() {
return fProxy.end(); }
186 void Remove(list<Box>::iterator it) { fProxy.erase(it); }
187 list<Box>& GetList() {
return fProxy; }
193 SparseData::SparseData(vector<double>&
min, vector<double>&
max)
198 Box originalBox(min, max);
199 fList =
new ProxyListBox();
200 fList->PushBack(originalBox);
203 SparseData::SparseData(
const unsigned int dim,
double min[],
double max[])
208 vector<double> minv(min,min+dim);
209 vector<double> maxv(max,max+dim);
210 Box originalBox(minv, maxv);
211 fList =
new ProxyListBox();
212 fList->PushBack(originalBox);
215 SparseData::~SparseData()
221 return fList->GetList().size();
224 unsigned int SparseData::NDim()
const
227 return fList->Begin()->GetMin().size();
231 const double content,
const double error)
238 Box littleBox(min, max);
239 list<Box>::iterator it;
242 it = std::find_if(fList->Begin(), fList->End(), BoxContainer(littleBox));
243 if ( it != fList->End() )
247 cout <<
"SparseData::Add -> FAILED! box not found! " << endl;
248 cout << littleBox << endl;
254 it->AddVal( content );
259 littleBox.GetMin(), littleBox.GetMax(),
260 it->GetMin().size(), it->GetMin().size() - 1,
261 fList->GetList(), content, error );
267 void SparseData::GetPoint(
const unsigned int i,
268 std::vector<double>&
min, std::vector<double>&
max,
269 double& content,
double& error)
274 unsigned int counter = 0;
275 list<Box>::iterator it = fList->Begin();
276 while ( it != fList->End() && counter != i ) {
281 if ( (it == fList->End()) || (counter != i) )
282 throw std::out_of_range(
"SparseData::GetPoint");
286 content = it->GetVal();
287 error = it->GetError();
290 void SparseData::PrintList()
const
293 copy(fList->Begin(), fList->End(), ostream_iterator<Box>(cout,
"\n------\n"));
297 void SparseData::GetBinData(
BinData& bd)
const
301 list<Box>::iterator it = fList->Begin();
302 const unsigned int dim = it->GetMin().size();
306 for ( ; it != fList->End(); ++it )
308 vector<double> mid(dim);
310 for (
unsigned int i = 0; i < dim; ++i)
312 mid[i] = ((it->GetMax()[i] - it->GetMin()[i]) /2) + it->GetMin()[i];
315 bd.
Add(&mid[0], it->GetVal(), it->GetError());
319 void SparseData::GetBinDataIntegral(
BinData& bd)
const
324 list<Box>::iterator it = fList->Begin();
326 bd.
Initialize(fList->GetList().size(), it->GetMin().size());
328 for ( ; it != fList->End(); ++it )
331 bd.
Add(&(it->GetMin()[0]), it->GetVal(), it->GetError());
337 void SparseData::GetBinDataNoZeros(
BinData& bd)
const
342 list<Box>::iterator it = fList->Begin();
343 const unsigned int dim = it->GetMin().size();
347 for ( ; it != fList->End(); ++it )
350 if ( it->GetVal() == 0 )
continue;
351 vector<double> mid(dim);
353 for (
unsigned int i = 0; i < dim; ++i)
355 mid[i] = ((it->GetMax()[i] - it->GetMin()[i]) /2) + it->GetMin()[i];
358 bd.
Add(&mid[0], it->GetVal(), it->GetError());
366 copy(b.GetMin().begin(), b.GetMin().end(), ostream_iterator<double>(os,
" "));
368 copy(b.GetMax().begin(), b.GetMax().end(), ostream_iterator<double>(os,
" "));
369 os <<
"val: " << b.GetVal();
void Initialize(unsigned int maxpoints, unsigned int dim=1, ErrorType err=kValueError)
preallocate a data set with given size , dimension and error type (to get the full point size) If the...
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
void Add(THist< DIMENSION, PRECISIONA > &to, THist< DIMENSION, PRECISIONB > &from)
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 AddBinUpEdge(const double *xup)
add the bin width data, a pointer to an array with the bin upper edge information.
std::map< std::string, std::string >::const_iterator iter
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 ...
TRObject operator()(const T1 &t1) const
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)
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Bool_t operator==(const TDatime &d1, const TDatime &d2)
ostream & operator<<(ostream &os, const ROOT::Fit::Box &b)