116 gROOT->GetListOfCleanups()->Add(
this);
133 gROOT->GetListOfCleanups()->Remove(
this);
142 if (
dynamic_cast<const TChain*
>(
T)) {
146 Error(
"BuildIndex",
"Creating a TChainIndex unsuccessful - switching to TTreeIndex");
190 if (
tree == 0)
return 0;
195 for (
Int_t i = 0; i < nb; ++i) {
209 if (strlen(selection)) {
211 if (!select || !select->
GetNdim()) {
221 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
223 if (entryNumber < 0)
break;
225 if (localEntry < 0)
break;
233 for(
Int_t current = 0; current<ndata && !keep; current++) {
293 const char *macrofilename,
const char *cutfilename,
296 if (!macrofilename || strlen(macrofilename)==0)
return 0;
302 if (cutfilename && strlen(cutfilename))
308 TString selname = wrapperPrefix;
313 if (aclicMode.
Length()==0) {
314 Warning(
"DrawScript",
"TTreeProxy does not work in interpreted mode yet. The script will be compiled.");
317 selname.
Append(aclicMode);
319 Info(
"DrawScript",
"%s",
Form(
"Will process tree/chain using %s",selname.
Data()));
343 TString possibleFilename = varexp0;
345 if ( dot_pos !=
kNPOS
346 && possibleFilename.
Index(
"Alt$")<0 && possibleFilename.
Index(
"Entries$")<0
347 && possibleFilename.
Index(
"LocalEntries$")<0
348 && possibleFilename.
Index(
"Length$")<0 && possibleFilename.
Index(
"Entry$")<0
349 && possibleFilename.
Index(
"LocalEntry$")<0
350 && possibleFilename.
Index(
"Min$")<0 && possibleFilename.
Index(
"Max$")<0
351 && possibleFilename.
Index(
"MinIf$")<0 && possibleFilename.
Index(
"MaxIf$")<0
352 && possibleFilename.
Index(
"Iteration$")<0 && possibleFilename.
Index(
"Sum$")<0
353 && possibleFilename.
Index(
">")<0 && possibleFilename.
Index(
"<")<0
358 "Drawing using a C++ file currently requires that both the expression and the selection are files\n\t\"%s\" is not a file",
365 possibleFilename = selection;
366 if (possibleFilename.
Index(
"Alt$")<0 && possibleFilename.
Index(
"Entries$")<0
367 && possibleFilename.
Index(
"LocalEntries$")<0
368 && possibleFilename.
Index(
"Length$")<0 && possibleFilename.
Index(
"Entry$")<0
369 && possibleFilename.
Index(
"LocalEntry$")<0
370 && possibleFilename.
Index(
"Min$")<0 && possibleFilename.
Index(
"Max$")<0
371 && possibleFilename.
Index(
"MinIf$")<0 && possibleFilename.
Index(
"MaxIf$")<0
372 && possibleFilename.
Index(
"Iteration$")<0 && possibleFilename.
Index(
"Sum$")<0
373 && possibleFilename.
Index(
">")<0 && possibleFilename.
Index(
"<")<0
377 "Drawing using a C++ file currently requires that both the expression and the selection are files\n\t\"%s\" is not a file",
386 if (evlist && elist){
391 if (cvarexp) cvarexp->
SetTitle(varexp0);
392 if (cselection) cselection->
SetTitle(selection);
409 gROOT->ProcessLineFast(
"new TCanvas();");
446 gPad->DrawFrame(-1.,-1.,1.,1.);
455 Warning(
"DrawSelect",
"The selected TTree subset is empty.");
460 if (
fDimension == 1 && !(optpara||optcandle)) {
465 }
else if (
fDimension == 2 && !(optpara||optcandle)) {
484 }
else if (
fDimension == 3 && !(optpara||optcandle)) {
490 }
else if (action == 33) {
497 if (opt.
Contains(
"same")) noscat -= 4;
505 }
else if (
fDimension == 4 && !(optpara||optcandle)) {
512 for (
Int_t col=0;col<ncolors;col++) {
515 if (draw) pm3d->
Draw();
518 }
else if (
fDimension > 1 && (optpara || optcandle)) {
523 gROOT->ProcessLine(
Form(
"TParallelCoord::SetEntryList((TParallelCoord*)0x%lx,(TEntryList*)0x%lx)",
560 Int_t nch = option ? strlen(option) + 10 : 10;
561 char *opt =
new char[nch];
562 if (option) strlcpy(opt,option,nch-1);
563 else strlcpy(opt,
"goff",5);
568 Int_t fitResult = -1;
593 return s.GetSelectedRows();
606 nentries = lastentry - firstentry + 1;
623 TTHREAD_TLS_DECL(std::string,column);
624 if (colindex<0 )
return "";
626 i1 = index[colindex] + 1;
627 n = index[colindex+1] - i1;
628 column = varexp(i1,
n).
Data();
630 return column.c_str();
647 const char* ltitle = leaf->
GetTitle();
648 if (mother && mother!=branch) {
649 branchname = mother->
GetName();
650 if (branchname[branchname.
Length()-1]!=
'.') {
653 if (strncmp(branchname.
Data(),ltitle,branchname.
Length())==0) {
659 branchname += ltitle;
664 char *bname = (
char*)branchname.
Data();
665 char *twodim = (
char*)strstr(bname,
"[");
666 if (twodim) *twodim = 0;
668 if (*bname ==
'.') *bname=
'_';
669 if (*bname ==
',') *bname=
'_';
670 if (*bname ==
':') *bname=
'_';
671 if (*bname ==
'<') *bname=
'_';
672 if (*bname ==
'>') *bname=
'_';
726 thead.
Form(
"%s.h", classname);
727 FILE *fp = fopen(thead,
"w");
729 Error(
"MakeClass",
"cannot open output file %s", thead.
Data());
733 tcimp.
Form(
"%s.C", classname);
734 FILE *fpc = fopen(tcimp,
"w");
736 Error(
"MakeClass",
"cannot open output file %s", tcimp.
Data());
744 treefile =
"Memory Directory";
759 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
760 fprintf(fp,
"// This class has been automatically generated on\n");
761 fprintf(fp,
"// %s by ROOT version %s\n",td.
AsString(),
gROOT->GetVersion());
764 fprintf(fp,
"// found on file: %s\n",treefile.
Data());
768 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
770 fprintf(fp,
"#ifndef %s_h\n",classname);
771 fprintf(fp,
"#define %s_h\n",classname);
773 fprintf(fp,
"#include <TROOT.h>\n");
774 fprintf(fp,
"#include <TChain.h>\n");
775 fprintf(fp,
"#include <TFile.h>\n");
776 if (isHbook) fprintf(fp,
"#include <THbookFile.h>\n");
777 if (opt.
Contains(
"selector")) fprintf(fp,
"#include <TSelector.h>\n");
781 fprintf(fp,
"\n// Header file for the classes stored in the TTree if any.\n");
784 for (
l=0;
l<nleaves;
l++) {
790 if (declfile && declfile[0]) {
791 static const char *precstl =
"prec_stl/";
792 static const unsigned int precstl_len = strlen(precstl);
793 static const char *rootinclude =
"include/";
794 static const unsigned int rootinclude_len = strlen(rootinclude);
795 if (strncmp(declfile,precstl,precstl_len) == 0) {
796 fprintf(fp,
"#include <%s>\n",declfile+precstl_len);
798 }
else if (strncmp(declfile,
"/usr/include/",13) == 0) {
799 fprintf(fp,
"#include <%s>\n",declfile+strlen(
"/include/c++/"));
800 listOfHeaders.
Add(
new TNamed(cl->
GetName(),declfile+strlen(
"/include/c++/")));
801 }
else if (strstr(declfile,
"/include/c++/") != 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 (strncmp(declfile,rootinclude,rootinclude_len) == 0) {
805 fprintf(fp,
"#include <%s>\n",declfile+rootinclude_len);
808 fprintf(fp,
"#include \"%s\"\n",declfile);
821 for (
l=0;
l<nleaves;
l++) {
835 for (
l=0;
l<nleaves;
l++) {
848 fprintf(fp,
"class %s : public TSelector {\n",classname);
849 fprintf(fp,
"public :\n");
850 fprintf(fp,
" TTree *fChain; //!pointer to the analyzed TTree or TChain\n");
852 fprintf(fp,
"class %s {\n",classname);
853 fprintf(fp,
"public :\n");
854 fprintf(fp,
" TTree *fChain; //!pointer to the analyzed TTree or TChain\n");
855 fprintf(fp,
" Int_t fCurrent; //!current Tree number in a TChain\n");
858 fprintf(fp,
"\n// Fixed size dimensions of array or collections stored in the TTree if any.\n");
860 for (
l=0;
l<nleaves;
l++) {
862 strlcpy(blen,leaf->
GetName(),
sizeof(blen));
865 if (*bname ==
'.') *bname=
'_';
866 if (*bname ==
',') *bname=
'_';
867 if (*bname ==
':') *bname=
'_';
868 if (*bname ==
'<') *bname=
'_';
869 if (*bname ==
'>') *bname=
'_';
873 if (blen[lenb-1] ==
'_') {
876 if (len <= 0) len = 1;
877 fprintf(fp,
" static constexpr Int_t kMax%s = %d;\n",blen,len);
885 fprintf(fp,
"\n // Declaration of leaf types\n");
889 const char *headOK =
" ";
890 const char *headcom =
" //";
892 char branchname[1024];
899 for (
l=0;
l<nleaves;
l++) {
904 len = leaf->
GetLen();
if (len<=0) len = 1;
908 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
909 strlcpy(aprefix,branch->
GetName(),
sizeof(aprefix));
911 else leafStatus[
l] = 1;
914 strlcat(branchname,
".",
sizeof(branchname));
915 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
918 char *dim = (
char*)strstr(branchname,
"[");
if (dim) dim[0] = 0;
921 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
923 char *twodim = (
char*)strstr(leaf->
GetTitle(),
"][");
926 if (*bname ==
'.') *bname=
'_';
927 if (*bname ==
',') *bname=
'_';
928 if (*bname ==
':') *bname=
'_';
929 if (*bname ==
'<') *bname=
'_';
930 if (*bname ==
'>') *bname=
'_';
936 if (!leafobj->
GetClass()) {leafStatus[
l] = 1; head = headcom;}
938 if (leafStatus[
l] == 0) mustInit.
Add(leafobj);
944 strlcpy(blen,leafcount->
GetName(),
sizeof(blen));
947 if (*bname ==
'.') *bname=
'_';
948 if (*bname ==
',') *bname=
'_';
949 if (*bname ==
':') *bname=
'_';
950 if (*bname ==
'<') *bname=
'_';
951 if (*bname ==
'>') *bname=
'_';
955 if (blen[lenb-1] ==
'_') {blen[lenb-1] = 0; kmax = 1;}
956 else snprintf(blen,
sizeof(blen),
"%d",len);
965 fprintf(fp,
" %-15s %s_;\n",
"Int_t", branchname);
969 fprintf(fp,
" %-15s *%s;\n",bre->
GetClassName(), branchname);
977 fprintf(fp,
"%s%-15s *%s;\n",headcom,bre->
GetClassName(), branchname);
979 fprintf(fp,
"%s%-15s *%s;\n",head,bre->
GetClassName(), branchname);
986 fprintf(fp,
"%s%-15s *%s;\n",head,bre->
GetClassName(), branchname);
987 if (leafStatus[
l] == 0) mustInit.
Add(bre);
992 if (!cle) {leafStatus[
l] = 1;
continue;}
995 strlcpy(brename,bre->
GetName(),255);
996 char *bren = brename;
997 char *adot = strrchr(bren,
'.');
998 if (adot) bren = adot+1;
999 char *brack = strchr(bren,
'[');
1000 if (brack) *brack = 0;
1006 if (leafcount) fprintf(fp,
"%s%-15s %s[kMax%s];\n",head,elem->
GetTypeName(), branchname,blen);
1007 else fprintf(fp,
"%s%-15s %s;\n",head,elem->
GetTypeName(), branchname);
1010 fprintf(fp,
"%s%-15s %s;\n",head,bre->
GetClassName(), branchname);
1015 if (strlen(leaf->
GetTypeName()) == 0) {leafStatus[
l] = 1;
continue;}
1026 const char *stars =
" ";
1033 char *dimInName = (
char*) strstr(branchname,
"[");
1034 if ( twodim || dimInName ) {
1036 dimensions = dimInName;
1039 if (twodim) dimensions += (
char*)(twodim+1);
1041 const char* leafcountName = leafcount->
GetName();
1045 strlcpy(b2len,l2->
GetName(),
sizeof(b2len));
1048 if (*bname ==
'.') *bname=
'_';
1049 if (*bname ==
',') *bname=
'_';
1050 if (*bname ==
':') *bname=
'_';
1051 if (*bname ==
'<') *bname=
'_';
1052 if (*bname ==
'>') *bname=
'_';
1055 leafcountName = b2len;
1057 if (dimensions.
Length()) {
1058 if (kmax) fprintf(fp,
" %-14s %s%s[kMax%s]%s; //[%s]\n",leaf->
GetTypeName(), stars,
1059 branchname,blen,dimensions.
Data(),leafcountName);
1060 else fprintf(fp,
" %-14s %s%s[%d]%s; //[%s]\n",leaf->
GetTypeName(), stars,
1061 branchname,len,dimensions.
Data(),leafcountName);
1063 if (kmax) fprintf(fp,
" %-14s %s%s[kMax%s]; //[%s]\n",leaf->
GetTypeName(), stars, branchname,blen,leafcountName);
1064 else fprintf(fp,
" %-14s %s%s[%d]; //[%s]\n",leaf->
GetTypeName(), stars, branchname,len,leafcountName);
1066 if (stars[0]==
'*') {
1068 if (kmax)
n =
new TNamed(branchname,
Form(
"kMax%s",blen));
1073 if (strstr(branchname,
"[")) len = 1;
1074 if (len < 2) fprintf(fp,
" %-15s %s;\n",leaf->
GetTypeName(), branchname);
1076 if (twodim) fprintf(fp,
" %-15s %s%s;\n",leaf->
GetTypeName(), branchname,(
char*)strstr(leaf->
GetTitle(),
"["));
1077 else fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,len);
1084 fprintf(fp,
" // List of branches\n");
1085 for (
l=0;
l<nleaves;
l++) {
1086 if (leafStatus[
l])
continue;
1094 fprintf(fp,
" %s(TTree * /*tree*/ =0) : fChain(0) { }\n",classname) ;
1095 fprintf(fp,
" virtual ~%s() { }\n",classname);
1096 fprintf(fp,
" virtual Int_t Version() const { return 2; }\n");
1097 fprintf(fp,
" virtual void Begin(TTree *tree);\n");
1098 fprintf(fp,
" virtual void SlaveBegin(TTree *tree);\n");
1099 fprintf(fp,
" virtual void Init(TTree *tree);\n");
1100 fprintf(fp,
" virtual Bool_t Notify();\n");
1101 fprintf(fp,
" virtual Bool_t Process(Long64_t entry);\n");
1102 fprintf(fp,
" virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }\n");
1103 fprintf(fp,
" virtual void SetOption(const char *option) { fOption = option; }\n");
1104 fprintf(fp,
" virtual void SetObject(TObject *obj) { fObject = obj; }\n");
1105 fprintf(fp,
" virtual void SetInputList(TList *input) { fInput = input; }\n");
1106 fprintf(fp,
" virtual TList *GetOutputList() const { return fOutput; }\n");
1107 fprintf(fp,
" virtual void SlaveTerminate();\n");
1108 fprintf(fp,
" virtual void Terminate();\n\n");
1109 fprintf(fp,
" ClassDef(%s,0);\n",classname);
1112 fprintf(fp,
"#endif\n");
1116 fprintf(fp,
" %s(TTree *tree=0);\n",classname);
1117 fprintf(fp,
" virtual ~%s();\n",classname);
1118 fprintf(fp,
" virtual Int_t Cut(Long64_t entry);\n");
1119 fprintf(fp,
" virtual Int_t GetEntry(Long64_t entry);\n");
1120 fprintf(fp,
" virtual Long64_t LoadTree(Long64_t entry);\n");
1121 fprintf(fp,
" virtual void Init(TTree *tree);\n");
1122 fprintf(fp,
" virtual void Loop();\n");
1123 fprintf(fp,
" virtual Bool_t Notify();\n");
1124 fprintf(fp,
" virtual void Show(Long64_t entry = -1);\n");
1127 fprintf(fp,
"#endif\n");
1131 fprintf(fp,
"#ifdef %s_cxx\n",classname);
1133 fprintf(fp,
"%s::%s(TTree *tree) : fChain(0) \n",classname,classname);
1135 fprintf(fp,
"// if parameter tree is not specified (or zero), connect the file\n");
1136 fprintf(fp,
"// used to generate this class and read the Tree.\n");
1137 fprintf(fp,
" if (tree == 0) {\n");
1139 fprintf(fp,
"\n#ifdef SINGLE_TREE\n");
1140 fprintf(fp,
" // The following code should be used if you want this class to access\n");
1141 fprintf(fp,
" // a single tree instead of a chain\n");
1144 fprintf(fp,
" THbookFile *f = (THbookFile*)gROOT->GetListOfBrowsables()->FindObject(\"%s\");\n",
1146 fprintf(fp,
" if (!f) {\n");
1147 fprintf(fp,
" f = new THbookFile(\"%s\");\n",treefile.
Data());
1151 fprintf(fp,
" tree = (TTree*)f->Get(%d);\n\n",hid);
1153 fprintf(fp,
" TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(\"%s\");\n",treefile.
Data());
1154 fprintf(fp,
" if (!f || !f->IsOpen()) {\n");
1155 fprintf(fp,
" f = new TFile(\"%s\");\n",treefile.
Data());
1159 fprintf(fp,
" dir->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1161 fprintf(fp,
" f->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1165 fprintf(fp,
"#else // SINGLE_TREE\n\n");
1166 fprintf(fp,
" // The following code should be used if you want this class to access a chain\n");
1167 fprintf(fp,
" // of trees.\n");
1168 fprintf(fp,
" TChain * chain = new TChain(\"%s\",\"%s\");\n",
1175 fprintf(fp,
" chain->Add(\"%s/%s\");\n",element->
GetTitle(),element->
GetName());
1178 fprintf(fp,
" tree = chain;\n");
1179 fprintf(fp,
"#endif // SINGLE_TREE\n\n");
1182 fprintf(fp,
" Init(tree);\n");
1189 fprintf(fp,
"%s::~%s()\n",classname,classname);
1191 fprintf(fp,
" if (!fChain) return;\n");
1195 fprintf(fp,
" delete fChain->GetCurrentFile();\n");
1202 fprintf(fp,
"Int_t %s::GetEntry(Long64_t entry)\n",classname);
1204 fprintf(fp,
"// Read contents of entry.\n");
1206 fprintf(fp,
" if (!fChain) return 0;\n");
1207 fprintf(fp,
" return fChain->GetEntry(entry);\n");
1212 fprintf(fp,
"Long64_t %s::LoadTree(Long64_t entry)\n",classname);
1214 fprintf(fp,
"// Set the environment to read one entry\n");
1215 fprintf(fp,
" if (!fChain) return -5;\n");
1216 fprintf(fp,
" Long64_t centry = fChain->LoadTree(entry);\n");
1217 fprintf(fp,
" if (centry < 0) return centry;\n");
1218 fprintf(fp,
" if (fChain->GetTreeNumber() != fCurrent) {\n");
1219 fprintf(fp,
" fCurrent = fChain->GetTreeNumber();\n");
1220 fprintf(fp,
" Notify();\n");
1222 fprintf(fp,
" return centry;\n");
1228 fprintf(fp,
"void %s::Init(TTree *tree)\n",classname);
1230 fprintf(fp,
" // The Init() function is called when the selector needs to initialize\n"
1231 " // a new tree or chain. Typically here the branch addresses and branch\n"
1232 " // pointers of the tree will be set.\n"
1233 " // It is normally not necessary to make changes to the generated\n"
1234 " // code, but the routine can be extended by the user if needed.\n"
1235 " // Init() will be called many times when running on PROOF\n"
1236 " // (once per file to be processed).\n\n");
1237 if (mustInit.
Last()) {
1238 TIter next(&mustInit);
1240 fprintf(fp,
" // Set object pointer\n");
1241 while( (obj = next()) ) {
1243 strlcpy(branchname,((
TBranch*)obj)->
GetName(),
sizeof(branchname));
1245 strlcpy(branchname,((
TLeaf*)obj)->
GetName(),
sizeof(branchname));
1250 if (*bname ==
'.') *bname=
'_';
1251 if (*bname ==
',') *bname=
'_';
1252 if (*bname ==
':') *bname=
'_';
1253 if (*bname ==
'<') *bname=
'_';
1254 if (*bname ==
'>') *bname=
'_';
1257 fprintf(fp,
" %s = 0;\n",branchname );
1260 if (mustInitArr.
Last()) {
1261 TIter next(&mustInitArr);
1263 fprintf(fp,
" // Set array pointer\n");
1264 while( (info = (
TNamed*)next()) ) {
1265 fprintf(fp,
" for(int i=0; i<%s; ++i) %s[i] = 0;\n",info->
GetTitle(),info->
GetName());
1269 fprintf(fp,
" // Set branch addresses and branch pointers\n");
1270 fprintf(fp,
" if (!tree) return;\n");
1271 fprintf(fp,
" fChain = tree;\n");
1272 if (!opt.
Contains(
"selector")) fprintf(fp,
" fCurrent = -1;\n");
1273 fprintf(fp,
" fChain->SetMakeClass(1);\n");
1275 for (
l=0;
l<nleaves;
l++) {
1276 if (leafStatus[
l])
continue;
1281 strlcpy(aprefix,branch->
GetName(),
sizeof(aprefix));
1285 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1286 strlcat(branchname,
".",
sizeof(branchname));
1287 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1290 char *dim = (
char*)strstr(branchname,
"[");
if (dim) dim[0] = 0;
1293 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1296 if (bre->
GetType() == 3 || bre->
GetType()==4) strlcat(branchname,
"_",
sizeof(branchname));
1300 char *brak = strstr(branchname,
"[");
if (brak) *brak = 0;
1301 char *twodim = (
char*)strstr(bname,
"[");
if (twodim) *twodim = 0;
1303 if (*bname ==
'.') *bname=
'_';
1304 if (*bname ==
',') *bname=
'_';
1305 if (*bname ==
':') *bname=
'_';
1306 if (*bname ==
'<') *bname=
'_';
1307 if (*bname ==
'>') *bname=
'_';
1310 const char *maybedisable =
"";
1312 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());
1313 maybedisable =
"// ";
1320 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1326 if (leafcount) len = leafcount->
GetMaximum()+1;
1327 if (len > 1) fprintf(fp,
"%s fChain->SetBranchAddress(\"%s\", %s, &b_%s);\n",
1329 else fprintf(fp,
"%s fChain->SetBranchAddress(\"%s\", &%s, &b_%s);\n",
1334 fprintf(fp,
" Notify();\n");
1341 fprintf(fp,
"Bool_t %s::Notify()\n",classname);
1343 fprintf(fp,
" // The Notify() function is called when a new file is opened. This\n"
1344 " // can be either for a new TTree in a TChain or when when a new TTree\n"
1345 " // is started when using PROOF. It is normally not necessary to make changes\n"
1346 " // to the generated code, but the routine can be extended by the\n"
1347 " // user if needed. The return value is currently not used.\n\n");
1348 fprintf(fp,
" return kTRUE;\n");
1354 fprintf(fp,
"void %s::Show(Long64_t entry)\n",classname);
1356 fprintf(fp,
"// Print contents of entry.\n");
1357 fprintf(fp,
"// If entry is not specified, print current entry\n");
1359 fprintf(fp,
" if (!fChain) return;\n");
1360 fprintf(fp,
" fChain->Show(entry);\n");
1365 fprintf(fp,
"Int_t %s::Cut(Long64_t entry)\n",classname);
1367 fprintf(fp,
"// This function may be called from Loop.\n");
1368 fprintf(fp,
"// returns 1 if entry is accepted.\n");
1369 fprintf(fp,
"// returns -1 otherwise.\n");
1371 fprintf(fp,
" return 1;\n");
1374 fprintf(fp,
"#endif // #ifdef %s_cxx\n",classname);
1379 fprintf(fpc,
"#define %s_cxx\n",classname);
1380 fprintf(fpc,
"#include \"%s\"\n",thead.
Data());
1381 fprintf(fpc,
"#include <TH2.h>\n");
1382 fprintf(fpc,
"#include <TStyle.h>\n");
1383 fprintf(fpc,
"#include <TCanvas.h>\n");
1385 fprintf(fpc,
"void %s::Loop()\n",classname);
1387 fprintf(fpc,
"// In a ROOT session, you can do:\n");
1388 fprintf(fpc,
"// root> .L %s.C\n",classname);
1389 fprintf(fpc,
"// root> %s t\n",classname);
1390 fprintf(fpc,
"// root> t.GetEntry(12); // Fill t data members with entry number 12\n");
1391 fprintf(fpc,
"// root> t.Show(); // Show values of entry 12\n");
1392 fprintf(fpc,
"// root> t.Show(16); // Read and show values of entry 16\n");
1393 fprintf(fpc,
"// root> t.Loop(); // Loop on all entries\n");
1394 fprintf(fpc,
"//\n");
1395 fprintf(fpc,
"\n// This is the loop skeleton where:\n");
1396 fprintf(fpc,
"// jentry is the global entry number in the chain\n");
1397 fprintf(fpc,
"// ientry is the entry number in the current Tree\n");
1398 fprintf(fpc,
"// Note that the argument to GetEntry must be:\n");
1399 fprintf(fpc,
"// jentry for TChain::GetEntry\n");
1400 fprintf(fpc,
"// ientry for TTree::GetEntry and TBranch::GetEntry\n");
1401 fprintf(fpc,
"//\n");
1402 fprintf(fpc,
"// To read only selected branches, Insert statements like:\n");
1403 fprintf(fpc,
"// METHOD1:\n");
1404 fprintf(fpc,
"// fChain->SetBranchStatus(\"*\",0); // disable all branches\n");
1405 fprintf(fpc,
"// fChain->SetBranchStatus(\"branchname\",1); // activate branchname\n");
1406 fprintf(fpc,
"// METHOD2: replace line\n");
1407 fprintf(fpc,
"// fChain->GetEntry(jentry); //read all branches\n");
1408 fprintf(fpc,
"//by b_branchname->GetEntry(ientry); //read only this branch\n");
1409 fprintf(fpc,
" if (fChain == 0) return;\n");
1410 fprintf(fpc,
"\n Long64_t nentries = fChain->GetEntriesFast();\n");
1411 fprintf(fpc,
"\n Long64_t nbytes = 0, nb = 0;\n");
1412 fprintf(fpc,
" for (Long64_t jentry=0; jentry<nentries;jentry++) {\n");
1413 fprintf(fpc,
" Long64_t ientry = LoadTree(jentry);\n");
1414 fprintf(fpc,
" if (ientry < 0) break;\n");
1415 fprintf(fpc,
" nb = fChain->GetEntry(jentry); nbytes += nb;\n");
1416 fprintf(fpc,
" // if (Cut(ientry) < 0) continue;\n");
1417 fprintf(fpc,
" }\n");
1422 fprintf(fpc,
"#define %s_cxx\n",classname);
1423 fprintf(fpc,
"// The class definition in %s.h has been generated automatically\n",classname);
1424 fprintf(fpc,
"// by the ROOT utility TTree::MakeSelector(). This class is derived\n");
1425 fprintf(fpc,
"// from the ROOT class TSelector. For more information on the TSelector\n"
1426 "// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.\n\n");
1427 fprintf(fpc,
"// The following methods are defined in this file:\n");
1428 fprintf(fpc,
"// Begin(): called every time a loop on the tree starts,\n");
1429 fprintf(fpc,
"// a convenient place to create your histograms.\n");
1430 fprintf(fpc,
"// SlaveBegin(): called after Begin(), when on PROOF called only on the\n"
1431 "// slave servers.\n");
1432 fprintf(fpc,
"// Process(): called for each event, in this function you decide what\n");
1433 fprintf(fpc,
"// to read and fill your histograms.\n");
1434 fprintf(fpc,
"// SlaveTerminate: called at the end of the loop on the tree, when on PROOF\n"
1435 "// called only on the slave servers.\n");
1436 fprintf(fpc,
"// Terminate(): called at the end of the loop on the tree,\n");
1437 fprintf(fpc,
"// a convenient place to draw/fit your histograms.\n");
1438 fprintf(fpc,
"//\n");
1439 fprintf(fpc,
"// To use this file, try the following session on your Tree T:\n");
1440 fprintf(fpc,
"//\n");
1441 fprintf(fpc,
"// root> T->Process(\"%s.C\")\n",classname);
1442 fprintf(fpc,
"// root> T->Process(\"%s.C\",\"some options\")\n",classname);
1443 fprintf(fpc,
"// root> T->Process(\"%s.C+\")\n",classname);
1444 fprintf(fpc,
"//\n\n");
1445 fprintf(fpc,
"#include \"%s\"\n",thead.
Data());
1446 fprintf(fpc,
"#include <TH2.h>\n");
1447 fprintf(fpc,
"#include <TStyle.h>\n");
1451 fprintf(fpc,
"void %s::Begin(TTree * /*tree*/)\n",classname);
1453 fprintf(fpc,
" // The Begin() function is called at the start of the query.\n");
1454 fprintf(fpc,
" // When running with PROOF Begin() is only called on the client.\n");
1455 fprintf(fpc,
" // The tree argument is deprecated (on PROOF 0 is passed).\n");
1457 fprintf(fpc,
" TString option = GetOption();\n");
1462 fprintf(fpc,
"void %s::SlaveBegin(TTree * /*tree*/)\n",classname);
1464 fprintf(fpc,
" // The SlaveBegin() function is called after the Begin() function.\n");
1465 fprintf(fpc,
" // When running with PROOF SlaveBegin() is called on each slave server.\n");
1466 fprintf(fpc,
" // The tree argument is deprecated (on PROOF 0 is passed).\n");
1468 fprintf(fpc,
" TString option = GetOption();\n");
1473 fprintf(fpc,
"Bool_t %s::Process(Long64_t entry)\n",classname);
1475 fprintf(fpc,
" // The Process() function is called for each entry in the tree (or possibly\n"
1476 " // keyed object in the case of PROOF) to be processed. The entry argument\n"
1477 " // specifies which entry in the currently loaded tree is to be processed.\n"
1478 " // It can be passed to either %s::GetEntry() or TBranch::GetEntry()\n"
1479 " // to read either all or the required parts of the data. When processing\n"
1480 " // keyed objects with PROOF, the object is already loaded and is available\n"
1481 " // via the fObject pointer.\n"
1483 " // This function should contain the \"body\" of the analysis. It can contain\n"
1484 " // simple or elaborate selection criteria, run algorithms on the data\n"
1485 " // of the event and typically fill histograms.\n"
1487 " // The processing can be stopped by calling Abort().\n"
1489 " // Use fStatus to set the return value of TTree::Process().\n"
1491 " // The return value is currently not used.\n\n", classname);
1493 fprintf(fpc,
" return kTRUE;\n");
1497 fprintf(fpc,
"void %s::SlaveTerminate()\n",classname);
1499 fprintf(fpc,
" // The SlaveTerminate() function is called after all entries or objects\n"
1500 " // have been processed. When running with PROOF SlaveTerminate() is called\n"
1501 " // on each slave server.");
1507 fprintf(fpc,
"void %s::Terminate()\n",classname);
1509 fprintf(fpc,
" // The Terminate() function is the last function to be called during\n"
1510 " // a query. It always runs on the client, it can be used to present\n"
1511 " // the results graphically or save the results to file.");
1517 delete [] leafStatus;
1555 FILE *fp = fopen(tfile,
"w");
1557 Error(
"MakeCode",
"cannot open output file %s", tfile.
Data());
1564 treefile =
"Memory Directory";
1576 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
1577 fprintf(fp,
"// This file has been automatically generated \n");
1578 fprintf(fp,
"// (%s by ROOT version%s)\n",td.
AsString(),
gROOT->GetVersion());
1581 fprintf(fp,
"// found on file: %s\n",treefile.
Data());
1585 fprintf(fp,
"//////////////////////////////////////////////////////////\n");
1591 fprintf(fp,
"//Reset ROOT and connect tree file\n");
1592 fprintf(fp,
" gROOT->Reset();\n");
1594 fprintf(fp,
"\n#ifdef SINGLE_TREE\n");
1595 fprintf(fp,
" // The following code should be used if you want this code to access\n");
1596 fprintf(fp,
" // a single tree instead of a chain\n");
1598 fprintf(fp,
" TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(\"%s\");\n",treefile.
Data());
1599 fprintf(fp,
" if (!f) {\n");
1600 fprintf(fp,
" f = new TFile(\"%s\");\n",treefile.
Data());
1604 fprintf(fp,
" dir->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1606 fprintf(fp,
" f->GetObject(\"%s\",tree);\n\n",
fTree->
GetName());
1609 fprintf(fp,
"#else // SINGLE_TREE\n\n");
1610 fprintf(fp,
" // The following code should be used if you want this code to access a chain\n");
1611 fprintf(fp,
" // of trees.\n");
1612 fprintf(fp,
" TChain *%s = new TChain(\"%s\",\"%s\");\n",
1622 fprintf(fp,
"#endif // SINGLE_TREE\n\n");
1626 fprintf(fp,
"//Declaration of leaves types\n");
1631 const char *headOK =
" ";
1632 const char *headcom =
" //";
1634 char branchname[1024];
1635 for (
l=0;
l<nleaves;
l++) {
1644 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1645 strlcat(branchname,
".",
sizeof(branchname));
1646 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1649 char *dim = (
char*)strstr(branchname,
"[");
1650 if (dim) dim[0] = 0;
1653 if (leafcount) strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1654 else strlcpy(branchname,leaf->
GetTitle(),
sizeof(branchname));
1656 char *twodim = (
char*)strstr(leaf->
GetTitle(),
"][");
1659 if (*bname ==
'.') *bname=
'_';
1660 if (*bname ==
',') *bname=
'_';
1661 if (*bname ==
':') *bname=
'_';
1662 if (*bname ==
'<') *bname=
'_';
1663 if (*bname ==
'>') *bname=
'_';
1668 if (leafobj->
GetClass()) head = headOK;
1669 else head = headcom;
1677 char *dimInName = (
char*) strstr(branchname,
"[");
1679 if ( twodim || dimInName ) {
1681 dimensions = dimInName;
1684 if (twodim) dimensions += (
char*)(twodim+1);
1686 if (dimensions.
Length()) {
1687 fprintf(fp,
" %-15s %s[%d]%s;\n",leaf->
GetTypeName(), branchname,len,dimensions.
Data());
1689 fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,len);
1692 if (strstr(branchname,
"[")) len = 1;
1693 if (len < 2) fprintf(fp,
" %-15s %s;\n",leaf->
GetTypeName(), branchname);
1694 else fprintf(fp,
" %-15s %s[%d];\n",leaf->
GetTypeName(), branchname,len);
1699 fprintf(fp,
"\n // Set branch addresses.\n");
1700 for (
l=0;
l<nleaves;
l++) {
1708 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1709 strlcat(branchname,
".",
sizeof(branchname));
1710 strlcat(branchname,leaf->
GetTitle(),
sizeof(branchname));
1713 char *dim = (
char*)strstr(branchname,
"[");
1714 if (dim) dim[0] = 0;
1717 if (leafcount) strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1718 else strlcpy(branchname,leaf->
GetTitle(),
sizeof(branchname));
1722 if (*bname ==
'.') *bname=
'_';
1723 if (*bname ==
',') *bname=
'_';
1724 if (*bname ==
':') *bname=
'_';
1725 if (*bname ==
'<') *bname=
'_';
1726 if (*bname ==
'>') *bname=
'_';
1729 char *brak = strstr(branchname,
"[");
1730 if (brak) *brak = 0;
1733 strlcpy(branchname,branch->
GetName(),
sizeof(branchname));
1735 if (!leafobj->
GetClass()) head = headcom;
1737 if (leafcount) len = leafcount->
GetMaximum()+1;
1738 if (len > 1 || brak) fprintf(fp,
"%s%s->SetBranchAddress(\"%s\",%s);\n",head,
fTree->
GetName(),branch->
GetName(),branchname);
1739 else fprintf(fp,
"%s%s->SetBranchAddress(\"%s\",&%s);\n",head,
fTree->
GetName(),branch->
GetName(),branchname);
1743 fprintf(fp,
"\n// This is the loop skeleton\n");
1744 fprintf(fp,
"// To read only selected branches, Insert statements like:\n");
1745 fprintf(fp,
"// %s->SetBranchStatus(\"*\",0); // disable all branches\n",
fTree->
GetName());
1746 fprintf(fp,
"// %s->SetBranchStatus(\"branchname\",1); // activate branchname\n",
GetName());
1747 fprintf(fp,
"\n Long64_t nentries = %s->GetEntries();\n",
fTree->
GetName());
1748 fprintf(fp,
"\n Long64_t nbytes = 0;\n");
1749 fprintf(fp,
"// for (Long64_t i=0; i<nentries;i++) {\n");
1750 fprintf(fp,
"// nbytes += %s->GetEntry(i);\n",
fTree->
GetName());
1751 fprintf(fp,
"// }\n");
1754 printf(
"Macro: %s generated from Tree: %s\n",tfile.
Data(),
fTree->
GetName());
1913 const char *macrofilename,
const char *cutfilename,
1914 const char *option,
Int_t maxUnrolling)
1916 if (macrofilename==0 || strlen(macrofilename)==0 ) {
1918 Error(
"MakeProxy",
"A file name for the user script is required");
2005 std::vector<TString> cnames;
2014 if (nleaves < ncols) ncols = nleaves;
2015 nch = varexp ? strlen(varexp) : 0;
2021 if (strlen(selection)) {
2029 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2030 if (nch == 0 || allvar) {
2031 for (i=0;i<ncols;i++) {
2032 cnames.push_back( ((
TLeaf*)leaves->
At(i))->GetName() );
2042 for (i=0;i<ncols;i++) {
2064 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2066 if (entryNumber < 0)
break;
2068 if (localEntry < 0)
break;
2078 for(
int inst=0;inst<ndata;inst++) {
2086 if (inst==0) loaded =
kTRUE;
2090 for (i=0;i<ncols;i++) {
2096 for (i=0;i<ncols;i++) {
2193 if (!selector)
return -1;
2267 if (!
gROOT->IsBatch() && interval)
2271 Long64_t entry, entryNumber, localEntry;
2285 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2287 if (entryNumber < 0)
break;
2289 if (
gROOT->IsInterrupted())
break;
2291 if (localEntry < 0)
break;
2296 selector->
Process(localEntry);
2433 UInt_t colDefaultSize = 9;
2435 std::vector<TString> colFormats;
2436 std::vector<Int_t> colSizes;
2439 int start = opt.
Index(
"lenmax=");
2440 int numpos = start + strlen(
"lenmax=");
2443 while( (numpos+numlen<len) && isdigit(opt[numpos+numlen]) ) numlen++;
2444 TString num = opt(numpos,numlen);
2445 opt.
Remove(start,strlen(
"lenmax")+numlen);
2447 lenmax = atoi(num.
Data());
2450 int start = opt.
Index(
"colsize=");
2451 int numpos = start + strlen(
"colsize=");
2454 while( (numpos+numlen<len) && isdigit(opt[numpos+numlen]) ) numlen++;
2455 TString num = opt(numpos,numlen);
2456 opt.
Remove(start,strlen(
"size")+numlen);
2458 colDefaultSize = atoi(num.
Data());
2459 colPrecision = colDefaultSize;
2460 if (colPrecision>18) colPrecision = 18;
2463 int start = opt.
Index(
"precision=");
2464 int numpos = start + strlen(
"precision=");
2467 while( (numpos+numlen<len) && isdigit(opt[numpos+numlen]) ) numlen++;
2468 TString num = opt(numpos,numlen);
2469 opt.
Remove(start,strlen(
"precision")+numlen);
2471 colPrecision = atoi(num.
Data());
2473 TString defFormat =
Form(
"%d.%d",colDefaultSize,colPrecision);
2475 int start = opt.
Index(
"col=");
2476 int numpos = start + strlen(
"col=");
2479 while( (numpos+numlen<len) &&
2480 (isdigit(opt[numpos+numlen])
2481 || opt[numpos+numlen] ==
'c'
2482 || opt[numpos+numlen] ==
'd'
2483 || opt[numpos+numlen] ==
'i'
2484 || opt[numpos+numlen] ==
'o'
2485 || opt[numpos+numlen] ==
'x'
2486 || opt[numpos+numlen] ==
'X'
2487 || opt[numpos+numlen] ==
'u'
2488 || opt[numpos+numlen] ==
'f'
2489 || opt[numpos+numlen] ==
'e'
2490 || opt[numpos+numlen] ==
'E'
2491 || opt[numpos+numlen] ==
'g'
2492 || opt[numpos+numlen] ==
'G'
2493 || opt[numpos+numlen] ==
'l'
2494 || opt[numpos+numlen] ==
'L'
2495 || opt[numpos+numlen] ==
'h'
2496 || opt[numpos+numlen] ==
's'
2497 || opt[numpos+numlen] ==
'#'
2498 || opt[numpos+numlen]==
'.'
2499 || opt[numpos+numlen]==
':')) numlen++;
2500 TString flist = opt(numpos,numlen);
2501 opt.
Remove(start,strlen(
"col")+numlen);
2504 while(i<flist.
Length() && flist[i]==
':') {
2505 colFormats.push_back(defFormat);
2506 colSizes.push_back(colDefaultSize);
2509 for(; i<flist.
Length(); ++i) {
2510 int next = flist.
Index(
":",i);
2512 colFormats.push_back(defFormat);
2513 }
else if (next==
kNPOS) {
2514 colFormats.push_back(flist(i,flist.
Length()-i));
2517 colFormats.push_back(flist(i,next-i));
2520 UInt_t siz = atoi(colFormats[colFormats.size()-1].Data());
2521 colSizes.push_back( siz ? siz : colDefaultSize );
2526 std::vector<TString> cnames;
2532 const char *fname =
nullptr;
2537 if (!fname) fname =
"";
2538 Int_t lenfile = strlen(fname);
2541 fownname.
Append(
"-scan.dat");
2542 fname = fownname.
Data();
2544 out.open(fname, std::ios::out);
2546 Error(
"Scan",
"Can not open file for redirection");
2551 if (leaves==0)
return 0;
2553 if (nleaves < ncols) ncols = nleaves;
2554 nch = varexp ? strlen(varexp) : 0;
2560 if (selection && strlen(selection)) {
2562 if (!select)
return -1;
2563 if (!select->
GetNdim()) {
delete select;
return -1; }
2568 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2569 if (nch == 0 || allvar) {
2572 for (ui=0;ui<ncs;++ui) {
2576 if (cnames[ncols] == lf->
GetName() ) {
2578 }
else if (cnames[ncols][cnames[ncols].Length()-1]==
'.') {
2591 cnames[ncols].Append(
'.');
2597 cnames[ncols].Append(
'.');
2598 cnames[ncols].Append( lf->
GetName() );
2610 for(ui=colFormats.size();ui<ncols;++ui) {
2611 colFormats.push_back(defFormat);
2612 colSizes.push_back(colDefaultSize);
2616 for (ui=0;ui<ncols;ui++) {
2654 onerow =
"***********";
2655 if (hasArray) onerow +=
"***********";
2657 for (ui=0;ui<ncols;ui++) {
2658 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2662 out<<onerow.
Data()<<
"*"<<std::endl;
2664 printf(
"%s*\n",onerow.
Data());
2666 if (hasArray) onerow +=
"* Instance ";
2667 for (ui=0;ui<ncols;ui++) {
2668 TString numbFormat =
Form(
"* %%%d.%ds ",colSizes[ui],colSizes[ui]);
2672 out<<onerow.
Data()<<
"*"<<std::endl;
2674 printf(
"%s*\n",onerow.
Data());
2675 onerow =
"***********";
2676 if (hasArray) onerow +=
"***********";
2677 for (ui=0;ui<ncols;ui++) {
2678 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2682 out<<onerow.
Data()<<
"*"<<std::endl;
2684 printf(
"%s*\n",onerow.
Data());
2689 for (entry=firstentry;
2690 entry<(firstentry+
nentries) && !exitloop;
2693 if (entryNumber < 0)
break;
2695 if (localEntry < 0)
break;
2716 for (ui=0;ui<ncols;ui++) {
2717 if (ndata < var[ui]->GetNdata() ) {
2721 if (select && select->
GetNdata()==0) ndata = 0;
2726 if (lenmax && ndata>(
int)lenmax) ndata = lenmax;
2728 for(
int inst=0;inst<ndata;inst++) {
2734 if (inst==0) loaded =
kTRUE;
2738 for (ui=0;ui<ncols;ui++) {
2743 onerow =
Form(
"* %8lld ",entryNumber);
2745 onerow +=
Form(
"* %8d ",inst);
2747 for (ui=0;ui<ncols;++ui) {
2748 TString numbFormat =
Form(
"* %%%d.%ds ",colSizes[ui],colSizes[ui]);
2749 if (var[ui]->GetNdim()) onerow +=
Form(numbFormat.
Data(),var[ui]->
PrintValue(0,inst,colFormats[ui].Data()));
2751 TString emptyForm =
Form(
"* %%%dc ",colSizes[ui]);
2752 onerow +=
Form(emptyForm.
Data(),
' ');
2757 out<<onerow.
Data()<<
"*"<<std::endl;
2759 printf(
"%s*\n",onerow.
Data());
2762 fprintf(stderr,
"Type <CR> to continue or q to quit ==> ");
2766 while (readch !=
'\n' && readch != EOF) readch = getchar();
2767 if (answer ==
'q' || answer ==
'Q') {
2775 onerow =
"***********";
2776 if (hasArray) onerow +=
"***********";
2777 for (ui=0;ui<ncols;ui++) {
2778 TString starFormat =
Form(
"*%%%d.%ds",colSizes[ui]+2,colSizes[ui]+2);
2782 out<<onerow.
Data()<<
"*"<<std::endl;
2784 printf(
"%s*\n",onerow.
Data());
2807 std::vector<TString> cnames;
2814 if (nleaves < ncols) ncols = nleaves;
2815 nch = varexp ? strlen(varexp) : 0;
2821 if (strlen(selection)) {
2823 if (!select)
return 0;
2824 if (!select->
GetNdim()) {
delete select;
return 0; }
2830 if (varexp && !strcmp(varexp,
"*")) { ncols = nleaves; allvar = 1; }
2831 if (nch == 0 || allvar) {
2832 for (i=0;i<ncols;i++) {
2833 cnames.push_back( ((
TLeaf*)leaves->
At(i))->GetName() );
2842 for (i=0;i<ncols;i++) {
2849 for (i = 0; i < ncols; i++) {
2850 res->
AddField(i, var[i]->PrintValue(-1));
2864 const char *aresult;
2866 char *arow =
new char[ncols*50];
2870 for (entry=firstentry;entry<firstentry+
nentries;entry++) {
2872 if (entryNumber < 0)
break;
2874 if (localEntry < 0)
break;
2891 for(
int inst=0;inst<ndata;inst++) {
2898 if (inst==0) loaded =
kTRUE;
2902 for (i=0;i<ncols;i++) {
2907 for (i=0;i<ncols;i++) {
2909 len = strlen(aresult)+1;
2911 memcpy(arow,aresult,len);
2914 memcpy(arow+fields[i-1],aresult,len);
2915 fields[i] = fields[i-1] + len;
2949 if (
gROOT->IsBatch()) {
2950 Warning(
"StartViewer",
"viewer cannot run in batch mode");
2956 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TVirtualTreeViewer"))) {
2957 if (
h->LoadPlugin() == -1)
3037 TF1* fitfunc = (
TF1*)
gROOT->GetFunction(funcname);
3038 if (!fitfunc) {
Error(
"UnbinnedFit",
"Unknown function: %s",funcname);
return 0; }
3041 if (npar <=0) {
Error(
"UnbinnedFit",
"Illegal number of parameters = %d",npar);
return 0; }
3062 if (!fitOption.
Nograph) drawOpt =
"";
3066 Info(
"UnbinnedFit",
"Ignore option D with more than 4 variables");
3074 Error(
"UnbinnedFit",
"Cannot fit: no entries selected");
3085 std::vector<double *> vlist(ndim);
3086 for (
int i = 0; i < ndim; ++i)
3112 for (
Int_t bin=1;bin<=nbins;bin++) {
R__EXTERN TVirtualMutex * gROOTMutex
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
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 unbinned data sets (just x coordinates values) of any dimensions.
const char * GetFileName()
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.
virtual const char * GetClassName() const
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()
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,...
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).
Small helper to keep current directory context.
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
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...
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.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
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.
@ kNoAxis
NOTE: Must always be 0 !!!
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 Draw(Option_t *option="")
Draw this histogram with options.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
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
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
virtual void Add(TObject *obj)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual TObjLink * FirstLink() const
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual void Clear(Option_t *option="")
Remove all objects from the list.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Int_t GetEntriesFast() const
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
Int_t GetEntries() const
Return the number of objects in array (i.e.
TObject * UncheckedAt(Int_t i) const
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
TObject * At(Int_t idx) const
Wrapper around a TObject so it can be stored in a TList.
TObject * GetObject() const
Collectable string class.
const char * GetName() const
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.
R__ALWAYS_INLINE Bool_t IsZombie() const
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.
virtual void Draw(Option_t *option="")
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
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
virtual Int_t GetAction() const
TTreeFormula * GetVar1() const
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.
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)
virtual void Init(TTree *)
virtual int Version() const
virtual Bool_t Process(Long64_t)
virtual void SlaveBegin(TTree *)
virtual Bool_t ProcessCut(Long64_t)
virtual void SetOption(const char *option)
virtual Long64_t GetStatus() const
virtual void SetInputList(TList *input)
virtual TList * GetOutputList() const
virtual Bool_t Notify()
This method must be overridden to handle object notification.
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
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.
virtual Int_t MakeProxy(const char *classname, const char *macrofilename=0, const char *cutfilename=0, const char *option=0, Int_t maxUnrolling=3)
Generate a skeleton analysis class for this Tree using TBranchProxy.
TList * fInput
Pointer to the actual class of the TSelectorFromFile.
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 histogram used for the projection.
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)
Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves funct...
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.
TSelector * fSelectorFromFile
Pointer to current selector.
const char * fScanFileName
TList * fFormulaList
input list to the selector
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.
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.
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
Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
virtual void StartViewer(Int_t ww, Int_t wh)
Start the TTreeViewer on this TTree.
Bool_t fScanRedirect
Pointer to current Tree.
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 a user defined selector created by this TTreePlayer object.
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)
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 Long64_t GetEstimate() const
virtual TObjArray * GetListOfLeaves()
TFile * GetCurrentFile() const
Return pointer to the current file.
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.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
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 void Draw(Option_t *opt)
Default Draw method for all objects.
virtual Int_t GetTimerInterval() const
virtual void SetScanField(Int_t n=50)
virtual Long64_t GetCacheSize() const
virtual Int_t SetCacheSize(Long64_t cachesize=-1)
Set maximum size of the file cache .
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.
Type GetType(const std::string &Name)
static constexpr double s
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)