Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
23#include "ROOT/RStringView.hxx"
24#include "TNamed.h"
25
26#include <list>
27#include <vector>
28
29class RooAbsArg ;
30class RooArgList ;
31class TTree ;
32namespace RooBatchCompute {
33struct RunContext;
34}
35
36
37class RooAbsDataStore : public TNamed, public RooPrintable {
38public:
39
41 RooAbsDataStore(std::string_view name, std::string_view title, const RooArgSet& vars)
42 : TNamed(TString{name},TString{title}), _vars{vars} {}
43 RooAbsDataStore(const RooAbsDataStore& other, const char* newname=0)
44 : RooAbsDataStore(other, other._vars, newname) {}
45 RooAbsDataStore(const RooAbsDataStore& other, const RooArgSet& vars, const char* newname=0)
46 : TNamed(other), RooPrintable(other), _vars{vars}, _doDirtyProp{other._doDirtyProp}
47 {
48 if(newname) SetName(newname);
49 }
50
52
53 virtual RooAbsDataStore* clone(const char* newname=0) const = 0 ;
54 virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const = 0 ;
55
56 // Write current row
57 virtual Int_t fill() = 0 ;
58
59 // Retrieve a row
60 virtual const RooArgSet* get(Int_t index) const = 0 ;
61 virtual const RooArgSet* get() const { return &_vars ; }
62 virtual Double_t weight() const = 0 ;
63
66
67 double weight(Int_t index) const {
68 get(index) ;
69 return weight() ;
70 }
71 virtual Bool_t isWeighted() const = 0 ;
72
73 /// Retrieve batches for all observables in this data store.
74 virtual RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const = 0;
75 virtual RooAbsData::CategorySpans getCategoryBatches(std::size_t /*first*/, std::size_t /*len*/) const {
76 std::cerr << "This functionality is not yet implemented for this data store." << std::endl;
77 throw std::logic_error("getCategoryBatches() not implemented in RooAbsDataStore.");
78 return {};
79 }
80 virtual RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len) const = 0;
81
82 // Change observable name
83 virtual Bool_t changeObservableName(const char* from, const char* to) =0 ;
84
85 // Add one or more columns
86 virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) = 0 ;
87 virtual RooArgSet* addColumns(const RooArgList& varList) = 0 ;
88
89 // Merge column-wise
90 virtual RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) = 0 ;
91
92 // Add rows
93 virtual void append(RooAbsDataStore& other)= 0 ;
94
95 // General & bookkeeping methods
96 virtual Int_t numEntries() const = 0 ;
97 virtual Double_t sumEntries() const { return 0 ; } ;
98 virtual void reset() = 0 ;
99
100 // Buffer redirection routines used in inside RooAbsOptTestStatistics
101 virtual void attachBuffers(const RooArgSet& extObs) = 0 ;
102 virtual void resetBuffers() = 0 ;
103
104 virtual void setExternalWeightArray(const Double_t* /*arrayWgt*/, const Double_t* /*arrayWgtErrLo*/, const Double_t* /*arrayWgtErrHi*/, const Double_t* /*arraySumW2*/) {} ;
105
106 // Printing interface (human readable)
107 inline void Print(Option_t *options= 0) const override {
108 // Print contents on stdout
110 }
111
112 /// Print name of dataset
113 void printName(std::ostream& os) const override { os << GetName(); }
114 /// Print title of dataset
115 void printTitle(std::ostream& os) const override { os << GetTitle(); }
116 void printClassName(std::ostream& os) const override ;
117 void printArgs(std::ostream& os) const override;
118 /// Print value of the dataset, i.e. the sum of weights contained in the dataset
119 void printValue(std::ostream& os) const override { os << numEntries() << " entries" ; }
120 void printMultiline(std::ostream& os, Int_t content, Bool_t verbose, TString indent) const override;
121
122 /// Define default print options, for a given print style
123 virtual int defaultPrintContents(Option_t* /*opt*/) const override { return kName|kClassName|kArgs|kValue ; }
124
125
126 // Constant term optimizer interface
127 virtual void cacheArgs(const RooAbsArg* cacheOwner, RooArgSet& varSet, const RooArgSet* nset=0, Bool_t skipZeroWeights=kFALSE) = 0 ;
128 virtual const RooAbsArg* cacheOwner() = 0 ;
129 virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) = 0 ;
130 virtual void setArgStatus(const RooArgSet& set, Bool_t active) = 0 ;
131 const RooArgSet& cachedVars() const { return _cachedVars ; }
132 virtual void resetCache() = 0 ;
133 virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, Bool_t /* skipZeroWeights*/) {} ;
134
135 virtual void setDirtyProp(Bool_t flag) { _doDirtyProp = flag ; }
136 Bool_t dirtyProp() const { return _doDirtyProp ; }
137
138 virtual void checkInit() const {} ;
139
140 virtual Bool_t hasFilledCache() const { return kFALSE ; }
141
142 virtual const TTree* tree() const { return 0 ; }
143 virtual void dump() {}
144
145 virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0,
146 std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) = 0 ;
147
148 virtual void forceCacheUpdate() {} ;
149
150 protected:
151
154
155 Bool_t _doDirtyProp = true; // Switch do (de)activate dirty state propagation when loading a data point
156
157 ClassDefOverride(RooAbsDataStore,1) // Abstract Data Storage class
158};
159
160
161#endif
#define WRITE_TSTRING_COMPATIBLE_CONSTRUCTOR(Class_t)
Definition RooAbsData.h:69
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:329
static void indent(ostringstream &buf, int indent_level)
char name[80]
Definition TGX11.cxx:110
#define hi
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:69
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
virtual void reset()=0
RooAbsDataStore(const RooAbsDataStore &other, const char *newname=0)
virtual const RooAbsArg * cacheOwner()=0
virtual RooSpan< const double > getWeightBatch(std::size_t first, std::size_t len) const =0
virtual void attachBuffers(const RooArgSet &extObs)=0
virtual Bool_t hasFilledCache() const
virtual RooAbsData::CategorySpans getCategoryBatches(std::size_t, std::size_t) const
const RooArgSet & cachedVars() const
virtual void append(RooAbsDataStore &other)=0
virtual Bool_t changeObservableName(const char *from, const char *to)=0
virtual void resetBuffers()=0
virtual void setExternalWeightArray(const Double_t *, const Double_t *, const Double_t *, const Double_t *)
virtual const TTree * tree() const
void printArgs(std::ostream &os) const override
Print argument of dataset, i.e. the observable names.
virtual Double_t sumEntries() const
virtual void weightError(Double_t &lo, Double_t &hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const =0
Bool_t dirtyProp() const
virtual void cacheArgs(const RooAbsArg *cacheOwner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kFALSE)=0
virtual void checkInit() const
virtual RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const =0
Retrieve batches for all observables in this data store.
void printName(std::ostream &os) const override
Print name of dataset.
virtual int defaultPrintContents(Option_t *) const override
Define default print options, for a given print style.
RooAbsDataStore(const RooAbsDataStore &other, const RooArgSet &vars, const char *newname=0)
virtual Int_t fill()=0
virtual 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())=0
virtual Double_t weight() const =0
virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const =0
void printValue(std::ostream &os) const override
Print value of the dataset, i.e. the sum of weights contained in the dataset.
virtual RooAbsDataStore * clone(const char *newname=0) const =0
virtual RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList)=0
void printTitle(std::ostream &os) const override
Print title of dataset.
virtual void setDirtyProp(Bool_t flag)
double weight(Int_t index) const
virtual void resetCache()=0
virtual RooArgSet * addColumns(const RooArgList &varList)=0
virtual void recalculateCache(const RooArgSet *, Int_t, Int_t, Int_t, Bool_t)
virtual void forceCacheUpdate()
void printMultiline(std::ostream &os, Int_t content, Bool_t verbose, TString indent) const override
Detailed printing interface.
virtual void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)=0
virtual Bool_t isWeighted() const =0
void Print(Option_t *options=0) const override
Print TNamed name and title.
virtual void setArgStatus(const RooArgSet &set, Bool_t active)=0
virtual void dump()
virtual Int_t numEntries() const =0
virtual const RooArgSet * get() const
RooAbsDataStore(std::string_view name, std::string_view title, const RooArgSet &vars)
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)=0
void printClassName(std::ostream &os) const override
Print class name of dataset.
std::map< RooFit::Detail::DataKey, RooSpan< const double > > RealSpans
Definition RooAbsData.h:159
std::map< RooFit::Detail::DataKey, RooSpan< const RooAbsCategory::value_type > > CategorySpans
Definition RooAbsData.h:160
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
virtual StyleOption defaultPrintStyle(Option_t *opt) const
static std::ostream & defaultPrintStream(std::ostream *os=0)
Return a reference to the current default stream to use in Print().
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
A simple container to hold a batch of data values.
Definition RooSpan.h:34
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
virtual const char * GetTitle() const
Returns title of object.
Definition TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Basic string class.
Definition TString.h:136
A TTree represents a columnar dataset.
Definition TTree.h:79
Namespace for dispatching RooFit computations to various backends.
Definition first.py:1