Logo ROOT   6.10/09
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 \file RooAbsDataStore.cxx
19 \class RooAbsDataStore
20 \ingroup Roofitcore
21 
22 RooAbsDataStore is the abstract base class for data collection that
23 use a TTree as internal storage mechanism
24 **/
25 
26 #include "RooFit.h"
27 #include "RooMsgService.h"
28 #include "RooAbsDataStore.h"
29 
30 #include "Riostream.h"
31 #include <iomanip>
32 #include "TClass.h"
33 
34 using namespace std ;
35 
37 ;
38 
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// Default constructor
42 
44 {
45  _iterator = _vars.createIterator() ;
46  _cacheIter = _cachedVars.createIterator() ;
47  _doDirtyProp = kTRUE ;
48 }
49 
50 
51 
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Default constructor
55 
56 RooAbsDataStore::RooAbsDataStore(const char* name, const char* title, const RooArgSet& vars) :
57  TNamed(name,title)
58 {
59  // clone the fundamentals of the given data set into internal buffer
60  _vars.add(vars) ;
61 
65 }
66 
67 
68 
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 
72 RooAbsDataStore::RooAbsDataStore(const RooAbsDataStore& other, const char* newname) : TNamed(other), RooPrintable(other)
73 {
74  if (newname) {
75  SetName(newname) ;
76  }
77  _vars.add(other._vars) ;
80  _doDirtyProp = other._doDirtyProp ;
81 }
82 
83 
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 
87 RooAbsDataStore::RooAbsDataStore(const RooAbsDataStore& other, const RooArgSet& vars, const char* newname) : TNamed(other), RooPrintable(other)
88 {
89  if (newname) {
90  SetName(newname) ;
91  }
92  _vars.add(vars) ;
95  _doDirtyProp = other._doDirtyProp ;
96 }
97 
98 
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 /// Destructor
102 
104 {
105  delete _iterator ;
106  delete _cacheIter ;
107 }
108 
109 
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// Return true if currently loaded coordinate is considered valid within
113 /// the current range definitions of all observables
114 
116 {
117  return kTRUE ;
118 }
119 
120 
121 ////////////////////////////////////////////////////////////////////////////////
122 /// Print name of dataset
123 
124 void RooAbsDataStore::printName(ostream& os) const
125 {
126  os << GetName() ;
127 }
128 
129 
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Print title of dataset
133 
134 void RooAbsDataStore::printTitle(ostream& os) const
135 {
136  os << GetTitle() ;
137 }
138 
139 
140 
141 ////////////////////////////////////////////////////////////////////////////////
142 /// Print class name of dataset
143 
144 void RooAbsDataStore::printClassName(ostream& os) const
145 {
146  os << IsA()->GetName() ;
147 }
148 
149 
150 
151 ////////////////////////////////////////////////////////////////////////////////
152 /// Print value of the dataset, i.e. the sum of weights contained in the dataset
153 
154 void RooAbsDataStore::printValue(ostream& os) const
155 {
156  os << numEntries() << " entries" ;
157 }
158 
159 
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 /// Print argument of dataset, i.e. the observable names
163 
164 void RooAbsDataStore::printArgs(ostream& os) const
165 {
166  os << "[" ;
167  _iterator->Reset() ;
168  RooAbsArg* arg ;
169  Bool_t first(kTRUE) ;
170  while((arg=(RooAbsArg*)_iterator->Next())) {
171  if (first) {
172  first=kFALSE ;
173  } else {
174  os << "," ;
175  }
176  os << arg->GetName() ;
177  }
178  os << "]" ;
179 }
180 
181 
182 
183 
184 
185 
186 ////////////////////////////////////////////////////////////////////////////////
187 /// Define default print options, for a given print style
188 
190 {
191  return kName|kClassName|kArgs|kValue ;
192 }
193 
194 
195 
196 
197 
198 ////////////////////////////////////////////////////////////////////////////////
199 /// Detailed printing interface
200 
201 void RooAbsDataStore::printMultiline(ostream& os, Int_t /*content*/, Bool_t verbose, TString indent) const
202 {
203  os << indent << "DataStore " << GetName() << " (" << GetTitle() << ")" << endl ;
204  os << indent << " Contains " << numEntries() << " entries" << endl;
205 
206  if (!verbose) {
207  os << indent << " Observables " << _vars << endl ;
208  } else {
209  os << indent << " Observables: " << endl ;
211  }
212 
213  if(verbose) {
214  if (_cachedVars.getSize()>0) {
215  os << indent << " Caches " << _cachedVars << endl ;
216  }
217 // if(_truth.getSize() > 0) {
218 // os << indent << " Generated with ";
219 // TString deeper(indent) ;
220 // deeper += " " ;
221 // _truth.printStream(os,kName|kValue,kStandard,deeper) ;
222 // }
223  }
224 }
225 
226 
227 
virtual void printTitle(std::ostream &os) const
Print title of dataset.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
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;.
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
virtual ~RooAbsDataStore()
Destructor.
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:86
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)
Set the name of the TNamed.
Definition: TNamed.cxx:131
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.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
STL namespace.
Bool_t _doDirtyProp
Iterator over cached variables.
virtual Int_t numEntries() const =0
RooPlotable is a &#39;mix-in&#39; base class that define the standard RooFit plotting and printing methods...
Definition: RooPrintable.h:25
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
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
const Bool_t kFALSE
Definition: RtypesCore.h:92
#define ClassImp(name)
Definition: Rtypes.h:336
RooAbsDataStore()
Default constructor.
virtual TObject * Next()=0
virtual void printArgs(std::ostream &os) const
Print argument of dataset, i.e. the observable names.
Definition: first.py:1
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: RtypesCore.h:91
TIterator * _iterator
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48