133 #include "RConfigure.h"
136 #include "Riostream.h"
142 #include "TBaseClass.h"
147 #include "TBrowser.h"
149 #include "TInterpreter.h"
150 #include "TDataSetIter.h"
152 #include "TTableDescriptor.h"
153 #include "TColumnView.h"
159 #include "TProfile.h"
160 #include "TVirtualPad.h"
161 #include "TEventList.h"
162 #include "TPolyMarker.h"
165 #include "TPolyMarker3D.h"
167 #include "THLimitsFinder.h"
169 #include "TTableMap.h"
171 static TH1 *gCurrentTableHist = 0;
173 static const char *gDtorName =
"dtor";
174 static Int_t gNbins[4] = {100,100,100,100};
175 static Float_t gVmin[4] = {0,0,0,0};
176 static Float_t gVmax[4] = {20,20,20,20};
178 const char *TTable::fgTypeName[] = {
179 "NAN",
"float",
"int",
"long",
"short",
"double",
180 "unsigned int",
"unsigned long",
"unsigned short",
181 "unsigned char",
"char",
"Ptr_t"
198 static void ArrayLayout(UInt_t *layout,
const UInt_t *size, Int_t dim)
200 if (dim && layout && size) {
201 if (++layout[dim-1] >= size[dim-1]) {
204 ArrayLayout(layout,size, dim);
231 int prevPrec = out.precision();
232 const std::ios_base::fmtflags prevFmt = out.flags();
236 out << std::dec << std::setw(width) << std::setprecision(width-3) << *(
float *)buf;
239 out << std::dec << std::setw(width) << *(
int *)buf;
242 out << std::dec << std::setw(width) << *(Long_t *)buf;
245 out << std::dec << std::setw(width) << *(
short *)buf;
248 out << std::dec << std::setw(width) << std::setprecision(width-3) << *(
double *)buf;
251 out << std::dec << std::setw(width) << *(
unsigned int *)buf;
254 out << std::dec << std::setw(width) << *(ULong_t *)buf;
257 out << std::setw(width) <<
"0x" << std::hex << *(
unsigned short *)buf;
260 out << std::setw(width) <<
"0x" << std::hex << int(*(
unsigned char *)buf);
263 out << std::setw(width) << *(
char *)buf;
266 out << std::setw(width) << *(Bool_t *)buf;
269 out <<
"->" << std::setw(width) << *(
void **)buf;
275 out.precision(prevPrec);
284 return fgTypeName[type];
294 Int_t allTypes =
sizeof(fgTypeName)/
sizeof(
const char *);
295 for (
int i = 0; i < allTypes; i++)
296 if (!strcmp(fgTypeName[i],typeName))
return EColumnType(i);
305 if (!BoundsOk(
"TTable::At", i)) {
306 Warning(
"TTable::At",
"%s.%s",GetName(),
GetType());
309 return (
const void *)(fTable+i*fSize);
334 assert(!TestBit(kIsNotOwn));
335 if (!(srcTable && srcTable->
GetNRows()) || srcRow > srcTable->
GetNRows()-1 )
return 0;
338 if (!nRows) nRows = srcTable->
GetNRows();
340 Long_t extraRows = (tSize - dstRow) - nRows;
348 if (dstRow+nRows >
GetNRows()) SetNRows(dstRow+nRows);
349 ::memmove((*
this)[dstRow],(*srcTable)[srcRow],(
size_t)
GetRowSize()*nRows);
353 "This table is <%s> but the src table has a wrong type <%s>",
GetType()
380 TH1 *TTable::Draw(TCut varexp, TCut selection, Option_t *option, Int_t nentries, Int_t firstentry)
382 return TTable::Draw(varexp.GetTitle(), selection.GetTitle(), option, nentries, firstentry);
480 TH1 *TTable::Draw(
const char *varexp00,
const char *selection, Option_t *option,Int_t nentries, Int_t firstentry)
482 if (
GetNRows() == 0 || varexp00 == 0 || varexp00[0]==0)
return 0;
485 const char *hdefault =
"htemp";
490 char *varexp0 = StrDup(varexp00);
491 char *hname = strstr(varexp0,
">>");
493 TEventList *elist = 0;
494 Bool_t profile = kFALSE;
496 gCurrentTableHist = 0;
501 i = strcspn(varexp0,
">>");
502 Bool_t hnameplus = kFALSE;
503 while (*hname ==
' ') hname++;
507 while (*hname ==
' ') hname++;
510 if (hname[j] !=
' ')
break;
516 oldh1 = (TH1*)gDirectory->Get(hname);
517 if (oldh1 && !hnameplus) oldh1->Reset();
519 elist = (TEventList*)gDirectory->Get(hname);
521 elist =
new TEventList(hname,selection,1000,0);
523 if (elist && !hnameplus) elist->Reset();
526 if (!hname || *hname==0) {
529 oldh1 = (TH1*)gDirectory->Get(hdefault);
530 if (oldh1 ) { oldh1->Delete(); oldh1 = 0;}
535 const Char_t *expressions[] ={varexp0,0,0,0,selection};
536 Int_t maxExpressions =
sizeof(expressions)/
sizeof(Char_t *);
537 Char_t *nextColon = varexp0;
539 while ((nextColon = strchr(nextColon,
':')) && ( colIndex < maxExpressions - 1 ) ) {
542 expressions[colIndex] = nextColon;
546 expressions[colIndex] = selection;
551 Printf(
" Draw %s for <%s>\n", varexp00, selection);
562 Int_t dimension = colIndex;
564 TString title = expressions[0];
565 for (i=1;i<colIndex;i++) {
567 title += expressions[i];
569 Int_t nsel = strlen(selection);
571 if (nsel < 80-title.Length()) {
579 const Char_t *htitle = title.Data();
582 Int_t mustdelete = 0;
583 if (oldh1->InheritsFrom(TProfile::Class())) profile = kTRUE;
584 if (opt.Contains(
"prof")) {
585 if (!profile) mustdelete = 1;
587 if (oldh1->GetDimension() != dimension) mustdelete = 1;
590 Warning(
"Draw",
"Deleting old histogram with different dimensions");
591 delete oldh1; oldh1 = 0;
595 if (!gPad && !opt.Contains(
"goff") && dimension > 0) {
596 gROOT->MakeDefCanvas();
599 if (dimension == 1) {
603 if (gPad && opt.Contains(
"same")) {
604 TH1 *oldhtemp = (TH1*)gPad->FindObject(hdefault);
606 gNbins[0] = oldhtemp->GetXaxis()->GetNbins();
607 gVmin[0] = oldhtemp->GetXaxis()->GetXmin();
608 gVmax[0] = oldhtemp->GetXaxis()->GetXmax();
610 gVmin[0] = gPad->GetUxmin();
611 gVmax[0] = gPad->GetUxmax();
620 gNbins[0] = h1->GetXaxis()->GetNbins();
622 h1 =
new TH1F(hname,htitle,gNbins[0],gVmin[0],gVmax[0]);
624 h1->SetBit(kCanDelete);
627 if (opt.Length() && opt[0] ==
'e') h1->Sumw2();
630 EntryLoop(exprFileName,action, h1, nentries, firstentry, option);
633 if (!opt.Contains(
"goff")) h1->Draw(option);
636 }
else if (dimension == 2) {
638 if (!opt.Contains(
"same") && gPad) gPad->Clear();
639 if (!oldh1 || !opt.Contains(
"same")) {
642 if (opt.Contains(
"prof")) gNbins[1] = 100;
643 if (opt.Contains(
"same")) {
644 TH1 *oldhtemp = (TH1*)gPad->FindObject(hdefault);
646 gNbins[1] = oldhtemp->GetXaxis()->GetNbins();
647 gVmin[1] = oldhtemp->GetXaxis()->GetXmin();
648 gVmax[1] = oldhtemp->GetXaxis()->GetXmax();
649 gNbins[0] = oldhtemp->GetYaxis()->GetNbins();
650 gVmin[0] = oldhtemp->GetYaxis()->GetXmin();
651 gVmax[0] = oldhtemp->GetYaxis()->GetXmax();
654 gVmin[1] = gPad->GetUxmin();
655 gVmax[1] = gPad->GetUxmax();
657 gVmin[0] = gPad->GetUymin();
658 gVmax[0] = gPad->GetUymax();
664 if (profile || opt.Contains(
"prof")) {
668 hp = (TProfile*)oldh1;
670 if (action < 0) action = -4;
671 if (opt.Contains(
"profs"))
672 hp =
new TProfile(hname,htitle,gNbins[1],gVmin[1], gVmax[1],
"s");
674 hp =
new TProfile(hname,htitle,gNbins[1],gVmin[1], gVmax[1],
"");
676 hp->SetBit(kCanDelete);
681 EntryLoop(exprFileName,action,hp,nentries, firstentry, option);
683 if (!opt.Contains(
"goff")) hp->Draw(option);
689 h2 =
new TH2F(hname,htitle,gNbins[1],gVmin[1], gVmax[1], gNbins[0], gVmin[0], gVmax[0]);
691 const Int_t kNoStats = BIT(9);
692 h2->SetBit(kCanDelete);
693 h2->SetBit(kNoStats);
697 Int_t noscat = strlen(option);
698 if (opt.Contains(
"same")) noscat -= 4;
700 EntryLoop(exprFileName,action,h2,nentries, firstentry, option);
702 if (!opt.Contains(
"goff")) h2->Draw(option);
705 if (!oldh1 && !opt.Contains(
"same")) action = -12;
706 EntryLoop(exprFileName,action,h2,nentries, firstentry, option);
708 if (oldh1 && !opt.Contains(
"goff")) h2->Draw(option);
713 }
else if (dimension == 3) {
715 if (!opt.Contains(
"same")) action = -13;
716 EntryLoop(exprFileName,action,0,nentries, firstentry, option);
726 delete [] exprFileName;
728 return gCurrentTableHist;
735 static void FindGoodLimits(Int_t nbins, Int_t &newbins, Float_t &xmin, Float_t &xmax)
737 Double_t binlow=0,binhigh=0,binwidth=0;
739 Double_t dx = 0.1*(xmax-xmin);
740 Double_t umin = xmin - dx;
741 Double_t umax = xmax + dx;
742 if (umin < 0 && xmin >= 0) umin = 0;
743 if (umax > 0 && xmax <= 0) umax = 0;
745 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,03,5)
746 THLimitsFinder::Optimize(umin,umax,nbins,binlow,binhigh,n,binwidth,
"");
748 TGaxis::Optimize(umin,umax,nbins,binlow,binhigh,n,binwidth,
"");
751 if (binwidth <= 0 || binwidth > 1.e+39) {
786 ,Int_t nentries, Int_t firstentry, Option_t *option)
788 Double_t rmin[3],rmax[3];
789 if (gInterpreter->LoadFile((Char_t *)exprFileName) < 0) {
790 Error(
"EntryLoop",
"Error: loading file %s",exprFileName);
797 const Char_t *funcName =
"SelectionQWERTY";
799 const Char_t *argtypes =
"Float_t *,float **, int&, int& ";
801 G__ClassInfo globals;
802 G__MethodInfo func = globals.GetMethod(funcName,argtypes,&offset);
805 struct G__bytecodefunc *pbc = func.GetBytecode();
807 Error(
"EntryLoop",
"Bytecode compilation %s",funcName);
808 G__unloadfile((Char_t *)exprFileName);
817 Float_t results[] = {1,1,1,1,1};
818 Char_t **addressArray = (Char_t **)
new ULong_t[tabsDsc->
GetNRows()];
819 Char_t *thisTable = (Char_t *)GetArray();
820 const Char_t *argtypes =
"Float_t *,float **, int&, int& ";
822 ClassInfo_t *globals = gInterpreter->ClassInfo_Factory();
823 CallFunc_t *callfunc = gInterpreter->CallFunc_Factory();
824 gInterpreter->CallFunc_SetFunc(callfunc,globals,funcName,argtypes,&offset);
826 gInterpreter->CallFunc_SetArg(callfunc,(Long_t)(&results[0]));
827 gInterpreter->CallFunc_SetArg(callfunc,(Long_t)(addressArray));
828 gInterpreter->CallFunc_SetArg(callfunc,(Long_t)(&i));
829 gInterpreter->CallFunc_SetArg(callfunc,(Long_t)(&nRows));
833 #define CALLMETHOD gInterpreter->CallFunc_Exec(callfunc,0);
835 #define TAKEACTION_BEGIN \
836 descTable = tabsDsc->GetTable(); \
837 for (i=0; i < tabsDsc->GetNRows(); i++,descTable++ ) \
838 addressArray[i] = addressEntry + descTable->fOffset; \
839 for(i=firstentry;i<lastEntry;i++) { \
842 #define TAKEACTION_END for (int j=0; j < tabsDsc->GetNRows(); j++ ) addressArray[j] += rSize;}
845 if (firstentry < nRows ) {
847 Char_t *addressEntry = thisTable + rSize*firstentry;
848 Int_t lastEntry = TMath::Min(UInt_t(firstentry+nentries),UInt_t(nRows));
850 gVmin[0] = gVmin[1] = gVmin[2] = 1e30;
851 gVmax[0] = gVmax[1] = gVmax[2] = -gVmin[0];
858 if (gVmin[0] > results[0]) gVmin[0] = results[0];
859 if (gVmax[0] < results[0]) gVmax[0] = results[0];
864 if (gVmin[0] >= gVmax[0]) { gVmin[0] -= 1; gVmax[0] += 1;}
865 FindGoodLimits(nchans,gNbins[0],gVmin[0],gVmax[0]);
866 ((TH1 *)obj)->SetBins(gNbins[0],gVmin[0],gVmax[0]);
871 if (results[1]) ((TH1 *)obj)->Fill(Axis_t(results[0]),Stat_t(results[1]));
873 gCurrentTableHist = ((TH1 *)obj);
878 if (gVmin[0] > results[1]) gVmin[0] = results[1];
879 if (gVmax[0] < results[1]) gVmax[0] = results[1];
880 if (gVmin[1] > results[0]) gVmin[1] = results[0];
881 if (gVmax[1] < results[0]) gVmax[1] = results[0];
885 if (gVmin[0] >= gVmax[0]) { gVmin[0] -= 1; gVmax[0] += 1;}
886 FindGoodLimits(nchans,gNbins[0],gVmin[0],gVmax[0]);
887 if (gVmin[1] >= gVmax[1]) { gVmin[1] -= 1; gVmax[1] += 1;}
888 FindGoodLimits(nchans,gNbins[1],gVmin[1],gVmax[1]);
889 ((TH1*)obj)->SetBins(gNbins[1],gVmin[1],gVmax[1],gNbins[0],gVmin[0],gVmax[0]);
892 if (obj->IsA() == TH2F::Class()) {
894 if (results[2]) ((TH2F*)obj)->Fill(Axis_t(results[0]),Axis_t(results[1]),Stat_t(results[2]));
896 }
else if (obj->IsA() == TH2S::Class()) {
898 if (results[2]) ((TH2S*)obj)->Fill(Axis_t(results[0]),Axis_t(results[1]),Stat_t(results[2]));
900 }
else if (obj->IsA() == TH2C::Class()) {
902 if (results[2]) ((TH2C*)obj)->Fill(Axis_t(results[0]),Axis_t(results[1]),Stat_t(results[2]));
904 }
else if (obj->IsA() == TH2D::Class()) {
906 if (results[2]) ((TH2D*)obj)->Fill(Axis_t(results[0]),Axis_t(results[1]),Stat_t(results[2]));
909 gCurrentTableHist = ((TH1 *)obj);
914 if (gVmin[0] > results[1]) gVmin[0] = results[1];
915 if (gVmax[0] < results[1]) gVmax[0] = results[1];
916 if (gVmin[1] > results[0]) gVmin[1] = results[0];
917 if (gVmax[1] < results[0]) gVmax[1] = results[0];
921 if (gVmin[1] >= gVmax[1]) { gVmin[1] -= 1; gVmax[1] += 1;}
922 FindGoodLimits(nchans,gNbins[1],gVmin[1],gVmax[1]);
923 ((TProfile*)obj)->SetBins(gNbins[1],gVmin[1],gVmax[1]);
927 if (results[2]) ((TProfile*)obj)->Fill(Axis_t(results[0]),Axis_t(results[1]),Stat_t(results[2]));
933 if (gVmin[0] > results[1]) gVmin[0] = results[1];
934 if (gVmax[0] < results[1]) gVmax[0] = results[1];
935 if (gVmin[1] > results[0]) gVmin[1] = results[0];
936 if (gVmax[1] < results[0]) gVmax[1] = results[0];
940 if (gVmin[0] >= gVmax[0]) { gVmin[0] -= 1; gVmax[0] += 1;}
941 FindGoodLimits(nchans,gNbins[0],gVmin[0],gVmax[0]);
942 if (gVmin[1] >= gVmax[1]) { gVmin[1] -= 1; gVmax[1] += 1;}
943 FindGoodLimits(nchans,gNbins[1],gVmin[1],gVmax[1]);
944 ((TH2F*)obj)->SetBins(gNbins[1],gVmin[1],gVmax[1],gNbins[0],gVmin[0],gVmax[0]);
947 if (!strstr(option,
"same") && !strstr(option,
"goff")) {
948 ((TH2F*)obj)->DrawCopy(option);
954 Float_t *x =
new Float_t[lastEntry-firstentry];
955 Float_t *y =
new Float_t[lastEntry-firstentry];
957 Float_t umin = gPad->GetUxmin();
958 Float_t umax = gPad->GetUxmax();
959 Float_t vmin = gPad->GetUymin();
960 Float_t vmax = gPad->GetUymax();
961 Int_t pointIndex = 0;
964 u = gPad->XtoPad(results[0]);
965 v = gPad->YtoPad(results[1]);
966 if (u < umin) u = umin;
967 if (u > umax) u = umax;
968 if (v < vmin) v = vmin;
969 if (v > vmax) v = vmax;
975 if (pointIndex && !strstr(option,
"goff")) {
976 TPolyMarker *pm =
new TPolyMarker(pointIndex,x,y);
978 pm->SetBit(kCanDelete);
980 if (!((TH2F*)obj)->TestBit(kCanDelete))
982 for(i=0;i<pointIndex;i++) ((TH2F*)obj)->Fill(x[i], y[i]);
983 delete [] x;
delete [] y;
984 gCurrentTableHist = ((TH1*)obj);
990 if (gVmin[0] > results[2]) gVmin[0] = results[2];
991 if (gVmax[0] < results[2]) gVmax[0] = results[2];
992 if (gVmin[1] > results[1]) gVmin[1] = results[1];
993 if (gVmax[1] < results[1]) gVmax[1] = results[1];
994 if (gVmin[2] > results[0]) gVmin[2] = results[0];
995 if (gVmax[2] < results[0]) gVmax[2] = results[0];
998 rmin[0] = gVmin[2]; rmin[1] = gVmin[1]; rmin[2] = gVmin[0];
999 rmax[0] = gVmax[2]; rmax[1] = gVmax[1]; rmax[2] = gVmax[0];
1001 gPad->Range(-1,-1,1,1);
1002 TView::CreateView(1,rmin,rmax);
1005 TPolyMarker3D *pm3d =
new TPolyMarker3D(lastEntry-firstentry);
1006 pm3d->SetBit(kCanDelete);
1011 if (results[3]) pm3d->SetNextPoint(results[0],results[1],results[2]);
1017 Error(
"EntryLoop",
"unknown action \"%d\" for table <%s>", action, GetName());
1021 gInterpreter->CallFunc_Delete(callfunc);
1022 gInterpreter->ClassInfo_Delete(globals);
1023 gInterpreter->UnloadFile((Char_t *)exprFileName);
1024 delete [] addressArray;
1032 fSize(size),fN(0), fTable(0),fMaxIndex(0)
1034 if (size == 0) Warning(
"TTable(0)",
"Wrong table format");
1041 fSize(size),fN(0),fTable(0),fMaxIndex(0)
1050 fSize(size),fN(0),fTable(0),fMaxIndex(0)
1058 TTable::TTable(
const char *name,
const char *type, Int_t n, Char_t *array, Int_t size)
1059 :
TDataSet(name),fSize(size),fTable(0),fMaxIndex(0)
1075 Set(table.fN, table.fTable);
1086 if (
this != &rhs && rhs.
GetNRows() >0 ){
1111 SetfN(n); SetUsedRows(n);
1112 fTable = (
char *)arr;
1140 if (!BoundsOk(
"TTable::AddAt", i))
1142 if (row) memcpy(fTable+i*fSize,row,fSize);
1143 else memset(fTable+i*fSize,127,fSize);
1144 SetUsedRows(TMath::Max((Int_t)i+1,Int_t(fMaxIndex)));
1153 ::memcpy(dest,src,fSize*fN);
1169 for (
int i=0; i<= columnIndex; i++) nxc = nextComment();
1170 return nxc ? nxc->GetTitle() : 0;
1180 if (!TestBit(kIsNotOwn) && row && nRows ) {
1184 ::memmove(fTable+indx*fSize,row,fSize*nRows);
1186 return TestBit(kIsNotOwn) ? 0 : GetSize();
1205 Long_t nShifted = 0;
1210 ::memmove(fTable+indx*fSize,row,fSize*nRows);
1225 return (
void *)fTable;
1236 if (newsize > fN)
ReAlloc(newsize);
1237 return (
void *)fTable;
1245 if (!TestBit(kIsNotOwn) && newsize > 0) {
1247 Int_t sleepCounter = 0;
1248 while (!(arr = realloc(fTable,fSize*newsize))) {
1251 "Not enough memory to Reallocate %d bytes for table <%s::%s>. Please cancel some jobs",
1252 newsize,
GetType(),GetName());
1253 gSystem->Sleep(1000*600);
1254 if (sleepCounter > 30) {
1255 Error(
"ReAlloc",
"I can not wait anymore. Good bye");
1260 fTable = (
char *)arr;
1272 Int_t sleepCounter = 0;
1273 while (!(ptr = malloc(fSize*fN))) {
1276 "Not enough memory to allocate %d rows for table <%s::%s>. Please cancel some jobs",
1278 gSystem->Sleep(1000*600);
1279 if (sleepCounter > 30){
1280 Error(
"Create",
"I can not wait anymore. Good bye");
1284 fTable = (Char_t *)ptr;
1286 memset(fTable,0,fSize*fN);
1297 Int_t nrows = TMath::Min(Int_t(
GetNRows()),6);
1298 if (nrows == 0) nrows = 1;
1301 UInt_t nCol = GetNumberOfColumns();
1302 for (UInt_t i = 0;i<nCol;i++){
1304 UInt_t nDim = GetDimensions(i);
1305 const Char_t *colName = GetColumnName(i);
1309 if( GetColumnType(i)== kPtr) {
1310 UInt_t offset = GetOffset(i);
1313 TString nameMap =
"*";
1314 nameMap += m->Table()->GetName();
1315 b->Add(m,nameMap.Data());
1319 view->SetBit(kCanDelete);
1320 b->Add(view,view->GetName());
1323 const UInt_t *indx = GetIndexArray(i);
1324 UInt_t totalSize = 1;
1326 for (k=0;k<nDim; k++) totalSize *= indx[k];
1327 for (k=0;k<totalSize;k++) {
1329 buffer.Form(
"%s[%d]",colName,k);
1331 view->SetBit(kCanDelete);
1332 b->Add(view,view->GetName());
1344 if (!fTable)
return;
1345 Bool_t dtor = kFALSE;
1346 dtor = opt && (strcmp(opt,gDtorName)==0);
1347 if (!opt || !opt[0] || dtor ) {
1348 if (! TestBit(kIsNotOwn)) {
1379 if (dsc) cl = dsc->RowClass();
1380 else Error(
"GetRowClass()",
"Table descriptor of <%s::%s> table lost",
1422 void TTable::Fit(
const char *formula ,
const char *varexp,
const char *selection,Option_t *option ,Option_t *goption,Int_t nentries, Int_t firstentry)
1424 TString opt(option);
1427 Draw(varexp,selection,opt,nentries,firstentry);
1429 TH1 *hfit = gCurrentTableHist;
1431 Printf(
"hname=%s, formula=%s, option=%s, goption=%s\n",hfit->GetName(),formula,option,goption);
1433 Bool_t canDeleteBit = hfit->TestBit(kCanDelete);
1434 if (canDeleteBit) hfit->ResetBit(kCanDelete);
1435 hfit->Fit(formula,option,goption);
1436 if (TestBit(canDeleteBit)) hfit->SetBit(kCanDelete);
1438 else Printf(
"ERROR hfit=0\n");
1462 (fList && fList->Last() ? kTRUE : kFALSE)
1477 char const *cell,*colname,*table;
1479 int icol,irow,colsize,wordsize,nwords,iword,nerr,offset;
1483 table = (
const char*)GetArray();
1485 int ncols = rowDes->GetNumberOfColumns();
1490 for (icol=0; icol < ncols; icol++) {
1491 code = rowDes->GetColumnType(icol);
1492 if (code!=kFloat && code!=kDouble)
continue;
1494 offset = rowDes->GetOffset (icol);
1495 colsize = rowDes->GetColumnSize(icol);
1496 wordsize = rowDes->GetTypeSize (icol);
1497 nwords = colsize/wordsize;
1498 for (irow=0; irow < nrows; irow++) {
1499 cell = table + offset + irow*lrow;
1500 for (iword=0;iword<nwords; iword++,cell+=wordsize) {
1501 word = (code==kDouble) ? *(
double*)cell : *(
float*)cell;
1502 if (TMath::Finite(word))
continue;
1504 nerr++; colname = rowDes->GetColumnName(icol);
1505 Warning(
"NaN",
" Table %s.%s.%d\n",GetName(),colname,irow);
1519 TString tableType(type);
1520 TString t = tableType.Strip();
1522 TString classname(
"St_");
1524 TClass *cl = TClass::GetClass(classname);
1529 table->SetName(name);
1531 table->SetUsedRows(size);
1542 Error(where,
"index %d out of bounds (size: %d, this: 0x%lx)", i, fN, (Long_t)
this);
1554 Error(
"Print",
" No dictionary entry for <%s> structure", GetTitle());
1555 if (lenbuf>0) iOut += snprintf(strbuf,lenbuf,
" *** Errror ***");
1559 TROOT::IndentLevel();
1562 Char_t *typenam =
new Char_t [strlen(dscT->GetName())+1];
1563 strlcpy(typenam,dscT->GetName(),strlen(dscT->GetName())+1);
1565 Char_t *last = strrchr(typenam,
'_');
1568 if (last) eon = strstr(last,
"_st");
1570 if (eon) *eon =
'\0';
1571 iOut += snprintf(strbuf+iOut,lenbuf-iOut,
"struct %s {",typenam);
1574 std::cout <<
"struct " << dscT->GetName() <<
" {" << std::endl;
1580 for (;dsc != dscE; ++dsc) {
1581 TROOT::IndentLevel();
1582 TString name =
GetTypeName(EColumnType((*dsc).fType));
1585 name.ReplaceAll(
"unsigned char",
"octet");
1586 name.ReplaceAll(
"int",
"long");
1587 iOut += snprintf(strbuf+iOut,lenbuf-iOut,
" %s %s",name.Data(),(*dsc).fColumnName);
1589 std::cout <<
'\t'<< name.Data() <<
'\t'<< (*dsc).fColumnName;
1592 Int_t dim = (*dsc).fDimensions;
1593 for (indx = 0; indx < dim; indx++) {
1595 iOut += snprintf(strbuf+iOut,lenbuf-iOut,
"[%d]",(*dsc).fIndexArray[indx]);
1597 std::cout <<
"[" << std::dec << (*dsc).fIndexArray[indx]<<
"]";
1602 iOut += snprintf(strbuf+iOut,lenbuf-iOut,
";");
1604 const char *title = nxc ? nxc->GetTitle() :
" ";
1605 std::cout <<
";\t//" << title << std::endl;
1609 TROOT::IndentLevel();
1611 iOut += snprintf(strbuf+iOut,lenbuf-iOut,
"}");
1613 std::cout <<
"}" << std::endl;
1622 std::cout << std::endl <<
" ---------------------------------------------------------------------------------------" << std::endl
1624 <<
" Allocated rows: "<<fN
1625 <<
"\t Used rows: "<<fMaxIndex
1626 <<
"\t Row size: " << fSize <<
" bytes"
1640 const Char_t *
TTable::Print(Int_t row, Int_t rownumber,
const Char_t *,
const Char_t *)
const
1643 Int_t
const width = 8;
1645 Int_t rowNumber = rownumber;
1646 if (row > Int_t(GetSize()) || GetSize() == UInt_t(0)) {
1648 std::cout <<
" ======================================================================================" << std::endl
1649 <<
" There are " << GetSize() <<
" allocated rows for this table only" << std::endl
1650 <<
" ======================================================================================" << std::endl;
1653 if (rowNumber > Int_t(GetSize()-row)) rowNumber = GetSize()-row;
1654 if (!rowNumber)
return 0;
1655 rowStep = TMath::Min(rowStep,rowNumber);
1659 UInt_t *cdatime = 0;
1660 Bool_t isdate = kFALSE;
1663 if (!dscT )
return 0;
1667 const Char_t *startRow = (
const Char_t *)GetArray() + row*
GetRowSize();
1668 Int_t rowCount = rowNumber;
1669 Int_t thisLoopLenth = 0;
1670 const Char_t *nextRow = 0;
1674 std::cout <<
" ======================================================================================" << std::endl
1675 <<
" There is NO filled row in this table" << std::endl
1676 <<
" ======================================================================================" << std::endl;
1679 std::cout <<
" Table: " << dscT->GetName()<<
"\t";
1680 for (Int_t j = row+rowNumber-rowCount; j<row+rowNumber-rowCount+rowStep && j < row+rowNumber ;j++) {
1682 if (j>=10) hW -= (int)TMath::Log10(
float(j))-1;
1683 std::cout << std::setw(hW) <<
"["<<j<<
"]";
1686 std::cout << std::endl
1687 <<
" ======================================================================================" << std::endl;
1692 for (; member != dscE; ++member){
1693 TString membertype =
GetTypeName(EColumnType((*member).fType));
1695 if (strcmp((*member).fColumnName,
"fDatime") == 0 && EColumnType((*member).fType) == kUInt)
1697 std::cout << membertype.Data();
1700 Int_t dim = (*member).fDimensions;
1702 UInt_t *arrayLayout = 0;
1704 arrayLayout =
new UInt_t[dim];
1705 memset(arrayLayout,0,dim*
sizeof(Int_t));
1707 Int_t arrayLength = 1;
1708 while (indx < dim ){
1709 arrayLength *= (*member).fIndexArray[indx];
1713 Int_t offset = (*member).fOffset;
1715 thisLoopLenth = TMath::Min(rowCount,rowStep);
1717 Bool_t breakLoop = kFALSE;
1719 for (indexOffset=0; indexOffset < arrayLength && !breakLoop; indexOffset++) {
1722 if (!indexOffset) std::cout <<
"\t" << (*member).fColumnName;
1723 else std::cout <<
"\t" << std::setw(strlen((*member).fColumnName)) <<
" ";
1726 for (Int_t i=0;i<dim;i++) std::cout <<
"["<<std::dec<<arrayLayout[i]<<
"]";
1727 ArrayLayout(arrayLayout,(*member).fIndexArray,dim);
1730 if ( strlen((*member).fColumnName)+3*dim < 8) std::cout <<
"\t";
1732 for (thisStepRows = 0;thisStepRows < thisLoopLenth; thisStepRows++,nextRow +=
GetRowSize()) {
1733 const char *pointer = nextRow + offset + indexOffset*(*member).fTypeSize;
1735 cdatime = (UInt_t*)pointer;
1736 TDatime::GetDateTime(cdatime[0],cdate,ctime);
1737 std::cout << cdate <<
"/" << ctime;
1738 }
else if ((*member).fType == kChar && dim == 1) {
1739 char charbuffer[11];
1740 strlcpy(charbuffer,pointer,TMath::Min(10,arrayLength)+1);
1742 std::cout <<
"\"" << charbuffer;
1743 if (arrayLength > 10)
1744 std::cout <<
" . . . ";
1748 AsString((
void *)pointer,EColumnType((*member).fType),width,std::cout);
1753 if (indexOffset==0) {
1755 std::cout <<
" " << (
const char *)(nxc ? nxc->GetTitle() :
"no comment");
1757 std::cout << std::endl;
1759 if (arrayLayout)
delete [] arrayLayout;
1761 rowCount -= thisLoopLenth;
1764 std::cout <<
"---------------------------------------------------------------------------------------" << std::endl;
1773 TROOT::IndentLevel();
1774 Printf(
"\tclass %s: public TTable\t --> Allocated rows: %d\t Used rows: %d\t Row size: %d bytes\n",
1775 IsA()->GetName(),
int(fN),
int(fMaxIndex),
int(fSize));
1787 void TTable::Project(
const char *hname,
const char *varexp,
const char *selection, Option_t *option,Int_t nentries, Int_t firstentry)
1790 var.Form(
"%s>>%s",varexp,hname);
1792 TString opt(option);
1795 Draw(var,selection,opt,nentries,firstentry);
1812 UInt_t arrayLayout[10],arraySize[10];
1813 const unsigned char *pointer=0,*startRow=0;
1814 int i,rowCount;
unsigned char ic;
1816 out <<
"TDataSet *CreateTable() { " << std::endl;
1822 if (!rowNumber || !dscT ) {
1823 out <<
"// The output table was bad-defined!" << std::endl
1824 <<
" fprintf(stderr, \"Bad table found. Please remove me\\n\");" << std::endl
1825 <<
" return 0; } " << std::endl;
1829 startRow = (
const UChar_t *)GetArray();
1830 assert(startRow!=0);
1832 const Char_t *rowId =
"row";
1833 const Char_t *tableId =
"tableSet";
1837 const char *className = IsA()->GetName();
1839 out <<
"// -----------------------------------------------------------------" << std::endl;
1840 out <<
"// " <<
Path()
1841 <<
" Allocated rows: "<< rowNumber
1842 <<
" Used rows: "<< rowNumber
1843 <<
" Row size: " << fSize <<
" bytes" << std::endl;
1844 out <<
"// " <<
" Table: " << dscT->GetName()<<
"[0]--> "
1845 << dscT->GetName()<<
"["<<rowNumber-1 <<
"]" << std::endl;
1846 out <<
"// ====================================================================" << std::endl;
1847 out <<
"// ------ Test whether this table share library was loaded ------" << std::endl;
1848 out <<
" if (!TClass::GetClass(\"" << className <<
"\")) return 0;" << std::endl;
1849 out << dscT->GetName() <<
" " << rowId <<
";" << std::endl
1850 << className <<
" *" << tableId <<
" = new "
1852 <<
"(\""<<GetName()<<
"\"," <<
GetNRows() <<
");" << std::endl
1853 <<
"//" <<std::endl ;
1857 for (rowCount=0;rowCount<rowNumber; rowCount++,startRow += fSize, nextComment.Reset()) {
1858 out <<
"memset(" <<
"&" << rowId <<
",0," << tableId <<
"->GetRowSize()" <<
");" << std::endl ;
1863 for (; member != dscE; ++member) {
1864 TString memberType =
GetTypeName(EColumnType((*member).fType));
1865 TString memberName((*member).fColumnName);
1869 TString memberTitle(nxc ? nxc->GetTitle() :
"no comment");
1871 Int_t offset = (*member).fOffset;
1873 if (memberName.Index(
"name",0,TString::kIgnoreCase)>=0) mayBeName=1999;
1874 if (memberName.Index(
"file",0,TString::kIgnoreCase)>=0) mayBeName=1999;
1875 int typeSize = (*member).fTypeSize;
1878 Int_t dim = (*member).fDimensions;
1879 if (dim) memset(arrayLayout,0,dim*
sizeof(Int_t));
1880 Int_t arrayLength = 1;
1881 for (
int indx=0;indx < dim ;indx++){
1882 arraySize[indx] = (*member).fIndexArray[indx];;
1883 arrayLength *= arraySize[indx];
1887 int charLen = (memberType.CompareTo(
"char")==0);
1889 charLen=arrayLength;
1890 pointer = startRow + offset;
1893 charLen = strlen((
const char*)pointer)+1;
1894 if (charLen>arrayLength) charLen = arrayLength;
1896 for(;charLen && !pointer[charLen-1];charLen--){;}
1897 if (!charLen) charLen=1;
1900 out <<
" memcpy(&" << rowId <<
"." << (
const char*)memberName;
1902 for (
int ii=0; ii<charLen;ii++) {
1904 if (ic && (isalnum(ic)
1905 || strchr(
"!#$%&()*+-,./:;<>=?@{}[]_|~",ic))) {
1908 out <<
"\\x" << std::setw(2) << std::setfill(
'0') << std::hex << (unsigned)ic ;
1909 out << std::setw(1) << std::setfill(
' ') << std::dec;
1912 out <<
"\"," << std::dec << charLen <<
");";
1913 out <<
"// " << (
const char*)memberTitle << std::endl;
1919 for (indexOffset=0; indexOffset < arrayLength ; indexOffset++) {
1920 out << std::setw(3) <<
" " ;
1921 out <<
" " << rowId <<
"." << (
const char*)memberName;
1924 for (i=0;i<dim;i++) {out <<
"["<<std::dec<<arrayLayout[i]<<
"]";}
1925 ArrayLayout(arrayLayout,arraySize,dim);}
1930 pointer = startRow + offset + indexOffset*typeSize;
1932 AsString((
void *)pointer,EColumnType((*member).fType),10,out);
1935 if (indexOffset==0) out <<
"; // " << (
const char*)memberTitle;
1936 out <<
";" << std::endl;
1940 out << tableId <<
"->AddAt(&" << rowId <<
");" << std::endl;
1943 out <<
"// ----------------- end of code ---------------" << std::endl
1944 <<
" return (TDataSet *)tableSet;" << std::endl
1945 <<
"}" << std::endl;
1955 if (fN != n)
Clear();
1957 if (fN == 0)
return;
1966 if (fTable) free(fTable);
1967 fTable = (Char_t *)table;
1981 static Char_t *GetExpressionFileName()
1983 const Char_t *tempDirs = gSystem->Getenv(
"TEMP");
1984 if (!tempDirs) tempDirs = gSystem->Getenv(
"TMP");
1985 if (!tempDirs) tempDirs =
"/tmp";
1986 if (gSystem->AccessPathName(tempDirs)) tempDirs =
".";
1987 if (gSystem->AccessPathName(tempDirs))
return 0;
1989 fileName.Form(
"Selection.C.%d.tmp",gSystem->GetPid());
1990 return gSystem->ConcatFileName(tempDirs,fileName.Data());
2005 const Char_t *typeNames[] = {
"NAN",
"float",
"int",
"long",
"short",
"double"
2006 ,
"unsigned int",
"unsigned long",
"unsigned short",
"unsigned char"
2007 ,
"char",
"TTableMap &"};
2008 const char *resID =
"results";
2009 const char *addressID =
"address";
2010 Char_t *fileName = GetExpressionFileName();
2012 Error(
"MakeExpression",
"Can not create a temporary file");
2019 Error(
"MakeExpression",
"Can not open the temporary file <%s>",fileName);
2027 str <<
"void SelectionQWERTY(float *"<<resID<<
", float **"<<addressID<<
", int& i$, int& n$ )" << std::endl;
2028 str <<
"{" << std::endl;
2030 for (i=0; i < dsc->
GetNRows(); i++,descTable++ ) {
2032 const Char_t *columnName = descTable->fColumnName;
2033 const Char_t *type = 0;
2035 for (Int_t exCount = 0; exCount < nExpressions; exCount++) {
2036 if (expressions[exCount] && expressions[exCount][0] && strstr(expressions[exCount],columnName))
goto LETSTRY;
2040 Bool_t isScalar = !(descTable->fDimensions);
2041 Bool_t isFloat = descTable->fType == kFloat;
2042 type = typeNames[descTable->fType];
2044 if (!isScalar) str <<
"*";
2046 str << columnName <<
" = " ;
2047 if (isScalar) str <<
"*(";
2048 if (!isFloat) str <<
"(" << type <<
"*)";
2049 str << addressID <<
"[" << i <<
"]";
2050 if (isScalar) str <<
")" ;
2051 str <<
";" << std::endl;
2054 for (i=0; i < nExpressions; i++ ) {
2055 if (expressions[i] && expressions[i][0])
2056 str <<
" "<<resID<<
"["<<i<<
"]=(float)(" << expressions[i] <<
");" << std::endl;
2060 str <<
"}" << std::endl;
2063 if (str.good())
return fileName;
2076 ::memset(fTable,c,fSize*fN);
2091 for (;links != lastLinks;links++) {
2093 if (wipe)
delete *mp;
2104 if (fN < n)
Clear();
2108 if (fN == 0)
return;
2119 if (b.IsReading()) {
2120 TDataSet::Streamer(b);
2126 TDataSet::Streamer(b);
2137 if (b.IsReading()) {
2146 long len = b.Length() + (20+4) + (20+4) + 4;
2147 b.SetBufferOffset(len);
2154 Warning(
"StreamerHeader",
"Schema evolution warning: row size mismatch: expected %ld, read %ld bytes\n",
GetRowSize(),rbytes);
2162 long len = b.Length() + (4) + (4);
2163 b.SetBufferOffset(len);
2181 #ifdef StreamElelement
2182 #define __StreamElelement__ StreamElelement
2183 #undef StreamElelement
2186 #define StreamElementIn(type) case TTableDescriptor::_NAME2_(k,type): \
2187 if (evolutionOn) { \
2188 if (nextCol->fDimensions) { \
2189 if (nextCol->fOffset != UInt_t(-1)) { \
2190 R__b.ReadFastArray((_NAME2_(type,_t) *)(row+nextCol->fOffset),nextCol->fSize/sizeof(_NAME2_(type,_t))); \
2192 _NAME2_(type,_t) *readPtrV = new _NAME2_(type,_t)[nextCol->fSize/sizeof(_NAME2_(type,_t))]; \
2193 R__b.ReadFastArray((_NAME2_(type,_t) *)(row+nextCol->fOffset),nextCol->fSize/sizeof(_NAME2_(type,_t))); \
2194 delete [] readPtrV; \
2199 _NAME2_(type,_t) skipBuffer; \
2200 _NAME2_(type,_t) *readPtr = (_NAME2_(type,_t) *)(row+nextCol->fOffset); \
2201 if (nextCol->fOffset == UInt_t(-1)) readPtr = &skipBuffer; \
2205 if (nextCol->fDimensions) { \
2206 R__b.ReadFastArray ((_NAME2_(type,_t) *)(row+nextCol->fOffset),nextCol->fSize/sizeof(_NAME2_(type,_t))); \
2208 R__b >> *(_NAME2_(type,_t) *)(row+nextCol->fOffset); \
2212 #define StreamElementOut(type) case TTableDescriptor::_NAME2_(k,type): \
2213 if (nextCol->fDimensions) \
2214 R__b.WriteFastArray((_NAME2_(type,_t) *)(row+nextCol->fOffset), nextCol->fSize/sizeof(_NAME2_(type,_t))); \
2216 R__b << *(_NAME2_(type,_t) *)(row+nextCol->fOffset); \
2227 Error(
"GetRowDescriptors()",
"%s has no dictionary !",GetName());
2253 void TTable::Streamer(TBuffer &R__b)
2258 if (R__b.IsReading()) {
2260 R__v = R__b.ReadVersion();
2261 Bool_t evolutionOn = kFALSE;
2263 if (IsA() != TTableDescriptor::Class()) {
2265 R__b >> ioDescriptor;
2268 ioDescriptor->Streamer(R__b);
2270 if (!currentDescriptor) {
2271 currentDescriptor = ioDescriptor;
2274 if (currentDescriptor->fSecondDescriptor != ioDescriptor) {
2276 delete currentDescriptor->fSecondDescriptor;
2277 currentDescriptor->fSecondDescriptor = ioDescriptor;
2281 evolutionOn = (Bool_t)ioDescriptor->
UpdateOffsets(currentDescriptor);
2285 if (fMaxIndex <= 0)
return;
2287 Int_t maxColumns = ioDescriptor->NumberOfColumns();
2289 if (evolutionOn)
Reset(0);
2290 for (Int_t indx=0;indx<fMaxIndex;indx++,row += rowSize) {
2292 for (Int_t colCounter=0; colCounter < maxColumns; colCounter++,nextCol++) {
2294 switch(nextCol->fType) {
2295 StreamElementIn(Float);
2296 StreamElementIn(Int);
2297 StreamElementIn(Long);
2298 StreamElementIn(Short);
2299 StreamElementIn(Double);
2300 StreamElementIn(UInt);
2301 StreamElementIn(ULong);
2302 StreamElementIn(UChar);
2303 StreamElementIn(Char);
2304 StreamElementIn(Bool);
2305 case TTableDescriptor::kPtr: {
2311 if (nextCol->fOffset == UInt_t(-1))
delete readPtr;
2312 else *(
Ptr_t *)(row+nextCol->fOffset) = readPtr;
2314 *(
Ptr_t *)(row+nextCol->fOffset) = readPtr;
2324 TSeqCollection *save = fList;
2325 R__b.WriteVersion(TTable::IsA());
2328 if (IsA() != TTableDescriptor::Class()) {
2329 if ( Class_Version()>3 ) {
2330 R__b << ioDescriptor;
2332 ioDescriptor->Streamer(R__b);
2335 if ( Class_Version()<=3 ) fList = 0;
2339 if (fMaxIndex <= 0)
return;
2341 Int_t maxColumns = ioDescriptor->NumberOfColumns();
2343 for (Int_t indx=0;indx<fMaxIndex;indx++,row += rowSize) {
2345 for (Int_t colCounter=0; colCounter < maxColumns; colCounter++,nextCol++) {
2347 switch(nextCol->fType) {
2348 StreamElementOut(Float);
2349 StreamElementOut(Int);
2350 StreamElementOut(Long);
2351 StreamElementOut(Short);
2352 StreamElementOut(Double);
2353 StreamElementOut(UInt);
2354 StreamElementOut(ULong);
2355 StreamElementOut(UChar);
2356 StreamElementOut(Char);
2357 StreamElementOut(Bool);
2358 case TTableDescriptor::kPtr:
2359 R__b << *(
Ptr_t *)(row+nextCol->fOffset);
2369 #ifdef __StreamElelement__
2370 #define StreamElelement __StreamElelement__
2371 #undef __StreamElelement__
2387 if (set->HasData()) {
2389 if (strcmp(GetTitle(),set->GetTitle()) == 0 ) {
2391 Adopt(table->GetSize(),table->GetArray());
2397 table->SetBit(kIsNotOwn);
2399 ResetBit(kIsNotOwn);
2402 "This table is <%s> but the updating one has a wrong type <%s>",GetTitle(),set->GetTitle());
2413 TClass *r = TClass::GetClass(structName,1);
2421 const Char_t *TTable::GetColumnName(Int_t columnIndex)
const {
return GetRowDescriptors()->ColumnName(columnIndex); }
2422 const UInt_t *TTable::GetIndexArray(Int_t columnIndex)
const {
return GetRowDescriptors()->IndexArray(columnIndex); }
2423 UInt_t TTable::GetNumberOfColumns()
const {
return GetRowDescriptors()->NumberOfColumns(); }
2425 UInt_t TTable::GetOffset(Int_t columnIndex)
const {
return GetRowDescriptors()->Offset(columnIndex); }
2426 Int_t TTable::GetOffset(
const Char_t *columnName)
const {
return GetRowDescriptors()->Offset(columnName); }
2428 UInt_t TTable::GetColumnSize(Int_t columnIndex)
const {
return GetRowDescriptors()->ColumnSize(columnIndex); }
2429 Int_t TTable::GetColumnSize(
const Char_t *columnName)
const {
return GetRowDescriptors()->ColumnSize(columnName); }
2431 UInt_t TTable::GetTypeSize(Int_t columnIndex)
const {
return GetRowDescriptors()->TypeSize(columnIndex); }
2432 Int_t TTable::GetTypeSize(
const Char_t *columnName)
const {
return GetRowDescriptors()->TypeSize(columnName); }
2434 UInt_t TTable::GetDimensions(Int_t columnIndex)
const {
return GetRowDescriptors()->Dimensions(columnIndex); }
2435 Int_t TTable::GetDimensions(
const Char_t *columnName)
const {
return GetRowDescriptors()->Dimensions(columnName); }
2437 TTable::EColumnType TTable::GetColumnType(Int_t columnIndex)
const {
return GetRowDescriptors()->ColumnType(columnIndex); }
2438 TTable::EColumnType TTable::GetColumnType(
const Char_t *columnName)
const {
return GetRowDescriptors()->ColumnType(columnName); }
2450 fCurrentRowPtr = (
const Char_t *)t->GetArray();
2456 for( i = 0; ptr != lastPtr; ++ptr,++i)
2457 if ( tabsDsc->ColumnType(i) == type ) fPtrs.push_back(tabsDsc->Offset(i));
2458 if (fPtrs.size()==0) {
2468 void TTable::iterator::operator++() { ++fCurrentRow; }
2469 void TTable::iterator::operator++(
int) { fCurrentRow++; }
2470 void TTable::iterator::operator--() { --fCurrentRow; }
2471 void TTable::iterator::operator--(
int) { fCurrentRow--; }
2472 TTable::iterator TTable::iterator::operator+(Int_t idx) { std::vector<Long_t>::iterator addition = fCurrentRow+idx;
return TTable::iterator(*fThisTable,addition); }
2473 TTable::iterator TTable::iterator::operator-(Int_t idx) { std::vector<Long_t>::iterator subtraction = fCurrentRow-idx;
return TTable::iterator(*fThisTable,subtraction); }
2474 void TTable::iterator::operator+=(Int_t idx) { fCurrentRow+=idx; }
2475 void TTable::iterator::operator-=(Int_t idx) { fCurrentRow-=idx; }
2476 void *TTable::iterator::rowPtr()
const {
return (
void *)(((
const char *)fThisTable->GetArray()) + (*fCurrentRow)*fRowSize ); }
2477 TTable::iterator::operator
void *()
const {
return rowPtr(); }
2478 Int_t TTable::iterator::operator-(
const iterator &it)
const {
return (*fCurrentRow)-(*(it.fCurrentRow)); }
2479 Long_t TTable::iterator::operator *()
const {
return *fCurrentRow; }
2480 Bool_t TTable::iterator::operator==(
const iterator &t)
const {
return ( (fCurrentRow == t.fCurrentRow) && (fThisTable == t.fThisTable) ); }
2481 Bool_t TTable::iterator::operator!=(
const iterator &t)
const {
return !operator==(t); }
virtual Long_t InsertRows(const void *rows, Long_t indx, UInt_t nRows=1)
Int_t SetfN(Long_t len)
to be documented
virtual TClass * GetRowClass() const
to be documented
virtual Long_t GetRowSize() const
Returns the size (in bytes) of one table row.
virtual void PrintContents(Option_t *opt="") const
virtual const Char_t * GetType() const
Returns the type of the wrapped C-structure kept as the TNamed title.
void StreamerHeader(TBuffer &b, Version_t version=3)
Read "table parameters first".
virtual void Delete(Option_t *opt="")
virtual Int_t UpdateOffsets(const TTableDescriptor *newDesciptor)
TTable & operator=(const TTable &rhs)
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
virtual void Browse(TBrowser *b)
Wrap each table coulumn with TColumnView object to browse.
virtual const Char_t * PrintHeader() const
Print general table inforamtion.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TTable(const char *name=0, Int_t size=0)
Default TTable ctor.
virtual void PrintContents(Option_t *opt="") const
to be documented
Int_t ColumnByName(const Char_t *columnName=0) const
Find the column index but the column name.
static const char * TableDictionary(const char *className, const char *structName, TTableDescriptor *&ColDescriptors)
virtual void Set(Int_t n)
Set array size of TTable object to n longs. If n<0 leave array unchanged.
Int_t CopyRows(const TTable *srcTable, Long_t srcRow=0, Long_t dstRow=0, Long_t nRows=0, Bool_t expand=kFALSE)
virtual Bool_t EntryLoop(const Char_t *exprFileName, Int_t &action, TObject *obj, Int_t nentries=1000000000, Int_t firstentry=0, Option_t *option="")
virtual TTableDescriptor * GetRowDescriptors() const
to be documented
virtual void SetType(const char *const type)
to be documented
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Bool_t OutOfBoundsError(const char *where, Int_t i) const
Generate an out-of-bounds error. Always returns false.
virtual Int_t AddAt(const void *c)
virtual Long_t AppendRows(const void *row, UInt_t nRows)
virtual void Fit(const char *formula, const char *varexp, const char *selection="", Option_t *option="", Option_t *goption="", Int_t nentries=1000000000, Int_t firstentry=0)
virtual void Update()
to be documented
virtual void ResetMap(Bool_t wipe=kTRUE)
virtual void DeleteRows(Long_t indx, UInt_t nRows=1)
virtual ~TTable()
Delete TTable object.
virtual TTableDescriptor * GetTableDescriptors() const
protected: create a new TTableDescriptor descriptor for this table
void StreamerTable(TBuffer &b, Version_t version=3)
Stream an object of class TTable.
virtual Int_t Purge(Option_t *opt="")
void SetTablePointer(void *table)
to be documented
void CopyStruct(Char_t *dest, const Char_t *src)
static EColumnType GetTypeId(const char *typeName)
static TTable * New(const Char_t *name, const Char_t *type, void *array, UInt_t size)
This static method creates a new TTable object if provided.
virtual Long_t GetTableSize() const
Returns the number of the allocated rows.
virtual Char_t * MakeExpression(const Char_t *expressions[], Int_t nExpressions)
static const char * GetTypeName(EColumnType type)
return table type name
virtual void Project(const char *hname, const char *varexp, const char *selection="", Option_t *option="", Int_t nentries=1000000000, Int_t firstentry=0)
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
virtual TString Path() const
return the full path of this data set
virtual TTableDescriptor * GetDescriptorPointer() const
to be documented
virtual void SetDescriptorPointer(TTableDescriptor *list)
to be documented
piterator(const TTable *t=0, EColumnType type=kPtr)
to be documented
virtual void Delete(Option_t *opt="")
virtual Bool_t IsFolder() const
virtual void Clear(Option_t *opt="")
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
virtual void Adopt(Int_t n, void *array)
TDataSet * MakeCommentField(Bool_t createFlag=kTRUE)
Instantiate a comment dataset if any.
virtual void CopySet(TTable &array)
to be documented
void ReAlloc(Int_t newsize)
The table is reallocated if it is an owner of the internal array.
virtual const Char_t * GetColumnComment(Int_t columnIndex) const
Get a comment from the table descriptor.
virtual void AsString(void *buf, EColumnType type, Int_t width, std::ostream &out) const
virtual void Reset(Int_t c=0)
Fill the entire table with byte "c" ; / c=0 "be default"
virtual Int_t Purge(Option_t *opt="")
Shrink the table to free the unused but still allocated rows.