46 #include "TDirectory.h"
104 fFormulaList =
new TList();
105 fFormulaList->SetOwner(
kTRUE);
107 fSelectorFromFile = 0;
110 fInput =
new TList();
111 fInput->Add(
new TNamed(
"varexp",
""));
112 fInput->Add(
new TNamed(
"selection",
""));
113 fSelector->SetInputList(fInput);
114 gROOT->GetListOfCleanups()->Add(
this);
129 gROOT->GetListOfCleanups()->Remove(
this);
138 if (dynamic_cast<const TChain*>(T)) {
142 Error(
"BuildIndex",
"Creating a TChainIndex unsuccessfull - switching to TTreeIndex");
186 if (tree == 0)
return 0;
191 for (
Int_t i = 0; i < nb; ++i) {
205 if (strlen(selection)) {
207 if (!select || !select->
GetNdim()) {
217 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
219 if (entryNumber < 0)
break;
221 if (localEntry < 0)
break;
229 for(
Int_t current = 0; current<ndata && !keep; current++) {
289 const char *macrofilename,
const char *cutfilename,
292 if (!macrofilename || strlen(macrofilename)==0)
return 0;
298 if (cutfilename && strlen(cutfilename))
304 TString selname = wrapperPrefix;
309 if (aclicMode.
Length()==0) {
310 Warning(
"DrawScript",
"TTreeProxy does not work in interpreted mode yet. The script will be compiled.");
313 selname.
Append(aclicMode);
315 Info(
"DrawScript",
"%s",
Form(
"Will process tree/chain using %s",selname.
Data()));
339 TString possibleFilename = varexp0;
341 if ( dot_pos !=
kNPOS
342 && possibleFilename.
Index(
"Alt$")<0 && possibleFilename.
Index(
"Entries$")<0
343 && possibleFilename.
Index(
"LocalEntries$")<0
344 && possibleFilename.
Index(
"Length$")<0 && possibleFilename.
Index(
"Entry$")<0
345 && possibleFilename.
Index(
"LocalEntry$")<0
346 && possibleFilename.
Index(
"Min$")<0 && possibleFilename.
Index(
"Max$")<0
347 && possibleFilename.
Index(
"MinIf$")<0 && possibleFilename.
Index(
"MaxIf$")<0
348 && possibleFilename.
Index(
"Iteration$")<0 && possibleFilename.
Index(
"Sum$")<0
349 && possibleFilename.
Index(
">")<0 && possibleFilename.
Index(
"<")<0
354 "Drawing using a C++ file currently requires that both the expression and the selection are files\n\t\"%s\" is not a file",
358 return DrawScript(
"generatedSel",varexp0,selection,option,nentries,firstentry);
361 possibleFilename = selection;
362 if (possibleFilename.
Index(
"Alt$")<0 && possibleFilename.
Index(
"Entries$")<0
363 && possibleFilename.
Index(
"LocalEntries$")<0
364 && possibleFilename.
Index(
"Length$")<0 && possibleFilename.
Index(
"Entry$")<0
365 && possibleFilename.
Index(
"LocalEntry$")<0
366 && possibleFilename.
Index(
"Min$")<0 && possibleFilename.
Index(
"Max$")<0
367 && possibleFilename.
Index(
"MinIf$")<0 && possibleFilename.
Index(
"MaxIf$")<0
368 && possibleFilename.
Index(
"Iteration$")<0 && possibleFilename.
Index(
"Sum$")<0
369 && possibleFilename.
Index(
">")<0 && possibleFilename.
Index(
"<")<0
373 "Drawing using a C++ file currently requires that both the expression and the selection are files\n\t\"%s\" is not a file",
382 if (evlist && elist){
387 if (cvarexp) cvarexp->
SetTitle(varexp0);
388 if (cselection) cselection->
SetTitle(selection);
405 gROOT->ProcessLineFast(
"new TCanvas();");
446 gPad->DrawFrame(-1.,-1.,1.,1.);
454 Warning(
"DrawSelect",
"The selected TTree subset is empty.");
464 }
else if (
fDimension == 2 && !(optpara||optcandle)) {
472 if (l == 0 || opt ==
"same") graph =
kTRUE;
483 }
else if (
fDimension == 3 && !(optpara||optcandle)) {
489 }
else if (action == 33) {
496 if (opt.
Contains(
"same")) noscat -= 4;
504 }
else if (
fDimension == 4 && !(optpara||optcandle)) {
511 for (
Int_t col=0;col<ncolors;col++) {
514 if (draw) pm3d->
Draw();
517 }
else if (optpara || optcandle) {
520 fTree->
Draw(
">>enlist",selection,
"entrylist",nentries,firstentry);
522 gROOT->ProcessLine(
Form(
"TParallelCoord::SetEntryList((TParallelCoord*)0x%lx,(TEntryList*)0x%lx)",
526 }
else if (optgl5d) {
559 Int_t nch = option ? strlen(option) + 10 : 10;
560 char *opt =
new char[nch];
561 if (option) strlcpy(opt,option,nch-1);
562 else strlcpy(opt,
"goff",5);
567 Int_t fitResult = -1;
602 Long64_t lastentry = firstentry + nentries - 1;
605 nentries = lastentry - firstentry + 1;
622 TTHREAD_TLS_DECL(std::string,column);
623 if (colindex<0 )
return "";
625 i1 = index[colindex] + 1;
626 n = index[colindex+1] - i1;
627 column = varexp(i1,n).
Data();
629 return column.c_str();
646 const char* ltitle = leaf->
GetTitle();
647 if (mother && mother!=branch) {
648 branchname = mother->
GetName();
649 if (branchname[branchname.Length()-1]!=
'.') {
652 if (strncmp(branchname.Data(),ltitle,branchname.Length())==0) {
658 branchname += ltitle;
663 char *bname = (
char*)branchname.Data();
664 char *twodim = (
char*)strstr(bname,
"[");
665 if (twodim) *twodim = 0;
667 if (*bname ==
'.') *bname=
'_';
668 if (*bname ==
',') *bname=
'_';
669 if (*bname ==
':') *bname=
'_';
670 if (*bname ==
'<') *bname=
'_';
671 if (*bname ==
'>') *bname=
'_';
725 thead.
Form(
"%s.h", classname);
726 FILE *fp = fopen(thead,
"w");
728 Error(
"MakeClass",
"cannot open output file %s", thead.
Data());
732 tcimp.
Form(
"%s.C", classname);
733 FILE *fpc = fopen(tcimp,
"w");
735 Error(
"MakeClass",
"cannot open output file %s", tcimp.
Data());
743 treefile =
"Memory Directory";
758 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
759 fprintf(fp,
"// This class has been automatically generated on\n");
760 fprintf(fp,
"// %s by ROOT version %s\n",td.
AsString(),
gROOT->GetVersion());
763 fprintf(fp,
"// found on file: %s\n",treefile.
Data());
767 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
769 fprintf(fp,
"#ifndef %s_h\n",classname);
770 fprintf(fp,
"#define %s_h\n",classname);
772 fprintf(fp,
"#include <TROOT.h>\n");
773 fprintf(fp,
"#include <TChain.h>\n");
774 fprintf(fp,
"#include <TFile.h>\n");
775 if (isHbook) fprintf(fp,
"#include <THbookFile.h>\n");
776 if (opt.
Contains(
"selector")) fprintf(fp,
"#include <TSelector.h>\n");
780 fprintf(fp,
"\n// Header file for the classes stored in the TTree if any.\n");
783 for (l=0;l<nleaves;l++) {
789 if (declfile && declfile[0]) {
790 static const char *precstl =
"prec_stl/";
791 static const unsigned int precstl_len = strlen(precstl);
792 static const char *rootinclude =
"include/";
793 static const unsigned int rootinclude_len = strlen(rootinclude);
794 if (strncmp(declfile,precstl,precstl_len) == 0) {
795 fprintf(fp,
"#include <%s>\n",declfile+precstl_len);
797 }
else if (strncmp(declfile,
"/usr/include/",13) == 0) {
798 fprintf(fp,
"#include <%s>\n",declfile+strlen(
"/include/c++/"));
799 listOfHeaders.
Add(
new TNamed(cl->
GetName(),declfile+strlen(
"/include/c++/")));
800 }
else if (strstr(declfile,
"/include/c++/") != 0) {
801 fprintf(fp,
"#include <%s>\n",declfile+strlen(
"/include/c++/"));
802 listOfHeaders.
Add(
new TNamed(cl->
GetName(),declfile+strlen(
"/include/c++/")));
803 }
else if (strncmp(declfile,rootinclude,rootinclude_len) == 0) {
804 fprintf(fp,
"#include <%s>\n",declfile+rootinclude_len);
807 fprintf(fp,
"#include \"%s\"\n",declfile);
820 for (l=0;l<nleaves;l++) {
831 for (
Int_t file=0;file<ntrees;file++) {
834 for (l=0;l<nleaves;l++) {
847 fprintf(fp,
"class %s : public TSelector {\n",classname);
848 fprintf(fp,
"public :\n");
849 fprintf(fp,
" TTree *fChain; //!pointer to the analyzed TTree or TChain\n");
851 fprintf(fp,
"class %s {\n",classname);
852 fprintf(fp,
"public :\n");
853 fprintf(fp,
" TTree *fChain; //!pointer to the analyzed TTree or TChain\n");
854 fprintf(fp,
" Int_t fCurrent; //!current Tree number in a TChain\n");
857 fprintf(fp,
"\n// Fixed size dimensions of array or collections stored in the TTree if any.\n");
859 for (l=0;l<nleaves;l++) {
861 strlcpy(blen,leaf->
GetName(),
sizeof(blen));
864 if (*bname ==
'.') *bname=
'_';
865 if (*bname ==
',') *bname=
'_';
866 if (*bname ==
':') *bname=
'_';
867 if (*bname ==
'<') *bname=
'_';
868 if (*bname ==
'>') *bname=
'_';
872 if (blen[lenb-1] ==
'_') {
875 if (len <= 0) len = 1;
876 fprintf(fp,
" const Int_t kMax%s = %d;\n",blen,len);
884 fprintf(fp,
"\n // Declaration of leaf types\n");
888 const char *headOK =
" ";
889 const char *headcom =
" //";
891 char branchname[1024];
898 for (l=0;l<nleaves;l++) {
903 len = leaf->
GetLen();
if (len<=0) len = 1;
907 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
908 strlcpy(aprefix,branch->
GetName(),
sizeof(aprefix));
910 else leafStatus[
l] = 1;
913 strlcat(branchname,
".",
sizeof(branchname));
914 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
917 char *dim = (
char*)strstr(branchname,
"[");
if (dim) dim[0] = 0;
920 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
922 char *twodim = (
char*)strstr(leaf->
GetTitle(),
"][");
925 if (*bname ==
'.') *bname=
'_';
926 if (*bname ==
',') *bname=
'_';
927 if (*bname ==
':') *bname=
'_';
928 if (*bname ==
'<') *bname=
'_';
929 if (*bname ==
'>') *bname=
'_';
935 if (!leafobj->
GetClass()) {leafStatus[
l] = 1; head = headcom;}
937 if (leafStatus[l] == 0) mustInit.
Add(leafobj);
943 strlcpy(blen,leafcount->
GetName(),
sizeof(blen));
946 if (*bname ==
'.') *bname=
'_';
947 if (*bname ==
',') *bname=
'_';
948 if (*bname ==
':') *bname=
'_';
949 if (*bname ==
'<') *bname=
'_';
950 if (*bname ==
'>') *bname=
'_';
954 if (blen[lenb-1] ==
'_') {blen[lenb-1] = 0; kmax = 1;}
955 else snprintf(blen,
sizeof(blen),
"%d",len);
964 fprintf(fp,
" %-15s %s_;\n",
"Int_t", branchname);
968 fprintf(fp,
" %-15s *%s;\n",bre->
GetClassName(), branchname);
976 fprintf(fp,
"%s%-15s *%s;\n",headcom,bre->
GetClassName(), branchname);
978 fprintf(fp,
"%s%-15s *%s;\n",head,bre->
GetClassName(), branchname);
985 fprintf(fp,
"%s%-15s *%s;\n",head,bre->
GetClassName(), branchname);
986 if (leafStatus[l] == 0) mustInit.
Add(bre);
991 if (!cle) {leafStatus[
l] = 1;
continue;}
994 strlcpy(brename,bre->
GetName(),255);
995 char *bren = brename;
996 char *adot = strrchr(bren,
'.');
997 if (adot) bren = adot+1;
998 char *brack = strchr(bren,
'[');
999 if (brack) *brack = 0;
1005 if (leafcount) fprintf(fp,
"%s%-15s %s[kMax%s];\n",head,elem->
GetTypeName(), branchname,blen);
1006 else fprintf(fp,
"%s%-15s %s;\n",head,elem->
GetTypeName(), branchname);
1009 fprintf(fp,
"%s%-15s %s;\n",head,bre->
GetClassName(), branchname);
1014 if (strlen(leaf->
GetTypeName()) == 0) {leafStatus[
l] = 1;
continue;}
1025 const char *stars =
" ";
1032 char *dimInName = (
char*) strstr(branchname,
"[");
1033 if ( twodim || dimInName ) {
1035 dimensions = dimInName;
1038 if (twodim) dimensions += (
char*)(twodim+1);
1040 const char* leafcountName = leafcount->
GetName();
1044 strlcpy(b2len,l2->
GetName(),
sizeof(b2len));
1047 if (*bname ==
'.') *bname=
'_';
1048 if (*bname ==
',') *bname=
'_';
1049 if (*bname ==
':') *bname=
'_';
1050 if (*bname ==
'<') *bname=
'_';
1051 if (*bname ==
'>') *bname=
'_';
1054 leafcountName = b2len;
1056 if (dimensions.
Length()) {
1057 if (kmax) fprintf(fp,
" %-14s %s%s[kMax%s]%s; //[%s]\n",leaf->
GetTypeName(), stars,
1058 branchname,blen,dimensions.
Data(),leafcountName);
1059 else fprintf(fp,
" %-14s %s%s[%d]%s; //[%s]\n",leaf->
GetTypeName(), stars,
1060 branchname,len,dimensions.
Data(),leafcountName);
1062 if (kmax) fprintf(fp,
" %-14s %s%s[kMax%s]; //[%s]\n",leaf->
GetTypeName(), stars, branchname,blen,leafcountName);
1063 else fprintf(fp,
" %-14s %s%s[%d]; //[%s]\n",leaf->
GetTypeName(), stars, branchname,len,leafcountName);
1065 if (stars[0]==
'*') {
1067 if (kmax) n =
new TNamed(branchname,
Form(
"kMax%s",blen));
1068 else n =
new TNamed(branchname,
Form(
"%d",len));
1072 if (strstr(branchname,
"[")) len = 1;
1073 if (len < 2) fprintf(fp,
" %-15s %s;\n",leaf->
GetTypeName(), branchname);
1075 if (twodim) fprintf(fp,
" %-15s %s%s;\n",leaf->
GetTypeName(), branchname,(
char*)strstr(leaf->
GetTitle(),
"["));
1076 else fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,len);
1083 fprintf(fp,
" // List of branches\n");
1084 for (l=0;l<nleaves;l++) {
1085 if (leafStatus[l])
continue;
1093 fprintf(fp,
" %s(TTree * /*tree*/ =0) : fChain(0) { }\n",classname) ;
1094 fprintf(fp,
" virtual ~%s() { }\n",classname);
1095 fprintf(fp,
" virtual Int_t Version() const { return 2; }\n");
1096 fprintf(fp,
" virtual void Begin(TTree *tree);\n");
1097 fprintf(fp,
" virtual void SlaveBegin(TTree *tree);\n");
1098 fprintf(fp,
" virtual void Init(TTree *tree);\n");
1099 fprintf(fp,
" virtual Bool_t Notify();\n");
1100 fprintf(fp,
" virtual Bool_t Process(Long64_t entry);\n");
1101 fprintf(fp,
" virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }\n");
1102 fprintf(fp,
" virtual void SetOption(const char *option) { fOption = option; }\n");
1103 fprintf(fp,
" virtual void SetObject(TObject *obj) { fObject = obj; }\n");
1104 fprintf(fp,
" virtual void SetInputList(TList *input) { fInput = input; }\n");
1105 fprintf(fp,
" virtual TList *GetOutputList() const { return fOutput; }\n");
1106 fprintf(fp,
" virtual void SlaveTerminate();\n");
1107 fprintf(fp,
" virtual void Terminate();\n\n");
1108 fprintf(fp,
" ClassDef(%s,0);\n",classname);
1111 fprintf(fp,
"#endif\n");
1115 fprintf(fp,
" %s(TTree *tree=0);\n",classname);
1116 fprintf(fp,
" virtual ~%s();\n",classname);
1117 fprintf(fp,
" virtual Int_t Cut(Long64_t entry);\n");
1118 fprintf(fp,
" virtual Int_t GetEntry(Long64_t entry);\n");
1119 fprintf(fp,
" virtual Long64_t LoadTree(Long64_t entry);\n");
1120 fprintf(fp,
" virtual void Init(TTree *tree);\n");
1121 fprintf(fp,
" virtual void Loop();\n");
1122 fprintf(fp,
" virtual Bool_t Notify();\n");
1123 fprintf(fp,
" virtual void Show(Long64_t entry = -1);\n");
1126 fprintf(fp,
"#endif\n");
1130 fprintf(fp,
"#ifdef %s_cxx\n",classname);
1132 fprintf(fp,
"%s::%s(TTree *tree) : fChain(0) \n",classname,classname);
1134 fprintf(fp,
"// if parameter tree is not specified (or zero), connect the file\n");
1135 fprintf(fp,
"// used to generate this class and read the Tree.\n");
1136 fprintf(fp,
" if (tree == 0) {\n");
1138 fprintf(fp,
"\n#ifdef SINGLE_TREE\n");
1139 fprintf(fp,
" // The following code should be used if you want this class to access\n");
1140 fprintf(fp,
" // a single tree instead of a chain\n");
1143 fprintf(fp,
" THbookFile *f = (THbookFile*)gROOT->GetListOfBrowsables()->FindObject(\"%s\");\n",
1145 fprintf(fp,
" if (!f) {\n");
1146 fprintf(fp,
" f = new THbookFile(\"%s\");\n",treefile.
Data());
1150 fprintf(fp,
" tree = (TTree*)f->Get(%d);\n\n",hid);
1152 fprintf(fp,
" TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(\"%s\");\n",treefile.
Data());
1153 fprintf(fp,
" if (!f || !f->IsOpen()) {\n");
1154 fprintf(fp,
" f = new TFile(\"%s\");\n",treefile.
Data());
1158 fprintf(fp,
" dir->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1160 fprintf(fp,
" f->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1164 fprintf(fp,
"#else // SINGLE_TREE\n\n");
1165 fprintf(fp,
" // The following code should be used if you want this class to access a chain\n");
1166 fprintf(fp,
" // of trees.\n");
1167 fprintf(fp,
" TChain * chain = new TChain(\"%s\",\"%s\");\n",
1174 fprintf(fp,
" chain->Add(\"%s/%s\");\n",element->
GetTitle(),element->
GetName());
1177 fprintf(fp,
" tree = chain;\n");
1178 fprintf(fp,
"#endif // SINGLE_TREE\n\n");
1181 fprintf(fp,
" Init(tree);\n");
1188 fprintf(fp,
"%s::~%s()\n",classname,classname);
1190 fprintf(fp,
" if (!fChain) return;\n");
1194 fprintf(fp,
" delete fChain->GetCurrentFile();\n");
1201 fprintf(fp,
"Int_t %s::GetEntry(Long64_t entry)\n",classname);
1203 fprintf(fp,
"// Read contents of entry.\n");
1205 fprintf(fp,
" if (!fChain) return 0;\n");
1206 fprintf(fp,
" return fChain->GetEntry(entry);\n");
1211 fprintf(fp,
"Long64_t %s::LoadTree(Long64_t entry)\n",classname);
1213 fprintf(fp,
"// Set the environment to read one entry\n");
1214 fprintf(fp,
" if (!fChain) return -5;\n");
1215 fprintf(fp,
" Long64_t centry = fChain->LoadTree(entry);\n");
1216 fprintf(fp,
" if (centry < 0) return centry;\n");
1217 fprintf(fp,
" if (fChain->GetTreeNumber() != fCurrent) {\n");
1218 fprintf(fp,
" fCurrent = fChain->GetTreeNumber();\n");
1219 fprintf(fp,
" Notify();\n");
1221 fprintf(fp,
" return centry;\n");
1227 fprintf(fp,
"void %s::Init(TTree *tree)\n",classname);
1229 fprintf(fp,
" // The Init() function is called when the selector needs to initialize\n"
1230 " // a new tree or chain. Typically here the branch addresses and branch\n"
1231 " // pointers of the tree will be set.\n"
1232 " // It is normally not necessary to make changes to the generated\n"
1233 " // code, but the routine can be extended by the user if needed.\n"
1234 " // Init() will be called many times when running on PROOF\n"
1235 " // (once per file to be processed).\n\n");
1236 if (mustInit.
Last()) {
1239 fprintf(fp,
" // Set object pointer\n");
1240 while( (obj =
next()) ) {
1242 strlcpy(branchname,((
TBranch*)obj)->
GetName(),
sizeof(branchname));
1244 strlcpy(branchname,((
TLeaf*)obj)->
GetName(),
sizeof(branchname));
1249 if (*bname ==
'.') *bname=
'_';
1250 if (*bname ==
',') *bname=
'_';
1251 if (*bname ==
':') *bname=
'_';
1252 if (*bname ==
'<') *bname=
'_';
1253 if (*bname ==
'>') *bname=
'_';
1256 fprintf(fp,
" %s = 0;\n",branchname );
1259 if (mustInitArr.
Last()) {
1262 fprintf(fp,
" // Set array pointer\n");
1264 fprintf(fp,
" for(int i=0; i<%s; ++i) %s[i] = 0;\n",info->
GetTitle(),info->
GetName());
1268 fprintf(fp,
" // Set branch addresses and branch pointers\n");
1269 fprintf(fp,
" if (!tree) return;\n");
1270 fprintf(fp,
" fChain = tree;\n");
1271 if (!opt.
Contains(
"selector")) fprintf(fp,
" fCurrent = -1;\n");
1272 fprintf(fp,
" fChain->SetMakeClass(1);\n");
1274 for (l=0;l<nleaves;l++) {
1275 if (leafStatus[l])
continue;
1280 strlcpy(aprefix,branch->
GetName(),
sizeof(aprefix));
1284 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1285 strlcat(branchname,
".",
sizeof(branchname));
1286 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1289 char *dim = (
char*)strstr(branchname,
"[");
if (dim) dim[0] = 0;
1292 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1295 if (bre->
GetType() == 3 || bre->
GetType()==4) strlcat(branchname,
"_",
sizeof(branchname));
1299 char *brak = strstr(branchname,
"[");
if (brak) *brak = 0;
1300 char *twodim = (
char*)strstr(bname,
"[");
if (twodim) *twodim = 0;
1302 if (*bname ==
'.') *bname=
'_';
1303 if (*bname ==
',') *bname=
'_';
1304 if (*bname ==
':') *bname=
'_';
1305 if (*bname ==
'<') *bname=
'_';
1306 if (*bname ==
'>') *bname=
'_';
1309 const char *maybedisable =
"";
1312 maybedisable =
"// ";
1319 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1325 if (leafcount) len = leafcount->
GetMaximum()+1;
1326 if (len > 1) fprintf(fp,
"%s fChain->SetBranchAddress(\"%s\", %s, &b_%s);\n",
1328 else fprintf(fp,
"%s fChain->SetBranchAddress(\"%s\", &%s, &b_%s);\n",
1333 fprintf(fp,
" Notify();\n");
1340 fprintf(fp,
"Bool_t %s::Notify()\n",classname);
1342 fprintf(fp,
" // The Notify() function is called when a new file is opened. This\n"
1343 " // can be either for a new TTree in a TChain or when when a new TTree\n"
1344 " // is started when using PROOF. It is normally not necessary to make changes\n"
1345 " // to the generated code, but the routine can be extended by the\n"
1346 " // user if needed. The return value is currently not used.\n\n");
1347 fprintf(fp,
" return kTRUE;\n");
1353 fprintf(fp,
"void %s::Show(Long64_t entry)\n",classname);
1355 fprintf(fp,
"// Print contents of entry.\n");
1356 fprintf(fp,
"// If entry is not specified, print current entry\n");
1358 fprintf(fp,
" if (!fChain) return;\n");
1359 fprintf(fp,
" fChain->Show(entry);\n");
1364 fprintf(fp,
"Int_t %s::Cut(Long64_t entry)\n",classname);
1366 fprintf(fp,
"// This function may be called from Loop.\n");
1367 fprintf(fp,
"// returns 1 if entry is accepted.\n");
1368 fprintf(fp,
"// returns -1 otherwise.\n");
1370 fprintf(fp,
" return 1;\n");
1373 fprintf(fp,
"#endif // #ifdef %s_cxx\n",classname);
1378 fprintf(fpc,
"#define %s_cxx\n",classname);
1379 fprintf(fpc,
"#include \"%s\"\n",thead.
Data());
1380 fprintf(fpc,
"#include <TH2.h>\n");
1381 fprintf(fpc,
"#include <TStyle.h>\n");
1382 fprintf(fpc,
"#include <TCanvas.h>\n");
1384 fprintf(fpc,
"void %s::Loop()\n",classname);
1386 fprintf(fpc,
"// In a ROOT session, you can do:\n");
1387 fprintf(fpc,
"// root> .L %s.C\n",classname);
1388 fprintf(fpc,
"// root> %s t\n",classname);
1389 fprintf(fpc,
"// root> t.GetEntry(12); // Fill t data members with entry number 12\n");
1390 fprintf(fpc,
"// root> t.Show(); // Show values of entry 12\n");
1391 fprintf(fpc,
"// root> t.Show(16); // Read and show values of entry 16\n");
1392 fprintf(fpc,
"// root> t.Loop(); // Loop on all entries\n");
1393 fprintf(fpc,
"//\n");
1394 fprintf(fpc,
"\n// This is the loop skeleton where:\n");
1395 fprintf(fpc,
"// jentry is the global entry number in the chain\n");
1396 fprintf(fpc,
"// ientry is the entry number in the current Tree\n");
1397 fprintf(fpc,
"// Note that the argument to GetEntry must be:\n");
1398 fprintf(fpc,
"// jentry for TChain::GetEntry\n");
1399 fprintf(fpc,
"// ientry for TTree::GetEntry and TBranch::GetEntry\n");
1400 fprintf(fpc,
"//\n");
1401 fprintf(fpc,
"// To read only selected branches, Insert statements like:\n");
1402 fprintf(fpc,
"// METHOD1:\n");
1403 fprintf(fpc,
"// fChain->SetBranchStatus(\"*\",0); // disable all branches\n");
1404 fprintf(fpc,
"// fChain->SetBranchStatus(\"branchname\",1); // activate branchname\n");
1405 fprintf(fpc,
"// METHOD2: replace line\n");
1406 fprintf(fpc,
"// fChain->GetEntry(jentry); //read all branches\n");
1407 fprintf(fpc,
"//by b_branchname->GetEntry(ientry); //read only this branch\n");
1408 fprintf(fpc,
" if (fChain == 0) return;\n");
1409 fprintf(fpc,
"\n Long64_t nentries = fChain->GetEntriesFast();\n");
1410 fprintf(fpc,
"\n Long64_t nbytes = 0, nb = 0;\n");
1411 fprintf(fpc,
" for (Long64_t jentry=0; jentry<nentries;jentry++) {\n");
1412 fprintf(fpc,
" Long64_t ientry = LoadTree(jentry);\n");
1413 fprintf(fpc,
" if (ientry < 0) break;\n");
1414 fprintf(fpc,
" nb = fChain->GetEntry(jentry); nbytes += nb;\n");
1415 fprintf(fpc,
" // if (Cut(ientry) < 0) continue;\n");
1416 fprintf(fpc,
" }\n");
1421 fprintf(fpc,
"#define %s_cxx\n",classname);
1422 fprintf(fpc,
"// The class definition in %s.h has been generated automatically\n",classname);
1423 fprintf(fpc,
"// by the ROOT utility TTree::MakeSelector(). This class is derived\n");
1424 fprintf(fpc,
"// from the ROOT class TSelector. For more information on the TSelector\n"
1425 "// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.\n\n");
1426 fprintf(fpc,
"// The following methods are defined in this file:\n");
1427 fprintf(fpc,
"// Begin(): called every time a loop on the tree starts,\n");
1428 fprintf(fpc,
"// a convenient place to create your histograms.\n");
1429 fprintf(fpc,
"// SlaveBegin(): called after Begin(), when on PROOF called only on the\n"
1430 "// slave servers.\n");
1431 fprintf(fpc,
"// Process(): called for each event, in this function you decide what\n");
1432 fprintf(fpc,
"// to read and fill your histograms.\n");
1433 fprintf(fpc,
"// SlaveTerminate: called at the end of the loop on the tree, when on PROOF\n"
1434 "// called only on the slave servers.\n");
1435 fprintf(fpc,
"// Terminate(): called at the end of the loop on the tree,\n");
1436 fprintf(fpc,
"// a convenient place to draw/fit your histograms.\n");
1437 fprintf(fpc,
"//\n");
1438 fprintf(fpc,
"// To use this file, try the following session on your Tree T:\n");
1439 fprintf(fpc,
"//\n");
1440 fprintf(fpc,
"// root> T->Process(\"%s.C\")\n",classname);
1441 fprintf(fpc,
"// root> T->Process(\"%s.C\",\"some options\")\n",classname);
1442 fprintf(fpc,
"// root> T->Process(\"%s.C+\")\n",classname);
1443 fprintf(fpc,
"//\n\n");
1444 fprintf(fpc,
"#include \"%s\"\n",thead.
Data());
1445 fprintf(fpc,
"#include <TH2.h>\n");
1446 fprintf(fpc,
"#include <TStyle.h>\n");
1450 fprintf(fpc,
"void %s::Begin(TTree * /*tree*/)\n",classname);
1452 fprintf(fpc,
" // The Begin() function is called at the start of the query.\n");
1453 fprintf(fpc,
" // When running with PROOF Begin() is only called on the client.\n");
1454 fprintf(fpc,
" // The tree argument is deprecated (on PROOF 0 is passed).\n");
1456 fprintf(fpc,
" TString option = GetOption();\n");
1461 fprintf(fpc,
"void %s::SlaveBegin(TTree * /*tree*/)\n",classname);
1463 fprintf(fpc,
" // The SlaveBegin() function is called after the Begin() function.\n");
1464 fprintf(fpc,
" // When running with PROOF SlaveBegin() is called on each slave server.\n");
1465 fprintf(fpc,
" // The tree argument is deprecated (on PROOF 0 is passed).\n");
1467 fprintf(fpc,
" TString option = GetOption();\n");
1472 fprintf(fpc,
"Bool_t %s::Process(Long64_t entry)\n",classname);
1474 fprintf(fpc,
" // The Process() function is called for each entry in the tree (or possibly\n"
1475 " // keyed object in the case of PROOF) to be processed. The entry argument\n"
1476 " // specifies which entry in the currently loaded tree is to be processed.\n"
1477 " // It can be passed to either %s::GetEntry() or TBranch::GetEntry()\n"
1478 " // to read either all or the required parts of the data. When processing\n"
1479 " // keyed objects with PROOF, the object is already loaded and is available\n"
1480 " // via the fObject pointer.\n"
1482 " // This function should contain the \"body\" of the analysis. It can contain\n"
1483 " // simple or elaborate selection criteria, run algorithms on the data\n"
1484 " // of the event and typically fill histograms.\n"
1486 " // The processing can be stopped by calling Abort().\n"
1488 " // Use fStatus to set the return value of TTree::Process().\n"
1490 " // The return value is currently not used.\n\n", classname);
1492 fprintf(fpc,
" return kTRUE;\n");
1496 fprintf(fpc,
"void %s::SlaveTerminate()\n",classname);
1498 fprintf(fpc,
" // The SlaveTerminate() function is called after all entries or objects\n"
1499 " // have been processed. When running with PROOF SlaveTerminate() is called\n"
1500 " // on each slave server.");
1506 fprintf(fpc,
"void %s::Terminate()\n",classname);
1508 fprintf(fpc,
" // The Terminate() function is the last function to be called during\n"
1509 " // a query. It always runs on the client, it can be used to present\n"
1510 " // the results graphically or save the results to file.");
1516 delete [] leafStatus;
1554 FILE *fp = fopen(tfile,
"w");
1556 Error(
"MakeCode",
"cannot open output file %s", tfile.
Data());
1563 treefile =
"Memory Directory";
1575 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
1576 fprintf(fp,
"// This file has been automatically generated \n");
1577 fprintf(fp,
"// (%s by ROOT version%s)\n",td.
AsString(),
gROOT->GetVersion());
1580 fprintf(fp,
"// found on file: %s\n",treefile.
Data());
1584 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
1590 fprintf(fp,
"//Reset ROOT and connect tree file\n");
1591 fprintf(fp,
" gROOT->Reset();\n");
1593 fprintf(fp,
"\n#ifdef SINGLE_TREE\n");
1594 fprintf(fp,
" // The following code should be used if you want this code to access\n");
1595 fprintf(fp,
" // a single tree instead of a chain\n");
1597 fprintf(fp,
" TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(\"%s\");\n",treefile.
Data());
1598 fprintf(fp,
" if (!f) {\n");
1599 fprintf(fp,
" f = new TFile(\"%s\");\n",treefile.
Data());
1603 fprintf(fp,
" dir->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1605 fprintf(fp,
" f->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1608 fprintf(fp,
"#else // SINGLE_TREE\n\n");
1609 fprintf(fp,
" // The following code should be used if you want this code to access a chain\n");
1610 fprintf(fp,
" // of trees.\n");
1611 fprintf(fp,
" TChain *%s = new TChain(\"%s\",\"%s\");\n",
1621 fprintf(fp,
"#endif // SINGLE_TREE\n\n");
1625 fprintf(fp,
"//Declaration of leaves types\n");
1630 const char *headOK =
" ";
1631 const char *headcom =
" //";
1633 char branchname[1024];
1634 for (l=0;l<nleaves;l++) {
1643 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1644 strlcat(branchname,
".",
sizeof(branchname));
1645 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1648 char *dim = (
char*)strstr(branchname,
"[");
1649 if (dim) dim[0] = 0;
1652 if (leafcount) strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1653 else strlcpy(branchname,leaf->
GetTitle(),
sizeof(branchname));
1655 char *twodim = (
char*)strstr(leaf->
GetTitle(),
"][");
1658 if (*bname ==
'.') *bname=
'_';
1659 if (*bname ==
',') *bname=
'_';
1660 if (*bname ==
':') *bname=
'_';
1661 if (*bname ==
'<') *bname=
'_';
1662 if (*bname ==
'>') *bname=
'_';
1667 if (leafobj->
GetClass()) head = headOK;
1668 else head = headcom;
1676 char *dimInName = (
char*) strstr(branchname,
"[");
1678 if ( twodim || dimInName ) {
1680 dimensions = dimInName;
1683 if (twodim) dimensions += (
char*)(twodim+1);
1685 if (dimensions.
Length()) {
1686 fprintf(fp,
" %-15s %s[%d]%s;\n",leaf->
GetTypeName(), branchname,len,dimensions.
Data());
1688 fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,len);
1691 if (strstr(branchname,
"[")) len = 1;
1692 if (len < 2) fprintf(fp,
" %-15s %s;\n",leaf->
GetTypeName(), branchname);
1693 else fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,len);
1698 fprintf(fp,
"\n // Set branch addresses.\n");
1699 for (l=0;l<nleaves;l++) {
1707 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1708 strlcat(branchname,
".",
sizeof(branchname));
1709 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1712 char *dim = (
char*)strstr(branchname,
"[");
1713 if (dim) dim[0] = 0;
1716 if (leafcount) strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1717 else strlcpy(branchname,leaf->
GetTitle(),
sizeof(branchname));
1721 if (*bname ==
'.') *bname=
'_';
1722 if (*bname ==
',') *bname=
'_';
1723 if (*bname ==
':') *bname=
'_';
1724 if (*bname ==
'<') *bname=
'_';
1725 if (*bname ==
'>') *bname=
'_';
1728 char *brak = strstr(branchname,
"[");
1729 if (brak) *brak = 0;
1732 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1734 if (!leafobj->
GetClass()) head = headcom;
1736 if (leafcount) len = leafcount->
GetMaximum()+1;
1737 if (len > 1 || brak) fprintf(fp,
"%s%s->SetBranchAddress(\"%s\",%s);\n",head,
fTree->
GetName(),branch->
GetName(),branchname);
1738 else fprintf(fp,
"%s%s->SetBranchAddress(\"%s\",&%s);\n",head,
fTree->
GetName(),branch->
GetName(),branchname);
1742 fprintf(fp,
"\n// This is the loop skeleton\n");
1743 fprintf(fp,
"// To read only selected branches, Insert statements like:\n");
1744 fprintf(fp,
"// %s->SetBranchStatus(\"*\",0); // disable all branches\n",
fTree->
GetName());
1745 fprintf(fp,
"// %s->SetBranchStatus(\"branchname\",1); // activate branchname\n",
GetName());
1746 fprintf(fp,
"\n Long64_t nentries = %s->GetEntries();\n",
fTree->
GetName());
1747 fprintf(fp,
"\n Long64_t nbytes = 0;\n");
1748 fprintf(fp,
"// for (Long64_t i=0; i<nentries;i++) {\n");
1749 fprintf(fp,
"// nbytes += %s->GetEntry(i);\n",
fTree->
GetName());
1750 fprintf(fp,
"// }\n");
1911 const char *macrofilename,
const char *cutfilename,
1912 const char *option,
Int_t maxUnrolling)
1914 if (macrofilename==0 || strlen(macrofilename)==0 ) {
1916 Error(
"MakeProxy",
"A file name for the user script is required");
2000 std::vector<TString> cnames;
2009 if (nleaves < ncols) ncols = nleaves;
2010 nch = varexp ? strlen(varexp) : 0;
2016 if (strlen(selection)) {
2018 if (!select)
return principal;
2019 if (!select->
GetNdim()) {
delete select;
return principal; }
2024 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2025 if (nch == 0 || allvar) {
2026 for (i=0;i<ncols;i++) {
2037 for (i=0;i<ncols;i++) {
2059 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2061 if (entryNumber < 0)
break;
2063 if (localEntry < 0)
break;
2073 for(
int inst=0;inst<
ndata;inst++) {
2081 if (inst==0) loaded =
kTRUE;
2085 for (i=0;i<ncols;i++) {
2091 for (i=0;i<ncols;i++) {
2094 principal->
AddRow(xvars);
2188 if (!selector)
return -1;
2255 if (tpf) tpf->
SetEntryRange(firstentry,firstentry+nentries);
2262 if (!
gROOT->IsBatch() && interval)
2280 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2282 if (entryNumber < 0)
break;
2284 if (
gROOT->IsInterrupted())
break;
2286 if (localEntry < 0)
break;
2291 selector->
Process(localEntry);
2418 UInt_t colDefaultSize = 9;
2420 std::vector<TString> colFormats;
2421 std::vector<Int_t> colSizes;
2424 int start = opt.
Index(
"lenmax=");
2425 int numpos = start + strlen(
"lenmax=");
2428 while( (numpos+numlen<len) && isdigit(opt[numpos+numlen]) ) numlen++;
2429 TString num = opt(numpos,numlen);
2430 opt.
Remove(start,strlen(
"lenmax")+numlen);
2432 lenmax = atoi(num.
Data());
2435 int start = opt.
Index(
"colsize=");
2436 int numpos = start + strlen(
"colsize=");
2439 while( (numpos+numlen<len) && isdigit(opt[numpos+numlen]) ) numlen++;
2440 TString num = opt(numpos,numlen);
2441 opt.
Remove(start,strlen(
"size")+numlen);
2443 colDefaultSize = atoi(num.
Data());
2444 colPrecision = colDefaultSize;
2445 if (colPrecision>18) colPrecision = 18;
2448 int start = opt.
Index(
"precision=");
2449 int numpos = start + strlen(
"precision=");
2452 while( (numpos+numlen<len) && isdigit(opt[numpos+numlen]) ) numlen++;
2453 TString num = opt(numpos,numlen);
2454 opt.
Remove(start,strlen(
"precision")+numlen);
2456 colPrecision = atoi(num.
Data());
2458 TString defFormat =
Form(
"%d.%d",colDefaultSize,colPrecision);
2460 int start = opt.
Index(
"col=");
2461 int numpos = start + strlen(
"col=");
2464 while( (numpos+numlen<len) &&
2465 (isdigit(opt[numpos+numlen])
2466 || opt[numpos+numlen] ==
'c'
2467 || opt[numpos+numlen] ==
'd'
2468 || opt[numpos+numlen] ==
'i'
2469 || opt[numpos+numlen] ==
'o'
2470 || opt[numpos+numlen] ==
'x'
2471 || opt[numpos+numlen] ==
'X'
2472 || opt[numpos+numlen] ==
'u'
2473 || opt[numpos+numlen] ==
'f'
2474 || opt[numpos+numlen] ==
'e'
2475 || opt[numpos+numlen] ==
'E'
2476 || opt[numpos+numlen] ==
'g'
2477 || opt[numpos+numlen] ==
'G'
2478 || opt[numpos+numlen] ==
'l'
2479 || opt[numpos+numlen] ==
'L'
2480 || opt[numpos+numlen] ==
'h'
2481 || opt[numpos+numlen] ==
's'
2482 || opt[numpos+numlen] ==
'#'
2483 || opt[numpos+numlen]==
'.'
2484 || opt[numpos+numlen]==
':')) numlen++;
2485 TString flist = opt(numpos,numlen);
2486 opt.
Remove(start,strlen(
"col")+numlen);
2489 while(i<flist.
Length() && flist[i]==
':') {
2490 colFormats.push_back(defFormat);
2491 colSizes.push_back(colDefaultSize);
2494 for(; i<flist.
Length(); ++i) {
2497 colFormats.push_back(defFormat);
2498 }
else if (next==
kNPOS) {
2499 colFormats.push_back(flist(i,flist.
Length()-i));
2502 colFormats.push_back(flist(i,next-i));
2505 UInt_t siz = atoi(colFormats[colFormats.size()-1].Data());
2506 colSizes.push_back( siz ? siz : colDefaultSize );
2511 std::vector<TString> cnames;
2522 if (!fname) fname = (
char*)
"";
2523 lenfile = strlen(fname);
2526 fname =
new char[nch2+10];
2528 strlcat(fname,
"-scan.dat",nch2+10);
2532 if (!lenfile)
delete [] fname;
2533 Error(
"Scan",
"Can not open file for redirection");
2538 if (leaves==0)
return 0;
2540 if (nleaves < ncols) ncols = nleaves;
2541 nch = varexp ? strlen(varexp) : 0;
2547 if (selection && strlen(selection)) {
2549 if (!select)
return -1;
2550 if (!select->
GetNdim()) {
delete select;
return -1; }
2555 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2556 if (nch == 0 || allvar) {
2559 for (ui=0;ui<ncs;++ui) {
2563 if (cnames[ncols] == lf->
GetName() ) {
2565 }
else if (cnames[ncols][cnames[ncols].Length()-1]==
'.') {
2578 cnames[ncols].Append(
'.');
2583 cnames[ncols].Append(
'.');
2584 cnames[ncols].Append( lf->
GetName() );
2596 for(ui=colFormats.size();ui<ncols;++ui) {
2597 colFormats.push_back(defFormat);
2598 colSizes.push_back(colDefaultSize);
2602 for (ui=0;ui<ncols;ui++) {
2640 onerow =
"***********";
2641 if (hasArray) onerow +=
"***********";
2643 for (ui=0;ui<ncols;ui++) {
2644 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2648 out<<onerow.
Data()<<
"*"<<std::endl;
2652 if (hasArray) onerow +=
"* Instance ";
2653 for (ui=0;ui<ncols;ui++) {
2654 TString numbFormat =
Form(
"* %%%d.%ds ",colSizes[ui],colSizes[ui]);
2658 out<<onerow.Data()<<
"*"<<std::endl;
2660 printf(
"%s*\n",onerow.Data());
2661 onerow =
"***********";
2662 if (hasArray) onerow +=
"***********";
2663 for (ui=0;ui<ncols;ui++) {
2664 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2668 out<<onerow.Data()<<
"*"<<std::endl;
2670 printf(
"%s*\n",onerow.Data());
2675 for (entry=firstentry;
2676 entry<(firstentry+
nentries) && !exitloop;
2679 if (entryNumber < 0)
break;
2681 if (localEntry < 0)
break;
2702 for (ui=0;ui<ncols;ui++) {
2703 if (ndata < var[ui]->GetNdata() ) {
2707 if (select && select->
GetNdata()==0) ndata = 0;
2712 if (lenmax && ndata>(
int)lenmax) ndata = lenmax;
2714 for(
int inst=0;inst<
ndata;inst++) {
2720 if (inst==0) loaded =
kTRUE;
2724 for (ui=0;ui<ncols;ui++) {
2729 onerow =
Form(
"* %8lld ",entryNumber);
2731 onerow +=
Form(
"* %8d ",inst);
2733 for (ui=0;ui<ncols;++ui) {
2734 TString numbFormat =
Form(
"* %%%d.%ds ",colSizes[ui],colSizes[ui]);
2735 if (var[ui]->GetNdim()) onerow +=
Form(numbFormat.
Data(),var[ui]->
PrintValue(0,inst,colFormats[ui].
Data()));
2737 TString emptyForm =
Form(
"* %%%dc ",colSizes[ui]);
2738 onerow +=
Form(emptyForm.
Data(),
' ');
2743 out<<onerow.Data()<<
"*"<<std::endl;
2745 printf(
"%s*\n",onerow.Data());
2748 fprintf(stderr,
"Type <CR> to continue or q to quit ==> ");
2752 while (readch !=
'\n' && readch != EOF) readch = getchar();
2753 if (answer ==
'q' || answer ==
'Q') {
2761 onerow =
"***********";
2762 if (hasArray) onerow +=
"***********";
2763 for (ui=0;ui<ncols;ui++) {
2764 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2768 out<<onerow.Data()<<
"*"<<std::endl;
2770 printf(
"%s*\n",onerow.Data());
2771 if (select)
Printf(
"==> %lld selected %s", fSelectedRows,
2772 fSelectedRows == 1 ?
"entry" :
"entries");
2793 std::vector<TString> cnames;
2800 if (nleaves < ncols) ncols = nleaves;
2801 nch = varexp ? strlen(varexp) : 0;
2807 if (strlen(selection)) {
2809 if (!select)
return 0;
2810 if (!select->
GetNdim()) {
delete select;
return 0; }
2816 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2817 if (nch == 0 || allvar) {
2818 for (i=0;i<ncols;i++) {
2828 for (i=0;i<ncols;i++) {
2835 for (i = 0; i < ncols; i++) {
2836 res->
AddField(i, var[i]->PrintValue(-1));
2850 const char *aresult;
2852 char *arow =
new char[ncols*50];
2856 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2858 if (entryNumber < 0)
break;
2860 if (localEntry < 0)
break;
2877 for(
int inst=0;inst<
ndata;inst++) {
2884 if (inst==0) loaded =
kTRUE;
2888 for (i=0;i<ncols;i++) {
2893 for (i=0;i<ncols;i++) {
2895 len = strlen(aresult)+1;
2897 memcpy(arow,aresult,len);
2900 memcpy(arow+fields[i-1],aresult,len);
2901 fields[i] = fields[i-1] + len;
2935 if (
gROOT->IsBatch()) {
2936 Warning(
"StartViewer",
"viewer cannot run in batch mode");
2942 if ((h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualTreeViewer"))) {
3022 TF1* fitfunc = (
TF1*)
gROOT->GetFunction(funcname);
3023 if (!fitfunc) {
Error(
"UnbinnedFit",
"Unknown function: %s",funcname);
return 0; }
3026 if (npar <=0) {
Error(
"UnbinnedFit",
"Illegal number of parameters = %d",npar);
return 0; }
3046 TString drawOpt =
"goff para";
3051 Info(
"UnbinnedFit",
"Ignore option D with more than 4 variables");
3052 nsel =
DrawSelect(varexp, selection,
"goff para", nentries, firstentry);
3059 Error(
"UnbinnedFit",
"Cannot fit: no entries selected");
3070 std::vector<double *> vlist(ndim);
3071 for (
int i = 0; i < ndim; ++i)
const char * GetName() const
Returns name of object.
virtual Int_t GetLen() const
Return the number of effective elements of this leaf.
virtual const char * GetTitle() const
Returns title of object.
void DeleteSelectorFromFile()
Delete any selector created by this object.
virtual void SetLineWidth(Width_t lwidth)
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
static TString R__GetBranchPointerName(TLeaf *leaf, Bool_t replace=kTRUE)
Return the name of the branch pointer needed by MakeClass/MakeSelector.
virtual Int_t GetDimension() const
Ssiz_t Last(char c) const
Find last occurrence of a character c.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual int Version() const
TList * GetListOfFunctions() const
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form: ~~~ {.cpp} [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)]...
Principal Components Analysis (PCA)
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual Double_t * GetVal(Int_t i) const
Return the last values corresponding to the i-th component of the formula being processed (where the ...
void AddRow(TSQLRow *row)
Adopt a row to result set.
Bool_t ProcessEvents()
Process events if timer did time out.
virtual Long64_t GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const
return the number of entries to be processed this function checks that nentries is not bigger than th...
Abstract interface for Tree Index.
const char * GetTypeName() const
virtual Bool_t Notify()
This method must be overridden to handle object notification.
virtual TLeaf * GetLeaf(const char *branchname, const char *leafname)
Return a pointer to the leaf name in the current tree.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual Bool_t SendProcessingProgress(Double_t, Double_t, Bool_t=kFALSE)
void AdoptReferenceProxy(TVirtualRefProxy *proxy)
Adopt the Reference proxy pointer to indicate that this class represents a reference.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
virtual TList * GetOutputList() const
Collectable string class.
TSelectorDraw * fSelector
Pointer to histogram used for the projection.
const char * GetNameByIndex(TString &varexp, Int_t *index, Int_t colindex)
Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves funct...
Bool_t GetCanvasPreferGL() const
TEventList * GetEventList() const
virtual void SetEstimate(Long64_t n)
Set number of entries to estimate variable limits.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
TTreeFormula * GetVar2() const
TBranchElement * GetBranchCount2() const
virtual Bool_t ProcessCut(Long64_t)
A TLeaf for a general object derived from TObject.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual Long64_t GetSelectedRows() const
R__EXTERN TStyle * gStyle
virtual Int_t GetDimension() const
R__EXTERN Foption_t Foption
virtual Int_t Fill()
Fill all branches.
virtual TEntryList * GetEntryList()
Returns the entry list, set to this tree.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
A specialized TFileCacheRead object for a TTree.
virtual Long64_t GetEntriesFriend() const
Return pointer to the 1st Leaf named name in any Branch of this Tree or any branch in the list of fri...
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual void Print(Option_t *opt="MSE") const
Print the statistics Options are M Print mean values of original data S Print sigma values of origina...
void ToUpper()
Change string to upper case.
static const char * filename()
virtual Long64_t GetSelectedRows() const
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
Int_t LoadPlugin()
Load the plugin library for this handler.
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
virtual Long64_t GetDrawFlag() const
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
R__EXTERN TVirtualMutex * gROOTMutex
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
TBranch * GetBranch() const
virtual Long64_t GetEntryNumber(Long64_t entry) const
Return entry number corresponding to entry.
virtual Long64_t Scan(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Loop on Tree and print entries passing selection.
Int_t GetEntriesFast() const
virtual TTree * CloneTree(Long64_t nentries=-1, Option_t *option="")
Create a clone of this tree and copy nentries.
virtual Long64_t GetEstimate() const
A TChainElement describes a component of a TChain.
TFile * GetCurrentFile() const
Return pointer to the current file.
Long_t ExecPlugin(int nargs, const T &...params)
virtual const char * GetPath() const
Returns the full path of the directory.
A Tree Index with majorname and minorname.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual void SetTree(const TTree *tree)
If a list for a tree with such name and filename exists, sets it as the current sublist If not...
virtual void SetTree(TTree *t)
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
virtual Bool_t GetCleanElist() const
TPrincipal * Principal(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Interface to the Principal Components Analysis class.
TFitResultPtr UnBinFit(ROOT::Fit::UnBinData *data, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption)
fit an unbin data set (from tree or from histogram buffer) using a TF1 pointer and fit options...
const char * Data() const
TFileCacheRead * GetCacheRead(TObject *tree=0) const
Return a pointer to the current read cache.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual Long64_t DrawSelect(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Draw expression varexp for specified entries that matches the selection.
virtual void SetTextFont(Font_t tfont=62)
virtual void ProcessFill(Long64_t)
Long64_t * GetTreeOffset() const
virtual TObjArray * GetListOfBranches()
virtual Long64_t DrawScript(const char *wrapperPrefix, const char *macrofilename, const char *cutfilename, Option_t *option, Long64_t nentries, Long64_t firstentry)
Draw the result of a C++ script.
virtual TTree * CopyTree(const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Copy a Tree with selection, make a clone of this Tree header, then copy the selected entries...
Class defining interface to a row of a TTree query result.
virtual Long64_t Process(const char *filename, Option_t *option, Long64_t nentries, Long64_t firstentry)
Process this tree executing the TSelector code in the specified filename.
The TNamed class is the base class for all named ROOT classes.
virtual Bool_t Notify()
This method must be overridden to handle object notification.
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
TTreeFormula * GetVar3() const
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
if(pyself &&pyself!=Py_None)
TString & Append(const char *cs)
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
virtual Int_t GetAction() const
std::vector< std::vector< double > > Data
const char * GetTypeName() const
Returns name of leaf type.
Base class for several text objects.
TSelector * fSelectorFromFile
Pointer to current selector.
virtual void Begin(TTree *)
TObjArray * GetListOfBranches()
virtual Long64_t LoadTree(Long64_t entry)
Find the tree which contains entry, and set it as the current tree.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TH1 * GetOldHistogram() const
virtual void MakeHistograms(const char *name="pca", Option_t *option="epsdx")
Make histograms of the result of the analysis.
virtual void SetTextAlign(Short_t align=11)
virtual ~TTreePlayer()
Tree destructor.
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual TFile * GetFile() const
virtual void StartViewer(Int_t ww, Int_t wh)
Start the TTreeViewer on this TTree.
virtual Int_t GetMaximum() const
virtual Int_t GetDimension() const
TObject * UncheckedAt(Int_t i) const
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
const char * GetFileName()
virtual void SetEstimate(Long64_t n)
Set number of entries to estimate variable limits.
virtual Int_t GetTimerInterval() const
virtual Double_t GetBinCenter(Int_t bin) const
return bin center for 1D historam Better to use h1.GetXaxis().GetBinCenter(bin)
virtual void SetEntryRange(Long64_t emin, Long64_t emax)
Set the minimum and maximum entry number to be processed this information helps to optimize the numbe...
virtual Int_t MakeReader(const char *classname, Option_t *option)
Generate skeleton selector class for this tree.
virtual Long64_t GetMaxEntryLoop() const
virtual Bool_t Notify()
This function is called at the first entry of a new tree in a chain.
virtual const char * GetTypeName() const
virtual void SetEstimate(Long64_t nentries=1000000)
Set number of entries to estimate variable limits.
R__EXTERN TSystem * gSystem
virtual void AddRow(const Double_t *x)
Begin_Html.
TClass * fSelectorClass
Pointer to a user defined selector created by this TTreePlayer object.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual Long64_t GetCacheSize() const
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist...
const char * fScanFileName
Class defining interface to a TTree query result with the same interface as for SQL databases...
virtual Int_t GetTreeNumber() const
A container proxy, which allows to access references stored in a TRefArray from TTree::Draw.
virtual Int_t MakeProxy(const char *classname, const char *macrofilename=0, const char *cutfilename=0, const char *option=0, Int_t maxUnrolling=3)
Generate a skeleton analysis class for this Tree using TBranchProxy.
TDirectory * GetDirectory() const
virtual void SlaveBegin(TTree *)
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
TObject * GetObject() const
TBranch * GetMother() const
Get our top-level parent branch in the tree.
TList * fInput
Pointer to the actual class of the TSelectorFromFile.
virtual void SetNotify(TObject *obj)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
virtual void UpdateFormulaLeaves()
virtual void LabelsDeflate(Option_t *axis="X")
Reduce the number of bins for the axis passed in the option to the number of bins having a label...
virtual Int_t UnbinnedFit(const char *formula, const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
char * Form(const char *fmt,...)
virtual Double_t GetSumOfWeights() const
Return the sum of weights excluding under/overflows.
virtual Bool_t SendProcessingStatus(const char *, Bool_t=kFALSE)
TObject * GetObject() const
A TEventList object is a list of selected events (entries) in a TTree.
virtual const char * GetName() const
Returns name of object.
The ROOT global object gROOT contains a list of all defined classes.
virtual Int_t MakeCode(const char *filename)
Generate skeleton function for this Tree.
virtual void MakePrincipals()
Perform the principal components analysis.
virtual TObjLink * FirstLink() const
virtual void Draw(Option_t *option="")
Draws 3-D polymarker with its current attributes.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
virtual TLeaf * GetLeafCount() const
A Branch for the case of an object.
A specialized TSelector for TTree::Draw.
virtual void SlaveTerminate()
virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Process this tree executing the TSelector code in the specified filename.
static TSelector * GetSelector(const char *filename)
The code in filename is loaded (interpreted or compiled, see below), filename must contain a valid cl...
TString & Remove(Ssiz_t pos)
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
ClassImp(TTreePlayer) TTreePlayer
Default Tree constructor.
virtual Int_t GetSize() const
virtual void ResetAbort()
virtual void SetEntryList(TEntryList *list, Option_t *opt="")
Set an EntryList.
virtual const char * GetName() const
Returns name of object.
virtual TObjArray * GetElements() const =0
virtual EAbort GetAbort() const
TClass * GetClass() const
Wrapper around a TObject so it can be stored in a TList.
TSelector * fSelectorUpdate
Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
Bool_t fScanRedirect
Pointer to current Tree.
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
virtual TTree * GetTree() const
#define R__LOCKGUARD(mutex)
virtual Bool_t Process(Long64_t)
TObjArray * GetListOfLeaves()
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any. ...
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual void Clear(Option_t *option="")
Remove all objects from the list.
virtual Int_t SetCacheSize(Long64_t cachesize=-1)
Set maximum size of the file cache .
virtual void RecursiveRemove(TObject *obj)
cleanup pointers in the player pointing to obj
The class is derived from the ROOT class TSelector.
Bool_t IsBranchFolder() const
virtual void SetOption(const char *option)
virtual Long64_t GetN() const
Abstract Base Class for Fitting.
virtual UInt_t SetCanExtend(UInt_t extendBitMask)
make the histogram axes extendable / not extendable according to the bit mask returns the previous bi...
Mother of all ROOT objects.
virtual Bool_t IsFileInIncludePath(const char *name, char **fullpath=0)
Return true if 'name' is a file that can be found in the ROOT include path or the current directory...
const char * GetDeclFileName() const
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
virtual Long64_t GetEntries(const char *selection)
Return the number of entries matching the selection.
virtual void Add(TObject *obj)
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
A chain is a collection of files containg TTree objects.
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
virtual TVirtualIndex * BuildIndex(const TTree *T, const char *majorname, const char *minorname)
Build the index for the tree (see TTree::BuildIndex)
virtual void SetTextColor(Color_t tcolor=1)
virtual void MakeCode(const char *filename="pca", Option_t *option="")
Generates the file , with .C appended if it does argument doesn't end in ...
virtual UInt_t SplitNames(const TString &varexp, std::vector< TString > &names)
Build Index array for names in varexp.
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.
TList * fFormulaList
input list to the selector
virtual void SetTextSize(Float_t tsize=1)
TObject * At(Int_t idx) const
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
A TTree is a list of TBranches.
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any. ...
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
const char * AsString() const
Return the date & time as a string (ctime() format).
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
virtual Int_t Fit(const char *formula, const char *varexp, const char *selection, Option_t *option, Option_t *goption, Long64_t nentries, Long64_t firstentry)
Fit a projected item(s) from a Tree.
A List of entry numbers in a TTree or TChain.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual Int_t MakeClass(const char *classname, Option_t *option)
Generate skeleton analysis class for this Tree.
virtual void SetScanField(Int_t n=50)
void AddField(Int_t field, const char *fieldname)
Add field name to result set.
virtual Int_t GetNpar() const
Int_t GetStreamerType() const
TTreeFormula * GetVar1() const
virtual Long64_t GetStatus() const
virtual Int_t GetScanField() const
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
virtual TObjArray * GetListOfLeaves()
virtual void Init(TTree *)
virtual TSQLResult * Query(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Loop on Tree and return TSQLResult object containing entries passing selection.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.