00001 #ifndef __CINT__
00002 #include <stdlib.h>
00003 #include <stdio.h>
00004 #include "TObject.h"
00005 #include "TClass.h"
00006 #include "TH1.h"
00007 #include "TObjectTable.h"
00008 #include "TMath.h"
00009 #include "TRegexp.h"
00010 #include "TClonesArray.h"
00011
00012 #include "StMkDeb.h"
00013 #include <typeinfo>
00014 #endif // !__CINT__
00015
00016 void ojtable(const char *className=0);
00017
00018 #ifndef __CINT__
00019 int SizeOfH(TObject *to);
00020
00021 void ojtable(const char *className)
00022 {
00023 static int fTableOffset = 0;
00024 if (!fTableOffset) fTableOffset = gObjectTable->IsA()->GetDataMemberOffset("fTable");
00025
00026 TClass *kl;
00027 if (className && !*className) className=0;
00028
00029 const char *qwe = ".*";
00030 if (className) qwe = className;
00031 TRegexp regexp(qwe); int regexpLen=0;
00032
00033 int sz = gObjectTable->GetSize();
00034 int *ptr = new int[sz];
00035 int *idx = new int[sz];
00036
00037 TObject **tab = *((TObject ***)((char*)gObjectTable+fTableOffset));
00038 TObject *to;
00039 printf ("tab %p[%d]\n",tab,sz);
00040 int i,num=0;
00041 double hSize=0;
00042 int hNumb=0;
00043 const char *info_name = 0;
00044 for (i=0;i<sz;i++)
00045 {
00046 to = tab[i];
00047 if (!to) continue;
00048 if (!to->TestBit(TObject::kNotDeleted)) continue;
00049 int hs = SizeOfH(to);
00050 if (hs) {hSize+=hs; hNumb++;}
00051 if (className && regexp.Index(to->ClassName(),®expLen)<0) continue;
00052 const char *mk = StMkDeb::GetUser(to);
00053 if(mk && *mk) printf("%s(%p) in %s\n",to->ClassName(),to,mk);
00054 ptr[num++]=int(to);
00055 }
00056 printf("TH1 N=%d, Size = %g\n",hNumb,hSize);
00057
00058 TMath::Sort(num,ptr,idx,0);
00059 int last = 0;
00060 printf("Selected %d objects\n",num);
00061 for (i=0;i<num;i++) {
00062 int ix = idx[i];
00063 to = (TObject*)ptr[ix];
00064 int dist = 0;
00065 if (i) dist = ptr[ix]-last;
00066 last = ptr[ix];
00067
00068
00069
00070
00071 info_name = "??";
00072 info_name=typeid(*to).name();
00073 kl = to->IsA();
00074 printf ("%4d +%6d : obj = %p(%3d) %s::%s \tinfo=%s\n",i,dist,to,kl->Size(),kl->GetName(),to->GetName(),info_name);
00075
00076 if (strcmp("TClonesArray",kl->GetName())) continue;
00077 TClonesArray *tcl = ((TClonesArray*)to);
00078 printf(" Sizes = %d %d\n",tcl->GetLast()+1,tcl->Capacity());
00079 tcl->ls("");
00080
00081
00082
00083
00084 }
00085 delete [] ptr;
00086 delete [] idx;
00087 }
00088
00089 int SizeOfH(TObject *to)
00090 {
00091 TClass *kl = to->IsA();
00092 if (!kl) return 0;
00093 if (!kl->InheritsFrom(TH1::Class())) return 0;
00094 int s0 = kl->Size();
00095 TH1 *h = (TH1 *)to;
00096 int nbins = h->GetNbinsX()*h->GetNbinsY()*h->GetNbinsZ();
00097 int szw = 0;
00098 if (kl->InheritsFrom("TArrayC")) szw=1;
00099 else if (kl->InheritsFrom("TArrayS")) szw=2;
00100 else if (kl->InheritsFrom("TArrayI")) szw=4;
00101 else if (kl->InheritsFrom("TArrayF")) szw=4;
00102 else if (kl->InheritsFrom("TArrayD")) szw=8;
00103 return s0 + nbins*szw;
00104 }
00105 #endif //-__CINT__