Logo ROOT   master
Reference Guide
RooCompositeDataStore.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_COMPOSITE_DATA_STORE
17 #define ROO_COMPOSITE_DATA_STORE
18 
19 #include "RooAbsDataStore.h"
20 #include <map>
21 #include <string>
22 
23 class RooAbsArg ;
24 class RooArgList ;
25 class RooFormulaVar ;
26 class RooArgSet ;
27 class RooCategory ;
28 
29 
31 public:
32 
34 
35  // Ctors from DataStore
36  RooCompositeDataStore(const char* name, const char* title, const RooArgSet& vars, RooCategory& indexCat, std::map<std::string,RooAbsDataStore*> inputData) ;
37 
38  // Empty ctor
39  virtual RooAbsDataStore* clone(const char* newname=0) const { return new RooCompositeDataStore(*this,newname) ; }
40  virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const { return new RooCompositeDataStore(*this,vars,newname) ; }
41 
42  RooCompositeDataStore(const RooCompositeDataStore& other, const char* newname=0) ;
43  RooCompositeDataStore(const RooCompositeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
44  virtual ~RooCompositeDataStore() ;
45 
46  virtual void dump() ;
47 
48  // Write current row
49  virtual Int_t fill() ;
50 
51  virtual Double_t sumEntries() const ;
52 
53  // Retrieve a row
54  using RooAbsDataStore::get ;
55  virtual const RooArgSet* get(Int_t index) const ;
56  virtual Double_t weight() const ;
57  virtual Double_t weight(Int_t index) const ;
59  virtual void weightError(Double_t& lo, Double_t& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const ;
60  virtual Bool_t isWeighted() const ;
61 
62  // Change observable name
63  virtual Bool_t changeObservableName(const char* from, const char* to) ;
64 
65  // Add one or more columns
66  virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) ;
67  virtual RooArgSet* addColumns(const RooArgList& varList) ;
68 
69  // Merge column-wise
70  RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) ;
71 
72  RooCategory* index() { return _indexCat ; }
73 
74  // Add rows
75  virtual void append(RooAbsDataStore& other) ;
76 
77  // General & bookkeeping methods
78  virtual Bool_t valid() const ;
79  virtual Int_t numEntries() const ;
80  virtual void reset() ;
81 
82  // Buffer redirection routines used in inside RooAbsOptTestStatistics
83  virtual void attachBuffers(const RooArgSet& extObs) ;
84  virtual void resetBuffers() ;
85 
86  // Constant term optimizer interface
87  virtual void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0, Bool_t skipZeroWeights=kFALSE) ;
88  virtual const RooAbsArg* cacheOwner() { return 0 ; }
89  virtual void setArgStatus(const RooArgSet& set, Bool_t active) ;
90  virtual void resetCache() ;
91 
92  virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, Bool_t /*skipZeroWeights*/) ;
93  virtual Bool_t hasFilledCache() const ;
94 
95  void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0,
96  std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max());
97 
98  virtual void forceCacheUpdate() ;
99 
100  virtual std::vector<RooSpan<const double>> getBatch(std::size_t first, std::size_t last) const {
101  //TODO
102  std::cerr << "This functionality is not yet implemented for composite data stores." << std::endl;
103  throw std::logic_error("RooCompositeDataStore doesn't have batch access yet.");
104 
105  std::vector<double> vec(first, last);
106  return {RooSpan<const double>(vec)};
107  }
108 
109  protected:
110 
111  void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) ;
112 
113  std::map<Int_t,RooAbsDataStore*> _dataMap ;
115  mutable RooAbsDataStore* _curStore ; //! Datastore associated with current event
116  mutable Int_t _curIndex ; //! Index associated with current event
118 
119  ClassDef(RooCompositeDataStore,1) // Composite Data Storage class
120 };
121 
122 
123 #endif
virtual std::vector< RooSpan< const double > > getBatch(std::size_t first, std::size_t last) const
virtual const RooArgSet * get() const
A simple container to hold a batch of data values.
Definition: RooSpan.h:32
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
void loadValues(const RooAbsDataStore *tds, const RooFormulaVar *select=0, const char *rangeName=0, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max())
virtual Int_t numEntries() const
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
virtual ~RooCompositeDataStore()
Destructor.
virtual void setArgStatus(const RooArgSet &set, Bool_t active)
virtual Bool_t hasFilledCache() const
const RooArgSet & cachedVars() const
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore *> dstoreList)
#define ClassDef(name, id)
Definition: Rtypes.h:322
virtual void attachBuffers(const RooArgSet &extObs)
virtual RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=0) const
std::map< Int_t, RooAbsDataStore * > _dataMap
virtual Int_t fill()
Forward fill request to appropriate subset.
Bool_t _ownComps
Index associated with current event.
RooCompositeDataStore combines several disjunct datasets into one.
virtual Bool_t changeObservableName(const char *from, const char *to)
Change name of internal observable named &#39;from&#39; into &#39;to&#39;.
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
WVE ownership issue here!! Caller (a RooAbsData) should take ownership of all arguments, but only does for the first one here...
virtual void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kFALSE)
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:23
void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)
Initialize cache of dataset: attach variables of cache ArgSet to the corresponding TTree branches...
const Bool_t kFALSE
Definition: RtypesCore.h:90
virtual RooArgSet * addColumns(const RooArgList &varList)
WVE ownership issue here!! Caller (a RooAbsData) should take ownership of all arguments, but only does for the first one here...
virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:29
virtual Double_t sumEntries() const
Forward fill request to appropriate subset.
Int_t _curIndex
Datastore associated with current event.
virtual Bool_t isWeighted() const
virtual Bool_t valid() const
Return true if currently loaded coordinate is considered valid within the current range definitions o...
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
float type_of_call hi(const int &, const int &)
Definition: first.py:1
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:73
virtual RooAbsDataStore * clone(const char *newname=0) const
const Bool_t kTRUE
Definition: RtypesCore.h:89
virtual const RooAbsArg * cacheOwner()
char name[80]
Definition: TGX11.cxx:109
virtual void append(RooAbsDataStore &other)
virtual void recalculateCache(const RooArgSet *, Int_t, Int_t, Int_t, Bool_t)
Forward recalculate request to all subsets.
virtual Double_t weight() const