119 gROOT->GetListOfCleanups()->Add(
this);
136 gROOT->GetListOfCleanups()->Remove(
this);
145 if (
dynamic_cast<const TChain*
>(T)) {
147 if (
index->IsZombie()) {
149 Error(
"BuildIndex",
"Creating a TChainIndex unsuccessful - switching to TTreeIndex");
193 if (
tree == 0)
return 0;
198 for (
Int_t i = 0; i < nb; ++i) {
212 if (strlen(selection)) {
214 if (!select || !select->
GetNdim()) {
224 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
226 if (entryNumber < 0)
break;
228 if (localEntry < 0)
break;
236 for(
Int_t current = 0; current<ndata && !keep; current++) {
296 const char *macrofilename,
const char *cutfilename,
299 if (!macrofilename || strlen(macrofilename)==0)
return 0;
305 if (cutfilename && strlen(cutfilename))
311 TString selname = wrapperPrefix;
316 if (aclicMode.
Length()==0) {
317 Warning(
"DrawScript",
"TTreeProxy does not work in interpreted mode yet. The script will be compiled.");
320 selname.
Append(aclicMode);
322 Info(
"DrawScript",
"%s",
Form(
"Will process tree/chain using %s",selname.
Data()));
346 TString possibleFilename = varexp0;
348 if ( dot_pos !=
kNPOS
349 && possibleFilename.
Index(
"Alt$")<0 && possibleFilename.
Index(
"Entries$")<0
350 && possibleFilename.
Index(
"LocalEntries$")<0
351 && possibleFilename.
Index(
"Length$")<0 && possibleFilename.
Index(
"Entry$")<0
352 && possibleFilename.
Index(
"LocalEntry$")<0
353 && possibleFilename.
Index(
"Min$")<0 && possibleFilename.
Index(
"Max$")<0
354 && possibleFilename.
Index(
"MinIf$")<0 && possibleFilename.
Index(
"MaxIf$")<0
355 && possibleFilename.
Index(
"Iteration$")<0 && possibleFilename.
Index(
"Sum$")<0
356 && possibleFilename.
Index(
">")<0 && possibleFilename.
Index(
"<")<0
361 "Drawing using a C++ file currently requires that both the expression and the selection are files\n\t\"%s\" is not a file",
368 possibleFilename = selection;
369 if (possibleFilename.
Index(
"Alt$")<0 && possibleFilename.
Index(
"Entries$")<0
370 && possibleFilename.
Index(
"LocalEntries$")<0
371 && possibleFilename.
Index(
"Length$")<0 && possibleFilename.
Index(
"Entry$")<0
372 && possibleFilename.
Index(
"LocalEntry$")<0
373 && possibleFilename.
Index(
"Min$")<0 && possibleFilename.
Index(
"Max$")<0
374 && possibleFilename.
Index(
"MinIf$")<0 && possibleFilename.
Index(
"MaxIf$")<0
375 && possibleFilename.
Index(
"Iteration$")<0 && possibleFilename.
Index(
"Sum$")<0
376 && possibleFilename.
Index(
">")<0 && possibleFilename.
Index(
"<")<0
380 "Drawing using a C++ file currently requires that both the expression and the selection are files\n\t\"%s\" is not a file",
389 if (evlist && elist){
394 if (cvarexp) cvarexp->
SetTitle(varexp0);
395 if (cselection) cselection->
SetTitle(selection);
412 gROOT->ProcessLineFast(
"new TCanvas();");
449 gPad->DrawFrame(-1.,-1.,1.,1.);
458 Warning(
"DrawSelect",
"The selected TTree subset is empty.");
463 if (
fDimension == 1 && !(optpara||optcandle)) {
468 }
else if (
fDimension == 2 && !(optpara||optcandle)) {
487 }
else if (
fDimension == 3 && !(optpara||optcandle)) {
493 }
else if (action == 33) {
500 if (opt.
Contains(
"same")) noscat -= 4;
508 }
else if (
fDimension == 4 && !(optpara||optcandle)) {
515 for (
Int_t col=0;col<ncolors;col++) {
518 if (draw) pm3d->
Draw();
521 }
else if (
fDimension > 1 && (optpara || optcandle)) {
526 gROOT->ProcessLine(
Form(
"TParallelCoord::SetEntryList((TParallelCoord*)0x%zx,(TEntryList*)0x%zx)",
527 (
size_t)para, (size_t)enlist));
531 gROOT->ProcessLineFast(
Form(
"(new TGL5DDataSet((TTree *)0x%zx))->Draw(\"%s\");", (
size_t)
fTree, opt.
Data()));
564 char *opt =
new char[nch];
566 else strlcpy(opt,
"goff",5);
571 Int_t fitResult = -1;
609 nentries = lastentry - firstentry + 1;
626 TTHREAD_TLS_DECL(std::string,column);
627 if (colindex<0 )
return "";
629 i1 =
index[colindex] + 1;
630 n =
index[colindex+1] - i1;
631 column = varexp(i1,
n).
Data();
633 return column.c_str();
650 const char* ltitle = leaf->
GetTitle();
651 if (mother && mother!=branch) {
652 branchname = mother->
GetName();
653 if (branchname[branchname.
Length()-1]!=
'.') {
656 if (strncmp(branchname.
Data(),ltitle,branchname.
Length())==0) {
662 branchname += ltitle;
667 char *bname = (
char*)branchname.
Data();
668 char *twodim = (
char*)strstr(bname,
"[");
669 if (twodim) *twodim = 0;
671 if (*bname ==
'.') *bname=
'_';
672 if (*bname ==
',') *bname=
'_';
673 if (*bname ==
':') *bname=
'_';
674 if (*bname ==
'<') *bname=
'_';
675 if (*bname ==
'>') *bname=
'_';
729 thead.
Form(
"%s.h", classname);
730 FILE *fp = fopen(thead,
"w");
732 Error(
"MakeClass",
"cannot open output file %s", thead.
Data());
736 tcimp.
Form(
"%s.C", classname);
737 FILE *fpc = fopen(tcimp,
"w");
739 Error(
"MakeClass",
"cannot open output file %s", tcimp.
Data());
747 treefile =
"Memory Directory";
762 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
763 fprintf(fp,
"// This class has been automatically generated on\n");
764 fprintf(fp,
"// %s by ROOT version %s\n",td.
AsString(),
gROOT->GetVersion());
767 fprintf(fp,
"// found on file: %s\n",treefile.
Data());
771 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
773 fprintf(fp,
"#ifndef %s_h\n",classname);
774 fprintf(fp,
"#define %s_h\n",classname);
776 fprintf(fp,
"#include <TROOT.h>\n");
777 fprintf(fp,
"#include <TChain.h>\n");
778 fprintf(fp,
"#include <TFile.h>\n");
779 if (isHbook) fprintf(fp,
"#include <THbookFile.h>\n");
780 if (opt.
Contains(
"selector")) fprintf(fp,
"#include <TSelector.h>\n");
784 fprintf(fp,
"\n// Header file for the classes stored in the TTree if any.\n");
787 for (
l=0;
l<nleaves;
l++) {
793 if (declfile && declfile[0]) {
794 static const char *precstl =
"prec_stl/";
795 static const unsigned int precstl_len = strlen(precstl);
796 static const char *rootinclude =
"include/";
797 static const unsigned int rootinclude_len = strlen(rootinclude);
798 if (strncmp(declfile,precstl,precstl_len) == 0) {
799 fprintf(fp,
"#include <%s>\n",declfile+precstl_len);
801 }
else if (strncmp(declfile,
"/usr/include/",13) == 0) {
802 fprintf(fp,
"#include <%s>\n",declfile+strlen(
"/include/c++/"));
803 listOfHeaders.
Add(
new TNamed(cl->
GetName(),declfile+strlen(
"/include/c++/")));
804 }
else if (strstr(declfile,
"/include/c++/") != 0) {
805 fprintf(fp,
"#include <%s>\n",declfile+strlen(
"/include/c++/"));
806 listOfHeaders.
Add(
new TNamed(cl->
GetName(),declfile+strlen(
"/include/c++/")));
807 }
else if (strncmp(declfile,rootinclude,rootinclude_len) == 0) {
808 fprintf(fp,
"#include <%s>\n",declfile+rootinclude_len);
811 fprintf(fp,
"#include \"%s\"\n",declfile);
824 for (
l=0;
l<nleaves;
l++) {
838 for (
l=0;
l<nleaves;
l++) {
851 fprintf(fp,
"class %s : public TSelector {\n",classname);
852 fprintf(fp,
"public :\n");
853 fprintf(fp,
" TTree *fChain; //!pointer to the analyzed TTree or TChain\n");
855 fprintf(fp,
"class %s {\n",classname);
856 fprintf(fp,
"public :\n");
857 fprintf(fp,
" TTree *fChain; //!pointer to the analyzed TTree or TChain\n");
858 fprintf(fp,
" Int_t fCurrent; //!current Tree number in a TChain\n");
861 fprintf(fp,
"\n// Fixed size dimensions of array or collections stored in the TTree if any.\n");
863 for (
l=0;
l<nleaves;
l++) {
865 strlcpy(blen,leaf->
GetName(),
sizeof(blen));
868 if (*bname ==
'.') *bname=
'_';
869 if (*bname ==
',') *bname=
'_';
870 if (*bname ==
':') *bname=
'_';
871 if (*bname ==
'<') *bname=
'_';
872 if (*bname ==
'>') *bname=
'_';
876 if (blen[lenb-1] ==
'_') {
880 fprintf(fp,
" static constexpr Int_t kMax%s = %d;\n",blen,
len);
888 fprintf(fp,
"\n // Declaration of leaf types\n");
892 const char *headOK =
" ";
893 const char *headcom =
" //";
895 char branchname[1024];
902 for (
l=0;
l<nleaves;
l++) {
911 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
912 strlcpy(aprefix,branch->
GetName(),
sizeof(aprefix));
914 else leafStatus[
l] = 1;
917 strlcat(branchname,
".",
sizeof(branchname));
918 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
921 char *dim = (
char*)strstr(branchname,
"[");
if (dim) dim[0] = 0;
924 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
926 char *twodim = (
char*)strstr(leaf->
GetTitle(),
"][");
929 if (*bname ==
'.') *bname=
'_';
930 if (*bname ==
',') *bname=
'_';
931 if (*bname ==
':') *bname=
'_';
932 if (*bname ==
'<') *bname=
'_';
933 if (*bname ==
'>') *bname=
'_';
939 if (!leafobj->
GetClass()) {leafStatus[
l] = 1; head = headcom;}
941 if (leafStatus[
l] == 0) mustInit.
Add(leafobj);
947 strlcpy(blen,leafcount->
GetName(),
sizeof(blen));
950 if (*bname ==
'.') *bname=
'_';
951 if (*bname ==
',') *bname=
'_';
952 if (*bname ==
':') *bname=
'_';
953 if (*bname ==
'<') *bname=
'_';
954 if (*bname ==
'>') *bname=
'_';
958 if (blen[lenb-1] ==
'_') {blen[lenb-1] = 0; kmax = 1;}
968 fprintf(fp,
" %-15s %s_;\n",
"Int_t", branchname);
972 fprintf(fp,
" %-15s *%s;\n",bre->
GetClassName(), branchname);
980 fprintf(fp,
"%s%-15s *%s;\n",headcom,bre->
GetClassName(), branchname);
982 fprintf(fp,
"%s%-15s *%s;\n",head,bre->
GetClassName(), branchname);
989 fprintf(fp,
"%s%-15s *%s;\n",head,bre->
GetClassName(), branchname);
990 if (leafStatus[
l] == 0) mustInit.
Add(bre);
995 if (!cle) {leafStatus[
l] = 1;
continue;}
998 strlcpy(brename,bre->
GetName(),255);
999 char *bren = brename;
1000 char *adot = strrchr(bren,
'.');
1001 if (adot) bren = adot+1;
1002 char *brack = strchr(bren,
'[');
1003 if (brack) *brack = 0;
1009 if (leafcount) fprintf(fp,
"%s%-15s %s[kMax%s];\n",head,elem->
GetTypeName(), branchname,blen);
1010 else fprintf(fp,
"%s%-15s %s;\n",head,elem->
GetTypeName(), branchname);
1013 fprintf(fp,
"%s%-15s %s;\n",head,bre->
GetClassName(), branchname);
1018 if (strlen(leaf->
GetTypeName()) == 0) {leafStatus[
l] = 1;
continue;}
1029 const char *stars =
" ";
1036 char *dimInName = (
char*) strstr(branchname,
"[");
1037 if ( twodim || dimInName ) {
1039 dimensions = dimInName;
1042 if (twodim) dimensions += (
char*)(twodim+1);
1044 const char* leafcountName = leafcount->
GetName();
1048 strlcpy(b2len,l2->
GetName(),
sizeof(b2len));
1051 if (*bname ==
'.') *bname=
'_';
1052 if (*bname ==
',') *bname=
'_';
1053 if (*bname ==
':') *bname=
'_';
1054 if (*bname ==
'<') *bname=
'_';
1055 if (*bname ==
'>') *bname=
'_';
1058 leafcountName = b2len;
1060 if (dimensions.
Length()) {
1061 if (kmax) fprintf(fp,
" %-14s %s%s[kMax%s]%s; //[%s]\n",leaf->
GetTypeName(), stars,
1062 branchname,blen,dimensions.
Data(),leafcountName);
1063 else fprintf(fp,
" %-14s %s%s[%d]%s; //[%s]\n",leaf->
GetTypeName(), stars,
1064 branchname,
len,dimensions.
Data(),leafcountName);
1066 if (kmax) fprintf(fp,
" %-14s %s%s[kMax%s]; //[%s]\n",leaf->
GetTypeName(), stars, branchname,blen,leafcountName);
1067 else fprintf(fp,
" %-14s %s%s[%d]; //[%s]\n",leaf->
GetTypeName(), stars, branchname,
len,leafcountName);
1069 if (stars[0]==
'*') {
1071 if (kmax)
n =
new TNamed(branchname,
Form(
"kMax%s",blen));
1076 if (strstr(branchname,
"["))
len = 1;
1077 if (
len < 2) fprintf(fp,
" %-15s %s;\n",leaf->
GetTypeName(), branchname);
1079 if (twodim) fprintf(fp,
" %-15s %s%s;\n",leaf->
GetTypeName(), branchname,(
char*)strstr(leaf->
GetTitle(),
"["));
1080 else fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,
len);
1087 fprintf(fp,
" // List of branches\n");
1088 for (
l=0;
l<nleaves;
l++) {
1089 if (leafStatus[
l])
continue;
1097 fprintf(fp,
" %s(TTree * /*tree*/ =0) : fChain(0) { }\n",classname) ;
1098 fprintf(fp,
" virtual ~%s() { }\n",classname);
1099 fprintf(fp,
" virtual Int_t Version() const { return 2; }\n");
1100 fprintf(fp,
" virtual void Begin(TTree *tree);\n");
1101 fprintf(fp,
" virtual void SlaveBegin(TTree *tree);\n");
1102 fprintf(fp,
" virtual void Init(TTree *tree);\n");
1103 fprintf(fp,
" virtual Bool_t Notify();\n");
1104 fprintf(fp,
" virtual Bool_t Process(Long64_t entry);\n");
1105 fprintf(fp,
" virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }\n");
1106 fprintf(fp,
" virtual void SetOption(const char *option) { fOption = option; }\n");
1107 fprintf(fp,
" virtual void SetObject(TObject *obj) { fObject = obj; }\n");
1108 fprintf(fp,
" virtual void SetInputList(TList *input) { fInput = input; }\n");
1109 fprintf(fp,
" virtual TList *GetOutputList() const { return fOutput; }\n");
1110 fprintf(fp,
" virtual void SlaveTerminate();\n");
1111 fprintf(fp,
" virtual void Terminate();\n\n");
1112 fprintf(fp,
" ClassDef(%s,0);\n",classname);
1115 fprintf(fp,
"#endif\n");
1119 fprintf(fp,
" %s(TTree *tree=0);\n",classname);
1120 fprintf(fp,
" virtual ~%s();\n",classname);
1121 fprintf(fp,
" virtual Int_t Cut(Long64_t entry);\n");
1122 fprintf(fp,
" virtual Int_t GetEntry(Long64_t entry);\n");
1123 fprintf(fp,
" virtual Long64_t LoadTree(Long64_t entry);\n");
1124 fprintf(fp,
" virtual void Init(TTree *tree);\n");
1125 fprintf(fp,
" virtual void Loop();\n");
1126 fprintf(fp,
" virtual Bool_t Notify();\n");
1127 fprintf(fp,
" virtual void Show(Long64_t entry = -1);\n");
1130 fprintf(fp,
"#endif\n");
1134 fprintf(fp,
"#ifdef %s_cxx\n",classname);
1136 fprintf(fp,
"%s::%s(TTree *tree) : fChain(0) \n",classname,classname);
1138 fprintf(fp,
"// if parameter tree is not specified (or zero), connect the file\n");
1139 fprintf(fp,
"// used to generate this class and read the Tree.\n");
1140 fprintf(fp,
" if (tree == 0) {\n");
1142 fprintf(fp,
"\n#ifdef SINGLE_TREE\n");
1143 fprintf(fp,
" // The following code should be used if you want this class to access\n");
1144 fprintf(fp,
" // a single tree instead of a chain\n");
1147 fprintf(fp,
" THbookFile *f = (THbookFile*)gROOT->GetListOfBrowsables()->FindObject(\"%s\");\n",
1149 fprintf(fp,
" if (!f) {\n");
1150 fprintf(fp,
" f = new THbookFile(\"%s\");\n",treefile.
Data());
1154 fprintf(fp,
" tree = (TTree*)f->Get(%d);\n\n",hid);
1156 fprintf(fp,
" TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(\"%s\");\n",treefile.
Data());
1157 fprintf(fp,
" if (!f || !f->IsOpen()) {\n");
1158 fprintf(fp,
" f = new TFile(\"%s\");\n",treefile.
Data());
1162 fprintf(fp,
" dir->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1164 fprintf(fp,
" f->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1168 fprintf(fp,
"#else // SINGLE_TREE\n\n");
1169 fprintf(fp,
" // The following code should be used if you want this class to access a chain\n");
1170 fprintf(fp,
" // of trees.\n");
1171 fprintf(fp,
" TChain * chain = new TChain(\"%s\",\"%s\");\n",
1178 fprintf(fp,
" chain->Add(\"%s/%s\");\n",element->
GetTitle(),element->
GetName());
1181 fprintf(fp,
" tree = chain;\n");
1182 fprintf(fp,
"#endif // SINGLE_TREE\n\n");
1185 fprintf(fp,
" Init(tree);\n");
1192 fprintf(fp,
"%s::~%s()\n",classname,classname);
1194 fprintf(fp,
" if (!fChain) return;\n");
1198 fprintf(fp,
" delete fChain->GetCurrentFile();\n");
1205 fprintf(fp,
"Int_t %s::GetEntry(Long64_t entry)\n",classname);
1207 fprintf(fp,
"// Read contents of entry.\n");
1209 fprintf(fp,
" if (!fChain) return 0;\n");
1210 fprintf(fp,
" return fChain->GetEntry(entry);\n");
1215 fprintf(fp,
"Long64_t %s::LoadTree(Long64_t entry)\n",classname);
1217 fprintf(fp,
"// Set the environment to read one entry\n");
1218 fprintf(fp,
" if (!fChain) return -5;\n");
1219 fprintf(fp,
" Long64_t centry = fChain->LoadTree(entry);\n");
1220 fprintf(fp,
" if (centry < 0) return centry;\n");
1221 fprintf(fp,
" if (fChain->GetTreeNumber() != fCurrent) {\n");
1222 fprintf(fp,
" fCurrent = fChain->GetTreeNumber();\n");
1223 fprintf(fp,
" Notify();\n");
1225 fprintf(fp,
" return centry;\n");
1231 fprintf(fp,
"void %s::Init(TTree *tree)\n",classname);
1233 fprintf(fp,
" // The Init() function is called when the selector needs to initialize\n"
1234 " // a new tree or chain. Typically here the branch addresses and branch\n"
1235 " // pointers of the tree will be set.\n"
1236 " // It is normally not necessary to make changes to the generated\n"
1237 " // code, but the routine can be extended by the user if needed.\n"
1238 " // Init() will be called many times when running on PROOF\n"
1239 " // (once per file to be processed).\n\n");
1240 if (mustInit.
Last()) {
1241 TIter next(&mustInit);
1243 fprintf(fp,
" // Set object pointer\n");
1244 while( (obj = next()) ) {
1246 strlcpy(branchname,((
TBranch*)obj)->
GetName(),
sizeof(branchname));
1248 strlcpy(branchname,((
TLeaf*)obj)->
GetName(),
sizeof(branchname));
1253 if (*bname ==
'.') *bname=
'_';
1254 if (*bname ==
',') *bname=
'_';
1255 if (*bname ==
':') *bname=
'_';
1256 if (*bname ==
'<') *bname=
'_';
1257 if (*bname ==
'>') *bname=
'_';
1260 fprintf(fp,
" %s = 0;\n",branchname );
1263 if (mustInitArr.
Last()) {
1264 TIter next(&mustInitArr);
1266 fprintf(fp,
" // Set array pointer\n");
1267 while( (info = (
TNamed*)next()) ) {
1268 fprintf(fp,
" for(int i=0; i<%s; ++i) %s[i] = 0;\n",info->
GetTitle(),info->
GetName());
1272 fprintf(fp,
" // Set branch addresses and branch pointers\n");
1273 fprintf(fp,
" if (!tree) return;\n");
1274 fprintf(fp,
" fChain = tree;\n");
1275 if (!opt.
Contains(
"selector")) fprintf(fp,
" fCurrent = -1;\n");
1276 fprintf(fp,
" fChain->SetMakeClass(1);\n");
1278 for (
l=0;
l<nleaves;
l++) {
1279 if (leafStatus[
l])
continue;
1284 strlcpy(aprefix,branch->
GetName(),
sizeof(aprefix));
1288 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1289 strlcat(branchname,
".",
sizeof(branchname));
1290 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1293 char *dim = (
char*)strstr(branchname,
"[");
if (dim) dim[0] = 0;
1296 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1299 if (bre->
GetType() == 3 || bre->
GetType()==4) strlcat(branchname,
"_",
sizeof(branchname));
1303 char *brak = strstr(branchname,
"[");
if (brak) *brak = 0;
1304 char *twodim = (
char*)strstr(bname,
"[");
if (twodim) *twodim = 0;
1306 if (*bname ==
'.') *bname=
'_';
1307 if (*bname ==
',') *bname=
'_';
1308 if (*bname ==
':') *bname=
'_';
1309 if (*bname ==
'<') *bname=
'_';
1310 if (*bname ==
'>') *bname=
'_';
1313 const char *maybedisable =
"";
1315 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,
kFALSE).Data());
1316 maybedisable =
"// ";
1323 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1330 if (
len > 1) fprintf(fp,
"%s fChain->SetBranchAddress(\"%s\", %s, &b_%s);\n",
1332 else fprintf(fp,
"%s fChain->SetBranchAddress(\"%s\", &%s, &b_%s);\n",
1337 fprintf(fp,
" Notify();\n");
1344 fprintf(fp,
"Bool_t %s::Notify()\n",classname);
1346 fprintf(fp,
" // The Notify() function is called when a new file is opened. This\n"
1347 " // can be either for a new TTree in a TChain or when when a new TTree\n"
1348 " // is started when using PROOF. It is normally not necessary to make changes\n"
1349 " // to the generated code, but the routine can be extended by the\n"
1350 " // user if needed. The return value is currently not used.\n\n");
1351 fprintf(fp,
" return kTRUE;\n");
1357 fprintf(fp,
"void %s::Show(Long64_t entry)\n",classname);
1359 fprintf(fp,
"// Print contents of entry.\n");
1360 fprintf(fp,
"// If entry is not specified, print current entry\n");
1362 fprintf(fp,
" if (!fChain) return;\n");
1363 fprintf(fp,
" fChain->Show(entry);\n");
1368 fprintf(fp,
"Int_t %s::Cut(Long64_t entry)\n",classname);
1370 fprintf(fp,
"// This function may be called from Loop.\n");
1371 fprintf(fp,
"// returns 1 if entry is accepted.\n");
1372 fprintf(fp,
"// returns -1 otherwise.\n");
1374 fprintf(fp,
" return 1;\n");
1377 fprintf(fp,
"#endif // #ifdef %s_cxx\n",classname);
1382 fprintf(fpc,
"#define %s_cxx\n",classname);
1383 fprintf(fpc,
"#include \"%s\"\n",thead.
Data());
1384 fprintf(fpc,
"#include <TH2.h>\n");
1385 fprintf(fpc,
"#include <TStyle.h>\n");
1386 fprintf(fpc,
"#include <TCanvas.h>\n");
1388 fprintf(fpc,
"void %s::Loop()\n",classname);
1390 fprintf(fpc,
"// In a ROOT session, you can do:\n");
1391 fprintf(fpc,
"// root> .L %s.C\n",classname);
1392 fprintf(fpc,
"// root> %s t\n",classname);
1393 fprintf(fpc,
"// root> t.GetEntry(12); // Fill t data members with entry number 12\n");
1394 fprintf(fpc,
"// root> t.Show(); // Show values of entry 12\n");
1395 fprintf(fpc,
"// root> t.Show(16); // Read and show values of entry 16\n");
1396 fprintf(fpc,
"// root> t.Loop(); // Loop on all entries\n");
1397 fprintf(fpc,
"//\n");
1398 fprintf(fpc,
"\n// This is the loop skeleton where:\n");
1399 fprintf(fpc,
"// jentry is the global entry number in the chain\n");
1400 fprintf(fpc,
"// ientry is the entry number in the current Tree\n");
1401 fprintf(fpc,
"// Note that the argument to GetEntry must be:\n");
1402 fprintf(fpc,
"// jentry for TChain::GetEntry\n");
1403 fprintf(fpc,
"// ientry for TTree::GetEntry and TBranch::GetEntry\n");
1404 fprintf(fpc,
"//\n");
1405 fprintf(fpc,
"// To read only selected branches, Insert statements like:\n");
1406 fprintf(fpc,
"// METHOD1:\n");
1407 fprintf(fpc,
"// fChain->SetBranchStatus(\"*\",0); // disable all branches\n");
1408 fprintf(fpc,
"// fChain->SetBranchStatus(\"branchname\",1); // activate branchname\n");
1409 fprintf(fpc,
"// METHOD2: replace line\n");
1410 fprintf(fpc,
"// fChain->GetEntry(jentry); //read all branches\n");
1411 fprintf(fpc,
"//by b_branchname->GetEntry(ientry); //read only this branch\n");
1412 fprintf(fpc,
" if (fChain == 0) return;\n");
1413 fprintf(fpc,
"\n Long64_t nentries = fChain->GetEntriesFast();\n");
1414 fprintf(fpc,
"\n Long64_t nbytes = 0, nb = 0;\n");
1415 fprintf(fpc,
" for (Long64_t jentry=0; jentry<nentries;jentry++) {\n");
1416 fprintf(fpc,
" Long64_t ientry = LoadTree(jentry);\n");
1417 fprintf(fpc,
" if (ientry < 0) break;\n");
1418 fprintf(fpc,
" nb = fChain->GetEntry(jentry); nbytes += nb;\n");
1419 fprintf(fpc,
" // if (Cut(ientry) < 0) continue;\n");
1420 fprintf(fpc,
" }\n");
1425 fprintf(fpc,
"#define %s_cxx\n",classname);
1426 fprintf(fpc,
"// The class definition in %s.h has been generated automatically\n",classname);
1427 fprintf(fpc,
"// by the ROOT utility TTree::MakeSelector(). This class is derived\n");
1428 fprintf(fpc,
"// from the ROOT class TSelector. For more information on the TSelector\n"
1429 "// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.\n\n");
1430 fprintf(fpc,
"// The following methods are defined in this file:\n");
1431 fprintf(fpc,
"// Begin(): called every time a loop on the tree starts,\n");
1432 fprintf(fpc,
"// a convenient place to create your histograms.\n");
1433 fprintf(fpc,
"// SlaveBegin(): called after Begin(), when on PROOF called only on the\n"
1434 "// slave servers.\n");
1435 fprintf(fpc,
"// Process(): called for each event, in this function you decide what\n");
1436 fprintf(fpc,
"// to read and fill your histograms.\n");
1437 fprintf(fpc,
"// SlaveTerminate: called at the end of the loop on the tree, when on PROOF\n"
1438 "// called only on the slave servers.\n");
1439 fprintf(fpc,
"// Terminate(): called at the end of the loop on the tree,\n");
1440 fprintf(fpc,
"// a convenient place to draw/fit your histograms.\n");
1441 fprintf(fpc,
"//\n");
1442 fprintf(fpc,
"// To use this file, try the following session on your Tree T:\n");
1443 fprintf(fpc,
"//\n");
1444 fprintf(fpc,
"// root> T->Process(\"%s.C\")\n",classname);
1445 fprintf(fpc,
"// root> T->Process(\"%s.C\",\"some options\")\n",classname);
1446 fprintf(fpc,
"// root> T->Process(\"%s.C+\")\n",classname);
1447 fprintf(fpc,
"//\n\n");
1448 fprintf(fpc,
"#include \"%s\"\n",thead.
Data());
1449 fprintf(fpc,
"#include <TH2.h>\n");
1450 fprintf(fpc,
"#include <TStyle.h>\n");
1454 fprintf(fpc,
"void %s::Begin(TTree * /*tree*/)\n",classname);
1456 fprintf(fpc,
" // The Begin() function is called at the start of the query.\n");
1457 fprintf(fpc,
" // When running with PROOF Begin() is only called on the client.\n");
1458 fprintf(fpc,
" // The tree argument is deprecated (on PROOF 0 is passed).\n");
1460 fprintf(fpc,
" TString option = GetOption();\n");
1465 fprintf(fpc,
"void %s::SlaveBegin(TTree * /*tree*/)\n",classname);
1467 fprintf(fpc,
" // The SlaveBegin() function is called after the Begin() function.\n");
1468 fprintf(fpc,
" // When running with PROOF SlaveBegin() is called on each slave server.\n");
1469 fprintf(fpc,
" // The tree argument is deprecated (on PROOF 0 is passed).\n");
1471 fprintf(fpc,
" TString option = GetOption();\n");
1476 fprintf(fpc,
"Bool_t %s::Process(Long64_t entry)\n",classname);
1478 fprintf(fpc,
" // The Process() function is called for each entry in the tree (or possibly\n"
1479 " // keyed object in the case of PROOF) to be processed. The entry argument\n"
1480 " // specifies which entry in the currently loaded tree is to be processed.\n"
1481 " // It can be passed to either %s::GetEntry() or TBranch::GetEntry()\n"
1482 " // to read either all or the required parts of the data. When processing\n"
1483 " // keyed objects with PROOF, the object is already loaded and is available\n"
1484 " // via the fObject pointer.\n"
1486 " // This function should contain the \"body\" of the analysis. It can contain\n"
1487 " // simple or elaborate selection criteria, run algorithms on the data\n"
1488 " // of the event and typically fill histograms.\n"
1490 " // The processing can be stopped by calling Abort().\n"
1492 " // Use fStatus to set the return value of TTree::Process().\n"
1494 " // The return value is currently not used.\n\n", classname);
1496 fprintf(fpc,
" return kTRUE;\n");
1500 fprintf(fpc,
"void %s::SlaveTerminate()\n",classname);
1502 fprintf(fpc,
" // The SlaveTerminate() function is called after all entries or objects\n"
1503 " // have been processed. When running with PROOF SlaveTerminate() is called\n"
1504 " // on each slave server.");
1510 fprintf(fpc,
"void %s::Terminate()\n",classname);
1512 fprintf(fpc,
" // The Terminate() function is the last function to be called during\n"
1513 " // a query. It always runs on the client, it can be used to present\n"
1514 " // the results graphically or save the results to file.");
1520 delete [] leafStatus;
1558 FILE *fp = fopen(tfile,
"w");
1560 Error(
"MakeCode",
"cannot open output file %s", tfile.
Data());
1567 treefile =
"Memory Directory";
1579 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
1580 fprintf(fp,
"// This file has been automatically generated \n");
1581 fprintf(fp,
"// (%s by ROOT version%s)\n",td.
AsString(),
gROOT->GetVersion());
1584 fprintf(fp,
"// found on file: %s\n",treefile.
Data());
1588 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
1594 fprintf(fp,
"//Reset ROOT and connect tree file\n");
1595 fprintf(fp,
" gROOT->Reset();\n");
1597 fprintf(fp,
"\n#ifdef SINGLE_TREE\n");
1598 fprintf(fp,
" // The following code should be used if you want this code to access\n");
1599 fprintf(fp,
" // a single tree instead of a chain\n");
1601 fprintf(fp,
" TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(\"%s\");\n",treefile.
Data());
1602 fprintf(fp,
" if (!f) {\n");
1603 fprintf(fp,
" f = new TFile(\"%s\");\n",treefile.
Data());
1607 fprintf(fp,
" dir->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1609 fprintf(fp,
" f->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1612 fprintf(fp,
"#else // SINGLE_TREE\n\n");
1613 fprintf(fp,
" // The following code should be used if you want this code to access a chain\n");
1614 fprintf(fp,
" // of trees.\n");
1615 fprintf(fp,
" TChain *%s = new TChain(\"%s\",\"%s\");\n",
1625 fprintf(fp,
"#endif // SINGLE_TREE\n\n");
1629 fprintf(fp,
"//Declaration of leaves types\n");
1634 const char *headOK =
" ";
1635 const char *headcom =
" //";
1637 char branchname[1024];
1638 for (
l=0;
l<nleaves;
l++) {
1647 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1648 strlcat(branchname,
".",
sizeof(branchname));
1649 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1652 char *dim = (
char*)strstr(branchname,
"[");
1653 if (dim) dim[0] = 0;
1656 if (leafcount) strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1657 else strlcpy(branchname,leaf->
GetTitle(),
sizeof(branchname));
1659 char *twodim = (
char*)strstr(leaf->
GetTitle(),
"][");
1662 if (*bname ==
'.') *bname=
'_';
1663 if (*bname ==
',') *bname=
'_';
1664 if (*bname ==
':') *bname=
'_';
1665 if (*bname ==
'<') *bname=
'_';
1666 if (*bname ==
'>') *bname=
'_';
1671 if (leafobj->
GetClass()) head = headOK;
1672 else head = headcom;
1680 char *dimInName = (
char*) strstr(branchname,
"[");
1682 if ( twodim || dimInName ) {
1684 dimensions = dimInName;
1687 if (twodim) dimensions += (
char*)(twodim+1);
1689 if (dimensions.
Length()) {
1690 fprintf(fp,
" %-15s %s[%d]%s;\n",leaf->
GetTypeName(), branchname,
len,dimensions.
Data());
1692 fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,
len);
1695 if (strstr(branchname,
"["))
len = 1;
1696 if (
len < 2) fprintf(fp,
" %-15s %s;\n",leaf->
GetTypeName(), branchname);
1697 else fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,
len);
1702 fprintf(fp,
"\n // Set branch addresses.\n");
1703 for (
l=0;
l<nleaves;
l++) {
1711 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1712 strlcat(branchname,
".",
sizeof(branchname));
1713 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1716 char *dim = (
char*)strstr(branchname,
"[");
1717 if (dim) dim[0] = 0;
1720 if (leafcount) strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1721 else strlcpy(branchname,leaf->
GetTitle(),
sizeof(branchname));
1725 if (*bname ==
'.') *bname=
'_';
1726 if (*bname ==
',') *bname=
'_';
1727 if (*bname ==
':') *bname=
'_';
1728 if (*bname ==
'<') *bname=
'_';
1729 if (*bname ==
'>') *bname=
'_';
1732 char *brak = strstr(branchname,
"[");
1733 if (brak) *brak = 0;
1736 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1738 if (!leafobj->
GetClass()) head = headcom;
1741 if (
len > 1 || brak) fprintf(fp,
"%s%s->SetBranchAddress(\"%s\",%s);\n",head,
fTree->
GetName(),branch->
GetName(),branchname);
1742 else fprintf(fp,
"%s%s->SetBranchAddress(\"%s\",&%s);\n",head,
fTree->
GetName(),branch->
GetName(),branchname);
1746 fprintf(fp,
"\n// This is the loop skeleton\n");
1747 fprintf(fp,
"// To read only selected branches, Insert statements like:\n");
1748 fprintf(fp,
"// %s->SetBranchStatus(\"*\",0); // disable all branches\n",
fTree->
GetName());
1749 fprintf(fp,
"// %s->SetBranchStatus(\"branchname\",1); // activate branchname\n",
GetName());
1750 fprintf(fp,
"\n Long64_t nentries = %s->GetEntries();\n",
fTree->
GetName());
1751 fprintf(fp,
"\n Long64_t nbytes = 0;\n");
1752 fprintf(fp,
"// for (Long64_t i=0; i<nentries;i++) {\n");
1753 fprintf(fp,
"// nbytes += %s->GetEntry(i);\n",
fTree->
GetName());
1754 fprintf(fp,
"// }\n");
1757 printf(
"Macro: %s generated from Tree: %s\n",tfile.
Data(),
fTree->
GetName());
1916 const char *macrofilename,
const char *cutfilename,
1919 if (macrofilename==0 || strlen(macrofilename)==0 ) {
1921 Error(
"MakeProxy",
"A file name for the user script is required");
2008 std::vector<TString> cnames;
2017 if (nleaves < ncols) ncols = nleaves;
2018 nch = varexp ? strlen(varexp) : 0;
2024 if (strlen(selection)) {
2032 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2033 if (nch == 0 || allvar) {
2034 for (i=0;i<ncols;i++) {
2035 cnames.push_back( ((
TLeaf*)leaves->
At(i))->GetName() );
2045 for (i=0;i<ncols;i++) {
2067 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2069 if (entryNumber < 0)
break;
2071 if (localEntry < 0)
break;
2081 for(
int inst=0;inst<ndata;inst++) {
2089 if (inst==0) loaded =
kTRUE;
2093 for (i=0;i<ncols;i++) {
2099 for (i=0;i<ncols;i++) {
2196 if (!selector)
return -1;
2272 if (!
gROOT->IsBatch() && interval)
2276 Long64_t entry, entryNumber, localEntry;
2290 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2292 if (entryNumber < 0)
break;
2294 if (
gROOT->IsInterrupted())
break;
2296 if (localEntry < 0)
break;
2301 selector->
Process(localEntry);
2438 UInt_t colDefaultSize = 9;
2440 std::vector<TString> colFormats;
2441 std::vector<Int_t> colSizes;
2444 int start = opt.
Index(
"lenmax=");
2445 int numpos = start + strlen(
"lenmax=");
2448 while( (numpos+numlen<
len) && isdigit(opt[numpos+numlen]) ) numlen++;
2449 TString num = opt(numpos,numlen);
2450 opt.
Remove(start,strlen(
"lenmax")+numlen);
2452 lenmax = atoi(num.
Data());
2455 int start = opt.
Index(
"colsize=");
2456 int numpos = start + strlen(
"colsize=");
2459 while( (numpos+numlen<
len) && isdigit(opt[numpos+numlen]) ) numlen++;
2460 TString num = opt(numpos,numlen);
2461 opt.
Remove(start,strlen(
"size")+numlen);
2463 colDefaultSize = atoi(num.
Data());
2464 colPrecision = colDefaultSize;
2465 if (colPrecision>18) colPrecision = 18;
2468 int start = opt.
Index(
"precision=");
2469 int numpos = start + strlen(
"precision=");
2472 while( (numpos+numlen<
len) && isdigit(opt[numpos+numlen]) ) numlen++;
2473 TString num = opt(numpos,numlen);
2474 opt.
Remove(start,strlen(
"precision")+numlen);
2476 colPrecision = atoi(num.
Data());
2478 TString defFormat =
Form(
"%d.%d",colDefaultSize,colPrecision);
2480 int start = opt.
Index(
"col=");
2481 int numpos = start + strlen(
"col=");
2484 while( (numpos+numlen<
len) &&
2485 (isdigit(opt[numpos+numlen])
2486 || opt[numpos+numlen] ==
'c'
2487 || opt[numpos+numlen] ==
'd'
2488 || opt[numpos+numlen] ==
'i'
2489 || opt[numpos+numlen] ==
'o'
2490 || opt[numpos+numlen] ==
'x'
2491 || opt[numpos+numlen] ==
'X'
2492 || opt[numpos+numlen] ==
'u'
2493 || opt[numpos+numlen] ==
'f'
2494 || opt[numpos+numlen] ==
'e'
2495 || opt[numpos+numlen] ==
'E'
2496 || opt[numpos+numlen] ==
'g'
2497 || opt[numpos+numlen] ==
'G'
2498 || opt[numpos+numlen] ==
'l'
2499 || opt[numpos+numlen] ==
'L'
2500 || opt[numpos+numlen] ==
'h'
2501 || opt[numpos+numlen] ==
's'
2502 || opt[numpos+numlen] ==
'#'
2503 || opt[numpos+numlen]==
'.'
2504 || opt[numpos+numlen]==
':')) numlen++;
2505 TString flist = opt(numpos,numlen);
2506 opt.
Remove(start,strlen(
"col")+numlen);
2509 while(i<flist.
Length() && flist[i]==
':') {
2510 colFormats.push_back(defFormat);
2511 colSizes.push_back(colDefaultSize);
2514 for(; i<flist.
Length(); ++i) {
2515 int next = flist.
Index(
":",i);
2517 colFormats.push_back(defFormat);
2518 }
else if (next==
kNPOS) {
2519 colFormats.push_back(flist(i,flist.
Length()-i));
2522 colFormats.push_back(flist(i,next-i));
2525 UInt_t siz = atoi(colFormats[colFormats.size()-1].Data());
2526 colSizes.push_back( siz ? siz : colDefaultSize );
2531 std::vector<TString> cnames;
2537 const char *fname =
nullptr;
2542 if (!fname) fname =
"";
2543 Int_t lenfile = strlen(fname);
2546 fownname.
Append(
"-scan.dat");
2547 fname = fownname.
Data();
2549 out.open(fname, std::ios::out);
2551 Error(
"Scan",
"Can not open file for redirection");
2556 if (leaves==0)
return 0;
2558 if (nleaves < ncols) ncols = nleaves;
2559 nch = varexp ? strlen(varexp) : 0;
2565 if (selection && strlen(selection)) {
2567 if (!select)
return -1;
2568 if (!select->
GetNdim()) {
delete select;
return -1; }
2573 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2574 if (nch == 0 || allvar) {
2577 for (ui=0;ui<ncs;++ui) {
2581 if (cnames[ncols] == lf->
GetName() ) {
2583 }
else if (cnames[ncols][cnames[ncols].Length()-1]==
'.') {
2596 cnames[ncols].Append(
'.');
2602 cnames[ncols].Append(
'.');
2603 cnames[ncols].Append( lf->
GetName() );
2615 for(ui=colFormats.size();ui<ncols;++ui) {
2616 colFormats.push_back(defFormat);
2617 colSizes.push_back(colDefaultSize);
2621 for (ui=0;ui<ncols;ui++) {
2659 onerow =
"***********";
2660 if (hasArray) onerow +=
"***********";
2662 for (ui=0;ui<ncols;ui++) {
2663 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2667 out<<onerow.
Data()<<
"*"<<std::endl;
2669 printf(
"%s*\n",onerow.
Data());
2671 if (hasArray) onerow +=
"* Instance ";
2672 for (ui=0;ui<ncols;ui++) {
2673 TString numbFormat =
Form(
"* %%%d.%ds ",colSizes[ui],colSizes[ui]);
2677 out<<onerow.
Data()<<
"*"<<std::endl;
2679 printf(
"%s*\n",onerow.
Data());
2680 onerow =
"***********";
2681 if (hasArray) onerow +=
"***********";
2682 for (ui=0;ui<ncols;ui++) {
2683 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2687 out<<onerow.
Data()<<
"*"<<std::endl;
2689 printf(
"%s*\n",onerow.
Data());
2694 for (entry=firstentry;
2695 entry<(firstentry+
nentries) && !exitloop;
2698 if (entryNumber < 0)
break;
2700 if (localEntry < 0)
break;
2721 for (ui=0;ui<ncols;ui++) {
2722 if (ndata < var[ui]->GetNdata() ) {
2726 if (select && select->
GetNdata()==0) ndata = 0;
2731 if (lenmax && ndata>(
int)lenmax) ndata = lenmax;
2733 for(
int inst=0;inst<ndata;inst++) {
2739 if (inst==0) loaded =
kTRUE;
2743 for (ui=0;ui<ncols;ui++) {
2748 onerow =
Form(
"* %8lld ",entryNumber);
2750 onerow +=
Form(
"* %8d ",inst);
2752 for (ui=0;ui<ncols;++ui) {
2753 TString numbFormat =
Form(
"* %%%d.%ds ",colSizes[ui],colSizes[ui]);
2754 if (var[ui]->GetNdim()) onerow +=
Form(numbFormat.
Data(),var[ui]->
PrintValue(0,inst,colFormats[ui].Data()));
2756 TString emptyForm =
Form(
"* %%%dc ",colSizes[ui]);
2757 onerow +=
Form(emptyForm.
Data(),
' ');
2762 out<<onerow.
Data()<<
"*"<<std::endl;
2764 printf(
"%s*\n",onerow.
Data());
2767 fprintf(stderr,
"Type <CR> to continue or q to quit ==> ");
2771 while (readch !=
'\n' && readch != EOF) readch = getchar();
2772 if (answer ==
'q' || answer ==
'Q') {
2780 onerow =
"***********";
2781 if (hasArray) onerow +=
"***********";
2782 for (ui=0;ui<ncols;ui++) {
2783 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2787 out<<onerow.
Data()<<
"*"<<std::endl;
2789 printf(
"%s*\n",onerow.
Data());
2812 std::vector<TString> cnames;
2819 if (nleaves < ncols) ncols = nleaves;
2820 nch = varexp ? strlen(varexp) : 0;
2826 if (strlen(selection)) {
2828 if (!select)
return 0;
2829 if (!select->
GetNdim()) {
delete select;
return 0; }
2835 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2836 if (nch == 0 || allvar) {
2837 for (i=0;i<ncols;i++) {
2838 cnames.push_back( ((
TLeaf*)leaves->
At(i))->GetName() );
2847 for (i=0;i<ncols;i++) {
2854 for (i = 0; i < ncols; i++) {
2855 res->
AddField(i, var[i]->PrintValue(-1));
2869 const char *aresult;
2871 char *arow =
new char[ncols*50];
2875 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2877 if (entryNumber < 0)
break;
2879 if (localEntry < 0)
break;
2896 for(
int inst=0;inst<ndata;inst++) {
2903 if (inst==0) loaded =
kTRUE;
2907 for (i=0;i<ncols;i++) {
2912 for (i=0;i<ncols;i++) {
2914 len = strlen(aresult)+1;
2916 memcpy(arow,aresult,
len);
2919 memcpy(arow+fields[i-1],aresult,
len);
2920 fields[i] = fields[i-1] +
len;
2964 if ((hname ==
"RTreeViewer") && !
gROOT->IsWebDisplay()) {
2965 printf(
"\nWARNING!\n");
2966 printf(
"rootrc parameter \"TreeViewer.Name\" with web-based viewer disabled for security reasons.\n");
2967 printf(
"See https://root.cern/about/security/#2023-11-26-open-port-for-control-of-web-gui-allows-read-and-write-access-to-file-system for more information.\n");
2968 printf(
"For environments controlling the security issues you can enable web display by calling\n");
2969 printf(
"gROOT->SetWebDisplay(); in ROOT prompt or in startup scripts\n\n");
2971 hname =
"TTreeViewer";
2978 if (
gROOT->IsBatch()) {
2979 if ((hname !=
"RTreeViewer") ||
gROOT->IsWebDisplayBatch()) {
2980 Warning(
"StartViewer",
"The tree viewer cannot run in batch mode");
2985 if (
auto h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualTreeViewer", hname.
Data())) {
2986 if (
h->LoadPlugin() != -1)
3065 TF1* fitfunc = (
TF1*)
gROOT->GetFunction(funcname);
3066 if (!fitfunc) {
Error(
"UnbinnedFit",
"Unknown function: %s",funcname);
return 0; }
3069 if (npar <=0) {
Error(
"UnbinnedFit",
"Illegal number of parameters = %d",npar);
return 0; }
3090 if (!fitOption.
Nograph) drawOpt =
"";
3094 Info(
"UnbinnedFit",
"Ignore option D with more than 4 variables");
3102 Error(
"UnbinnedFit",
"Cannot fit: no entries selected");
3113 std::vector<double *> vlist(ndim);
3114 for (
int i = 0; i < ndim; ++i)
3140 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
static TString R__GetBranchPointerName(TLeaf *leaf, Bool_t replace=kTRUE)
Return the name of the branch pointer needed by MakeClass/MakeSelector.
R__EXTERN Foption_t Foption
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.
Bool_t IsBranchFolder() const
Int_t GetStreamerType() const
TBranchElement * GetBranchCount2() 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.
virtual Long64_t LoadTree(Long64_t entry)
Find the tree which contains entry, and set it as the current tree.
Long64_t * GetTreeOffset() const
virtual TLeaf * GetLeaf(const char *branchname, const char *leafname)
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.
A TEventList object is a list of selected events (entries) in a TTree.
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 a suite of consecutive data records (TKey instances) with a well defined format.
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.
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
@ kNoAxis
NOTE: Must always be 0 !!!
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.
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
virtual Bool_t GetCleanElist() 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 ...
virtual Bool_t Notify()
This function is called at the first entry of a new tree in a chain.
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
Bool_t Notify() override
This method must be overridden to handle object notification.
virtual void ProcessFill(Long64_t)
This method is called for all selected entries.
virtual void Init(TTree *)
virtual int Version() const
virtual Bool_t 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 *)
virtual Bool_t ProcessCut(Long64_t)
This method is called before processing entry.
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...
virtual void UpdateFormulaLeaves()
this function is called by TChain::LoadTree when a new Tree is loaded.
TList * fInput
! input list to the selector
void DeleteSelectorFromFile()
Delete any selector created by this object.
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 Long64_t GetSelectedRows() const
virtual Long64_t GetEntries(const char *selection)
Return the number of entries matching the selection.
TSelectorDraw * fSelector
! Pointer to current selector
virtual Int_t UnbinnedFit(const char *formula, const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Unbinned fit of one or more variable(s) from a Tree.
const char * GetNameByIndex(TString &varexp, Int_t *index, Int_t colindex)
Return name corresponding to colindex in varexp.
virtual ~TTreePlayer()
Tree destructor.
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.
Long64_t fSelectedRows
Number of selected entries.
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)
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.
virtual Int_t MakeCode(const char *filename)
Generate skeleton function for this Tree.
TTree * fTree
! Pointer to current Tree
virtual Int_t MakeClass(const char *classname, Option_t *option)
Generate skeleton analysis class for this Tree.
virtual void SetEstimate(Long64_t n)
Set number of entries to estimate variable limits.
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 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.
virtual Int_t MakeProxy(const char *classname, const char *macrofilename=nullptr, const char *cutfilename=nullptr, const char *option=nullptr, Int_t maxUnrolling=3)
Generate a skeleton analysis class for this Tree using TBranchProxy.
TPrincipal * Principal(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
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
virtual void StartViewer(Int_t ww, Int_t wh)
Start the TTreeViewer on this TTree.
Bool_t fScanRedirect
Switch to redirect TTree::Scan output to a file.
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 Int_t GetDimension() const
TClass * fSelectorClass
! Pointer to the actual class of the TSelectorFromFile
virtual void SetTree(TTree *t)
virtual TVirtualIndex * BuildIndex(const TTree *T, const char *majorname, const char *minorname)
Build the index for the tree (see TTree::BuildIndex)
Int_t fDimension
Dimension of the current expression.
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.
TTreePlayer()
Default Tree constructor.
virtual Int_t MakeReader(const char *classname, Option_t *option)
Generate skeleton selector class for this tree.
virtual void RecursiveRemove(TObject *obj)
cleanup pointers in the player pointing to obj
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.
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.
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.
Bool_t EnableCache()
Enable the TTreeCache unless explicitly disabled for this TTree by a prior call to SetCacheSize(0).
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.
virtual void SetNotify(TObject *obj)
Sets the address of the object to be notified when the tree is loaded.
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)
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.