127 gROOT->GetListOfCleanups()->Add(
this);
144 gROOT->GetListOfCleanups()->Remove(
this);
153 if (
dynamic_cast<const TChain*
>(T)) {
155 if (
index->IsZombie()) {
157 Error(
"BuildIndex",
"Creating a TChainIndex unsuccessful - switching to TTreeIndex");
201 if (tree ==
nullptr)
return nullptr;
204 TObjArray* branches = tree->GetListOfBranches();
206 for (
Int_t i = 0; i < nb; ++i) {
220 if (strlen(selection)) {
222 if (!select || !select->
GetNdim()) {
232 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
234 if (entryNumber < 0)
break;
236 if (localEntry < 0)
break;
244 for(
Int_t current = 0; current<ndata && !keep; current++) {
304 const char *macrofilename,
const char *cutfilename,
307 if (!macrofilename || strlen(macrofilename)==0)
return 0;
313 if (cutfilename && strlen(cutfilename))
319 TString selname = wrapperPrefix;
324 if (aclicMode.
Length()==0) {
325 Warning(
"DrawScript",
"TTreeProxy does not work in interpreted mode yet. The script will be compiled.");
328 selname.
Append(aclicMode);
330 Info(
"DrawScript",
"%s",
Form(
"Will process tree/chain using %s",selname.
Data()));
354 TString possibleFilename = varexp0;
356 if ( dot_pos !=
kNPOS
357 && possibleFilename.
Index(
"Alt$")<0 && possibleFilename.
Index(
"Entries$")<0
358 && possibleFilename.
Index(
"LocalEntries$")<0
359 && possibleFilename.
Index(
"Length$")<0 && possibleFilename.
Index(
"Entry$")<0
360 && possibleFilename.
Index(
"LocalEntry$")<0
361 && possibleFilename.
Index(
"Min$")<0 && possibleFilename.
Index(
"Max$")<0
362 && possibleFilename.
Index(
"MinIf$")<0 && possibleFilename.
Index(
"MaxIf$")<0
363 && possibleFilename.
Index(
"Iteration$")<0 && possibleFilename.
Index(
"Sum$")<0
364 && possibleFilename.
Index(
">")<0 && possibleFilename.
Index(
"<")<0
369 "Drawing using a C++ file currently requires that both the expression and the selection are files\n\t\"%s\" is not a file",
376 possibleFilename = selection;
377 if (possibleFilename.
Index(
"Alt$")<0 && possibleFilename.
Index(
"Entries$")<0
378 && possibleFilename.
Index(
"LocalEntries$")<0
379 && possibleFilename.
Index(
"Length$")<0 && possibleFilename.
Index(
"Entry$")<0
380 && possibleFilename.
Index(
"LocalEntry$")<0
381 && possibleFilename.
Index(
"Min$")<0 && possibleFilename.
Index(
"Max$")<0
382 && possibleFilename.
Index(
"MinIf$")<0 && possibleFilename.
Index(
"MaxIf$")<0
383 && possibleFilename.
Index(
"Iteration$")<0 && possibleFilename.
Index(
"Sum$")<0
384 && possibleFilename.
Index(
">")<0 && possibleFilename.
Index(
"<")<0
388 "Drawing using a C++ file currently requires that both the expression and the selection are files\n\t\"%s\" is not a file",
397 if (evlist && elist){
402 if (cvarexp) cvarexp->
SetTitle(varexp0);
403 if (cselection) cselection->
SetTitle(selection);
407 bool optpara =
false;
408 bool optcandle =
false;
409 bool optgl5d =
false;
410 bool optnorm =
false;
412 if (opt.
Contains(
"para")) optpara =
true;
413 if (opt.
Contains(
"candle")) optcandle =
true;
414 if (opt.
Contains(
"gl5d")) optgl5d =
true;
420 gROOT->ProcessLineFast(
"new TCanvas();");
447 if (!drawflag && !opt.
Contains(
"goff")) draw =
true;
457 gPad->DrawFrame(-1.,-1.,1.,1.);
466 Warning(
"DrawSelect",
"The selected TTree subset is empty.");
471 if (
fDimension == 1 && !(optpara||optcandle)) {
476 }
else if (
fDimension == 2 && !(optpara||optcandle)) {
484 if (
l == 0 || opt ==
"same")
graph =
true;
495 }
else if (
fDimension == 3 && !(optpara||optcandle)) {
501 }
else if (action == 33) {
508 if (opt.
Contains(
"same")) noscat -= 4;
516 }
else if (
fDimension == 4 && !(optpara||optcandle)) {
523 for (
Int_t col=0;col<ncolors;col++) {
526 if (draw) pm3d->
Draw();
529 }
else if (
fDimension > 1 && (optpara || optcandle)) {
534 gROOT->ProcessLine(
Form(
"TParallelCoord::SetEntryList((TParallelCoord*)0x%zx,(TEntryList*)0x%zx)",
535 (
size_t)para, (size_t)enlist));
539 gROOT->ProcessLineFast(
Form(
"(new TGL5DDataSet((TTree *)0x%zx))->Draw(\"%s\");", (
size_t)
fTree, opt.
Data()));
572 char *opt =
new char[nch];
574 else strlcpy(opt,
"goff",5);
579 Int_t fitResult = -1;
617 nentries = lastentry - firstentry + 1;
634 TTHREAD_TLS_DECL(std::string,column);
635 if (colindex<0 )
return "";
637 i1 =
index[colindex] + 1;
638 n =
index[colindex+1] - i1;
639 column = varexp(i1,
n).
Data();
641 return column.c_str();
658 const char* ltitle = leaf->
GetTitle();
659 if (mother && mother!=branch) {
660 branchname = mother->
GetName();
661 if (branchname[branchname.
Length()-1]!=
'.') {
664 if (strncmp(branchname.
Data(),ltitle,branchname.
Length())==0) {
670 branchname += ltitle;
675 char *bname = (
char*)branchname.
Data();
676 char *twodim = (
char*)strstr(bname,
"[");
677 if (twodim) *twodim = 0;
679 if (*bname ==
'.') *bname=
'_';
680 if (*bname ==
',') *bname=
'_';
681 if (*bname ==
':') *bname=
'_';
682 if (*bname ==
'<') *bname=
'_';
683 if (*bname ==
'>') *bname=
'_';
684 if (*bname ==
'#') *bname=
'_';
685 if (*bname ==
'@') *bname=
'_';
739 thead.
Form(
"%s.h", classname);
740 FILE *fp = fopen(thead,
"w");
742 Error(
"MakeClass",
"cannot open output file %s", thead.
Data());
746 tcimp.
Form(
"%s.C", classname);
747 FILE *fpc = fopen(tcimp,
"w");
749 Error(
"MakeClass",
"cannot open output file %s", tcimp.
Data());
757 treefile =
"Memory Directory";
772 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
773 fprintf(fp,
"// This class has been automatically generated on\n");
774 fprintf(fp,
"// %s by ROOT version %s\n",td.
AsString(),
gROOT->GetVersion());
777 fprintf(fp,
"// found on file: %s\n",treefile.
Data());
781 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
783 fprintf(fp,
"#ifndef %s_h\n",classname);
784 fprintf(fp,
"#define %s_h\n",classname);
786 fprintf(fp,
"#include <TROOT.h>\n");
787 fprintf(fp,
"#include <TChain.h>\n");
788 fprintf(fp,
"#include <TFile.h>\n");
789 if (isHbook) fprintf(fp,
"#include <THbookFile.h>\n");
790 if (opt.
Contains(
"selector")) fprintf(fp,
"#include <TSelector.h>\n");
794 fprintf(fp,
"\n// Header file for the classes stored in the TTree if any.\n");
797 for (
l=0;
l<nleaves;
l++) {
803 if (declfile && declfile[0]) {
804 static const char *precstl =
"prec_stl/";
805 static const unsigned int precstl_len = strlen(precstl);
806 static const char *rootinclude =
"include/";
807 static const unsigned int rootinclude_len = strlen(rootinclude);
808 if (strncmp(declfile,precstl,precstl_len) == 0) {
809 fprintf(fp,
"#include <%s>\n",declfile+precstl_len);
811 }
else if (strncmp(declfile,
"/usr/include/",13) == 0) {
812 fprintf(fp,
"#include <%s>\n",declfile+strlen(
"/include/c++/"));
813 listOfHeaders.
Add(
new TNamed(cl->
GetName(),declfile+strlen(
"/include/c++/")));
814 }
else if (strstr(declfile,
"/include/c++/") !=
nullptr) {
815 fprintf(fp,
"#include <%s>\n",declfile+strlen(
"/include/c++/"));
816 listOfHeaders.
Add(
new TNamed(cl->
GetName(),declfile+strlen(
"/include/c++/")));
817 }
else if (strncmp(declfile,rootinclude,rootinclude_len) == 0) {
818 fprintf(fp,
"#include <%s>\n",declfile+rootinclude_len);
821 fprintf(fp,
"#include \"%s\"\n",declfile);
834 for (
l=0;
l<nleaves;
l++) {
845 for (
Int_t file=0;file<ntrees;file++) {
848 for (
l=0;
l<nleaves;
l++) {
861 fprintf(fp,
"class %s : public TSelector {\n",classname);
862 fprintf(fp,
"public :\n");
863 fprintf(fp,
" TTree *fChain; //!pointer to the analyzed TTree or TChain\n");
865 fprintf(fp,
"class %s {\n",classname);
866 fprintf(fp,
"public :\n");
867 fprintf(fp,
" TTree *fChain; //!pointer to the analyzed TTree or TChain\n");
868 fprintf(fp,
" Int_t fCurrent; //!current Tree number in a TChain\n");
871 fprintf(fp,
"\n// Fixed size dimensions of array or collections stored in the TTree if any.\n");
873 for (
l=0;
l<nleaves;
l++) {
875 strlcpy(blen,leaf->
GetName(),
sizeof(blen));
878 if (*bname ==
'.') *bname=
'_';
879 if (*bname ==
',') *bname=
'_';
880 if (*bname ==
':') *bname=
'_';
881 if (*bname ==
'<') *bname=
'_';
882 if (*bname ==
'>') *bname=
'_';
886 if (blen[lenb-1] ==
'_') {
890 fprintf(fp,
" static constexpr Int_t kMax%s = %d;\n",blen,
len);
898 fprintf(fp,
"\n // Declaration of leaf types\n");
902 const char *headOK =
" ";
903 const char *headcom =
" //";
905 char branchname[1024];
912 for (
l=0;
l<nleaves;
l++) {
921 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
922 strlcpy(aprefix,branch->
GetName(),
sizeof(aprefix));
924 else leafStatus[
l] = 1;
927 strlcat(branchname,
".",
sizeof(branchname));
928 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
931 char *dim = (
char*)strstr(branchname,
"[");
if (dim) dim[0] = 0;
934 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
936 char *twodim = (
char*)strstr(leaf->
GetTitle(),
"][");
939 if (*bname ==
'.') *bname=
'_';
940 if (*bname ==
',') *bname=
'_';
941 if (*bname ==
':') *bname=
'_';
942 if (*bname ==
'<') *bname=
'_';
943 if (*bname ==
'>') *bname=
'_';
949 if (!leafobj->
GetClass()) {leafStatus[
l] = 1; head = headcom;}
951 if (leafStatus[
l] == 0) mustInit.
Add(leafobj);
957 strlcpy(blen,leafcount->
GetName(),
sizeof(blen));
960 if (*bname ==
'.') *bname=
'_';
961 if (*bname ==
',') *bname=
'_';
962 if (*bname ==
':') *bname=
'_';
963 if (*bname ==
'<') *bname=
'_';
964 if (*bname ==
'>') *bname=
'_';
968 if (blen[lenb-1] ==
'_') {blen[lenb-1] = 0; kmax = 1;}
978 fprintf(fp,
" %-15s %s_;\n",
"Int_t", branchname);
982 fprintf(fp,
" %-15s *%s;\n",bre->
GetClassName(), branchname);
990 fprintf(fp,
"%s%-15s *%s;\n",headcom,bre->
GetClassName(), branchname);
992 fprintf(fp,
"%s%-15s *%s;\n",head,bre->
GetClassName(), branchname);
999 fprintf(fp,
"%s%-15s *%s;\n",head,bre->
GetClassName(), branchname);
1000 if (leafStatus[
l] == 0) mustInit.
Add(bre);
1005 if (!cle) {leafStatus[
l] = 1;
continue;}
1008 strlcpy(brename,bre->
GetName(),255);
1009 char *bren = brename;
1010 char *adot = strrchr(bren,
'.');
1011 if (adot) bren = adot+1;
1012 char *brack = strchr(bren,
'[');
1013 if (brack) *brack = 0;
1019 if (leafcount) fprintf(fp,
"%s%-15s %s[kMax%s];\n",head,elem->
GetTypeName(), branchname,blen);
1020 else fprintf(fp,
"%s%-15s %s;\n",head,elem->
GetTypeName(), branchname);
1023 fprintf(fp,
"%s%-15s %s;\n",head,bre->
GetClassName(), branchname);
1028 if (strlen(leaf->
GetTypeName()) == 0) {leafStatus[
l] = 1;
continue;}
1039 const char *stars =
" ";
1046 char *dimInName = (
char*) strstr(branchname,
"[");
1047 if ( twodim || dimInName ) {
1049 dimensions = dimInName;
1052 if (twodim) dimensions += (
char*)(twodim+1);
1054 const char* leafcountName = leafcount->
GetName();
1058 strlcpy(b2len,l2->
GetName(),
sizeof(b2len));
1061 if (*bname ==
'.') *bname=
'_';
1062 if (*bname ==
',') *bname=
'_';
1063 if (*bname ==
':') *bname=
'_';
1064 if (*bname ==
'<') *bname=
'_';
1065 if (*bname ==
'>') *bname=
'_';
1068 leafcountName = b2len;
1070 if (dimensions.
Length()) {
1071 if (kmax) fprintf(fp,
" %-14s %s%s[kMax%s]%s; //[%s]\n",leaf->
GetTypeName(), stars,
1072 branchname,blen,dimensions.
Data(),leafcountName);
1073 else fprintf(fp,
" %-14s %s%s[%d]%s; //[%s]\n",leaf->
GetTypeName(), stars,
1074 branchname,
len,dimensions.
Data(),leafcountName);
1076 if (kmax) fprintf(fp,
" %-14s %s%s[kMax%s]; //[%s]\n",leaf->
GetTypeName(), stars, branchname,blen,leafcountName);
1077 else fprintf(fp,
" %-14s %s%s[%d]; //[%s]\n",leaf->
GetTypeName(), stars, branchname,
len,leafcountName);
1079 if (stars[0]==
'*') {
1081 if (kmax)
n =
new TNamed(branchname,
Form(
"kMax%s",blen));
1086 if (strstr(branchname,
"["))
len = 1;
1087 if (
len < 2) fprintf(fp,
" %-15s %s;\n",leaf->
GetTypeName(), branchname);
1089 if (twodim) fprintf(fp,
" %-15s %s%s;\n",leaf->
GetTypeName(), branchname,(
char*)strstr(leaf->
GetTitle(),
"["));
1090 else fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,
len);
1097 fprintf(fp,
" // List of branches\n");
1098 for (
l=0;
l<nleaves;
l++) {
1099 if (leafStatus[
l])
continue;
1107 fprintf(fp,
" %s(TTree * /*tree*/ =0) : fChain(0) { }\n",classname) ;
1108 fprintf(fp,
" ~%s() override { }\n",classname);
1109 fprintf(fp,
" Int_t Version() const override { return 2; }\n");
1110 fprintf(fp,
" void Begin(TTree *tree) override;\n");
1111 fprintf(fp,
" void SlaveBegin(TTree *tree) override;\n");
1112 fprintf(fp,
" void Init(TTree *tree) override;\n");
1113 fprintf(fp,
" bool Notify() override;\n");
1114 fprintf(fp,
" bool Process(Long64_t entry) override;\n");
1115 fprintf(fp,
" Int_t GetEntry(Long64_t entry, Int_t getall = 0) override { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }\n");
1116 fprintf(fp,
" void SetOption(const char *option) override { fOption = option; }\n");
1117 fprintf(fp,
" void SetObject(TObject *obj) override { fObject = obj; }\n");
1118 fprintf(fp,
" void SetInputList(TList *input) override { fInput = input; }\n");
1119 fprintf(fp,
" TList* GetOutputList() const override { return fOutput; }\n");
1120 fprintf(fp,
" void SlaveTerminate() override;\n");
1121 fprintf(fp,
" void Terminate() override;\n\n");
1122 fprintf(fp,
" ClassDefOverride(%s,0);\n",classname);
1125 fprintf(fp,
"#endif\n");
1129 fprintf(fp,
" %s(TTree *tree=0);\n",classname);
1130 fprintf(fp,
" virtual ~%s();\n",classname);
1131 fprintf(fp,
" virtual Int_t Cut(Long64_t entry);\n");
1132 fprintf(fp,
" virtual Int_t GetEntry(Long64_t entry);\n");
1133 fprintf(fp,
" virtual Long64_t LoadTree(Long64_t entry);\n");
1134 fprintf(fp,
" virtual void Init(TTree *tree);\n");
1135 fprintf(fp,
" virtual void Loop();\n");
1136 fprintf(fp,
" virtual bool Notify();\n");
1137 fprintf(fp,
" virtual void Show(Long64_t entry = -1);\n");
1140 fprintf(fp,
"#endif\n");
1144 fprintf(fp,
"#ifdef %s_cxx\n",classname);
1146 fprintf(fp,
"%s::%s(TTree *tree) : fChain(0) \n",classname,classname);
1148 fprintf(fp,
"// if parameter tree is not specified (or zero), connect the file\n");
1149 fprintf(fp,
"// used to generate this class and read the Tree.\n");
1150 fprintf(fp,
" if (tree == 0) {\n");
1152 fprintf(fp,
"\n#ifdef SINGLE_TREE\n");
1153 fprintf(fp,
" // The following code should be used if you want this class to access\n");
1154 fprintf(fp,
" // a single tree instead of a chain\n");
1157 fprintf(fp,
" THbookFile *f = (THbookFile*)gROOT->GetListOfBrowsables()->FindObject(\"%s\");\n",
1159 fprintf(fp,
" if (!f) {\n");
1160 fprintf(fp,
" f = new THbookFile(\"%s\");\n",treefile.
Data());
1164 fprintf(fp,
" tree = (TTree*)f->Get(%d);\n\n",hid);
1166 fprintf(fp,
" TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(\"%s\");\n",treefile.
Data());
1167 fprintf(fp,
" if (!f || !f->IsOpen()) {\n");
1168 fprintf(fp,
" f = new TFile(\"%s\");\n",treefile.
Data());
1172 fprintf(fp,
" dir->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1174 fprintf(fp,
" f->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1178 fprintf(fp,
"#else // SINGLE_TREE\n\n");
1179 fprintf(fp,
" // The following code should be used if you want this class to access a chain\n");
1180 fprintf(fp,
" // of trees.\n");
1181 fprintf(fp,
" TChain * chain = new TChain(\"%s\",\"%s\");\n",
1188 fprintf(fp,
" chain->Add(\"%s/%s\");\n",element->
GetTitle(),element->
GetName());
1191 fprintf(fp,
" tree = chain;\n");
1192 fprintf(fp,
"#endif // SINGLE_TREE\n\n");
1195 fprintf(fp,
" Init(tree);\n");
1202 fprintf(fp,
"%s::~%s()\n",classname,classname);
1204 fprintf(fp,
" if (!fChain) return;\n");
1208 fprintf(fp,
" delete fChain->GetCurrentFile();\n");
1215 fprintf(fp,
"Int_t %s::GetEntry(Long64_t entry)\n",classname);
1217 fprintf(fp,
"// Read contents of entry.\n");
1219 fprintf(fp,
" if (!fChain) return 0;\n");
1220 fprintf(fp,
" return fChain->GetEntry(entry);\n");
1225 fprintf(fp,
"Long64_t %s::LoadTree(Long64_t entry)\n",classname);
1227 fprintf(fp,
"// Set the environment to read one entry\n");
1228 fprintf(fp,
" if (!fChain) return -5;\n");
1229 fprintf(fp,
" Long64_t centry = fChain->LoadTree(entry);\n");
1230 fprintf(fp,
" if (centry < 0) return centry;\n");
1231 fprintf(fp,
" if (fChain->GetTreeNumber() != fCurrent) {\n");
1232 fprintf(fp,
" fCurrent = fChain->GetTreeNumber();\n");
1233 fprintf(fp,
" Notify();\n");
1235 fprintf(fp,
" return centry;\n");
1241 fprintf(fp,
"void %s::Init(TTree *tree)\n",classname);
1243 fprintf(fp,
" // The Init() function is called when the selector needs to initialize\n"
1244 " // a new tree or chain. Typically here the branch addresses and branch\n"
1245 " // pointers of the tree will be set.\n"
1246 " // It is normally not necessary to make changes to the generated\n"
1247 " // code, but the routine can be extended by the user if needed.\n"
1248 " // Init() will be called many times when running on PROOF\n"
1249 " // (once per file to be processed).\n\n");
1250 if (mustInit.
Last()) {
1251 TIter next(&mustInit);
1253 fprintf(fp,
" // Set object pointer\n");
1254 while( (obj = next()) ) {
1256 strlcpy(branchname,((
TBranch*)obj)->
GetName(),
sizeof(branchname));
1258 strlcpy(branchname,((
TLeaf*)obj)->
GetName(),
sizeof(branchname));
1263 if (*bname ==
'.') *bname=
'_';
1264 if (*bname ==
',') *bname=
'_';
1265 if (*bname ==
':') *bname=
'_';
1266 if (*bname ==
'<') *bname=
'_';
1267 if (*bname ==
'>') *bname=
'_';
1270 fprintf(fp,
" %s = 0;\n",branchname );
1273 if (mustInitArr.
Last()) {
1274 TIter next(&mustInitArr);
1276 fprintf(fp,
" // Set array pointer\n");
1277 while( (info = (
TNamed*)next()) ) {
1278 fprintf(fp,
" for(int i=0; i<%s; ++i) %s[i] = 0;\n",info->
GetTitle(),info->
GetName());
1282 fprintf(fp,
" // Set branch addresses and branch pointers\n");
1283 fprintf(fp,
" if (!tree) return;\n");
1284 fprintf(fp,
" fChain = tree;\n");
1285 if (!opt.
Contains(
"selector")) fprintf(fp,
" fCurrent = -1;\n");
1286 fprintf(fp,
" fChain->SetMakeClass(1);\n");
1288 for (
l=0;
l<nleaves;
l++) {
1289 if (leafStatus[
l])
continue;
1294 strlcpy(aprefix,branch->
GetName(),
sizeof(aprefix));
1298 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1299 strlcat(branchname,
".",
sizeof(branchname));
1300 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1303 char *dim = (
char*)strstr(branchname,
"[");
if (dim) dim[0] = 0;
1306 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1309 if (bre->
GetType() == 3 || bre->
GetType()==4) strlcat(branchname,
"_",
sizeof(branchname));
1313 char *brak = strstr(branchname,
"[");
if (brak) *brak = 0;
1314 char *twodim = (
char*)strstr(bname,
"[");
if (twodim) *twodim = 0;
1316 if (*bname ==
'.') *bname=
'_';
1317 if (*bname ==
',') *bname=
'_';
1318 if (*bname ==
':') *bname=
'_';
1319 if (*bname ==
'<') *bname=
'_';
1320 if (*bname ==
'>') *bname=
'_';
1323 const char *maybedisable =
"";
1325 Error(
"MakeClass",
"The branch named %s (full path name: %s) is hidden by another branch of the same name and its data will not be loaded.",branch->
GetName(),
R__GetBranchPointerName(leaf,
false).Data());
1326 maybedisable =
"// ";
1333 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1340 if (
len > 1) fprintf(fp,
"%s fChain->SetBranchAddress(\"%s\", %s, &b_%s);\n",
1342 else fprintf(fp,
"%s fChain->SetBranchAddress(\"%s\", &%s, &b_%s);\n",
1347 fprintf(fp,
" Notify();\n");
1354 fprintf(fp,
"bool %s::Notify()\n",classname);
1356 fprintf(fp,
" // The Notify() function is called when a new file is opened. This\n"
1357 " // can be either for a new TTree in a TChain or when when a new TTree\n"
1358 " // is started when using PROOF. It is normally not necessary to make changes\n"
1359 " // to the generated code, but the routine can be extended by the\n"
1360 " // user if needed. The return value is currently not used.\n\n");
1361 fprintf(fp,
" return true;\n");
1367 fprintf(fp,
"void %s::Show(Long64_t entry)\n",classname);
1369 fprintf(fp,
"// Print contents of entry.\n");
1370 fprintf(fp,
"// If entry is not specified, print current entry\n");
1372 fprintf(fp,
" if (!fChain) return;\n");
1373 fprintf(fp,
" fChain->Show(entry);\n");
1378 fprintf(fp,
"Int_t %s::Cut(Long64_t entry)\n",classname);
1380 fprintf(fp,
"// This function may be called from Loop.\n");
1381 fprintf(fp,
"// returns 1 if entry is accepted.\n");
1382 fprintf(fp,
"// returns -1 otherwise.\n");
1384 fprintf(fp,
" return 1;\n");
1387 fprintf(fp,
"#endif // #ifdef %s_cxx\n",classname);
1392 fprintf(fpc,
"#define %s_cxx\n",classname);
1393 fprintf(fpc,
"#include \"%s\"\n",thead.
Data());
1394 fprintf(fpc,
"#include <TH2.h>\n");
1395 fprintf(fpc,
"#include <TStyle.h>\n");
1396 fprintf(fpc,
"#include <TCanvas.h>\n");
1398 fprintf(fpc,
"void %s::Loop()\n",classname);
1400 fprintf(fpc,
"// In a ROOT session, you can do:\n");
1401 fprintf(fpc,
"// root> .L %s.C\n",classname);
1402 fprintf(fpc,
"// root> %s t\n",classname);
1403 fprintf(fpc,
"// root> t.GetEntry(12); // Fill t data members with entry number 12\n");
1404 fprintf(fpc,
"// root> t.Show(); // Show values of entry 12\n");
1405 fprintf(fpc,
"// root> t.Show(16); // Read and show values of entry 16\n");
1406 fprintf(fpc,
"// root> t.Loop(); // Loop on all entries\n");
1407 fprintf(fpc,
"//\n");
1408 fprintf(fpc,
"\n// This is the loop skeleton where:\n");
1409 fprintf(fpc,
"// jentry is the global entry number in the chain\n");
1410 fprintf(fpc,
"// ientry is the entry number in the current Tree\n");
1411 fprintf(fpc,
"// Note that the argument to GetEntry must be:\n");
1412 fprintf(fpc,
"// jentry for TChain::GetEntry\n");
1413 fprintf(fpc,
"// ientry for TTree::GetEntry and TBranch::GetEntry\n");
1414 fprintf(fpc,
"//\n");
1415 fprintf(fpc,
"// To read only selected branches, Insert statements like:\n");
1416 fprintf(fpc,
"// METHOD1:\n");
1417 fprintf(fpc,
"// fChain->SetBranchStatus(\"*\",0); // disable all branches\n");
1418 fprintf(fpc,
"// fChain->SetBranchStatus(\"branchname\",1); // activate branchname\n");
1419 fprintf(fpc,
"// METHOD2: replace line\n");
1420 fprintf(fpc,
"// fChain->GetEntry(jentry); //read all branches\n");
1421 fprintf(fpc,
"//by b_branchname->GetEntry(ientry); //read only this branch\n");
1422 fprintf(fpc,
" if (fChain == 0) return;\n");
1423 fprintf(fpc,
"\n Long64_t nentries = fChain->GetEntriesFast();\n");
1424 fprintf(fpc,
"\n Long64_t nbytes = 0, nb = 0;\n");
1425 fprintf(fpc,
" for (Long64_t jentry=0; jentry<nentries;jentry++) {\n");
1426 fprintf(fpc,
" Long64_t ientry = LoadTree(jentry);\n");
1427 fprintf(fpc,
" if (ientry < 0) break;\n");
1428 fprintf(fpc,
" nb = fChain->GetEntry(jentry); nbytes += nb;\n");
1429 fprintf(fpc,
" // if (Cut(ientry) < 0) continue;\n");
1430 fprintf(fpc,
" }\n");
1435 fprintf(fpc,
"#define %s_cxx\n",classname);
1436 fprintf(fpc,
"// The class definition in %s.h has been generated automatically\n",classname);
1437 fprintf(fpc,
"// by the ROOT utility TTree::MakeSelector(). This class is derived\n");
1438 fprintf(fpc,
"// from the ROOT class TSelector. For more information on the TSelector\n"
1439 "// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.\n\n");
1440 fprintf(fpc,
"// The following methods are defined in this file:\n");
1441 fprintf(fpc,
"// Begin(): called every time a loop on the tree starts,\n");
1442 fprintf(fpc,
"// a convenient place to create your histograms.\n");
1443 fprintf(fpc,
"// SlaveBegin(): called after Begin(), when on PROOF called only on the\n"
1444 "// slave servers.\n");
1445 fprintf(fpc,
"// Process(): called for each event, in this function you decide what\n");
1446 fprintf(fpc,
"// to read and fill your histograms.\n");
1447 fprintf(fpc,
"// SlaveTerminate: called at the end of the loop on the tree, when on PROOF\n"
1448 "// called only on the slave servers.\n");
1449 fprintf(fpc,
"// Terminate(): called at the end of the loop on the tree,\n");
1450 fprintf(fpc,
"// a convenient place to draw/fit your histograms.\n");
1451 fprintf(fpc,
"//\n");
1452 fprintf(fpc,
"// To use this file, try the following session on your Tree T:\n");
1453 fprintf(fpc,
"//\n");
1454 fprintf(fpc,
"// root> T->Process(\"%s.C\")\n",classname);
1455 fprintf(fpc,
"// root> T->Process(\"%s.C\",\"some options\")\n",classname);
1456 fprintf(fpc,
"// root> T->Process(\"%s.C+\")\n",classname);
1457 fprintf(fpc,
"//\n\n");
1458 fprintf(fpc,
"#include \"%s\"\n",thead.
Data());
1459 fprintf(fpc,
"#include <TH2.h>\n");
1460 fprintf(fpc,
"#include <TStyle.h>\n");
1464 fprintf(fpc,
"void %s::Begin(TTree * /*tree*/)\n",classname);
1466 fprintf(fpc,
" // The Begin() function is called at the start of the query.\n");
1467 fprintf(fpc,
" // When running with PROOF Begin() is only called on the client.\n");
1468 fprintf(fpc,
" // The tree argument is deprecated (on PROOF 0 is passed).\n");
1470 fprintf(fpc,
" TString option = GetOption();\n");
1475 fprintf(fpc,
"void %s::SlaveBegin(TTree * /*tree*/)\n",classname);
1477 fprintf(fpc,
" // The SlaveBegin() function is called after the Begin() function.\n");
1478 fprintf(fpc,
" // When running with PROOF SlaveBegin() is called on each slave server.\n");
1479 fprintf(fpc,
" // The tree argument is deprecated (on PROOF 0 is passed).\n");
1481 fprintf(fpc,
" TString option = GetOption();\n");
1486 fprintf(fpc,
"bool %s::Process(Long64_t entry)\n",classname);
1488 fprintf(fpc,
" // The Process() function is called for each entry in the tree (or possibly\n"
1489 " // keyed object in the case of PROOF) to be processed. The entry argument\n"
1490 " // specifies which entry in the currently loaded tree is to be processed.\n"
1491 " // It can be passed to either %s::GetEntry() or TBranch::GetEntry()\n"
1492 " // to read either all or the required parts of the data. When processing\n"
1493 " // keyed objects with PROOF, the object is already loaded and is available\n"
1494 " // via the fObject pointer.\n"
1496 " // This function should contain the \"body\" of the analysis. It can contain\n"
1497 " // simple or elaborate selection criteria, run algorithms on the data\n"
1498 " // of the event and typically fill histograms.\n"
1500 " // The processing can be stopped by calling Abort().\n"
1502 " // Use fStatus to set the return value of TTree::Process().\n"
1504 " // The return value is currently not used.\n\n", classname);
1506 fprintf(fpc,
" return true;\n");
1510 fprintf(fpc,
"void %s::SlaveTerminate()\n",classname);
1512 fprintf(fpc,
" // The SlaveTerminate() function is called after all entries or objects\n"
1513 " // have been processed. When running with PROOF SlaveTerminate() is called\n"
1514 " // on each slave server.");
1520 fprintf(fpc,
"void %s::Terminate()\n",classname);
1522 fprintf(fpc,
" // The Terminate() function is the last function to be called during\n"
1523 " // a query. It always runs on the client, it can be used to present\n"
1524 " // the results graphically or save the results to file.");
1530 delete [] leafStatus;
1568 FILE *fp = fopen(tfile,
"w");
1570 Error(
"MakeCode",
"cannot open output file %s", tfile.
Data());
1577 treefile =
"Memory Directory";
1589 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
1590 fprintf(fp,
"// This file has been automatically generated \n");
1591 fprintf(fp,
"// (%s by ROOT version%s)\n",td.
AsString(),
gROOT->GetVersion());
1594 fprintf(fp,
"// found on file: %s\n",treefile.
Data());
1598 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
1604 fprintf(fp,
"//Reset ROOT and connect tree file\n");
1605 fprintf(fp,
" gROOT->Reset();\n");
1607 fprintf(fp,
"\n#ifdef SINGLE_TREE\n");
1608 fprintf(fp,
" // The following code should be used if you want this code to access\n");
1609 fprintf(fp,
" // a single tree instead of a chain\n");
1611 fprintf(fp,
" TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(\"%s\");\n",treefile.
Data());
1612 fprintf(fp,
" if (!f) {\n");
1613 fprintf(fp,
" f = new TFile(\"%s\");\n",treefile.
Data());
1617 fprintf(fp,
" dir->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1619 fprintf(fp,
" f->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1622 fprintf(fp,
"#else // SINGLE_TREE\n\n");
1623 fprintf(fp,
" // The following code should be used if you want this code to access a chain\n");
1624 fprintf(fp,
" // of trees.\n");
1625 fprintf(fp,
" TChain *%s = new TChain(\"%s\",\"%s\");\n",
1635 fprintf(fp,
"#endif // SINGLE_TREE\n\n");
1639 fprintf(fp,
"//Declaration of leaves types\n");
1644 const char *headOK =
" ";
1645 const char *headcom =
" //";
1647 char branchname[1024];
1648 for (
l=0;
l<nleaves;
l++) {
1657 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1658 strlcat(branchname,
".",
sizeof(branchname));
1659 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1662 char *dim = (
char*)strstr(branchname,
"[");
1663 if (dim) dim[0] = 0;
1666 if (leafcount) strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1667 else strlcpy(branchname,leaf->
GetTitle(),
sizeof(branchname));
1669 char *twodim = (
char*)strstr(leaf->
GetTitle(),
"][");
1672 if (*bname ==
'.') *bname=
'_';
1673 if (*bname ==
',') *bname=
'_';
1674 if (*bname ==
':') *bname=
'_';
1675 if (*bname ==
'<') *bname=
'_';
1676 if (*bname ==
'>') *bname=
'_';
1681 if (leafobj->
GetClass()) head = headOK;
1682 else head = headcom;
1690 char *dimInName = (
char*) strstr(branchname,
"[");
1692 if ( twodim || dimInName ) {
1694 dimensions = dimInName;
1697 if (twodim) dimensions += (
char*)(twodim+1);
1699 if (dimensions.
Length()) {
1700 fprintf(fp,
" %-15s %s[%d]%s;\n",leaf->
GetTypeName(), branchname,
len,dimensions.
Data());
1702 fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,
len);
1705 if (strstr(branchname,
"["))
len = 1;
1706 if (
len < 2) fprintf(fp,
" %-15s %s;\n",leaf->
GetTypeName(), branchname);
1707 else fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,
len);
1712 fprintf(fp,
"\n // Set branch addresses.\n");
1713 for (
l=0;
l<nleaves;
l++) {
1721 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1722 strlcat(branchname,
".",
sizeof(branchname));
1723 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1726 char *dim = (
char*)strstr(branchname,
"[");
1727 if (dim) dim[0] = 0;
1730 if (leafcount) strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1731 else strlcpy(branchname,leaf->
GetTitle(),
sizeof(branchname));
1735 if (*bname ==
'.') *bname=
'_';
1736 if (*bname ==
',') *bname=
'_';
1737 if (*bname ==
':') *bname=
'_';
1738 if (*bname ==
'<') *bname=
'_';
1739 if (*bname ==
'>') *bname=
'_';
1742 char *brak = strstr(branchname,
"[");
1743 if (brak) *brak = 0;
1746 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1748 if (!leafobj->
GetClass()) head = headcom;
1751 if (
len > 1 || brak) fprintf(fp,
"%s%s->SetBranchAddress(\"%s\",%s);\n",head,
fTree->
GetName(),branch->
GetName(),branchname);
1752 else fprintf(fp,
"%s%s->SetBranchAddress(\"%s\",&%s);\n",head,
fTree->
GetName(),branch->
GetName(),branchname);
1756 fprintf(fp,
"\n// This is the loop skeleton\n");
1757 fprintf(fp,
"// To read only selected branches, Insert statements like:\n");
1758 fprintf(fp,
"// %s->SetBranchStatus(\"*\",0); // disable all branches\n",
fTree->
GetName());
1759 fprintf(fp,
"// %s->SetBranchStatus(\"branchname\",1); // activate branchname\n",
GetName());
1760 fprintf(fp,
"\n Long64_t nentries = %s->GetEntries();\n",
fTree->
GetName());
1761 fprintf(fp,
"\n Long64_t nbytes = 0;\n");
1762 fprintf(fp,
"// for (Long64_t i=0; i<nentries;i++) {\n");
1763 fprintf(fp,
"// nbytes += %s->GetEntry(i);\n",
fTree->
GetName());
1764 fprintf(fp,
"// }\n");
1767 printf(
"Macro: %s generated from Tree: %s\n",tfile.
Data(),
fTree->
GetName());
1926 const char *macrofilename,
const char *cutfilename,
1929 if (macrofilename==
nullptr || strlen(macrofilename)==0 ) {
1931 Error(
"MakeProxy",
"A file name for the user script is required");
2018 std::vector<TString> cnames;
2027 if (nleaves < ncols) ncols = nleaves;
2028 nch = varexp ? strlen(varexp) : 0;
2034 if (strlen(selection)) {
2042 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2043 if (nch == 0 || allvar) {
2044 for (i=0;i<ncols;i++) {
2045 cnames.push_back( ((
TLeaf*)leaves->
At(i))->GetName() );
2055 for (i=0;i<ncols;i++) {
2077 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2079 if (entryNumber < 0)
break;
2081 if (localEntry < 0)
break;
2091 for(
int inst=0;inst<ndata;inst++) {
2092 bool loaded =
false;
2099 if (inst==0) loaded =
true;
2103 for (i=0;i<ncols;i++) {
2109 for (i=0;i<ncols;i++) {
2206 if (!selector)
return -1;
2282 if (!
gROOT->IsBatch() && interval)
2286 Long64_t entry, entryNumber, localEntry;
2288 bool useCutFill = selector->
Version() == 0;
2300 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2302 if (entryNumber < 0)
break;
2304 if (
gROOT->IsInterrupted())
break;
2306 if (localEntry < 0)
break;
2311 selector->
Process(localEntry);
2454 UInt_t colDefaultSize = 9;
2456 std::vector<TString> colFormats;
2457 std::vector<Int_t> colSizes;
2460 int start = opt.
Index(
"lenmax=");
2461 int numpos = start + strlen(
"lenmax=");
2464 while( (numpos+numlen<
len) && isdigit(opt[numpos+numlen]) ) numlen++;
2465 TString num = opt(numpos,numlen);
2466 opt.
Remove(start,strlen(
"lenmax")+numlen);
2468 lenmax = atoi(num.
Data());
2471 int start = opt.
Index(
"colsize=");
2472 int numpos = start + strlen(
"colsize=");
2475 while( (numpos+numlen<
len) && isdigit(opt[numpos+numlen]) ) numlen++;
2476 TString num = opt(numpos,numlen);
2477 opt.
Remove(start,strlen(
"size")+numlen);
2479 colDefaultSize = atoi(num.
Data());
2480 colPrecision = colDefaultSize;
2481 if (colPrecision>18) colPrecision = 18;
2484 int start = opt.
Index(
"precision=");
2485 int numpos = start + strlen(
"precision=");
2488 while( (numpos+numlen<
len) && isdigit(opt[numpos+numlen]) ) numlen++;
2489 TString num = opt(numpos,numlen);
2490 opt.
Remove(start,strlen(
"precision")+numlen);
2492 colPrecision = atoi(num.
Data());
2494 TString defFormat =
Form(
"%d.%d",colDefaultSize,colPrecision);
2496 int start = opt.
Index(
"col=");
2497 int numpos = start + strlen(
"col=");
2500 while( (numpos+numlen<
len) &&
2501 (isdigit(opt[numpos+numlen])
2502 || opt[numpos+numlen] ==
'c'
2503 || opt[numpos+numlen] ==
'd'
2504 || opt[numpos+numlen] ==
'i'
2505 || opt[numpos+numlen] ==
'o'
2506 || opt[numpos+numlen] ==
'x'
2507 || opt[numpos+numlen] ==
'X'
2508 || opt[numpos+numlen] ==
'u'
2509 || opt[numpos+numlen] ==
'f'
2510 || opt[numpos+numlen] ==
'e'
2511 || opt[numpos+numlen] ==
'E'
2512 || opt[numpos+numlen] ==
'g'
2513 || opt[numpos+numlen] ==
'G'
2514 || opt[numpos+numlen] ==
'l'
2515 || opt[numpos+numlen] ==
'L'
2516 || opt[numpos+numlen] ==
'h'
2517 || opt[numpos+numlen] ==
's'
2518 || opt[numpos+numlen] ==
'#'
2519 || opt[numpos+numlen]==
'.'
2520 || opt[numpos+numlen]==
':')) numlen++;
2521 TString flist = opt(numpos,numlen);
2522 opt.
Remove(start,strlen(
"col")+numlen);
2525 while(i<flist.
Length() && flist[i]==
':') {
2526 colFormats.push_back(defFormat);
2527 colSizes.push_back(colDefaultSize);
2530 for(; i<flist.
Length(); ++i) {
2531 int next = flist.
Index(
":",i);
2533 colFormats.push_back(defFormat);
2534 }
else if (next==
kNPOS) {
2535 colFormats.push_back(flist(i,flist.
Length()-i));
2538 colFormats.push_back(flist(i,next-i));
2541 UInt_t siz = atoi(colFormats[colFormats.size()-1].Data());
2542 colSizes.push_back( siz ? siz : colDefaultSize );
2547 std::vector<TString> cnames;
2553 const char *fname =
nullptr;
2558 if (!fname) fname =
"";
2559 Int_t lenfile = strlen(fname);
2562 fownname.
Append(
"-scan.dat");
2563 fname = fownname.
Data();
2565 out.open(fname, std::ios::out);
2567 Error(
"Scan",
"Can not open file for redirection");
2572 if (leaves==
nullptr)
return 0;
2574 if (nleaves < ncols) ncols = nleaves;
2575 nch = varexp ? strlen(varexp) : 0;
2581 if (selection && strlen(selection)) {
2583 if (!select)
return -1;
2584 if (!select->
GetNdim()) {
delete select;
return -1; }
2589 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2590 if (nch == 0 || allvar) {
2593 for (ui=0;ui<ncs;++ui) {
2597 if (cnames[ncols] == lf->
GetName() ) {
2599 }
else if (cnames[ncols][cnames[ncols].Length()-1]==
'.') {
2612 cnames[ncols].Append(
'.');
2618 cnames[ncols].Append(
'.');
2619 cnames[ncols].Append( lf->
GetName() );
2631 for(ui=colFormats.size();ui<ncols;++ui) {
2632 colFormats.push_back(defFormat);
2633 colSizes.push_back(colDefaultSize);
2637 for (ui=0;ui<ncols;ui++) {
2644 bool hasArray =
false;
2645 bool forceDim =
false;
2675 onerow =
"***********";
2676 if (hasArray) onerow +=
"***********";
2678 for (ui=0;ui<ncols;ui++) {
2679 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2683 out<<onerow.
Data()<<
"*"<<std::endl;
2685 printf(
"%s*\n",onerow.
Data());
2687 if (hasArray) onerow +=
"* Instance ";
2688 for (ui=0;ui<ncols;ui++) {
2689 TString numbFormat =
Form(
"* %%%d.%ds ",colSizes[ui],colSizes[ui]);
2693 out<<onerow.
Data()<<
"*"<<std::endl;
2695 printf(
"%s*\n",onerow.
Data());
2696 onerow =
"***********";
2697 if (hasArray) onerow +=
"***********";
2698 for (ui=0;ui<ncols;ui++) {
2699 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2703 out<<onerow.
Data()<<
"*"<<std::endl;
2705 printf(
"%s*\n",onerow.
Data());
2709 bool exitloop =
false;
2710 for (entry=firstentry;
2711 entry<(firstentry+
nentries) && !exitloop;
2714 if (entryNumber < 0)
break;
2716 if (localEntry < 0)
break;
2737 for (ui=0;ui<ncols;ui++) {
2738 if (ndata < var[ui]->GetNdata() ) {
2742 if (select && select->
GetNdata()==0) ndata = 0;
2747 if (lenmax && ndata>(
int)lenmax) ndata = lenmax;
2748 bool loaded =
false;
2749 for(
int inst=0;inst<ndata;inst++) {
2755 if (inst==0) loaded =
true;
2759 for (ui=0;ui<ncols;ui++) {
2764 onerow =
Form(
"* %8lld ",entryNumber);
2766 onerow +=
Form(
"* %8d ",inst);
2768 for (ui=0;ui<ncols;++ui) {
2769 TString numbFormat =
Form(
"* %%%d.%ds ",colSizes[ui],colSizes[ui]);
2770 if (var[ui]->GetNdim()) onerow +=
Form(numbFormat.
Data(),var[ui]->
PrintValue(0,inst,colFormats[ui].Data()));
2772 TString emptyForm =
Form(
"* %%%dc ",colSizes[ui]);
2773 onerow +=
Form(emptyForm.
Data(),
' ');
2778 out<<onerow.
Data()<<
"*"<<std::endl;
2780 printf(
"%s*\n",onerow.
Data());
2783 fprintf(stderr,
"Type <CR> to continue or q to quit ==> ");
2787 while (readch !=
'\n' && readch != EOF) readch = getchar();
2788 if (answer ==
'q' || answer ==
'Q') {
2796 onerow =
"***********";
2797 if (hasArray) onerow +=
"***********";
2798 for (ui=0;ui<ncols;ui++) {
2799 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2803 out<<onerow.
Data()<<
"*"<<std::endl;
2805 printf(
"%s*\n",onerow.
Data());
2828 std::vector<TString> cnames;
2835 if (nleaves < ncols) ncols = nleaves;
2836 nch = varexp ? strlen(varexp) : 0;
2842 if (strlen(selection)) {
2844 if (!select)
return nullptr;
2845 if (!select->
GetNdim()) {
delete select;
return nullptr; }
2851 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2852 if (nch == 0 || allvar) {
2853 for (i=0;i<ncols;i++) {
2854 cnames.push_back( ((
TLeaf*)leaves->
At(i))->GetName() );
2863 for (i=0;i<ncols;i++) {
2870 for (i = 0; i < ncols; i++) {
2871 res->
AddField(i, var[i]->PrintValue(-1));
2885 const char *aresult;
2887 char *arow =
new char[ncols*50];
2891 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2893 if (entryNumber < 0)
break;
2895 if (localEntry < 0)
break;
2911 bool loaded =
false;
2912 for(
int inst=0;inst<ndata;inst++) {
2919 if (inst==0) loaded =
true;
2923 for (i=0;i<ncols;i++) {
2928 for (i=0;i<ncols;i++) {
2930 len = strlen(aresult)+1;
2932 memcpy(arow,aresult,
len);
2935 memcpy(arow+fields[i-1],aresult,
len);
2936 fields[i] = fields[i-1] +
len;
2984 if (
gROOT->IsBatch()) {
2985 if ((hname !=
"RTreeViewer") ||
gROOT->IsWebDisplayBatch()) {
2986 Warning(
"StartViewer",
"The tree viewer cannot run in batch mode");
2991 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualTreeViewer", hname.
Data())) {
2992 if (
h->LoadPlugin() != -1)
3071 TF1* fitfunc = (
TF1*)
gROOT->GetFunction(funcname);
3072 if (!fitfunc) {
Error(
"UnbinnedFit",
"Unknown function: %s",funcname);
return 0; }
3075 if (npar <=0) {
Error(
"UnbinnedFit",
"Illegal number of parameters = %d",npar);
return 0; }
3096 if (!fitOption.
Nograph) drawOpt =
"";
3100 Info(
"UnbinnedFit",
"Ignore option D with more than 4 variables");
3108 Error(
"UnbinnedFit",
"Cannot fit: no entries selected");
3119 std::vector<double *> vlist(ndim);
3120 for (
int i = 0; i < ndim; ++i)
3146 for (
Int_t bin=1;bin<=nbins;bin++) {
R__EXTERN TApplication * gApplication
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
R__EXTERN TVirtualMutex * gROOTMutex
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
R__EXTERN Foption_t Foption
static TString R__GetBranchPointerName(TLeaf *leaf, bool replace=true)
Return the name of the branch pointer needed by MakeClass/MakeSelector.
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
#define R__LOCKGUARD(mutex)
Class describing the un-binned data sets (just x coordinates values) of any dimensions.
const char * GetFileName()
void InitializeGraphics(Bool_t only_web=kFALSE)
Initialize the graphics environment.
static void CreateApplication()
Static function used to create a default application environment.
static void NeedGraphicsLibs()
Static method.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
A Branch for the case of an object.
const char * GetClassName() const override
Return the name of the user class whose content is stored in this branch, if any.
Int_t GetStreamerType() const
TBranchElement * GetBranchCount2() const
bool IsBranchFolder() 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.
TObjArray * GetListOfBranches()
TClass * IsA() const override
TObjArray * GetListOfLeaves()
TBranch * GetMother() const
Get our top-level parent branch in the tree.
A TChainElement describes a component of a TChain.
A chain is a collection of files containing TTree objects.
Long64_t * GetTreeOffset() const
Long64_t LoadTree(Long64_t entry) override
Find the tree which contains entry, and set it as the current tree.
TLeaf * GetLeaf(const char *branchname, const char *leafname) override
Return a pointer to the leaf name in the current tree.
TClass instances represent classes, structs and namespaces in the ROOT type system.
void AdoptReferenceProxy(TVirtualRefProxy *proxy)
Adopt the Reference proxy pointer to indicate that this class represents a reference.
Bool_t HasInterpreterInfo() const
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
const char * GetDeclFileName() const
Return name of the file containing the declaration of this class.
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 SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
const char * AsString() const
Return the date & time as a string (ctime() format).
TDirectory::TContext keeps track and restore the current directory.
virtual const char * GetPath() const
Returns the full path of the directory.
virtual TFile * GetFile() const
A List of entry numbers in a TTree or TChain.
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 Long64_t GetN() const
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
<div class="legacybox"><h2>Legacy Code</h2> TEventList is a legacy interface: there will be no bug fi...
virtual Int_t GetNpar() const
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
@ kNoAxis
NOTE: Must always be 0 !!!
virtual Int_t GetDimension() const
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
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.
void Draw(Option_t *option="") override
Draw this histogram with options.
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...
virtual UInt_t SetCanExtend(UInt_t extendBitMask)
Make the histogram axes extendable / not extendable according to the bit mask returns the previous bi...
TList * GetListOfFunctions() const
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
virtual Double_t GetSumOfWeights() const
Return the sum of weights excluding under/overflows.
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.
A TLeaf for a general object derived from TObject.
TClass * GetClass() const
const char * GetTypeName() const override
Returns name of leaf type.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual Int_t GetMaximum() const
virtual const char * GetTypeName() const
virtual Int_t GetLen() const
Return the number of effective elements of this leaf, for the current entry.
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
TBranch * GetBranch() const
void Clear(Option_t *option="") override
Remove all objects from the list.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
virtual TObjLink * FirstLink() const
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Int_t GetEntriesFast() const
void AddAt(TObject *obj, Int_t idx) override
Add object at position ids.
TObject * Last() const override
Return the object in the last filled slot. Returns 0 if no entries.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
TObject * UncheckedAt(Int_t i) const
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
void Add(TObject *obj) override
Wrapper around a TObject so it can be stored in a TList.
TObject * GetObject() const
Collectable string class.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual Bool_t Notify()
This method must be overridden to handle object notification (the base implementation is no-op).
virtual const char * GetName() const
Returns name of object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
@ kCanDelete
if object in a list can be deleted
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void Draw(Option_t *option="") override
Draws 3-D polymarker with its current attributes.
Principal Components Analysis (PCA)
Bool_t ProcessEvents()
Process events if timer did time out.
A container proxy, which allows to access references stored in a TRefArray from TTree::Draw.
A specialized TSelector for TTree::Draw.
virtual void SetEstimate(Long64_t n)
Set number of entries to estimate variable limits.
TTreeFormula * GetVar3() const
See TSelectorDraw::GetVar.
virtual Long64_t GetDrawFlag() const
TH1 * GetOldHistogram() const
virtual UInt_t SplitNames(const TString &varexp, std::vector< TString > &names)
Build Index array for names in varexp.
TObject * GetObject() const
TTreeFormula * GetVar2() const
See TSelectorDraw::GetVar.
virtual Int_t GetAction() const
TTreeFormula * GetVar1() const
See TSelectorDraw::GetVar.
virtual Int_t GetDimension() const
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 ...
bool Notify() override
This function is called at the first entry of a new tree in a chain.
virtual bool GetCleanElist() const
The class is derived from the ROOT class TSelector.
virtual Long64_t GetSelectedRows() const
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
virtual EAbort GetAbort() const
virtual void ProcessFill(Long64_t)
This method is called for all selected entries.
virtual void Init(TTree *)
virtual int Version() const
virtual bool ProcessCut(Long64_t)
This method is called before processing entry.
virtual bool Process(Long64_t)
The Process() function is called for each entry in the tree (or possibly keyed object in the case of ...
TClass * IsA() const override
virtual void SlaveBegin(TTree *)
bool Notify() override
This method must be overridden to handle object notification (the base implementation is no-op).
virtual void SetOption(const char *option)
virtual Long64_t GetStatus() const
virtual void SetInputList(TList *input)
virtual TList * GetOutputList() const
virtual void SlaveTerminate()
virtual void ResetAbort()
virtual void Begin(TTree *)
static TSelector * GetSelector(const char *filename)
The code in filename is loaded (interpreted or compiled, see below), filename must contain a valid cl...
const char * GetTypeName() const
TClass * IsA() const override
void ToLower()
Change string to lower-case.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
void ToUpper()
Change string to upper case.
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Bool_t GetCanvasPreferGL() const
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
virtual Bool_t IsFileInIncludePath(const char *name, char **fullpath=nullptr)
Return true if 'name' is a file that can be found in the ROOT include path or the current directory.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form:
Base class for several text objects.
A cache to speed-up the reading of ROOT datasets.
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...
A Tree Index with majorname and minorname.
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Int_t MakeCode(const char *filename) override
Generate skeleton function for this Tree.
TTree * CopyTree(const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Copy a Tree with selection, make a clone of this Tree header, then copy the selected entries.
Long64_t DrawSelect(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Draw expression varexp for specified entries that matches the selection.
TList * fInput
! input list to the selector
void DeleteSelectorFromFile()
Delete any selector created by this object.
void SetEstimate(Long64_t n) override
Set number of entries to estimate variable limits.
Int_t UnbinnedFit(const char *formula, const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Unbinned fit of one or more variable(s) from a Tree.
void RecursiveRemove(TObject *obj) override
cleanup pointers in the player pointing to obj
Long64_t DrawScript(const char *wrapperPrefix, const char *macrofilename, const char *cutfilename, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Draw the result of a C++ script.
TSelectorDraw * fSelector
! Pointer to current selector
void SetTree(TTree *t) override
Long64_t GetSelectedRows() const override
Int_t MakeReader(const char *classname, Option_t *option) override
Generate skeleton selector class for this tree.
const char * GetNameByIndex(TString &varexp, Int_t *index, Int_t colindex)
Return name corresponding to colindex in varexp.
Long64_t fSelectedRows
Number of selected entries.
Long64_t Scan(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Loop on Tree and print entries passing selection.
TSelector * fSelectorFromFile
! Pointer to a user defined selector created by this TTreePlayer object
const char * fScanFileName
Name of the file where Scan is redirected.
TList * fFormulaList
! Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
bool fScanRedirect
Switch to redirect TTree::Scan output to a file.
TTree * fTree
! Pointer to current Tree
void StartViewer(Int_t ww, Int_t wh) override
Start the TTreeViewer on this TTree.
Int_t MakeProxy(const char *classname, const char *macrofilename=nullptr, const char *cutfilename=nullptr, const char *option=nullptr, Int_t maxUnrolling=3) override
Generate a skeleton analysis class for this Tree using TBranchProxy.
Int_t MakeClass(const char *classname, Option_t *option) override
Generate skeleton analysis class for this Tree.
TPrincipal * Principal(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Interface to the Principal Components Analysis class.
TSelector * fSelectorUpdate
! Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves fun...
TH1 * fHistogram
! Pointer to histogram used for the projection
void UpdateFormulaLeaves() override
this function is called by TChain::LoadTree when a new Tree is loaded.
Long64_t Process(const char *filename, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Process this tree executing the TSelector code in the specified filename.
TSQLResult * Query(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Loop on Tree and return TSQLResult object containing entries passing selection.
TClass * fSelectorClass
! Pointer to the actual class of the TSelectorFromFile
Long64_t GetEntries(const char *selection) override
Return the number of entries matching the selection.
Int_t GetDimension() const override
Int_t fDimension
Dimension of the current expression.
TVirtualIndex * BuildIndex(const TTree *T, const char *majorname, const char *minorname) override
Build the index for the tree (see TTree::BuildIndex)
TTreePlayer()
Default Tree constructor.
~TTreePlayer() override
Tree destructor.
Int_t Fit(const char *formula, const char *varexp, const char *selection, Option_t *option, Option_t *goption, Long64_t nentries, Long64_t firstentry) override
Fit a projected item(s) from a Tree.
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...
Class defining interface to a TTree query result with the same interface as for SQL databases.
void AddRow(TSQLRow *row)
Adopt a row to result set.
void AddField(Int_t field, const char *fieldname)
Add field name to result set.
Class defining interface to a row of a TTree query result.
A TTree represents a columnar dataset.
bool EnableCache()
Enable the TTreeCache unless explicitly disabled for this TTree by a prior call to SetCacheSize(0).
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual Int_t GetScanField() const
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual Long64_t GetEstimate() const
virtual TObjArray * GetListOfLeaves()
TFile * GetCurrentFile() const
Return pointer to the current file.
void Draw(Option_t *opt) override
Default Draw method for all objects.
virtual void SetNotify(TObject *obj)
Sets the address of the object to be notified when the tree is loaded.
TDirectory * GetDirectory() const
virtual TEntryList * GetEntryList()
Returns the entry list assigned to this tree.
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.
virtual Long64_t GetEntries() const
virtual void SetEstimate(Long64_t nentries=1000000)
Set number of entries to estimate variable limits.
virtual Long64_t GetEntryNumber(Long64_t entry) const
Return entry number corresponding to entry.
virtual TTree * CloneTree(Long64_t nentries=-1, Option_t *option="")
Create a clone of this tree and copy nentries.
virtual TTree * GetTree() const
virtual void SetEntryList(TEntryList *list, Option_t *opt="")
Set an EntryList.
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
TEventList * GetEventList() const
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 Int_t GetTreeNumber() const
virtual Int_t GetTimerInterval() const
virtual void SetScanField(Int_t n=50)
Sets the default maximum number of lines to be shown before <CR> when calling Scan().
virtual Long64_t GetCacheSize() const
virtual Long64_t GetMaxEntryLoop() const
Abstract Base Class for Fitting.
Abstract interface for Tree Index.
virtual Bool_t SendProcessingProgress(Double_t, Double_t, Bool_t=kFALSE)
virtual Bool_t SendProcessingStatus(const char *, Bool_t=kFALSE)
virtual TObjArray * GetElements() const =0
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.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.