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#include "RunContext.h"
21
22#include <map>
23#include <string>
24#include <vector>
25#include <list>
26
27class RooAbsArg ;
28class RooArgList ;
29class RooFormulaVar ;
30class RooArgSet ;
31class RooCategory ;
32
33
35public:
36
38
39 // Ctors from DataStore
40 RooCompositeDataStore(RooStringView name, RooStringView title, const RooArgSet& vars, RooCategory& indexCat, std::map<std::string,RooAbsDataStore*> const& inputData) ;
41
42 // Empty ctor
43 RooAbsDataStore* clone(const char* newname=0) const override { return new RooCompositeDataStore(*this,newname) ; }
44 RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const override { return new RooCompositeDataStore(*this,vars,newname) ; }
45
47 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
48 std::size_t nStart, std::size_t nStop) override;
49
50 RooCompositeDataStore(const RooCompositeDataStore& other, const char* newname=0) ;
51 RooCompositeDataStore(const RooCompositeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
52
53 ~RooCompositeDataStore() override ;
54
55 void dump() override ;
56
57 // Write current row
58 Int_t fill() override ;
59
60 Double_t sumEntries() const override ;
61
62 // Retrieve a row
64 const RooArgSet* get(Int_t index) const override ;
66 Double_t weight() const override ;
69 Bool_t isWeighted() const override ;
70
71 // Change observable name
72 Bool_t changeObservableName(const char* from, const char* to) override ;
73
74 // Add one column
75 RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) override ;
76
77 // Merge column-wise
78 RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) override ;
79
80 RooCategory* index() { return _indexCat ; }
81
82 // Add rows
83 void append(RooAbsDataStore& other) override ;
84
85 // General & bookkeeping methods
86 Int_t numEntries() const override ;
87 void reset() override ;
88
89 // Buffer redirection routines used in inside RooAbsOptTestStatistics
90 void attachBuffers(const RooArgSet& extObs) override ;
91 void resetBuffers() override ;
92
93 // Constant term optimizer interface
94 void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0, Bool_t skipZeroWeights=kFALSE) override ;
95 const RooAbsArg* cacheOwner() override { return 0 ; }
96 void setArgStatus(const RooArgSet& set, Bool_t active) override ;
97 void resetCache() override ;
98
99 void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, Bool_t /*skipZeroWeights*/) override ;
100 Bool_t hasFilledCache() const override ;
101
102 void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0,
103 std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) override;
104
105 void forceCacheUpdate() override ;
106
107 RooBatchCompute::RunContext getBatches(std::size_t first, std::size_t len) const override {
108 //TODO
109 std::cerr << "This functionality is not yet implemented for composite data stores." << std::endl;
110 throw std::logic_error("getBatches() not implemented for RooCompositeDataStore.");
111 (void)first; (void)len;
112 return {};
113 }
114 RooSpan<const double> getWeightBatch(std::size_t first, std::size_t len) const override;
115
116
117 protected:
118
119 void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) override ;
120
121 std::map<Int_t,RooAbsDataStore*> _dataMap ;
123 mutable RooAbsDataStore* _curStore = nullptr; ///<! Datastore associated with current event
124 mutable Int_t _curIndex = 0; ///<! Index associated with current event
125 mutable std::unique_ptr<std::vector<double>> _weightBuffer; ///<! Buffer for weights in case a batch of values is requested.
126 Bool_t _ownComps = false; ///<!
127
128 ClassDefOverride(RooCompositeDataStore,1) // Composite Data Storage class
129};
130
131
132#endif
const Bool_t kFALSE
Definition: RtypesCore.h:101
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
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:78
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
const RooArgSet & cachedVars() const
virtual Double_t weight() const =0
virtual const RooArgSet * get() const
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
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:28
RooCompositeDataStore combines several disjunct datasets into one.
void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars) override
Initialize cache of dataset: attach variables of cache ArgSet to the corresponding TTree branches.
std::unique_ptr< std::vector< double > > _weightBuffer
! Buffer for weights in case a batch of values is requested.
Int_t _curIndex
! Index associated with current event
RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=0) const override
Int_t numEntries() const override
RooAbsDataStore * reduce(RooStringView name, RooStringView title, const RooArgSet &vars, const RooFormulaVar *cutVar, const char *cutRange, std::size_t nStart, std::size_t nStop) override
Double_t sumEntries() const override
Forward fill request to appropriate subset.
std::map< Int_t, RooAbsDataStore * > _dataMap
Bool_t changeObservableName(const char *from, const char *to) override
Change name of internal observable named 'from' into 'to'.
void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kFALSE) override
Bool_t isWeighted() const override
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList) override
RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE) override
WVE ownership issue here!! Caller (a RooAbsData) should take ownership of all arguments,...
Bool_t hasFilledCache() const override
~RooCompositeDataStore() override
Destructor.
Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override
RooSpan< const double > getWeightBatch(std::size_t first, std::size_t len) const override
Get the weights of the events in the range [first, first+len).
void recalculateCache(const RooArgSet *, Int_t, Int_t, Int_t, Bool_t) override
Forward recalculate request to all subsets.
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()) override
void setArgStatus(const RooArgSet &set, Bool_t active) override
RooAbsDataStore * _curStore
! Datastore associated with current event
Int_t fill() override
Forward fill request to appropriate subset.
void attachBuffers(const RooArgSet &extObs) override
const RooAbsArg * cacheOwner() override
RooAbsDataStore * clone(const char *newname=0) const override
void append(RooAbsDataStore &other) override
virtual const RooArgSet * get() const
RooBatchCompute::RunContext getBatches(std::size_t first, std::size_t len) const override
Retrieve batches for all observables in this data store.
Double_t weight() const override
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:30
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
void(off) SmallVectorTemplateBase< T
Definition: first.py:1
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31