Logo ROOT   6.16/01
Reference Guide
RooDataSet.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooDataSet.h,v 1.59 2007/05/11 09:11:30 verkerke Exp $
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_DATA_SET
17#define ROO_DATA_SET
18
19class TDirectory ;
20class RooAbsRealLValue ;
21class RooRealVar ;
22class RooDataHist ;
23#include "RooAbsData.h"
24#include "RooDirItem.h"
25
26
27#define USEMEMPOOLFORDATASET
28template <class RooSet_t, size_t>
30
31class RooDataSet : public RooAbsData, public RooDirItem {
32public:
33
34#ifdef USEMEMPOOLFORDATASET
35 void* operator new (size_t bytes);
36 void operator delete (void *ptr);
37#endif
38
39
40 // Constructors, factory methods etc.
41 RooDataSet() ;
42
43 // Empty constructor
44 RooDataSet(const char *name, const char *title, const RooArgSet& vars, const char* wgtVarName=0) ;
45
46 // Universal constructor
47 RooDataSet(const char* name, const char* title, const RooArgSet& vars, const RooCmdArg& arg1, const RooCmdArg& arg2=RooCmdArg(),
48 const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(),const RooCmdArg& arg5=RooCmdArg(),
49 const RooCmdArg& arg6=RooCmdArg(),const RooCmdArg& arg7=RooCmdArg(),const RooCmdArg& arg8=RooCmdArg()) ;
50
51 // Constructor for subset of existing dataset
52 RooDataSet(const char *name, const char *title, RooDataSet *data, const RooArgSet& vars,
53 const char *cuts=0, const char* wgtVarName=0);
54 RooDataSet(const char *name, const char *title, RooDataSet *data, const RooArgSet& vars,
55 const RooFormulaVar& cutVar, const char* wgtVarName=0) ;
56
57
58 // Constructor importing data from external ROOT Tree
59 RooDataSet(const char *name, const char *title, TTree *ntuple, const RooArgSet& vars,
60 const char *cuts=0, const char* wgtVarName=0);
61 RooDataSet(const char *name, const char *title, TTree *t, const RooArgSet& vars,
62 const RooFormulaVar& cutVar, const char* wgtVarName=0) ;
63
64
65 RooDataSet(RooDataSet const & other, const char* newname=0) ;
66 virtual TObject* Clone(const char* newname=0) const { return new RooDataSet(*this,newname?newname:GetName()) ; }
67 virtual ~RooDataSet() ;
68
69 virtual RooAbsData* emptyClone(const char* newName=0, const char* newTitle=0, const RooArgSet* vars=0, const char* wgtVarName=0) const ;
70
71 RooDataHist* binnedClone(const char* newName=0, const char* newTitle=0) const ;
72
73 virtual Double_t sumEntries() const ;
74 virtual Double_t sumEntries(const char* cutSpec, const char* cutRange=0) const ;
75
76 virtual RooPlot* plotOnXY(RooPlot* frame,
77 const RooCmdArg& arg1=RooCmdArg::none(), const RooCmdArg& arg2=RooCmdArg::none(),
78 const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
79 const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
80 const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) const ;
81
82
83 // Read data from a text file and create a dataset from it.
84 // The possible options are: (D)ebug, (Q)uiet.
85 static RooDataSet *read(const char *filename, const RooArgList &variables,
86 const char *opts= "", const char* commonPath="",
87 const char *indexCatName=0) ;
88 Bool_t write(const char* filename) const;
89 Bool_t write(std::ostream & ofs) const;
90
91/* void setWeightVar(const char* name=0) ; */
92/* void setWeightVar(const RooAbsArg& arg) { */
93/* // Interpret given argument as event weight */
94/* setWeightVar(arg.GetName()) ; */
95/* } */
96 virtual Bool_t isWeighted() const ;
97 virtual Bool_t isNonPoissonWeighted() const ;
98
99 virtual Double_t weight() const ;
100 virtual Double_t weightSquared() const ;
101 virtual void weightError(Double_t& lo, Double_t& hi,ErrorType etype=SumW2) const ;
102 Double_t weightError(ErrorType etype=SumW2) const ;
103
104 virtual const RooArgSet* get(Int_t index) const;
105 virtual const RooArgSet* get() const ;
106
107 // Add one ore more rows of data
108 virtual void add(const RooArgSet& row, Double_t weight=1.0, Double_t weightError=0);
109 virtual void add(const RooArgSet& row, Double_t weight, Double_t weightErrorLo, Double_t weightErrorHi);
110
111 virtual void addFast(const RooArgSet& row, Double_t weight=1.0, Double_t weightError=0);
112
113 void append(RooDataSet& data) ;
114 Bool_t merge(RooDataSet* data1, RooDataSet* data2=0, RooDataSet* data3=0,
115 RooDataSet* data4=0, RooDataSet* data5=0, RooDataSet* data6=0) ;
116 Bool_t merge(std::list<RooDataSet*> dsetList) ;
117
118 virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) ;
119 virtual RooArgSet* addColumns(const RooArgList& varList) ;
120
121 // Plot the distribution of a real valued arg
123 TH2F* createHistogram(const RooAbsRealLValue& var1, const RooAbsRealLValue& var2, const char* cuts="",
124 const char *name= "hist") const;
125 TH2F* createHistogram(const RooAbsRealLValue& var1, const RooAbsRealLValue& var2, Int_t nx, Int_t ny,
126 const char* cuts="", const char *name="hist") const;
127
128 void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
129 virtual void printArgs(std::ostream& os) const ;
130 virtual void printValue(std::ostream& os) const ;
131
132 void SetName(const char *name) ;
133 void SetNameTitle(const char *name, const char* title) ;
134
135 static void cleanup();
136
137protected:
138
139 virtual RooAbsData* cacheClone(const RooAbsArg* newCacheOwner, const RooArgSet* newCacheVars, const char* newName=0) ;
140
141 friend class RooProdGenContext ;
142
143 void initialize(const char* wgtVarName) ;
144
145 // Cache copy feature is not publicly accessible
146 RooAbsData* reduceEng(const RooArgSet& varSubset, const RooFormulaVar* cutVar, const char* cutRange=0,
147 Int_t nStart=0, Int_t nStop=2000000000, Bool_t copyCache=kTRUE) ;
148 RooDataSet(const char *name, const char *title, RooDataSet *ntuple,
149 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange, int nStart, int nStop, Bool_t copyCache, const char* wgtVarName=0);
150
151 RooArgSet addWgtVar(const RooArgSet& origVars, const RooAbsArg* wgtVar) ;
152
153 RooArgSet _varsNoWgt ; // Vars without weight variable
154 RooRealVar* _wgtVar ; // Pointer to weight variable (if set)
155
156private:
157#ifdef USEMEMPOOLFORDATASET
158 typedef MemPoolForRooSets<RooDataSet, 5*150> MemPool; // 150 = about 100kb
159 static MemPool * memPool();
160#endif
161
162 ClassDef(RooDataSet,2) // Unbinned data set
163};
164
165#endif
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:324
float type_of_call hi(const int &, const int &)
Memory pool for RooArgSet and RooDataSet.
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
TH1 * createHistogram(const char *name, const RooAbsRealLValue &xvar, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Calls createHistogram(const char *name, const RooAbsRealLValue& xvar, const RooLinkedList& argList) c...
Definition: RooAbsData.cxx:613
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:50
RooDataSet is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
virtual void printArgs(std::ostream &os) const
Print argument of dataset, i.e. the observable names.
RooRealVar * _wgtVar
Definition: RooDataSet.h:154
virtual Double_t sumEntries() const
static void cleanup()
Definition: RooDataSet.cxx:66
RooArgSet _varsNoWgt
Definition: RooDataSet.h:153
RooAbsData * reduceEng(const RooArgSet &varSubset, const RooFormulaVar *cutVar, const char *cutRange=0, Int_t nStart=0, Int_t nStop=2000000000, Bool_t copyCache=kTRUE)
Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods.
Definition: RooDataSet.cxx:896
virtual void weightError(Double_t &lo, Double_t &hi, ErrorType etype=SumW2) const
Return asymmetric error on weight. (Dummy implementation returning zero)
Definition: RooDataSet.cxx:976
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a column with the values of the given (function) argument to this dataset.
virtual Double_t weight() const
Return event weight of current event.
Definition: RooDataSet.cxx:955
virtual Bool_t isWeighted() const
Return true if dataset contains weighted events.
void SetName(const char *name)
Change the name of this dataset into the given name.
Bool_t write(const char *filename) const
Write the contents of this dataset to an ASCII file with the specified name.
virtual Bool_t isNonPoissonWeighted() const
Returns true if histogram contains bins with entries with a non-integer weight.
RooArgSet addWgtVar(const RooArgSet &origVars, const RooAbsArg *wgtVar)
Helper function for constructor that adds optional weight variable to construct total set of observab...
Definition: RooDataSet.cxx:812
void initialize(const char *wgtVarName)
Initialize the dataset.
Definition: RooDataSet.cxx:871
MemPoolForRooSets< RooDataSet, 5 *150 > MemPool
Definition: RooDataSet.h:158
virtual Double_t weightSquared() const
Return event weight of current event.
Definition: RooDataSet.cxx:966
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print info about this dataset to the specified output stream.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0)
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
void SetNameTitle(const char *name, const char *title)
Change the title of this dataset into the given name.
static RooDataSet * read(const char *filename, const RooArgList &variables, const char *opts="", const char *commonPath="", const char *indexCatName=0)
Read given list of ascii files, and construct a data set, using the given ArgList as structure defini...
TH2F * createHistogram(const RooAbsRealLValue &var1, const RooAbsRealLValue &var2, const char *cuts="", const char *name="hist") const
Create a TH2F histogram of the distribution of the specified variable using this dataset.
virtual RooArgSet * addColumns(const RooArgList &varList)
Add a column with the values of the given list of (function) argument to this dataset.
virtual void printValue(std::ostream &os) const
Print value of the dataset, i.e. the sum of weights contained in the dataset.
void append(RooDataSet &data)
Add all data points of given data set to this data set.
RooDataSet()
Default constructor for persistence.
Definition: RooDataSet.cxx:125
Bool_t merge(RooDataSet *data1, RooDataSet *data2=0, RooDataSet *data3=0, RooDataSet *data4=0, RooDataSet *data5=0, RooDataSet *data6=0)
virtual RooAbsData * emptyClone(const char *newName=0, const char *newTitle=0, const RooArgSet *vars=0, const char *wgtVarName=0) const
Return an empty clone of this dataset.
Definition: RooDataSet.cxx:842
virtual ~RooDataSet()
Destructor.
Definition: RooDataSet.cxx:922
RooDataHist * binnedClone(const char *newName=0, const char *newTitle=0) const
Return binned clone of this dataset.
Definition: RooDataSet.cxx:933
virtual void addFast(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0)
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
static MemPool * memPool()
virtual const RooArgSet * get() const
Return a RooArgSet with the coordinates of the current event.
virtual RooAbsData * cacheClone(const RooAbsArg *newCacheOwner, const RooArgSet *newCacheVars, const char *newName=0)
Return a clone of this dataset containing only the cached variables.
Definition: RooDataSet.cxx:824
virtual RooPlot * plotOnXY(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Special plot method for 'X-Y' datasets used in Chi^2 fitting.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooDataSet.h:66
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
Definition: RooDirItem.h:22
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:41
RooProdGenContext is an efficient implementation of the generator context specific for RooProdPdf PDF...
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
Describe directory structure in memory.
Definition: TDirectory.h:34
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:250
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
A TTree object has a header with a name and a title.
Definition: TTree.h:71
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)