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 ;
32
33
34class RooAbsDataStore : public TNamed, public RooPrintable {
35public:
36
39 : TNamed(name,title), _vars{vars} {}
40 RooAbsDataStore(const RooAbsDataStore& other, const char* newname=nullptr)
41 : RooAbsDataStore(other, other._vars, newname) {}
42 RooAbsDataStore(const RooAbsDataStore& other, const RooArgSet& vars, const char* newname=nullptr)
43 : TNamed(other), RooPrintable(other), _vars{vars}, _doDirtyProp{other._doDirtyProp}
44 {
45 if(newname) SetName(newname);
46 }
47
48 virtual RooAbsDataStore* clone(const char* newname=nullptr) const = 0 ;
49 virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=nullptr) const = 0 ;
50
51 virtual std::unique_ptr<RooAbsDataStore> reduce(RooStringView name, RooStringView title,
52 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
53 std::size_t nStart, std::size_t nStop) = 0 ;
54
55 // Write current row
56 virtual Int_t fill() = 0 ;
57
58 // Retrieve a row
59 virtual const RooArgSet* get(Int_t index) const = 0 ;
60 virtual const RooArgSet* get() const { return &_vars ; }
61 virtual double weight() const = 0 ;
62
63 virtual double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const = 0 ;
64 virtual void weightError(double& lo, double& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const = 0 ;
65
66 double weight(Int_t index) const {
67 get(index) ;
68 return weight() ;
69 }
70 virtual bool isWeighted() const = 0 ;
71
72 /// Retrieve batches for all observables in this data store.
73 virtual RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const = 0;
74 virtual RooAbsData::CategorySpans getCategoryBatches(std::size_t /*first*/, std::size_t /*len*/) const {
75 std::cerr << "This functionality is not yet implemented for this data store." << std::endl;
76 throw std::logic_error("getCategoryBatches() not implemented in RooAbsDataStore.");
77 return {};
78 }
79 virtual std::span<const double> getWeightBatch(std::size_t first, std::size_t len) const = 0;
80
81 // Change observable name
82 virtual bool changeObservableName(const char* from, const char* to) =0 ;
83
84 // Add one or more columns
85 virtual RooAbsArg* addColumn(RooAbsArg& var, bool adjustRange=true) = 0 ;
86 RooArgSet* addColumns(const RooArgList& varList);
87
88 // Merge column-wise
89 virtual RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) = 0 ;
90
91 // Add rows
92 virtual void append(RooAbsDataStore& other)= 0 ;
93
94 // General & bookkeeping methods
95 virtual Int_t numEntries() const = 0 ;
96 virtual double sumEntries() const { return 0 ; } ;
97 virtual void reset() = 0 ;
98
99 // Buffer redirection routines used in inside RooAbsOptTestStatistics
100 virtual void attachBuffers(const RooArgSet& extObs) = 0 ;
101 virtual void resetBuffers() = 0 ;
102
103 virtual void setExternalWeightArray(const double* /*arrayWgt*/, const double* /*arrayWgtErrLo*/, const double* /*arrayWgtErrHi*/, const double* /*arraySumW2*/) {} ;
104
105 // Printing interface (human readable)
106 inline void Print(Option_t *options= nullptr) const override {
107 // Print contents on stdout
109 }
110
111 /// Print name of dataset
112 void printName(std::ostream& os) const override { os << GetName(); }
113 /// Print title of dataset
114 void printTitle(std::ostream& os) const override { os << GetTitle(); }
115 void printClassName(std::ostream& os) const override ;
116 void printArgs(std::ostream& os) const override;
117 /// Print value of the dataset, i.e. the sum of weights contained in the dataset
118 void printValue(std::ostream& os) const override { os << numEntries() << " entries" ; }
119 void printMultiline(std::ostream& os, Int_t content, bool verbose, TString indent) const override;
120
121 /// Define default print options, for a given print style
122 int defaultPrintContents(Option_t* /*opt*/) const override { return kName|kClassName|kArgs|kValue ; }
123
124
125 // Constant term optimizer interface
126 virtual void cacheArgs(const RooAbsArg* cacheOwner, RooArgSet& varSet, const RooArgSet* nset=nullptr, bool skipZeroWeights=false) = 0 ;
127 virtual const RooAbsArg* cacheOwner() = 0 ;
128 virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) = 0 ;
129 virtual void setArgStatus(const RooArgSet& set, bool active) = 0 ;
130 const RooArgSet& cachedVars() const { return _cachedVars ; }
131 virtual void resetCache() = 0 ;
132 virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, bool /* skipZeroWeights*/) {} ;
133
134 virtual void setDirtyProp(bool flag) { _doDirtyProp = flag ; }
135 bool dirtyProp() const { return _doDirtyProp ; }
136
137 virtual void checkInit() const {} ;
138
139 virtual bool hasFilledCache() const { return false ; }
140
141 virtual const TTree* tree() const { return nullptr ; }
142 virtual void dump() {}
143
144 virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=nullptr, const char* rangeName=nullptr,
145 std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) = 0 ;
146
147 virtual void forceCacheUpdate() {} ;
148
149 protected:
150
153
154 bool _doDirtyProp = true; ///< Switch do (de)activate dirty state propagation when loading a data point
155
156 ClassDefOverride(RooAbsDataStore,1) // Abstract Data Storage class
157};
158
159
160#endif
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
virtual void reset()=0
virtual const RooAbsArg * cacheOwner()=0
virtual void attachBuffers(const RooArgSet &extObs)=0
virtual void cacheArgs(const RooAbsArg *cacheOwner, RooArgSet &varSet, const RooArgSet *nset=nullptr, bool skipZeroWeights=false)=0
virtual RooAbsData::CategorySpans getCategoryBatches(std::size_t, std::size_t) const
virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar *select=nullptr, const char *rangeName=nullptr, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max())=0
const RooArgSet & cachedVars() const
virtual void append(RooAbsDataStore &other)=0
RooAbsDataStore(const RooAbsDataStore &other, const RooArgSet &vars, const char *newname=nullptr)
virtual const RooArgSet * get(Int_t index) const =0
virtual std::unique_ptr< RooAbsDataStore > reduce(RooStringView name, RooStringView title, const RooArgSet &vars, const RooFormulaVar *cutVar, const char *cutRange, std::size_t nStart, std::size_t nStop)=0
virtual void resetBuffers()=0
virtual RooAbsDataStore * clone(const char *newname=nullptr) const =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
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
RooAbsDataStore(const RooAbsDataStore &other, const char *newname=nullptr)
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_t fill()=0
virtual bool changeObservableName(const char *from, const char *to)=0
virtual double sumEntries() const
virtual void setArgStatus(const RooArgSet &set, bool active)=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.
RooAbsDataStore(RooStringView name, RooStringView title, const RooArgSet &vars)
virtual std::span< const double > getWeightBatch(std::size_t first, std::size_t len) const =0
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
void printMultiline(std::ostream &os, Int_t content, bool verbose, TString indent) const override
Detailed printing interface.
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.
virtual void recalculateCache(const RooArgSet *, Int_t, Int_t, Int_t, bool)
virtual RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=nullptr) const =0
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.
std::map< RooFit::Detail::DataKey, std::span< const double > > RealSpans
Definition RooAbsData.h:131
std::map< RooFit::Detail::DataKey, std::span< const RooAbsCategory::value_type > > CategorySpans
Definition RooAbsData.h:132
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:55
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=nullptr)
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,...
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...
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:139
A TTree represents a columnar dataset.
Definition TTree.h:79
Definition first.py:1