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