TTreeCloner.h

Go to the documentation of this file.
00001 // @(#)root/tree:$Id: TTreeCloner.h 37922 2011-01-31 22:26:42Z pcanal $
00002 // Author: Philippe Canal 07/11/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, 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_TTreeCloner
00013 #define ROOT_TTreeCloner
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TTreeCloner                                                          //
00018 //                                                                      //
00019 // Class implementing or helping  the various TTree cloning method      //
00020 //                                                                      //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #ifndef ROOT_TObjArray
00024 #include "TObjArray.h"
00025 #endif
00026 
00027 #include <vector>
00028 
00029 #ifdef R__OLDHPACC
00030 namespace std {
00031    using ::string;
00032    using ::vector;
00033 }
00034 #endif
00035 
00036 class TBranch;
00037 class TTree;
00038 
00039 class TTreeCloner {
00040    TString    fWarningMsg;       //Text of the error message lead to an 'invalid' state
00041 
00042    Bool_t     fIsValid;
00043    Bool_t     fNeedConversion;   //True if the fast merge is not possible but a slow merge might possible.
00044    UInt_t     fOptions;
00045    TTree     *fFromTree;
00046    TTree     *fToTree;
00047    Option_t  *fMethod;
00048    TObjArray  fFromBranches;
00049    TObjArray  fToBranches;
00050 
00051    UInt_t     fMaxBaskets;
00052    UInt_t    *fBasketBranchNum;  //[fMaxBaskets] Index of the branch(es) of the basket.
00053    UInt_t    *fBasketNum;        //[fMaxBaskets] index of the basket within the branch.
00054 
00055    Long64_t  *fBasketSeek;       //[fMaxBaskets] list of basket position to be read.
00056    Long64_t  *fBasketEntry;      //[fMaxBaskets] list of basket start entries.
00057    UInt_t    *fBasketIndex;      //[fMaxBaskets] ordered list of basket indices to be written.
00058 
00059    UShort_t   fPidOffset;        //Offset to be added to the copied key/basket.
00060 
00061    UInt_t     fCloneMethod;      //Indicates which cloning method was selected.
00062    Long64_t   fToStartEntries;   //Number of entries in the target tree before any addition.
00063 
00064    enum ECloneMethod {
00065       kDefault             = 0,
00066       kSortBasketsByBranch = 1,
00067       kSortBasketsByOffset = 2,
00068       kSortBasketsByEntry  = 3
00069    };
00070 
00071    class CompareSeek {
00072       TTreeCloner *fObject;
00073    public:
00074       CompareSeek(TTreeCloner *obj) : fObject(obj) {}
00075       bool operator()(UInt_t i1, UInt_t i2);
00076    };
00077 
00078    class CompareEntry {
00079       TTreeCloner *fObject;
00080    public:
00081       CompareEntry(TTreeCloner *obj) : fObject(obj) {}
00082       bool operator()(UInt_t i1, UInt_t i2);
00083    };
00084 
00085    friend class CompareSeek;
00086    friend class CompareEntry;
00087 
00088 public:
00089    enum EClonerOptions {
00090       kNone       = 0,
00091       kNoWarnings = BIT(1),
00092       kIgnoreMissingTopLevel = BIT(2)
00093    };
00094 
00095    TTreeCloner(TTree *from, TTree *to, Option_t *method, UInt_t options = kNone);
00096    virtual ~TTreeCloner();
00097 
00098    void   CloseOutWriteBaskets();
00099    UInt_t CollectBranches(TBranch *from, TBranch *to);
00100    UInt_t CollectBranches(TObjArray *from, TObjArray *to);
00101    UInt_t CollectBranches();
00102    void   CollectBaskets();
00103    void   CopyMemoryBaskets();
00104    void   CopyStreamerInfos();
00105    void   CopyProcessIds();
00106    const char *GetWarning() const { return fWarningMsg; }
00107    Bool_t Exec();
00108    Bool_t IsValid() { return fIsValid; }
00109    Bool_t NeedConversion() { return fNeedConversion; }
00110    void   SortBaskets();
00111    void   WriteBaskets();
00112 
00113    ClassDef(TTreeCloner,0); // helper used for the fast cloning of TTrees.
00114 };
00115 
00116 #endif

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