00001
00002
00003
00004
00005 #include "Riostream.h"
00006 #include "TDSet.h"
00007 #include "THashList.h"
00008 #include "TObjString.h"
00009 #include "TMap.h"
00010 #include "TProof.h"
00011
00012
00013 TDSet *make_tdset(const char *basedir, Int_t files_per_node)
00014 {
00015
00016
00017
00018
00019
00020
00021
00022 if (!gProof) {
00023 cout << "Must Start PROOF before using make_tdset.C" << endl;
00024 return 0;
00025 }
00026
00027 if (!basedir) {
00028 cout << "'basedir' must not be empty" << endl;
00029 return 0;
00030 }
00031
00032 if (files_per_node <= 0) {
00033 cout << "files_per_node must be > 0" << endl;
00034 return 0;
00035 }
00036
00037 TList* l = gProof->GetListOfSlaveInfos();
00038 if (!l) {
00039 cout << "No list of workers received!" << endl;
00040 return 0;
00041 }
00042 TIter nxw(l);
00043 TSlaveInfo *si = 0;
00044
00045 THashList nodelist;
00046 nodelist.SetOwner(kFALSE);
00047 while ((si = (TSlaveInfo *) nxw())) {
00048 if (!nodelist.FindObject(si->GetName())) nodelist.Add(new TPair(new TObjString(si->GetName()), si));
00049 }
00050
00051 TDSet *d = new TDSet("TTree","EventTree");
00052 TIter nxu(&nodelist);
00053 TPair *p = 0;
00054 si = 0;
00055 while ((p = (TPair *) nxu())) {
00056 si = (TSlaveInfo *) p->Value();
00057 for (Int_t j = 1; j <= files_per_node ; j++) {
00058 TString filestr;
00059 if (gProof->IsLite()) {
00060 filestr += "file://";
00061 } else {
00062 filestr += "root://";
00063 filestr += si->GetName();
00064 filestr += "/";
00065 }
00066 filestr += basedir;
00067 filestr += "/event_tree_";
00068 filestr += si->GetName();
00069 filestr += "_";
00070 filestr += j;
00071 filestr += ".root";
00072 d->Add(filestr);
00073 }
00074 }
00075
00076 return d;
00077 }