TDSet.h

Go to the documentation of this file.
00001 // @(#)root/proof:$Id: TDSet.h 34416 2010-07-14 15:39:20Z ganis $
00002 // Author: Fons Rademakers   11/01/02
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TDSet
00013 #define ROOT_TDSet
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TDSet                                                                //
00019 //                                                                      //
00020 // This class implements a data set to be used for PROOF processing.    //
00021 // The TDSet defines the class of which objects will be processed,      //
00022 // the directory in the file where the objects of that type can be      //
00023 // found and the list of files to be processed. The files can be        //
00024 // specified as logical file names (LFN's) or as physical file names    //
00025 // (PFN's). In case of LFN's the resolution to PFN's will be done       //
00026 // according to the currently active GRID interface.                    //
00027 // Examples:                                                            //
00028 //   TDSet treeset("TTree", "AOD");                                     //
00029 //   treeset.Add("lfn:/alien.cern.ch/alice/prod2002/file1");            //
00030 //   ...                                                                //
00031 //   treeset.AddFriend(friendset);                                      //
00032 //                                                                      //
00033 // or                                                                   //
00034 //                                                                      //
00035 //   TDSet objset("MyEvent", "*", "/events");                           //
00036 //   objset.Add("root://cms.cern.ch/user/prod2002/hprod_1.root");       //
00037 //   ...                                                                //
00038 //   objset.Add(set2003);                                               //
00039 //                                                                      //
00040 // Validity of file names will only be checked at processing time       //
00041 // (typically on the PROOF master server), not at creation time.        //
00042 //                                                                      //
00043 //////////////////////////////////////////////////////////////////////////
00044 
00045 #ifndef ROOT_TNamed
00046 #include "TNamed.h"
00047 #endif
00048 
00049 class TChain;
00050 class TCollection;
00051 class TCut;
00052 class TDSet;
00053 class TEventList;
00054 class TEntryList;
00055 class TFileInfo;
00056 class THashList;
00057 class TIter;
00058 class TList;
00059 class TProof;
00060 class TProofChain;
00061 class TTree;
00062 
00063 // For backward compatibility (handle correctly requests from old clients)
00064 #include <set>
00065 #include <list>
00066 
00067 class TDSetElement : public TNamed {
00068 public:
00069    typedef  std::list<std::pair<TDSetElement*, TString> > FriendsList_t;
00070    // TDSetElement status bits
00071    enum EStatusBits {
00072       kHasBeenLookedUp = BIT(15),
00073       kWriteV3         = BIT(16),
00074       kEmpty           = BIT(17),
00075       kCorrupted       = BIT(18),
00076       kNewRun          = BIT(19),
00077       kNewPacket       = BIT(20)
00078    };
00079 
00080 private:
00081    TString          fDirectory;  // directory in file where to look for objects
00082    Long64_t         fFirst;      // first entry to process
00083    Long64_t         fNum;        // number of entries to process
00084    TString          fMsd;        // mass storage domain name
00085    Long64_t         fTDSetOffset;// the global offset in the TDSet of the first
00086                                  // entry in this element
00087    TObject         *fEntryList;  // entry (or event) list to be used in processing
00088    Bool_t           fValid;      // whether or not the input values are valid
00089    Long64_t         fEntries;    // total number of possible entries in file
00090    TList           *fFriends;    // friend elements
00091 
00092    TString          fDataSet;    // Name of the dataset of which this element is part
00093    TList           *fAssocObjList;  // List of objects associated to this element
00094                                    // (e.g. TObjString describing associated files)
00095 
00096    Bool_t           HasBeenLookedUp() const { return TestBit(kHasBeenLookedUp); }
00097 
00098    TDSetElement& operator=(const TDSetElement &); // Not implemented
00099 
00100 public:
00101    TDSetElement();
00102    TDSetElement(const char *file, const char *objname = 0,
00103                 const char *dir = 0, Long64_t first = 0, Long64_t num = -1,
00104                 const char *msd = 0, const char *dataset = 0);
00105    TDSetElement(const TDSetElement& elem);
00106    virtual ~TDSetElement();
00107 
00108    virtual TList   *GetListOfFriends() const { return fFriends; }
00109    virtual void     AddFriend(TDSetElement *friendElement, const char *alias);
00110    virtual void     DeleteFriends();
00111    const char      *GetFileName() const { return GetName(); }
00112    Long64_t         GetFirst() const { return fFirst; }
00113    void             SetFirst(Long64_t first) { fFirst = first; }
00114    Long64_t         GetNum() const { return fNum; }
00115    Long64_t         GetEntries(Bool_t istree = kTRUE, Bool_t openfile = kTRUE);
00116    void             SetEntries(Long64_t ent) { fEntries = ent; }
00117    const char      *GetMsd() const { return fMsd; }
00118    void             SetNum(Long64_t num) { fNum = num; }
00119    Bool_t           GetValid() const { return fValid; }
00120    const char      *GetObjName() const { return GetTitle(); }
00121    const char      *GetDirectory() const;
00122    const char      *GetDataSet() const { return fDataSet; }
00123    void             SetDataSet(const char *dataset) { fDataSet = dataset; }
00124    void             AddAssocObj(TObject *assocobj);
00125    TList           *GetListOfAssocObjs() const { return fAssocObjList; }
00126    TObject         *GetAssocObj(Long64_t i, Bool_t isentry = kFALSE);
00127    void             Print(Option_t *options="") const;
00128    Long64_t         GetTDSetOffset() const { return fTDSetOffset; }
00129    void             SetTDSetOffset(Long64_t offset) { fTDSetOffset = offset; }
00130    void             SetEntryList(TObject *aList, Long64_t first = -1, Long64_t num = -1);
00131    TObject         *GetEntryList() const { return fEntryList; }
00132    void             Validate(Bool_t isTree);
00133    void             Validate(TDSetElement *elem);
00134    void             Invalidate() { fValid = kFALSE; }
00135    void             SetValid() { fValid = kTRUE; }
00136    Int_t            Compare(const TObject *obj) const;
00137    Bool_t           IsSortable() const { return kTRUE; }
00138    Int_t            Lookup(Bool_t force = kFALSE);
00139    void             SetLookedUp() { SetBit(kHasBeenLookedUp); }
00140    TFileInfo       *GetFileInfo(const char *type = "TTree");
00141 
00142    Int_t            MergeElement(TDSetElement *elem);
00143 
00144    ClassDef(TDSetElement,8)  // A TDSet element
00145 };
00146 
00147 
00148 class TDSet : public TNamed {
00149 
00150 public:
00151    // TDSet status bits
00152    enum EStatusBits {
00153       kWriteV3         = BIT(16),
00154       kEmpty           = BIT(17),
00155       kValidityChecked = BIT(18),  // Set if elements validiy has been checked
00156       kSomeInvalid     = BIT(19),  // Set if at least one element is invalid
00157       kMultiDSet       = BIT(20)   // Set if fElements is a list of datasets
00158    };
00159 
00160 private:
00161    Bool_t         fIsTree;      // true if type is a TTree (or TTree derived)
00162    TObject       *fEntryList;   //! entry (or event) list for processing
00163    TProofChain   *fProofChain;  //! for browsing purposes
00164 
00165    void           SplitEntryList(); //Split entry list between elements
00166 
00167    TDSet(const TDSet &);           // not implemented
00168    void operator=(const TDSet &);  // not implemented
00169 
00170 protected:
00171    TString        fDir;         // name of the directory
00172    TString        fType;        // type of objects (e.g. TTree);
00173    TString        fObjName;     // name of objects to be analyzed (e.g. TTree name)
00174    THashList     *fElements;    //-> list of TDSetElements (or TDSets, if in multi mode)
00175    TIter         *fIterator;    //! iterator on fElements
00176    TDSetElement  *fCurrent;     //! current element
00177    TList         *fSrvMaps;     //! list for mapping server coordinates for files
00178    TIter         *fSrvMapsIter; //! iterator on fSrvMaps
00179 
00180 public:
00181    TDSet();
00182    TDSet(const char *name, const char *objname = "*",
00183          const char *dir = "/", const char *type = 0);
00184    TDSet(const TChain &chain, Bool_t withfriends = kTRUE);
00185    virtual ~TDSet();
00186 
00187    virtual Bool_t        Add(const char *file, const char *objname = 0,
00188                              const char *dir = 0, Long64_t first = 0,
00189                              Long64_t num = -1, const char *msd = 0);
00190    virtual Bool_t        Add(TDSet *set);
00191    virtual Bool_t        Add(TCollection *fileinfo, const char *meta = 0,
00192                              Bool_t availableOnly = kFALSE, TCollection *badlist = 0);
00193    virtual Bool_t        Add(TFileInfo *fileinfo, const char *meta = 0);
00194    virtual void          AddFriend(TDSet *friendset, const char *alias);
00195 
00196    virtual Long64_t      Process(const char *selector, Option_t *option = "",
00197                                  Long64_t nentries = -1,
00198                                  Long64_t firstentry = 0,
00199                                  TObject *enl = 0); // *MENU*
00200    virtual Long64_t      Draw(const char *varexp, const char *selection,
00201                               Option_t *option = "", Long64_t nentries = -1,
00202                               Long64_t firstentry = 0); // *MENU*
00203    virtual Long64_t      Draw(const char *varexp, const TCut &selection,
00204                               Option_t *option = "", Long64_t nentries = -1,
00205                               Long64_t firstentry = 0); // *MENU*
00206    virtual void          Draw(Option_t *opt) { Draw(opt, "", "", 1000000000, 0); }
00207 
00208    Int_t                 ExportFileList(const char *filepath, Option_t *opt = "");
00209 
00210    void                  Print(Option_t *option="") const;
00211 
00212    void                  SetObjName(const char *objname);
00213    void                  SetDirectory(const char *dir);
00214 
00215    Bool_t                IsTree() const { return fIsTree; }
00216    Bool_t                IsValid() const { return !fType.IsNull(); }
00217    Bool_t                ElementsValid();
00218    const char           *GetType() const { return fType; }
00219    const char           *GetObjName() const { return fObjName; }
00220    const char           *GetDirectory() const { return fDir; }
00221    TList                *GetListOfElements() const { return (TList *)fElements; }
00222    Int_t                 GetNumOfFiles();
00223 
00224    Int_t                 Remove(TDSetElement *elem, Bool_t deleteElem = kTRUE);
00225 
00226    virtual void          Reset();
00227    virtual TDSetElement *Next(Long64_t totalEntries = -1);
00228    TDSetElement         *Current() const { return fCurrent; };
00229 
00230    static Long64_t       GetEntries(Bool_t isTree, const char *filename,
00231                                     const char *path, TString &objname);
00232 
00233    void                  AddInput(TObject *obj);
00234    void                  ClearInput();
00235    TObject              *GetOutput(const char *name);
00236    TList                *GetOutputList();
00237    virtual void          StartViewer(); // *MENU*
00238 
00239    virtual TTree        *GetTreeHeader(TProof *proof);
00240    virtual void          SetEntryList(TObject *aList);
00241    TObject              *GetEntryList() const { return fEntryList; }
00242    void                  Validate();
00243    void                  Validate(TDSet *dset);
00244 
00245    void                  Lookup(Bool_t removeMissing = kFALSE, TList **missingFiles = 0);
00246    void                  SetLookedUp();
00247 
00248    void                  SetSrvMaps(TList *srvmaps = 0);
00249 
00250    void                  SetWriteV3(Bool_t on = kTRUE);
00251 
00252    ClassDef(TDSet,8)  // Data set for remote processing (PROOF)
00253 };
00254 
00255 #endif

Generated on Tue Jul 5 14:26:46 2011 for ROOT_528-00b_version by  doxygen 1.5.1