Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RooAbsDataStore.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 #ifndef ROO_ABS_DATA_STORE
17 #define ROO_ABS_DATA_STORE
18 
19 #include "Rtypes.h"
20 #include "RooArgSet.h"
21 #include "RooAbsData.h"
22 #include "TNamed.h"
23 #include <list>
24 
25 
26 class RooAbsArg ;
27 class RooArgList ;
28 class TIterator ;
29 class TTree ;
30 
31 class RooAbsDataStore : public TNamed, public RooPrintable {
32 public:
33 
34  RooAbsDataStore() ;
35  RooAbsDataStore(const char* name, const char* title, const RooArgSet& vars) ;
36  RooAbsDataStore(const RooAbsDataStore& other, const char* newname=0) ;
37  RooAbsDataStore(const RooAbsDataStore& other, const RooArgSet& vars, const char* newname=0) ;
38  virtual RooAbsDataStore* clone(const char* newname=0) const = 0 ;
39  virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const = 0 ;
40  virtual ~RooAbsDataStore() ;
41 
42  // Write current row
43  virtual Int_t fill() = 0 ;
44 
45  // Retrieve a row
46  virtual const RooArgSet* get(Int_t index) const = 0 ;
47  virtual const RooArgSet* get() const { return &_vars ; }
48  virtual Double_t weight() const = 0 ;
49 
50  virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const = 0 ;
51  virtual void weightError(Double_t& lo, Double_t& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const = 0 ;
52 
53  virtual Double_t weight(Int_t index) const = 0 ;
54  virtual Bool_t isWeighted() const = 0 ;
55 
56  virtual std::vector<RooSpan<const double>> getBatch(std::size_t first, std::size_t last) const = 0;
57  virtual RooSpan<const double> getWeightBatch(std::size_t first, std::size_t last) const;
58 
59  // Change observable name
60  virtual Bool_t changeObservableName(const char* from, const char* to) =0 ;
61 
62  // Add one or more columns
63  virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) = 0 ;
64  virtual RooArgSet* addColumns(const RooArgList& varList) = 0 ;
65 
66  // Merge column-wise
67  virtual RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) = 0 ;
68 
69  // Add rows
70  virtual void append(RooAbsDataStore& other)= 0 ;
71 
72  // General & bookkeeping methods
73  virtual Bool_t valid() const = 0 ;
74  virtual Int_t numEntries() const = 0 ;
75  virtual Double_t sumEntries() const { return 0 ; } ;
76  virtual void reset() = 0 ;
77 
78  // Buffer redirection routines used in inside RooAbsOptTestStatistics
79  virtual void attachBuffers(const RooArgSet& extObs) = 0 ;
80  virtual void resetBuffers() = 0 ;
81 
82  virtual void setExternalWeightArray(const Double_t* /*arrayWgt*/, const Double_t* /*arrayWgtErrLo*/, const Double_t* /*arrayWgtErrHi*/, const Double_t* /*arraySumW2*/) {} ;
83 
84  // Printing interface (human readable)
85  inline virtual void Print(Option_t *options= 0) const {
86  // Print contents on stdout
87  printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
88  }
89 
90  virtual void printName(std::ostream& os) const ;
91  virtual void printTitle(std::ostream& os) const ;
92  virtual void printClassName(std::ostream& os) const ;
93  virtual void printArgs(std::ostream& os) const ;
94  virtual void printValue(std::ostream& os) const ;
95  void printMultiline(std::ostream& os, Int_t content, Bool_t verbose, TString indent) const ;
96 
97  virtual Int_t defaultPrintContents(Option_t* opt) const ;
98 
99 
100  // Constant term optimizer interface
101  virtual void cacheArgs(const RooAbsArg* cacheOwner, RooArgSet& varSet, const RooArgSet* nset=0, Bool_t skipZeroWeights=kFALSE) = 0 ;
102  virtual const RooAbsArg* cacheOwner() = 0 ;
103  virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) = 0 ;
104  virtual void setArgStatus(const RooArgSet& set, Bool_t active) = 0 ;
105  const RooArgSet& cachedVars() const { return _cachedVars ; }
106  virtual void resetCache() = 0 ;
107  virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, Bool_t /* skipZeroWeights*/) {} ;
108 
109  virtual void setDirtyProp(Bool_t flag) { _doDirtyProp = flag ; }
110  Bool_t dirtyProp() const { return _doDirtyProp ; }
111 
112  virtual void checkInit() const {} ;
113 
114  virtual Bool_t hasFilledCache() const { return kFALSE ; }
115 
116  virtual const TTree* tree() const { return 0 ; }
117  virtual void dump() {}
118 
119  virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0, Int_t nStart=0, Int_t nStop=2000000000) = 0 ;
120 
121  virtual void forceCacheUpdate() {} ;
122 
123  protected:
124 
125  RooArgSet _vars;
126  RooArgSet _cachedVars;
127 
128  Bool_t _doDirtyProp ; // Switch do (de)activate dirty state propagation when loading a data point
129 
130  ClassDef(RooAbsDataStore,1) // Abstract Data Storage class
131 };
132 
133 
134 #endif