00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef ROO_TREE_DATA_STORE
00017 #define ROO_TREE_DATA_STORE
00018
00019 #include "RooAbsDataStore.h"
00020 #include "TString.h"
00021
00022 class RooAbsArg ;
00023 class RooArgList ;
00024 class TTree ;
00025 class RooFormulaVar ;
00026 class RooArgSet ;
00027
00028
00029 class RooTreeDataStore : public RooAbsDataStore {
00030 public:
00031
00032 RooTreeDataStore() ;
00033 RooTreeDataStore(TTree* t, const RooArgSet& vars, const char* wgtVarName=0) ;
00034
00035
00036 RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, const char* wgtVarName=0) ;
00037 virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const { return new RooTreeDataStore(*this,vars,newname) ; }
00038
00039
00040 RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, TTree& t, const RooFormulaVar& select, const char* wgtVarName=0) ;
00041 RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, TTree& t, const char* selExpr=0, const char* wgtVarName=0) ;
00042
00043
00044 RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, const RooAbsDataStore& tds, const RooFormulaVar& select, const char* wgtVarName=0) ;
00045 RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, const RooAbsDataStore& tds, const char* selExpr=0, const char* wgtVarName=0) ;
00046
00047 RooTreeDataStore(const char *name, const char *title, RooAbsDataStore& tds,
00048 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
00049 Int_t nStart, Int_t nStop, Bool_t , const char* wgtVarName=0) ;
00050
00051 RooTreeDataStore(const RooTreeDataStore& other, const char* newname=0) ;
00052 RooTreeDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
00053 virtual ~RooTreeDataStore() ;
00054
00055
00056
00057 virtual Int_t fill() ;
00058
00059
00060 using RooAbsDataStore::get ;
00061 virtual const RooArgSet* get(Int_t index) const ;
00062 virtual Double_t weight() const ;
00063 virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const ;
00064 virtual void weightError(Double_t& lo, Double_t& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const ;
00065 virtual Double_t weight(Int_t index) const ;
00066 virtual Bool_t isWeighted() const { return (_wgtVar!=0||_extWgtArray!=0) ; }
00067
00068
00069 virtual Bool_t changeObservableName(const char* from, const char* to) ;
00070
00071
00072 virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) ;
00073 virtual RooArgSet* addColumns(const RooArgList& varList) ;
00074
00075
00076 RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) ;
00077
00078
00079 virtual void append(RooAbsDataStore& other) ;
00080
00081
00082 virtual Bool_t valid() const ;
00083 virtual Int_t numEntries() const ;
00084 virtual void reset() ;
00085
00086
00087 TTree& tree() { return *_tree ; }
00088 virtual const TTree* tree() const { return _tree ; }
00089
00090
00091 Stat_t GetEntries() const;
00092 void Reset(Option_t* option=0);
00093 Int_t Fill();
00094 Int_t GetEntry(Int_t entry = 0, Int_t getall = 0);
00095
00096 void Draw(Option_t* option = "") ;
00097
00098
00099 virtual void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0) ;
00100 virtual const RooAbsArg* cacheOwner() { return _cacheOwner ; }
00101 virtual void setArgStatus(const RooArgSet& set, Bool_t active) ;
00102 virtual void resetCache() ;
00103
00104 void loadValues(const TTree *t, const RooFormulaVar* select=0, const char* rangeName=0, Int_t nStart=0, Int_t nStop=2000000000) ;
00105 void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0, Int_t nStart=0, Int_t nStop=2000000000) ;
00106
00107 virtual void checkInit() const;
00108
00109 void setExternalWeightArray(Double_t* arrayWgt, Double_t* arrayWgtErrLo, Double_t* arrayWgtErrHi, Double_t* arraySumW2) {
00110 _extWgtArray = arrayWgt ;
00111 _extWgtErrLoArray = arrayWgtErrLo ;
00112 _extWgtErrHiArray = arrayWgtErrHi ;
00113 _extSumW2Array = arraySumW2 ;
00114 }
00115
00116 const RooArgSet& row() { return _varsww ; }
00117
00118 protected:
00119
00120 RooArgSet varsNoWeight(const RooArgSet& allVars, const char* wgtName=0) ;
00121 RooRealVar* weightVar(const RooArgSet& allVars, const char* wgtName=0) ;
00122
00123 void initialize();
00124 void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) ;
00125
00126
00127 void setBranchBufferSize(Int_t size) { _defTreeBufSize = size ; }
00128 Int_t getBranchBufferSize() const { return _defTreeBufSize ; }
00129
00130 static Int_t _defTreeBufSize ;
00131
00132 void createTree(const char* name, const char* title) ;
00133 TTree *_tree ;
00134 TTree *_cacheTree ;
00135 const RooAbsArg* _cacheOwner ;
00136 mutable Bool_t _defCtor ;
00137
00138 RooArgSet _varsww ;
00139 RooRealVar* _wgtVar ;
00140
00141 Double_t* _extWgtArray ;
00142 Double_t* _extWgtErrLoArray ;
00143 Double_t* _extWgtErrHiArray ;
00144 Double_t* _extSumW2Array ;
00145
00146 mutable Double_t _curWgt ;
00147 mutable Double_t _curWgtErrLo ;
00148 mutable Double_t _curWgtErrHi ;
00149 mutable Double_t _curWgtErr ;
00150
00151 ClassDef(RooTreeDataStore,2)
00152 };
00153
00154
00155 #endif