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