118 ,
Int_t numberRows):fsimpleArray(0),fParentTable(&table)
171 TString colName =
"user's defined";
199 TString colName =
"user's defined";
255 while((br = strchr(br+1,
'['))) {
269 const char *openBracket = colName.
Data()-1;
270 const char *closeBracket = colName.
Data()-1;
272 openBracket = strchr(openBracket+1,
'[');
273 closeBracket = strchr(closeBracket+1,
']');
274 if (closeBracket > openBracket)
277 Error(
"TTable ctor",
"Wrong parethethis <%s>",colName.
Data());
283 if (colName !=
"user's defined") {
325 if (sample > *p) isPreSorted =
kFALSE;
331 if (!isPreSorted)
QSort();
369 if (sample > *p) isPreSorted =
kFALSE;
375 if (!isPreSorted)
QSort();
413 if (sample > *p) isPreSorted =
kFALSE;
418 if (!isPreSorted)
QSort();
437 if (firstRow > arraySize)
return;
471 #define BINARYSEARCH(valuetype) Int_t TTableSorter::BinarySearch(valuetype value) const {\ 472 switch (fColType) { \ 473 case TTable::kFloat: \ 474 return SelectSearch(Float_t(value)); \ 475 case TTable::kInt : \ 476 return SelectSearch(Int_t(value)); \ 477 case TTable::kLong : \ 478 return SelectSearch(Long_t(value)); \ 479 case TTable::kShort : \ 480 return SelectSearch(Short_t(value)); \ 481 case TTable::kDouble : \ 482 return SelectSearch(Double_t(value)); \ 483 case TTable::kUInt: \ 484 return SelectSearch(UInt_t(value)); \ 485 case TTable::kULong : \ 486 return SelectSearch(ULong_t(value)); \ 487 case TTable::kUShort: \ 488 return SelectSearch(UShort_t(value)); \ 489 case TTable::kBool: \ 490 return SelectSearch(Bool_t(value)); \ 491 case TTable::kUChar: \ 492 return SelectSearch(UChar_t(value)); \ 493 case TTable::kChar: \ 494 return SelectSearch(Char_t(value)); \ 500 Int_t TTableSorter::BSearch(valuetype value) const{ \ 501 union { Bool_t Bool; \ 514 switch (fColType) { \ 515 case TTable::kFloat: \ 516 value_.Float = Float_t(value); break; \ 517 case TTable::kInt : \ 518 value_.Int = Int_t(value); break; \ 519 case TTable::kLong : \ 520 value_.Long = Long_t(value); break; \ 521 case TTable::kShort : \ 522 value_.Short = Short_t(value); break; \ 523 case TTable::kDouble : \ 524 value_.Double= Double_t(value);break; \ 525 case TTable::kUInt: \ 526 value_.UInt = UInt_t(value); break; \ 527 case TTable::kULong : \ 528 value_.ULong = ULong_t(value); break; \ 529 case TTable::kUShort: \ 530 value_.UShort= UShort_t(value);break; \ 531 case TTable::kUChar: \ 532 value_.UChar = UChar_t(value); break; \ 533 case TTable::kChar: \ 534 value_.Char = Char_t(value); break; \ 535 case TTable::kBool: \ 536 value_.Bool = Bool_t(value); break; \ 541 return BSearch(&value_); \ 543 Int_t TTableSorter::SelectSearch(valuetype value) const { \ 544 valuetype **array = (valuetype **)fSortIndex; \ 545 Int_t nabove, nbelow, middle; \ 546 nabove = fNumberOfRows+1; \ 548 while(nabove-nbelow > 1) { \ 549 middle = (nabove+nbelow)/2; \ 550 if (value == *array[middle-1]) { nbelow = middle; break; } \ 551 if (value < *array[middle-1]) nabove = middle; \ 552 else nbelow = middle; \ 555 ((TTableSorter *)this)->fLastFound = nbelow; \ 556 if (nbelow < 0) return nbelow; \ 557 return GetIndex(nbelow); \ 560 #define COMPAREFLOATVALUES(valuetype) \ 561 int TTableSorter::Search##valuetype (const void *elem1, const void **elem2) { \ 562 valuetype *value1 = (valuetype *)(elem1); \ 563 valuetype *value2 = (valuetype *)(*elem2); \ 564 valuetype diff = *value1-*value2; \ 566 if (diff > 0) res = 1; \ 567 else if (diff < 0) res = -1; \ 570 int TTableSorter::Compare##valuetype (const void **elem1, const void **elem2) {\ 571 valuetype *value1 = (valuetype *)(*elem1); \ 572 valuetype *value2 = (valuetype *)(*elem2); \ 573 valuetype diff = *value1-*value2; \ 575 if (diff > 0 ) res = 1; \ 576 else if (diff < 0) res = -1; \ 577 if (res) return res; \ 578 return int(value1-value2); \ 580 BINARYSEARCH(valuetype) 584 #define COMPAREVALUES(valuetype) \ 585 int TTableSorter::Search##valuetype (const void *elem1, const void **elem2) { \ 586 valuetype *value1 = (valuetype *)(elem1); \ 587 valuetype *value2 = (valuetype *)(*elem2); \ 588 return int(*value1-*value2); \ 590 int TTableSorter::Compare##valuetype (const void **elem1, const void **elem2) { \ 591 valuetype *value1 = (valuetype *)(*elem1); \ 592 valuetype *value2 = (valuetype *)(*elem2); \ 593 valuetype diff = *value1-*value2; \ 594 if (diff ) return diff; \ 595 return int(value1-value2); \ 597 BINARYSEARCH(valuetype) 611 #define COMPAREORDER(valuetype) Compare##valuetype 612 #define SEARCHORDER(valuetype) Search##valuetype 621 void **p = (
void **)::bsearch((
void *) value,
664 int TTableSorter::CompareUChar (
const void *elem1,
const void *elem2)
674 int TTableSorter::CompareChar (
const void *elem1,
const void *elem2)
695 if (firstRow) *firstRow = -1;
697 Int_t indx = firstIndx;
712 if (firstRow && count) *firstRow = indx-count;
751 const void *sample = row;
904 if (!classPtr)
return;
907 if (!(classPtr->
GetNdata()))
return;
922 if (!strcmp(
"float", types))
924 else if (!strcmp(
"int", types))
926 else if (!strcmp(
"long", types))
928 else if (!strcmp(
"short", types))
930 else if (!strcmp(
"double", types))
932 else if (!strcmp(
"unsigned int", types))
934 else if (!strcmp(
"unsigned long", types))
936 else if (!strcmp(
"unsigned short", types))
938 else if (!strcmp(
"unsigned char", types))
940 else if (!strcmp(
"char", types))
942 else if (!strcmp(
"bool", types))
947 Int_t globalIndex = 0;
948 if ( (dim = member->GetArrayDim()) ) {
951 Error(
"LearnTable",
"Wrong dimension");
958 globalIndex *= member->GetMaxIndex(indx);
963 fColOffset = member->GetOffset() + memberType->
Size() * globalIndex;
971 #undef COMPAREFLOATVALUES Int_t GetIndex(UInt_t sortedIndex) const
returns the original index of the row by its sorted index
void LearnTable()
LearnTable() allows the TTableSorter to learn the structure of the tables used to fill the ntuple...
virtual const char * GetName() const
Returns name of object.
Int_t GetNdata()
Return the number of data members of this class Note that in case the list of data members is not yet...
virtual TTable * GetTable() const
to be documented
static TDataType * GetDataType(EDataType type)
Given a EDataType type, get the TDataType* that represents it.
TString GetTypeName()
Get basic type of typedef, e,g.
All ROOT classes may have RTTI (run time type identification) support added.
virtual void SetName(const char *name)
Set the name of the TNamed.
const char * fFirstParentRow
virtual TClass * GetRowClass() const
to be documented
#define COMPAREVALUES(valuetype)
int compare(double v1, double v2, const std::string &name="", double scale=1.0)
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
virtual Int_t CountKey(const void *key, Int_t firstIndx=0, Bool_t bSearch=kTRUE, Int_t *firstRow=0) const
CountKey counts the number of rows with the key value equal "key".
Short_t Min(Short_t a, Short_t b)
Bool_t FillIndexArray()
File the array of the pointers and check whether the original table has been sorted to avoid an extra...
Int_t BSearch(const void *value) const
to be documented
COMPAREMETHOD fCompareMethod
virtual const Char_t * GetType() const
Returns the type of the wrapped C-structure kept as the TNamed title.
#define SEARCHORDER(valuetype)
virtual Int_t CountKeys() const
Counts the number of different key values.
const Char_t * fsimpleArray
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
#define COMPAREFLOATVALUES(valuetype)
Int_t(* CALLQSORT)(const void *, const void *)
virtual const char * GetTableType() const
to be documented
Int_t(* SEARCHMETHOD)(const void *, const void **)
void SetSearchMethod()
Select search function at once.
const TTable * fParentTable
virtual Int_t GetLastFound() const
void BuildRealData(void *pointer=0, Bool_t isTransient=kFALSE)
Build a full list of persistent data members.
#define COMPAREORDER(valuetype)
void BuildSorter(TString &colName, Int_t firstRow, Int_t numberRows)
BuildSorter backs TTableSorter ctor.
void QSort()
Call the standard C run-time library "qsort" function.
Basic data type descriptor (datatype information is obtained from CINT).
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual Int_t FindFirstKey(const void *key) const
Looks for the first index of the "key" within SORTED table AFTER sorting.
virtual Int_t GetNRows() const
The ROOT global object gROOT contains a list of all defined classes.
char * StrDup(const char *str)
Duplicate the string str.
SEARCHMETHOD fSearchMethod
const char * At(Int_t i) const
Int_t(* COMPAREMETHOD)(const void **, const void **)
TList * GetListOfRealData() const
Short_t Max(Short_t a, Short_t b)
TTable::EColumnType fColType
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Int_t Size() const
Get size of basic typedef'ed type.
virtual Long_t GetRowSize() const
Returns the size (in bytes) of one table row.
virtual ~TTableSorter()
to be documented
void SetSimpleArray(Int_t arraySize, Int_t firstRow, Int_t numberRows)
Set some common parameteres for the "simple" arrays.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetTableName() const
to be documented
virtual const char * GetTableTitle() const
to be documented
virtual const char * GetTitle() const
Returns title of object.
const char * Data() const