make_tdset.C

Go to the documentation of this file.
00001 // $Id: make_tdset.C,v 1.9 2007/07/16 09:57:39 rdm Exp $
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    // This script creates a TDSet object that can be used to process
00016    // the files generated with the make_event_trees.C script.
00017    // Conventions for file names made by that script are assumed.
00018    //
00019    // basedir:         location of files local to proof slaves
00020    // files_per_slave: number of files per node
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 }

Generated on Tue Jul 5 15:15:07 2011 for ROOT_528-00b_version by  doxygen 1.5.1