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(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 RooBatchCompute::RunContext getBatches(std::size_t first, std::size_t len) const = 0;
75 virtual RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len) const = 0;
76
77 // Change observable name
78 virtual Bool_t changeObservableName(const char* from, const char* to) =0 ;
79
80 // Add one or more columns
81 virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) = 0 ;
82 virtual RooArgSet* addColumns(const RooArgList& varList) = 0 ;
83
84 // Merge column-wise
85 virtual RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) = 0 ;
86
87 // Add rows
88 virtual void append(RooAbsDataStore& other)= 0 ;
89
90 // General & bookkeeping methods
91 virtual Int_t numEntries() const = 0 ;
92 virtual Double_t sumEntries() const { return 0 ; } ;
93 virtual void reset() = 0 ;
94
95 // Buffer redirection routines used in inside RooAbsOptTestStatistics
96 virtual void attachBuffers(const RooArgSet& extObs) = 0 ;
97 virtual void resetBuffers() = 0 ;
98
99 virtual void setExternalWeightArray(const Double_t* /*arrayWgt*/, const Double_t* /*arrayWgtErrLo*/, const Double_t* /*arrayWgtErrHi*/, const Double_t* /*arraySumW2*/) {} ;
100
101 // Printing interface (human readable)
102 inline void Print(Option_t *options= 0) const override {
103 // Print contents on stdout
105 }
106
107 /// Print name of dataset
108 void printName(std::ostream& os) const override { os << GetName(); }
109 /// Print title of dataset
110 void printTitle(std::ostream& os) const override { os << GetTitle(); }
111 void printClassName(std::ostream& os) const override ;
112 void printArgs(std::ostream& os) const override;
113 /// Print value of the dataset, i.e. the sum of weights contained in the dataset
114 void printValue(std::ostream& os) const override { os << numEntries() << " entries" ; }
115 void printMultiline(std::ostream& os, Int_t content, Bool_t verbose, TString indent) const override;
116
117 /// Define default print options, for a given print style
118 virtual int defaultPrintContents(Option_t* /*opt*/) const override { return kName|kClassName|kArgs|kValue ; }
119
120
121 // Constant term optimizer interface
122 virtual void cacheArgs(const RooAbsArg* cacheOwner, RooArgSet& varSet, const RooArgSet* nset=0, Bool_t skipZeroWeights=kFALSE) = 0 ;
123 virtual const RooAbsArg* cacheOwner() = 0 ;
124 virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) = 0 ;
125 virtual void setArgStatus(const RooArgSet& set, Bool_t active) = 0 ;
126 const RooArgSet& cachedVars() const { return _cachedVars ; }
127 virtual void resetCache() = 0 ;
128 virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, Bool_t /* skipZeroWeights*/) {} ;
129
130 virtual void setDirtyProp(Bool_t flag) { _doDirtyProp = flag ; }
131 Bool_t dirtyProp() const { return _doDirtyProp ; }
132
133 virtual void checkInit() const {} ;
134
135 virtual Bool_t hasFilledCache() const { return kFALSE ; }
136
137 virtual const TTree* tree() const { return 0 ; }
138 virtual void dump() {}
139
140 virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0,
141 std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) = 0 ;
142
143 virtual void forceCacheUpdate() {} ;
144
145 protected:
146
149
150 Bool_t _doDirtyProp = true; // Switch do (de)activate dirty state propagation when loading a data point
151
152 ClassDefOverride(RooAbsDataStore,1) // Abstract Data Storage class
153};
154
155
156#endif
int Int_t
Definition: CPyCppyy.h:43
#define WRITE_TSTRING_COMPATIBLE_CONSTRUCTOR(Class_t)
Definition: RooAbsData.h:60
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
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)
float type_of_call hi(const int &, const int &)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
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 void attachBuffers(const RooArgSet &extObs)=0
virtual Bool_t hasFilledCache() const
virtual void append(RooAbsDataStore &other)=0
virtual Bool_t changeObservableName(const char *from, const char *to)=0
virtual const RooAbsArg * cacheOwner()=0
virtual void resetBuffers()=0
virtual void setExternalWeightArray(const Double_t *, const Double_t *, const Double_t *, const Double_t *)
const RooArgSet & cachedVars() 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 RooBatchCompute::RunContext getBatches(std::size_t first, std::size_t len) const =0
Retrieve batches for all observables in this data store.
virtual void checkInit() const
virtual RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList)=0
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 RooSpan< const double > getWeightBatch(std::size_t first, std::size_t len) const =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.
void printTitle(std::ostream &os) const override
Print title of dataset.
virtual void setDirtyProp(Bool_t flag)
virtual RooAbsDataStore * clone(const char *newname=0) const =0
virtual const TTree * tree() const
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)=0
virtual RooArgSet * addColumns(const RooArgList &varList)=0
RooArgSet _cachedVars
double weight(Int_t index) const
virtual void resetCache()=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 const RooArgSet * get() const
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
RooAbsDataStore(std::string_view name, std::string_view title, const RooArgSet &vars)
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:35
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 TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual const char * GetTitle() const
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
basic_string_view< char > string_view
static const std::string name("name")
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