simple index class for fast search in linear cases
More...
#include <EdbMath.h>
|
static Double_t | BuildValue (Int_t major, Int_t minor) |
|
simple index class for fast search in linear cases
◆ TIndex2() [1/2]
◆ TIndex2() [2/2]
TIndex2::TIndex2 |
( |
int |
size | ) |
|
|
inline |
◆ ~TIndex2()
virtual TIndex2::~TIndex2 |
( |
| ) |
|
|
inlinevirtual |
◆ BuildIndex()
void TIndex2::BuildIndex |
( |
int |
n, |
|
|
double * |
w |
|
) |
| |
360{
361 Int_t *ind = new Int_t[n];
362 TMath::Sort(n,
w,ind,0);
363 Set(n);
364 for (Int_t i=0;i<n;i++) {
365 (*this)[i] =
w[ind[i]];
366 }
367}
void w(int rid=2, int nviews=2)
Definition: test.C:27
◆ BuildValue()
static Double_t TIndex2::BuildValue |
( |
Int_t |
major, |
|
|
Int_t |
minor |
|
) |
| |
|
inlinestatic |
58{return major+minor*1e-9;}
◆ Find()
Int_t TIndex2::Find |
( |
Int_t |
major, |
|
|
Int_t |
minor |
|
) |
| |
371{
372 if (GetSize()<1) return -1;
374 Int_t i = TMath::BinarySearch( fN, GetArray(), value);
375 if (i < 0) return -1;
376 if (TMath::Abs((*this)[i] - value) > 1.e-10) return -1;
377 return i;
378}
static Double_t BuildValue(Int_t major, Int_t minor)
Definition: EdbMath.h:58
◆ FindIndex()
Int_t TIndex2::FindIndex |
( |
Int_t |
major | ) |
|
return the value of minor (this make sence in the case when major is unique)
382{
384 if (fN<1) return -1;
385 Double_t value = (Double_t)major;
386 Int_t i = TMath::BinarySearch( fN, GetArray(), value);
387 if (i < -1) return -1;
388 if (i == -1) i++;
389 if(i>fN-1) return -1;
390 if( (*this)[i]<major ) i++;
391 if(i>fN-1) return -1;
392 if (TMath::Abs((*this)[i] - value) > .5) return -1;
393 return (Int_t)( ((*this)[i]-value+1e-10)*1e+9 );
394}
◆ FindIndexArr()
Int_t TIndex2::FindIndexArr |
( |
Int_t |
major, |
|
|
TArrayI & |
mina |
|
) |
| |
return the number of found events with given major
Output: mina - array of minors - should be big enough
398{
401
402 if (fN<1) return -1;
403 Double_t value = (Double_t)major;
404 Int_t i = TMath::BinarySearch( fN, GetArray(), value);
405 if (i < -1) return -1;
406 if (i == -1) i++;
407 if(i>fN-1) return -1;
408 if( (*this)[i]<major ) i++;
409 if(i>fN-1) return -1;
410 if (TMath::Abs((*this)[i] - value) > .5) return -1;
411
412 int na=mina.fN;
413 int ia=0;
414 for(ia=0; ia<na; ia++) {
415 if( (*this)[i+ia] > value+1-1e-10 ) break;
416 mina[ia] = (Int_t)( ((*this)[i+ia]-value+1e-10)*1e+9 );
417 }
418 return ia;
419}
◆ Major()
Int_t TIndex2::Major |
( |
int |
i | ) |
|
|
inline |
61{ return (Int_t)((*this)[i]); }
◆ Minor()
Int_t TIndex2::Minor |
( |
int |
i | ) |
|
|
inline |
62{
return (Int_t)(((*this)[i]- (Double_t)
Major(i)+1e-10)*1e+9 ); }
Int_t Major(int i)
Definition: EdbMath.h:61
◆ Print()
423{
424 for(int i=0; i<fN; i++)
426}
Int_t Minor(int i)
Definition: EdbMath.h:62
◆ SetMinor()
void TIndex2::SetMinor |
( |
int |
i, |
|
|
Int_t |
minor |
|
) |
| |
|
inline |
The documentation for this class was generated from the following files:
- /home/antonio/fedra_doxygen/src/libEmath/EdbMath.h
- /home/antonio/fedra_doxygen/src/libEmath/EdbMath.cxx