ROOT  6.06/08
Reference Guide
RooAbsDataStore.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$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 
17 //////////////////////////////////////////////////////////////////////////////
18 //
19 // BEGIN_HTML
20 // RooAbsDataStore is the abstract base class for data collection that
21 // use a TTree as internal storage mechanism
22 // END_HTML
23 //
24 
25 #include "RooFit.h"
26 #include "RooMsgService.h"
27 #include "RooAbsDataStore.h"
28 
29 #include "Riostream.h"
30 #include <iomanip>
31 #include "TClass.h"
32 
33 using namespace std ;
34 
36 ;
37 
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Default constructor
41 
43 {
44  _iterator = _vars.createIterator() ;
45  _cacheIter = _cachedVars.createIterator() ;
46  _doDirtyProp = kTRUE ;
47 }
48 
49 
50 
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// Default constructor
54 
55 RooAbsDataStore::RooAbsDataStore(const char* name, const char* title, const RooArgSet& vars) :
56  TNamed(name,title)
57 {
58  // clone the fundamentals of the given data set into internal buffer
59  _vars.add(vars) ;
60 
64 }
65 
66 
67 
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 
71 RooAbsDataStore::RooAbsDataStore(const RooAbsDataStore& other, const char* newname) : TNamed(other), RooPrintable(other)
72 {
73  if (newname) {
74  SetName(newname) ;
75  }
76  _vars.add(other._vars) ;
79  _doDirtyProp = other._doDirtyProp ;
80 }
81 
82 
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 
86 RooAbsDataStore::RooAbsDataStore(const RooAbsDataStore& other, const RooArgSet& vars, const char* newname) : TNamed(other), RooPrintable(other)
87 {
88  if (newname) {
89  SetName(newname) ;
90  }
91  _vars.add(vars) ;
94  _doDirtyProp = other._doDirtyProp ;
95 }
96 
97 
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Destructor
101 
103 {
104  delete _iterator ;
105  delete _cacheIter ;
106 }
107 
108 
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 /// Return true if currently loaded coordinate is considered valid within
112 /// the current range definitions of all observables
113 
115 {
116  return kTRUE ;
117 }
118 
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 /// Print name of dataset
122 
123 void RooAbsDataStore::printName(ostream& os) const
124 {
125  os << GetName() ;
126 }
127 
128 
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// Print title of dataset
132 
133 void RooAbsDataStore::printTitle(ostream& os) const
134 {
135  os << GetTitle() ;
136 }
137 
138 
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// Print class name of dataset
142 
143 void RooAbsDataStore::printClassName(ostream& os) const
144 {
145  os << IsA()->GetName() ;
146 }
147 
148 
149 
150 ////////////////////////////////////////////////////////////////////////////////
151 /// Print value of the dataset, i.e. the sum of weights contained in the dataset
152 
153 void RooAbsDataStore::printValue(ostream& os) const
154 {
155  os << numEntries() << " entries" ;
156 }
157 
158 
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 /// Print argument of dataset, i.e. the observable names
162 
163 void RooAbsDataStore::printArgs(ostream& os) const
164 {
165  os << "[" ;
166  _iterator->Reset() ;
167  RooAbsArg* arg ;
168  Bool_t first(kTRUE) ;
169  while((arg=(RooAbsArg*)_iterator->Next())) {
170  if (first) {
171  first=kFALSE ;
172  } else {
173  os << "," ;
174  }
175  os << arg->GetName() ;
176  }
177  os << "]" ;
178 }
179 
180 
181 
182 
183 
184 
185 ////////////////////////////////////////////////////////////////////////////////
186 /// Define default print options, for a given print style
187 
189 {
190  return kName|kClassName|kArgs|kValue ;
191 }
192 
193 
194 
195 
196 
197 ////////////////////////////////////////////////////////////////////////////////
198 /// Detailed printing interface
199 
200 void RooAbsDataStore::printMultiline(ostream& os, Int_t /*content*/, Bool_t verbose, TString indent) const
201 {
202  os << indent << "DataStore " << GetName() << " (" << GetTitle() << ")" << endl ;
203  os << indent << " Contains " << numEntries() << " entries" << endl;
204 
205  if (!verbose) {
206  os << indent << " Observables " << _vars << endl ;
207  } else {
208  os << indent << " Observables: " << endl ;
210  }
211 
212  if(verbose) {
213  if (_cachedVars.getSize()>0) {
214  os << indent << " Caches " << _cachedVars << endl ;
215  }
216 // if(_truth.getSize() > 0) {
217 // os << indent << " Generated with ";
218 // TString deeper(indent) ;
219 // deeper += " " ;
220 // _truth.printStream(os,kName|kValue,kStandard,deeper) ;
221 // }
222  }
223 }
224 
225 
226 
virtual void printTitle(std::ostream &os) const
Print title of dataset.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer, which is interpreted as an OR of &#39;enum ContentsOptions&#39; values and in the style given by &#39;enum StyleOption&#39;.
virtual ~RooAbsDataStore()
Destructor.
virtual void Reset()=0
virtual void printClassName(std::ostream &os) const
Print class name of dataset.
const char Option_t
Definition: RtypesCore.h:62
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
void printMultiline(std::ostream &os, Int_t content, Bool_t verbose, TString indent) const
Detailed printing interface.
virtual void printValue(std::ostream &os) const
Print value of the dataset, i.e. the sum of weights contained in the dataset.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
STL namespace.
Bool_t _doDirtyProp
Iterator over cached variables.
virtual Int_t numEntries() const =0
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TIterator * _cacheIter
Iterator over dimension variables.
virtual Bool_t valid() const =0
Return true if currently loaded coordinate is considered valid within the current range definitions o...
virtual void printName(std::ostream &os) const
Print name of dataset.
virtual Int_t defaultPrintContents(Option_t *opt) const
Define default print options, for a given print style.
RooArgSet _cachedVars
Int_t getSize() const
bool verbose
static void indent(ostringstream &buf, int indent_level)
#define ClassImp(name)
Definition: Rtypes.h:279
RooAbsDataStore()
Default constructor.
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual TObject * Next()=0
virtual void printArgs(std::ostream &os) const
Print argument of dataset, i.e. the observable names.
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
TIterator * _iterator
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
Definition: RooArgSet.cxx:448
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52