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(RooStringView name, RooStringView title, const RooArgSet& vars, RooCategory& indexCat, std::map<std::string,RooAbsDataStore*> const& inputData) ;
40
41 // Empty constructor.
42 RooAbsDataStore* clone(const char* newname=nullptr) const override { return new RooCompositeDataStore(*this,newname) ; }
43 RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=nullptr) const override { return new RooCompositeDataStore(*this,vars,newname) ; }
44
45 std::unique_ptr<RooAbsDataStore> reduce(RooStringView name, RooStringView title,
46 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
47 std::size_t nStart, std::size_t nStop) override;
48
49 RooCompositeDataStore(const RooCompositeDataStore& other, const char* newname=nullptr) ;
50 RooCompositeDataStore(const RooCompositeDataStore& other, const RooArgSet& vars, const char* newname=nullptr) ;
51
52 ~RooCompositeDataStore() override ;
53
54 void dump() override ;
55
56 // Write current row
57 Int_t fill() override ;
58
59 double sumEntries() const override ;
60
61 // Retrieve a row
63 const RooArgSet* get(Int_t index) const override ;
65 double weight() const override ;
66 double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override ;
67 void weightError(double& lo, double& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const override ;
68 bool isWeighted() const override ;
69
70 // Change observable name
71 bool changeObservableName(const char* from, const char* to) override ;
72
73 // Add one column
74 RooAbsArg* addColumn(RooAbsArg& var, bool adjustRange=true) override ;
75
76 // Merge column-wise
77 RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) override ;
78
79 RooCategory* index() { return _indexCat ; }
80
81 // Add rows
82 void append(RooAbsDataStore& other) override ;
83
84 // General & bookkeeping methods
85 Int_t numEntries() const override ;
86 void reset() override ;
87
88 // Buffer redirection routines used in inside RooAbsOptTestStatistics
89 void attachBuffers(const RooArgSet& extObs) override ;
90 void resetBuffers() override ;
91
92 // Constant term optimizer interface
93 void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=nullptr, bool skipZeroWeights=false) override ;
94 const RooAbsArg* cacheOwner() override { return nullptr ; }
95 void setArgStatus(const RooArgSet& set, bool active) override ;
96 void resetCache() override ;
97
98 void recalculateCache(const RooArgSet* /*proj*/, Int_t /*firstEvent*/, Int_t /*lastEvent*/, Int_t /*stepSize*/, bool /*skipZeroWeights*/) override ;
99 bool hasFilledCache() const override ;
100
101 void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=nullptr, const char* rangeName=nullptr,
102 std::size_t nStart=0, std::size_t nStop = std::numeric_limits<std::size_t>::max()) override;
103
104 void forceCacheUpdate() override ;
105
106 RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override {
107 //TODO
108 std::cerr << "This functionality is not yet implemented for composite data stores." << std::endl;
109 throw std::logic_error("getBatches() not implemented for RooCompositeDataStore.");
110 (void)first; (void)len;
111 return {};
112 }
113 std::span<const double> getWeightBatch(std::size_t first, std::size_t len) const override;
114
115
116 protected:
117
118 void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) override ;
119
120 std::map<Int_t,RooAbsDataStore*> _dataMap ;
122 mutable RooAbsDataStore* _curStore = nullptr; ///<! Datastore associated with current event
123 mutable Int_t _curIndex = 0; ///<! Index associated with current event
124 mutable std::unique_ptr<std::vector<double>> _weightBuffer; ///<! Buffer for weights in case a batch of values is requested.
125 bool _ownComps = false; ///<!
126
127 ClassDefOverride(RooCompositeDataStore,1) // Composite Data Storage class
128};
129
130
131#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
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
Abstract base class for a data collection.
const RooArgSet & cachedVars() const
virtual double weight() const =0
virtual const RooArgSet * get() const
std::map< RooFit::Detail::DataKey, std::span< const double > > RealSpans
Definition RooAbsData.h:131
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:24
Object to represent discrete states.
Definition RooCategory.h:28
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.
RooAbsDataStore * clone(const RooArgSet &vars, const char *newname=nullptr) const override
RooAbsArg * addColumn(RooAbsArg &var, bool adjustRange=true) override
WVE ownership issue here!! Caller (a RooAbsData) should take ownership of all arguments,...
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
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()) override
Int_t numEntries() const override
std::span< 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).
std::map< Int_t, RooAbsDataStore * > _dataMap
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList) override
bool changeObservableName(const char *from, const char *to) override
Change name of internal observable named 'from' into 'to'.
~RooCompositeDataStore() override
Destructor.
RooAbsDataStore * clone(const char *newname=nullptr) const override
void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=nullptr, bool skipZeroWeights=false) override
void recalculateCache(const RooArgSet *, Int_t, Int_t, Int_t, bool) override
Forward recalculate request to all subsets.
RooAbsData::RealSpans getBatches(std::size_t first, std::size_t len) const override
Retrieve batches for all observables in this data store.
bool isWeighted() const override
void setArgStatus(const RooArgSet &set, bool active) override
bool hasFilledCache() const override
RooAbsDataStore * _curStore
! Datastore associated with current event
double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override
double sumEntries() const override
Forward fill request to appropriate subset.
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) override
Int_t fill() override
Forward fill request to appropriate subset.
void attachBuffers(const RooArgSet &extObs) override
double weight() const override
const RooAbsArg * cacheOwner() override
void append(RooAbsDataStore &other) override
virtual const RooArgSet * get() const
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...