Logo ROOT  
Reference Guide
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
42 : TNamed(name,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
51 virtual RooAbsDataStore* clone(const char* newname=0) const = 0 ;
52 virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const = 0 ;
53
55 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
56 std::size_t nStart, std::size_t nStop) = 0 ;
57
58 // Write current row
59 virtual Int_t fill() = 0 ;
60
61 // Retrieve a row
62 virtual const RooArgSet* get(Int_t index) const = 0 ;
63 virtual const RooArgSet* get() const { return &_vars ; }
64 virtual double weight() const = 0 ;
65
66 virtual double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const = 0 ;
67 virtual void weightError(double& lo, double& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const = 0 ;
68
69 double weight(Int_t index) const {
70 get(index) ;
71 return weight() ;
72 }
73 virtual bool isWeighted() const = 0 ;
74
75 /// Retrieve batches for all observables in this data store.
76 virtual RooBatchCompute::RunContext getBatches(std::size_t first, std::size_t len) const = 0;
77 virtual std::map<const std::string, RooSpan<const RooAbsCategory::value_type>> getCategoryBatches(std::size_t /*first*/, std::size_t /*len*/) const {
78 std::cerr << "This functionality is not yet implemented for this data store." << std::endl;
79 throw std::logic_error("getCategoryBatches() not implemented in RooAbsDataStore.");
80 return {};
81 }
82 virtual RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len) const = 0;
83
84 // Change observable name
85 virtual bool changeObservableName(const char* from, const char* to) =0 ;
86
87 // Add one or more columns
88 virtual RooAbsArg* addColumn(RooAbsArg& var, bool adjustRange=true) = 0 ;
89 RooArgSet* addColumns(const RooArgList& varList);
90
91 // Merge column-wise
92 virtual RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) = 0 ;
93
94 // Add rows
95 virtual void append(RooAbsDataStore& other)= 0 ;
96
97 // General & bookkeeping methods
98 virtual Int_t numEntries() const = 0 ;
99 virtual double sumEntries() const { return 0 ; } ;
100 virtual void reset() = 0 ;
101
102 // Buffer redirection routines used in inside RooAbsOptTestStatistics
103 virtual void attachBuffers(const RooArgSet& extObs) = 0 ;
104 virtual void resetBuffers() = 0 ;
105
106 virtual void setExternalWeightArray(const double* /*arrayWgt*/, const double* /*arrayWgtErrLo*/, const double* /*arrayWgtErrHi*/, const double* /*arraySumW2*/) {} ;
107
108 // Printing interface (human readable)
109 inline void Print(Option_t *options= 0) const override {
110 // Print contents on stdout
112 }
113
114 /// Print name of dataset
115 void printName(std::ostream& os) const override { os << GetName(); }
116 /// Print title of dataset
117 void printTitle(std::ostream& os) const override { os << GetTitle(); }
118 void printClassName(std::ostream& os) const override ;
119 void printArgs(std::ostream& os) const override;
120 /// Print value of the dataset, i.e. the sum of weights contained in the dataset
121 void printValue(std::ostream& os) const override { os << numEntries() << " entries" ; }
122 void printMultiline(std::ostream& os, Int_t content, bool verbose, TString indent) const override;
123
124 /// Define default print options, for a given print style
125 int defaultPrintContents(Option_t* /*opt*/) const override { return kName|kClassName|kArgs|kValue ; }
126
127
128 // Constant term optimizer interface
129 virtual void cacheArgs(const RooAbsArg* cacheOwner, RooArgSet& varSet, const RooArgSet* nset=0, bool skipZeroWeights=false) = 0 ;
130 virtual const RooAbsArg* cacheOwner() = 0 ;
131 virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) = 0 ;
132 virtual void setArgStatus(const RooArgSet& set, bool active) = 0 ;
133 const RooArgSet& cachedVars() const { return _cachedVars ; }
134 virtual void resetCache() = 0 ;
135 virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, bool /* skipZeroWeights*/) {} ;
136
137 virtual void setDirtyProp(bool flag) { _doDirtyProp = flag ; }
138 bool dirtyProp() const { return _doDirtyProp ; }
139
140 virtual void checkInit() const {} ;
141
142 virtual bool hasFilledCache() const { return false ; }
143
144 virtual const TTree* tree() const { return 0 ; }
145 virtual void dump() {}
146
147 virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0,
148 std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) = 0 ;
149
150 virtual void forceCacheUpdate() {} ;
151
152 protected:
153
156
157 bool _doDirtyProp = true; ///< Switch do (de)activate dirty state propagation when loading a data point
158
159 ClassDefOverride(RooAbsDataStore,1) // Abstract Data Storage class
160};
161
162
163#endif
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition: TGX11.cxx:110
#define hi
Definition: THbookFile.cxx:128
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:77
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
const RooArgSet & cachedVars() const
virtual void append(RooAbsDataStore &other)=0
virtual const RooArgSet * get(Int_t index) const =0
virtual void resetBuffers()=0
virtual const TTree * tree() const
void printArgs(std::ostream &os) const override
Print argument of dataset, i.e. the observable names.
virtual bool isWeighted() const =0
virtual RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=0) const =0
virtual RooBatchCompute::RunContext getBatches(std::size_t first, std::size_t len) const =0
Retrieve batches for all observables in this data store.
virtual std::map< const std::string, RooSpan< const RooAbsCategory::value_type > > getCategoryBatches(std::size_t, std::size_t) const
virtual void checkInit() const
void printName(std::ostream &os) const override
Print name of dataset.
RooAbsDataStore(const RooAbsDataStore &other, const RooArgSet &vars, const char *newname=0)
virtual Int_t fill()=0
virtual bool changeObservableName(const char *from, const char *to)=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 sumEntries() const
virtual void setArgStatus(const RooArgSet &set, bool active)=0
virtual RooAbsDataStore * reduce(RooStringView name, RooStringView title, const RooArgSet &vars, const RooFormulaVar *cutVar, const char *cutRange, std::size_t nStart, std::size_t nStop)=0
bool _doDirtyProp
Switch do (de)activate dirty state propagation when loading a data point.
virtual void weightError(double &lo, double &hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const =0
virtual void setExternalWeightArray(const double *, const double *, const double *, const double *)
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
RooAbsDataStore(RooStringView name, RooStringView title, const RooArgSet &vars)
virtual RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList)=0
bool dirtyProp() const
virtual bool hasFilledCache() const
void printTitle(std::ostream &os) const override
Print title of dataset.
RooArgSet * addColumns(const RooArgList &varList)
virtual double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const =0
virtual RooAbsArg * addColumn(RooAbsArg &var, bool adjustRange=true)=0
virtual void cacheArgs(const RooAbsArg *cacheOwner, RooArgSet &varSet, const RooArgSet *nset=0, bool skipZeroWeights=false)=0
void printMultiline(std::ostream &os, Int_t content, bool verbose, TString indent) const override
Detailed printing interface.
RooArgSet _cachedVars
double weight(Int_t index) const
virtual void resetCache()=0
virtual void forceCacheUpdate()
virtual void setDirtyProp(bool flag)
virtual void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)=0
int defaultPrintContents(Option_t *) const override
Define default print options, for a given print style.
void Print(Option_t *options=0) const override
Print TNamed name and title.
virtual void recalculateCache(const RooArgSet *, Int_t, Int_t, Int_t, bool)
virtual double weight() const =0
virtual void dump()
virtual Int_t numEntries() const =0
virtual const RooArgSet * get() const
void printClassName(std::ostream &os) const override
Print class name of dataset.
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:57
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:30
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
Definition: RooPrintable.h:25
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 RooStringView is a wrapper around a C-syle string that can also be constructed from a std::string...
Definition: RooStringView.h:27
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition: TNamed.h:48
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
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
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31