Loading [MathJax]/extensions/tex2jax.js
ROOT  6.07/01
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
19 class TDirectory ;
20 class RooAbsRealLValue ;
21 class RooRealVar ;
22 class RooDataHist ;
23 #include "RooAbsData.h"
24 #include "RooDirItem.h"
25 
26 #define USEMEMPOOL
27 
28 
29 class RooDataSet : public RooAbsData, public RooDirItem {
30 public:
31 
32 #ifdef USEMEMPOOL
33  void* operator new (size_t bytes);
34  void operator delete (void *ptr);
35 #endif
36 
37 
38  // Constructors, factory methods etc.
39  RooDataSet() ;
40 
41  // Empty constructor
42  RooDataSet(const char *name, const char *title, const RooArgSet& vars, const char* wgtVarName=0) ;
43 
44  // Universal constructor
45  RooDataSet(const char* name, const char* title, const RooArgSet& vars, const RooCmdArg& arg1, const RooCmdArg& arg2=RooCmdArg(),
46  const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(),const RooCmdArg& arg5=RooCmdArg(),
47  const RooCmdArg& arg6=RooCmdArg(),const RooCmdArg& arg7=RooCmdArg(),const RooCmdArg& arg8=RooCmdArg()) ;
48 
49  // Constructor for subset of existing dataset
50  RooDataSet(const char *name, const char *title, RooDataSet *data, const RooArgSet& vars,
51  const char *cuts=0, const char* wgtVarName=0);
52  RooDataSet(const char *name, const char *title, RooDataSet *data, const RooArgSet& vars,
53  const RooFormulaVar& cutVar, const char* wgtVarName=0) ;
54 
55 
56  // Constructor importing data from external ROOT Tree
57  RooDataSet(const char *name, const char *title, TTree *ntuple, const RooArgSet& vars,
58  const char *cuts=0, const char* wgtVarName=0);
59  RooDataSet(const char *name, const char *title, TTree *t, const RooArgSet& vars,
60  const RooFormulaVar& cutVar, const char* wgtVarName=0) ;
61 
62 
63  RooDataSet(RooDataSet const & other, const char* newname=0) ;
64  virtual TObject* Clone(const char* newname=0) const { return new RooDataSet(*this,newname?newname:GetName()) ; }
65  virtual ~RooDataSet() ;
66 
67  virtual RooAbsData* emptyClone(const char* newName=0, const char* newTitle=0, const RooArgSet* vars=0, const char* wgtVarName=0) const ;
68 
69  RooDataHist* binnedClone(const char* newName=0, const char* newTitle=0) const ;
70 
71  virtual Double_t sumEntries() const ;
72  virtual Double_t sumEntries(const char* cutSpec, const char* cutRange=0) const ;
73 
74  virtual RooPlot* plotOnXY(RooPlot* frame,
75  const RooCmdArg& arg1=RooCmdArg::none(), const RooCmdArg& arg2=RooCmdArg::none(),
76  const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
77  const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
78  const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) const ;
79 
80 
81  // Read data from a text file and create a dataset from it.
82  // The possible options are: (D)ebug, (Q)uiet.
83  static RooDataSet *read(const char *filename, const RooArgList &variables,
84  const char *opts= "", const char* commonPath="",
85  const char *indexCatName=0) ;
86  Bool_t write(const char* filename) ;
87 
88 /* void setWeightVar(const char* name=0) ; */
89 /* void setWeightVar(const RooAbsArg& arg) { */
90 /* // Interpret given argument as event weight */
91 /* setWeightVar(arg.GetName()) ; */
92 /* } */
93  virtual Bool_t isWeighted() const ;
94  virtual Bool_t isNonPoissonWeighted() const ;
95 
96  virtual Double_t weight() const ;
97  virtual Double_t weightSquared() const ;
98  virtual void weightError(Double_t& lo, Double_t& hi,ErrorType etype=SumW2) const ;
99  Double_t weightError(ErrorType etype=SumW2) const ;
100 
101  virtual const RooArgSet* get(Int_t index) const;
102  virtual const RooArgSet* get() const ;
103 
104  // Add one ore more rows of data
105  virtual void add(const RooArgSet& row, Double_t weight=1.0, Double_t weightError=0);
106  virtual void add(const RooArgSet& row, Double_t weight, Double_t weightErrorLo, Double_t weightErrorHi);
107 
108  virtual void addFast(const RooArgSet& row, Double_t weight=1.0, Double_t weightError=0);
109 
110  void append(RooDataSet& data) ;
111  Bool_t merge(RooDataSet* data1, RooDataSet* data2=0, RooDataSet* data3=0,
112  RooDataSet* data4=0, RooDataSet* data5=0, RooDataSet* data6=0) ;
113  Bool_t merge(std::list<RooDataSet*> dsetList) ;
114 
115  virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) ;
116  virtual RooArgSet* addColumns(const RooArgList& varList) ;
117 
118  // Plot the distribution of a real valued arg
120  TH2F* createHistogram(const RooAbsRealLValue& var1, const RooAbsRealLValue& var2, const char* cuts="",
121  const char *name= "hist") const;
123  const char* cuts="", const char *name="hist") const;
124 
125  void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
126  virtual void printArgs(std::ostream& os) const ;
127  virtual void printValue(std::ostream& os) const ;
128 
129  void SetName(const char *name) ;
130  void SetNameTitle(const char *name, const char* title) ;
131 
132 protected:
133 
134  virtual RooAbsData* cacheClone(const RooAbsArg* newCacheOwner, const RooArgSet* newCacheVars, const char* newName=0) ;
135 
136  friend class RooProdGenContext ;
137 
138  void initialize(const char* wgtVarName) ;
139 
140  // Cache copy feature is not publicly accessible
141  RooAbsData* reduceEng(const RooArgSet& varSubset, const RooFormulaVar* cutVar, const char* cutRange=0,
142  Int_t nStart=0, Int_t nStop=2000000000, Bool_t copyCache=kTRUE) ;
143  RooDataSet(const char *name, const char *title, RooDataSet *ntuple,
144  const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange, int nStart, int nStop, Bool_t copyCache, const char* wgtVarName=0);
145 
146  RooArgSet addWgtVar(const RooArgSet& origVars, const RooAbsArg* wgtVar) ;
147 
148  RooArgSet _varsNoWgt ; // Vars without weight variable
149  RooRealVar* _wgtVar ; // Pointer to weight variable (if set)
150 
151  static void cleanup() ;
152  static char* _poolBegin ; //! Start of memory pool
153  static char* _poolCur ; //! Next free slot in memory pool
154  static char* _poolEnd ; //! End of memory pool
155 
156  ClassDef(RooDataSet,2) // Unbinned data set
157 };
158 
159 #endif
const int nx
Definition: kalman.C:16
tuple row
Definition: mrt.py:26
void SetName(const char *name)
Change the name of this dataset into the given name.
static char * _poolBegin
Definition: RooDataSet.h:152
virtual Bool_t isWeighted() const
Return true if dataset contains weighted events.
void variables(TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
Definition: variables.cxx:10
virtual RooArgSet * addColumns(const RooArgList &varList)
Add a column with the values of the given list of (function) argument to this dataset.
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:892
RooArgSet _varsNoWgt
Definition: RooDataSet.h:148
static const char * filename()
RooDataSet()
Default constructor for persistence.
Definition: RooDataSet.cxx:183
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Double_t weightSquared() const
Return event weight of current event.
const Bool_t kFALSE
Definition: Rtypes.h:92
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...
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
virtual void weightError(Double_t &lo, Double_t &hi, ErrorType etype=SumW2) const
Return asymmetric error on weight. (Dummy implementation returning zero)
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a column with the values of the given (function) argument to this dataset.
#define ClassDef(name, id)
Definition: Rtypes.h:254
const int ny
Definition: kalman.C:17
static char * _poolEnd
Next free slot in memory pool.
Definition: RooDataSet.h:154
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:946
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
static char * _poolCur
Start of memory pool.
Definition: RooDataSet.h:153
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 Double_t weight() const
Return event weight of current event.
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
virtual void printValue(std::ostream &os) const
Print value of the dataset, i.e. the sum of weights contained in the dataset.
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:874
void initialize(const char *wgtVarName)
Initialize the dataset.
Definition: RooDataSet.cxx:921
bool verbose
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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
Create and fill a ROOT histogram TH1,TH2 or TH3 with the values of this dataset.
Definition: RooAbsData.cxx:735
static void indent(ostringstream &buf, int indent_level)
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.
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
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...
virtual Double_t sumEntries() const
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...
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
Definition: RooPlot.h:41
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:862
double Double_t
Definition: RtypesCore.h:55
Bool_t write(const char *filename)
Write the contents of this dataset to an ASCII file with the specified name Each event will be writte...
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories...
Definition: RooDirItem.h:22
void append(RooDataSet &data)
Add all data points of given data set to this data set.
Describe directory structure in memory.
Definition: TDirectory.h:44
RooDataHist * binnedClone(const char *newName=0, const char *newTitle=0) const
Return binned clone of this dataset.
Definition: RooDataSet.cxx:981
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.
void SetNameTitle(const char *name, const char *title)
Change the title of this dataset into the given name.
Mother of all ROOT objects.
Definition: TObject.h:58
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Bool_t merge(RooDataSet *data1, RooDataSet *data2=0, RooDataSet *data3=0, RooDataSet *data4=0, RooDataSet *data5=0, RooDataSet *data6=0)
RooProdGenContext is an efficient implementation of the generator context specific for RooProdPdf PDF...
virtual ~RooDataSet()
Destructor.
Definition: RooDataSet.cxx:970
virtual Bool_t isNonPoissonWeighted() const
Returns true if histogram contains bins with entries with a non-integer weight.
RooRealVar * _wgtVar
Definition: RooDataSet.h:149
A TTree object has a header with a name and a title.
Definition: TTree.h:98
float type_of_call hi(const int &, const int &)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooDataSet.h:64
virtual void printArgs(std::ostream &os) const
Print argument of dataset, i.e. the observable names.
static void cleanup()
Clear memoery pool on exit to avoid reported memory leaks.
Definition: RooDataSet.cxx:82
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27