ROOT  6.06/09
Reference Guide
RooDataSet.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 // RooDataSet is a container class to hold unbinned data. Each data point
21 // in N-dimensional space is represented by a RooArgSet of RooRealVar, RooCategory
22 // or RooStringVar objects
23 // END_HTML
24 //
25 
26 #include "RooFit.h"
27 
28 #include "Riostream.h"
29 #include "Riostream.h"
30 #include <fstream>
31 #include "TTree.h"
32 #include "TH2.h"
33 #include "TDirectory.h"
34 #include "RooDataSet.h"
35 #include "RooPlot.h"
36 #include "RooAbsReal.h"
37 #include "Roo1DTable.h"
38 #include "RooCategory.h"
39 #include "RooFormulaVar.h"
40 #include "RooArgList.h"
41 #include "RooAbsRealLValue.h"
42 #include "RooRealVar.h"
43 #include "RooDataHist.h"
44 #include "RooMsgService.h"
45 #include "RooCmdConfig.h"
46 #include "RooHist.h"
47 #include "TROOT.h"
48 #include "TFile.h"
49 #include "RooTreeDataStore.h"
50 #include "RooVectorDataStore.h"
51 #include "RooCompositeDataStore.h"
52 #include "RooTreeData.h"
53 #include "RooSentinel.h"
54 #include "RooTrace.h"
55 
56 #if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)
57 char* operator+( streampos&, char* );
58 #endif
59 
60 using namespace std;
61 
63 ;
64 
65 
66 char* RooDataSet::_poolBegin = 0 ;
67 char* RooDataSet::_poolCur = 0 ;
68 char* RooDataSet::_poolEnd = 0 ;
69 #define POOLSIZE 1048576
70 
71 struct POOLDATA
72 {
73  void* _base ;
74 } ;
75 
76 static std::list<POOLDATA> _memPoolList ;
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Clear memoery pool on exit to avoid reported memory leaks
80 
82 {
83  std::list<POOLDATA>::iterator iter = _memPoolList.begin() ;
84  while(iter!=_memPoolList.end()) {
85  free(iter->_base) ;
86  iter->_base=0 ;
87  iter++ ;
88  }
89  _memPoolList.clear() ;
90 }
91 
92 
93 #ifdef USEMEMPOOL
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 /// Overloaded new operator guarantees that all RooDataSets allocated with new
97 /// have a unique address, a property that is exploited in several places
98 /// in roofit to quickly index contents on normalization set pointers.
99 /// The memory pool only allocates space for the class itself. The elements
100 /// stored in the set are stored outside the pool.
101 
102 void* RooDataSet::operator new (size_t bytes)
103 {
104  //cout << " RooDataSet::operator new(" << bytes << ")" << endl ;
105 
106  if (!_poolBegin || _poolCur+(sizeof(RooDataSet)) >= _poolEnd) {
107 
108  if (_poolBegin!=0) {
109  oocxcoutD((TObject*)0,Caching) << "RooDataSet::operator new(), starting new 1MB memory pool" << endl ;
110  }
111 
112  // Start pruning empty memory pools if number exceeds 3
113  if (_memPoolList.size()>3) {
114 
115  void* toFree(0) ;
116 
117  for (std::list<POOLDATA>::iterator poolIter = _memPoolList.begin() ; poolIter!=_memPoolList.end() ; ++poolIter) {
118 
119  // If pool is empty, delete it and remove it from list
120  if ((*(Int_t*)(poolIter->_base))==0) {
121  oocxcoutD((TObject*)0,Caching) << "RooDataSet::operator new(), pruning empty memory pool " << (void*)(poolIter->_base) << endl ;
122 
123  toFree = poolIter->_base ;
124  _memPoolList.erase(poolIter) ;
125  break ;
126  }
127  }
128 
129  free(toFree) ;
130  }
131 
132  void* mem = malloc(POOLSIZE) ;
133 
134  _poolBegin = (char*)mem ;
135  // Reserve space for pool counter at head of pool
136  _poolCur = _poolBegin+sizeof(Int_t) ;
137  _poolEnd = _poolBegin+(POOLSIZE) ;
138 
139  // Clear pool counter
140  *((Int_t*)_poolBegin)=0 ;
141 
142  POOLDATA p ;
143  p._base=mem ;
144  _memPoolList.push_back(p) ;
145 
147  }
148 
149  char* ptr = _poolCur ;
150  _poolCur += bytes ;
151 
152  // Increment use counter of pool
153  (*((Int_t*)_poolBegin))++ ;
154 
155  return ptr ;
156 
157 }
158 
159 
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 /// Memory is owned by pool, we need to do nothing to release it
163 
164 void RooDataSet::operator delete (void* ptr)
165 {
166  // Decrease use count in pool that ptr is on
167  for (std::list<POOLDATA>::iterator poolIter = _memPoolList.begin() ; poolIter!=_memPoolList.end() ; ++poolIter) {
168  if ((char*)ptr > (char*)poolIter->_base && (char*)ptr < (char*)poolIter->_base + POOLSIZE) {
169  (*(Int_t*)(poolIter->_base))-- ;
170  break ;
171  }
172  }
173 
174 }
175 
176 #endif
177 
178 
179 ////////////////////////////////////////////////////////////////////////////////
180 /// Default constructor for persistence
181 
182 RooDataSet::RooDataSet() : _wgtVar(0)
183 {
185 }
186 
187 
188 
189 
190 
191 ////////////////////////////////////////////////////////////////////////////////
192 /// Construct an unbinned dataset from a RooArgSet defining the dimensions of the data space. Optionally, data
193 /// can be imported at the time of construction.
194 ///
195 /// This constructor takes the following optional arguments
196 ///
197 /// Import(TTree*) -- Import contents of given TTree. Only braches of the TTree that have names
198 /// corresponding to those of the RooAbsArgs that define the RooDataSet are
199 /// imported.
200 /// ImportFromFile(const char* fileName, const char* treeName) -- Import tree with given name from file with given name.
201 ///
202 /// Import(RooDataSet&) -- Import contents of given RooDataSet. Only observables that are common with
203 /// the definition of this dataset will be imported
204 ///
205 /// Index(RooCategory&) -- Prepare import of datasets into a N+1 dimensional RooDataSet
206 /// where the extra discrete dimension labels the source of the imported histogram.
207 ///
208 /// Import(const char*, -- Import a dataset to be associated with the given state name of the index category
209 /// RooDataSet&) specified in Index(). If the given state name is not yet defined in the index
210 /// category it will be added on the fly. The import command can be specified
211 /// multiple times.
212 ///
213 /// Link(const char*, RooDataSet&) -- Link contents of supplied RooDataSet to this dataset for given index category state name.
214 /// In this mode, no data is copied and the linked dataset must be remain live for the duration
215 /// of this dataset. Note that link is active for both reading and writing, so modifications
216 /// to the aggregate dataset will also modify its components. Link() and Import() are mutually exclusive.
217 /// OwnLinked() -- Take ownership of all linked datasets
218 ///
219 /// Import(map<string,RooDataSet*>&) -- As above, but allows specification of many imports in a single operation
220 /// Link(map<string,RooDataSet*>&) -- As above, but allows specification of many links in a single operation
221 ///
222 ///
223 /// Cut(const char*) -- Apply the given cut specification when importing data
224 /// Cut(RooFormulaVar&)
225 ///
226 /// CutRange(const char*) -- Only accept events in the observable range with the given name
227 ///
228 /// WeightVar(const char*) -- Interpret the given variable as event weight rather than as observable
229 /// WeightVar(const RooAbsArg&)
230 ///
231 /// StoreError(const RooArgSet&) -- Store symmetric error along with value for given subset of observables
232 /// StoreAsymError(const RooArgSet&) -- Store asymmetric error along with value for given subset of observables
233 ///
234 
235 RooDataSet::RooDataSet(const char* name, const char* title, const RooArgSet& vars, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3,
236  const RooCmdArg& arg4,const RooCmdArg& arg5,const RooCmdArg& arg6,const RooCmdArg& arg7,const RooCmdArg& arg8) :
237  RooAbsData(name,title,RooArgSet(vars,(RooAbsArg*)RooCmdConfig::decodeObjOnTheFly("RooDataSet::RooDataSet", "IndexCat",0,0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)))
238 {
239  // Define configuration for this method
240  RooCmdConfig pc(Form("RooDataSet::ctor(%s)",GetName())) ;
241  pc.defineInt("ownLinked","OwnLinked",0) ;
242  pc.defineObject("impTree","ImportTree",0) ;
243  pc.defineObject("impData","ImportData",0) ;
244  pc.defineObject("indexCat","IndexCat",0) ;
245  pc.defineObject("impSliceData","ImportDataSlice",0,0,kTRUE) ; // array
246  pc.defineString("impSliceState","ImportDataSlice",0,"",kTRUE) ; // array
247  pc.defineObject("lnkSliceData","LinkDataSlice",0,0,kTRUE) ; // array
248  pc.defineString("lnkSliceState","LinkDataSlice",0,"",kTRUE) ; // array
249  pc.defineString("cutSpec","CutSpec",0,"") ;
250  pc.defineObject("cutVar","CutVar",0) ;
251  pc.defineString("cutRange","CutRange",0,"") ;
252  pc.defineString("wgtVarName","WeightVarName",0,"") ;
253  pc.defineInt("newWeight1","WeightVarName",0,0) ;
254  pc.defineString("fname","ImportFromFile",0,"") ;
255  pc.defineString("tname","ImportFromFile",1,"") ;
256  pc.defineObject("wgtVar","WeightVar",0) ;
257  pc.defineInt("newWeight2","WeightVar",0,0) ;
258  pc.defineObject("dummy1","ImportDataSliceMany",0) ;
259  pc.defineObject("dummy2","LinkDataSliceMany",0) ;
260  pc.defineSet("errorSet","StoreError",0) ;
261  pc.defineSet("asymErrSet","StoreAsymError",0) ;
262  pc.defineMutex("ImportTree","ImportData","ImportDataSlice","LinkDataSlice","ImportFromFile") ;
263  pc.defineMutex("CutSpec","CutVar") ;
264  pc.defineMutex("WeightVarName","WeightVar") ;
265  pc.defineDependency("ImportDataSlice","IndexCat") ;
266  pc.defineDependency("LinkDataSlice","IndexCat") ;
267  pc.defineDependency("OwnLinked","LinkDataSlice") ;
268 
269 
270  RooLinkedList l ;
271  l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
272  l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
273  l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
274  l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
275 
276  // Process & check varargs
277  pc.process(l) ;
278  if (!pc.ok(kTRUE)) {
279  assert(0) ;
280  return ;
281  }
282 
283  // Extract relevant objects
284  TTree* impTree = static_cast<TTree*>(pc.getObject("impTree")) ;
285  RooDataSet* impData = static_cast<RooDataSet*>(pc.getObject("impData")) ;
286  RooFormulaVar* cutVar = static_cast<RooFormulaVar*>(pc.getObject("cutVar")) ;
287  const char* cutSpec = pc.getString("cutSpec","",kTRUE) ;
288  const char* cutRange = pc.getString("cutRange","",kTRUE) ;
289  const char* wgtVarName = pc.getString("wgtVarName","",kTRUE) ;
290  RooRealVar* wgtVar = static_cast<RooRealVar*>(pc.getObject("wgtVar")) ;
291  const char* impSliceNames = pc.getString("impSliceState","",kTRUE) ;
292  const RooLinkedList& impSliceData = pc.getObjectList("impSliceData") ;
293  const char* lnkSliceNames = pc.getString("lnkSliceState","",kTRUE) ;
294  const RooLinkedList& lnkSliceData = pc.getObjectList("lnkSliceData") ;
295  RooCategory* indexCat = static_cast<RooCategory*>(pc.getObject("indexCat")) ;
296  RooArgSet* errorSet = pc.getSet("errorSet") ;
297  RooArgSet* asymErrorSet = pc.getSet("asymErrSet") ;
298  const char* fname = pc.getString("fname") ;
299  const char* tname = pc.getString("tname") ;
300  Int_t ownLinked = pc.getInt("ownLinked") ;
301  Int_t newWeight = pc.getInt("newWeight1") + pc.getInt("newWeight2") ;
302 
303  // Case 1 --- Link multiple dataset as slices
304  if (lnkSliceNames) {
305 
306  // Make import mapping if index category is specified
307  map<string,RooAbsData*> hmap ;
308  if (indexCat) {
309  char tmp[10240] ;
310  strlcpy(tmp,lnkSliceNames,10240) ;
311  char* token = strtok(tmp,",") ;
312  TIterator* hiter = lnkSliceData.MakeIterator() ;
313  while(token) {
314  hmap[token] = (RooAbsData*) hiter->Next() ;
315  token = strtok(0,",") ;
316  }
317  delete hiter ;
318  }
319 
320  // Lookup name of weight variable if it was specified by object reference
321  if (wgtVar) {
322  // coverity[UNUSED_VALUE]
323  wgtVarName = wgtVar->GetName() ;
324  }
325 
326  appendToDir(this,kTRUE) ;
327 
328  // Initialize RooDataSet with optional weight variable
329  initialize(0) ;
330 
331  map<string,RooAbsDataStore*> storeMap ;
332  RooCategory* icat = (RooCategory*) (indexCat ? _vars.find(indexCat->GetName()) : 0 ) ;
333  if (!icat) {
334  throw std::string("RooDataSet::RooDataSet() ERROR in constructor, cannot find index category") ;
335  }
336  for (map<string,RooAbsData*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
337  // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
338  if (indexCat && !indexCat->lookupType(hiter->first.c_str())) {
339  indexCat->defineType(hiter->first.c_str()) ;
340  coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
341  }
342  if (icat && !icat->lookupType(hiter->first.c_str())) {
343  icat->defineType(hiter->first.c_str()) ;
344  }
345  icat->setLabel(hiter->first.c_str()) ;
346  storeMap[icat->getLabel()]=hiter->second->store() ;
347 
348  // Take ownership of slice if requested
349  if (ownLinked) {
350  addOwnedComponent(hiter->first.c_str(),*hiter->second) ;
351  }
352  }
353 
354  // Create composite datastore
355  _dstore = new RooCompositeDataStore(name,title,_vars,*icat,storeMap) ;
356 
357  } else {
358 
359  if (wgtVar) {
360  wgtVarName = wgtVar->GetName() ;
361  }
362 
363  // Clone weight variable of imported dataset if we are not weighted
364  if (!wgtVar && !wgtVarName && impData && impData->_wgtVar) {
365  _wgtVar = (RooRealVar*) impData->_wgtVar->createFundamental() ;
366  _vars.addOwned(*_wgtVar) ;
367  wgtVarName = _wgtVar->GetName() ;
368  }
369 
370  // Create empty datastore
371  RooTreeDataStore* tstore(0) ;
372  RooVectorDataStore* vstore(0) ;
373 
374  if (defaultStorageType==Tree) {
375  tstore = new RooTreeDataStore(name,title,_vars,wgtVarName) ;
376  _dstore = tstore ;
377  } else if (defaultStorageType==Vector) {
378  if (wgtVarName && newWeight) {
379  RooAbsArg* wgttmp = _vars.find(wgtVarName) ;
380  if (wgttmp) {
381  wgttmp->setAttribute("NewWeight") ;
382  }
383  }
384  vstore = new RooVectorDataStore(name,title,_vars,wgtVarName) ;
385  _dstore = vstore ;
386  } else {
387  _dstore = 0 ;
388  }
389 
390 
391  // Make import mapping if index category is specified
392  map<string,RooDataSet*> hmap ;
393  if (indexCat) {
394  char tmp[100000] ;
395  strlcpy(tmp,impSliceNames,100000) ;
396  char* token = strtok(tmp,",") ;
397  TIterator* hiter = impSliceData.MakeIterator() ;
398  while(token) {
399  hmap[token] = (RooDataSet*) hiter->Next() ;
400  token = strtok(0,",") ;
401  }
402  delete hiter ;
403  }
404 
405  // process StoreError requests
406  if (errorSet) {
407  RooArgSet* intErrorSet = (RooArgSet*) _vars.selectCommon(*errorSet) ;
408  intErrorSet->setAttribAll("StoreError") ;
409  TIterator* iter = intErrorSet->createIterator() ;
410  RooAbsArg* arg ;
411  while((arg=(RooAbsArg*)iter->Next())) {
412  arg->attachToStore(*_dstore) ;
413  }
414  delete iter ;
415  delete intErrorSet ;
416  }
417  if (asymErrorSet) {
418  RooArgSet* intAsymErrorSet = (RooArgSet*) _vars.selectCommon(*asymErrorSet) ;
419  intAsymErrorSet->setAttribAll("StoreAsymError") ;
420  TIterator* iter = intAsymErrorSet->createIterator() ;
421  RooAbsArg* arg ;
422  while((arg=(RooAbsArg*)iter->Next())) {
423  arg->attachToStore(*_dstore) ;
424  }
425  delete iter ;
426  delete intAsymErrorSet ;
427  }
428 
429  // Lookup name of weight variable if it was specified by object reference
430  if (wgtVar) {
431  wgtVarName = wgtVar->GetName() ;
432  }
433 
434 
435  appendToDir(this,kTRUE) ;
436 
437  // Initialize RooDataSet with optional weight variable
438  if (wgtVarName && *wgtVarName) {
439  // Use the supplied weight column
440  initialize(wgtVarName) ;
441 
442  } else {
443  if (impData && impData->_wgtVar && vars.find(impData->_wgtVar->GetName())) {
444 
445  // Use the weight column of the source data set
446  initialize(impData->_wgtVar->GetName()) ;
447 
448  } else if (indexCat) {
449 
450  RooDataSet* firstDS = hmap.begin()->second ;
451  if (firstDS->_wgtVar && vars.find(firstDS->_wgtVar->GetName())) {
452  initialize(firstDS->_wgtVar->GetName()) ;
453  } else {
454  initialize(0) ;
455  }
456  } else {
457  initialize(0) ;
458  }
459  }
460 
461  // Import one or more datasets with a cut specification
462  if (cutSpec && *cutSpec) {
463 
464  // Create a RooFormulaVar cut from given cut expression
465  if (indexCat) {
466 
467  // Case 2a --- Import multiple RooDataSets as slices with cutspec
468  RooCategory* icat = (RooCategory*) _vars.find(indexCat->GetName()) ;
469  for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
470  // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
471  if (!indexCat->lookupType(hiter->first.c_str())) {
472  indexCat->defineType(hiter->first.c_str()) ;
473  coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
474  }
475  if (!icat->lookupType(hiter->first.c_str())) {
476  icat->defineType(hiter->first.c_str()) ;
477  }
478  icat->setLabel(hiter->first.c_str()) ;
479 
480  RooFormulaVar cutVarTmp(cutSpec,cutSpec,hiter->second->_vars) ;
481  _dstore->loadValues(hiter->second->store(),&cutVarTmp,cutRange) ;
482  }
483 
484  } else if (impData) {
485 
486  // Case 3a --- Import RooDataSet with cutspec
487  RooFormulaVar cutVarTmp(cutSpec,cutSpec,impData->_vars) ;
488  _dstore->loadValues(impData->store(),&cutVarTmp,cutRange);
489  } else if (impTree) {
490 
491  // Case 4a --- Import TTree from memory with cutspec
492  RooFormulaVar cutVarTmp(cutSpec,cutSpec,_vars) ;
493  if (tstore) {
494  tstore->loadValues(impTree,&cutVarTmp,cutRange);
495  } else {
496  RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
497  tmpstore.loadValues(impTree,&cutVarTmp,cutRange) ;
498  _dstore->append(tmpstore) ;
499  }
500  } else if (fname && strlen(fname)) {
501 
502  // Case 5a --- Import TTree from file with cutspec
503  TFile *f = TFile::Open(fname) ;
504  if (!f) {
505  coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' cannot be opened or does not exist" << endl ;
506  throw string(Form("RooDataSet::ctor(%s) ERROR file %s cannot be opened or does not exist",GetName(),fname)) ;
507  }
508  TTree* t = dynamic_cast<TTree*>(f->Get(tname)) ;
509  if (!t) {
510  coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' does not contain a TTree named '" << tname << "'" << endl ;
511  throw string(Form("RooDataSet::ctor(%s) ERROR file %s does not contain a TTree named %s",GetName(),fname,tname)) ;
512  }
513  RooFormulaVar cutVarTmp(cutSpec,cutSpec,_vars) ;
514  if (tstore) {
515  tstore->loadValues(t,&cutVarTmp,cutRange);
516  } else {
517  RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
518  tmpstore.loadValues(t,&cutVarTmp,cutRange) ;
519  _dstore->append(tmpstore) ;
520  }
521  f->Close() ;
522 
523  }
524 
525  // Import one or more datasets with a cut formula
526  } else if (cutVar) {
527 
528  if (indexCat) {
529 
530  // Case 2b --- Import multiple RooDataSets as slices with cutvar
531 
532  RooCategory* icat = (RooCategory*) _vars.find(indexCat->GetName()) ;
533  for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
534  // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
535  if (!indexCat->lookupType(hiter->first.c_str())) {
536  indexCat->defineType(hiter->first.c_str()) ;
537  coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
538  }
539  if (!icat->lookupType(hiter->first.c_str())) {
540  icat->defineType(hiter->first.c_str()) ;
541  }
542  icat->setLabel(hiter->first.c_str()) ;
543  _dstore->loadValues(hiter->second->store(),cutVar,cutRange) ;
544  }
545 
546 
547  } else if (impData) {
548  // Case 3b --- Import RooDataSet with cutvar
549  _dstore->loadValues(impData->store(),cutVar,cutRange);
550  } else if (impTree) {
551  // Case 4b --- Import TTree from memory with cutvar
552  if (tstore) {
553  tstore->loadValues(impTree,cutVar,cutRange);
554  } else {
555  RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
556  tmpstore.loadValues(impTree,cutVar,cutRange) ;
557  _dstore->append(tmpstore) ;
558  }
559  } else if (fname && strlen(fname)) {
560  // Case 5b --- Import TTree from file with cutvar
561  TFile *f = TFile::Open(fname) ;
562  if (!f) {
563  coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' cannot be opened or does not exist" << endl ;
564  throw string(Form("RooDataSet::ctor(%s) ERROR file %s cannot be opened or does not exist",GetName(),fname)) ;
565  }
566  TTree* t = dynamic_cast<TTree*>(f->Get(tname)) ;
567  if (!t) {
568  coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' does not contain a TTree named '" << tname << "'" << endl ;
569  throw string(Form("RooDataSet::ctor(%s) ERROR file %s does not contain a TTree named %s",GetName(),fname,tname)) ;
570  }
571  if (tstore) {
572  tstore->loadValues(t,cutVar,cutRange);
573  } else {
574  RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
575  tmpstore.loadValues(t,cutVar,cutRange) ;
576  _dstore->append(tmpstore) ;
577  }
578 
579  f->Close() ;
580  }
581 
582  // Import one or more datasets without cuts
583  } else {
584 
585  if (indexCat) {
586 
587  RooCategory* icat = (RooCategory*) _vars.find(indexCat->GetName()) ;
588  for (map<string,RooDataSet*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
589  // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
590  if (!indexCat->lookupType(hiter->first.c_str())) {
591  indexCat->defineType(hiter->first.c_str()) ;
592  coutI(InputArguments) << "RooDataSet::ctor(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat->GetName() << endl ;
593  }
594  if (!icat->lookupType(hiter->first.c_str())) {
595  icat->defineType(hiter->first.c_str()) ;
596  }
597  icat->setLabel(hiter->first.c_str()) ;
598  // Case 2c --- Import multiple RooDataSets as slices
599  _dstore->loadValues(hiter->second->store(),0,cutRange) ;
600  }
601 
602 
603  } else if (impData) {
604  // Case 3c --- Import RooDataSet
605  _dstore->loadValues(impData->store(),0,cutRange);
606  } else if (impTree) {
607  // Case 4c --- Import TTree from memort
608  if (tstore) {
609  tstore->loadValues(impTree,0,cutRange);
610  } else {
611  RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
612  tmpstore.loadValues(impTree,0,cutRange) ;
613  _dstore->append(tmpstore) ;
614  }
615  } else if (fname && strlen(fname)) {
616  // Case 5c --- Import TTree from file
617  TFile *f = TFile::Open(fname) ;
618  if (!f) {
619  coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' cannot be opened or does not exist" << endl ;
620  throw string(Form("RooDataSet::ctor(%s) ERROR file %s cannot be opened or does not exist",GetName(),fname)) ;
621  }
622  TTree* t = dynamic_cast<TTree*>(f->Get(tname)) ;
623  if (!t) {
624  coutE(InputArguments) << "RooDataSet::ctor(" << GetName() << ") ERROR file '" << fname << "' does not contain a TTree named '" << tname << "'" << endl ;
625  throw string(Form("RooDataSet::ctor(%s) ERROR file %s does not contain a TTree named %s",GetName(),fname,tname)) ;
626  }
627  if (tstore) {
628  tstore->loadValues(t,0,cutRange);
629  } else {
630  RooTreeDataStore tmpstore(name,title,_vars,wgtVarName) ;
631  tmpstore.loadValues(t,0,cutRange) ;
632  _dstore->append(tmpstore) ;
633  }
634  f->Close() ;
635  }
636  }
637 
638  }
640 }
641 
642 
643 
644 ////////////////////////////////////////////////////////////////////////////////
645 /// Constructor of an empty data set from a RooArgSet defining the dimensions
646 /// of the data space.
647 
648 RooDataSet::RooDataSet(const char *name, const char *title, const RooArgSet& vars, const char* wgtVarName) :
649  RooAbsData(name,title,vars)
650 {
651 // cout << "RooDataSet::ctor(" << this << ") storageType = " << ((defaultStorageType==Tree)?"Tree":"Vector") << endl ;
652  _dstore = (defaultStorageType==Tree) ? ((RooAbsDataStore*) new RooTreeDataStore(name,title,_vars,wgtVarName)) :
653  ((RooAbsDataStore*) new RooVectorDataStore(name,title,_vars,wgtVarName)) ;
654 
655  appendToDir(this,kTRUE) ;
656  initialize(wgtVarName) ;
658 }
659 
660 
661 ////////////////////////////////////////////////////////////////////////////////
662 /// Constructor of a data set from (part of) an existing data
663 /// set. The dimensions of the data set are defined by the 'vars'
664 /// RooArgSet, which can be identical to 'dset' dimensions, or a
665 /// subset thereof. The 'cuts' string is an optional RooFormula
666 /// expression and can be used to select the subset of the data
667 /// points in 'dset' to be copied. The cut expression can refer to
668 /// any variable in the source dataset. For cuts involving variables
669 /// other than those contained in the source data set, such as
670 /// intermediate formula objects, use the equivalent constructor
671 /// accepting RooFormulaVar reference as cut specification
672 ///
673 /// For most uses the RooAbsData::reduce() wrapper function, which
674 /// uses this constructor, is the most convenient way to create a
675 /// subset of an existing data
676 ///
677 
678 RooDataSet::RooDataSet(const char *name, const char *title, RooDataSet *dset,
679  const RooArgSet& vars, const char *cuts, const char* wgtVarName) :
680  RooAbsData(name,title,vars)
681 {
682  // Initialize datastore
683  _dstore = new RooTreeDataStore(name,title,_vars,*dset->_dstore,cuts,wgtVarName) ;
684 
685  appendToDir(this,kTRUE) ;
686 
687  if (wgtVarName) {
688  // Use the supplied weight column
689  initialize(wgtVarName) ;
690  } else {
691  if (dset->_wgtVar && vars.find(dset->_wgtVar->GetName())) {
692  // Use the weight column of the source data set
693  initialize(dset->_wgtVar->GetName()) ;
694  } else {
695  initialize(0) ;
696  }
697  }
699 }
700 
701 
702 ////////////////////////////////////////////////////////////////////////////////
703 /// Constructor of a data set from (part of) an existing data
704 /// set. The dimensions of the data set are defined by the 'vars'
705 /// RooArgSet, which can be identical to 'dset' dimensions, or a
706 /// subset thereof. The 'cutVar' formula variable is used to select
707 /// the subset of data points to be copied. For subsets without
708 /// selection on the data points, or involving cuts operating
709 /// exclusively and directly on the data set dimensions, the
710 /// equivalent constructor with a string based cut expression is
711 /// recommended.
712 ///
713 /// For most uses the RooAbsData::reduce() wrapper function, which
714 /// uses this constructor, is the most convenient way to create a
715 /// subset of an existing data
716 
717 RooDataSet::RooDataSet(const char *name, const char *title, RooDataSet *dset,
718  const RooArgSet& vars, const RooFormulaVar& cutVar, const char* wgtVarName) :
719  RooAbsData(name,title,vars)
720 {
721  // Initialize datastore
722  _dstore = new RooTreeDataStore(name,title,_vars,*dset->_dstore,cutVar,wgtVarName) ;
723 
724  appendToDir(this,kTRUE) ;
725 
726  if (wgtVarName) {
727  // Use the supplied weight column
728  initialize(wgtVarName) ;
729  } else {
730  if (dset->_wgtVar && vars.find(dset->_wgtVar->GetName())) {
731  // Use the weight column of the source data set
732  initialize(dset->_wgtVar->GetName()) ;
733  } else {
734  initialize(0) ;
735  }
736  }
738 }
739 
740 
741 
742 
743 ////////////////////////////////////////////////////////////////////////////////
744 /// Constructor of a data set from (part of) an ROOT TTRee. The dimensions
745 /// of the data set are defined by the 'vars' RooArgSet. For each dimension
746 /// specified, the TTree must have a branch with the same name. For category
747 /// branches, this branch should contain the numeric index value. Real dimensions
748 /// can be constructed from either 'Double_t' or 'Float_t' tree branches. In the
749 /// latter case, an automatic conversion is applied.
750 ///
751 /// The 'cutVar' formula variable
752 /// is used to select the subset of data points to be copied.
753 /// For subsets without selection on the data points, or involving cuts
754 /// operating exclusively and directly on the data set dimensions, the equivalent
755 /// constructor with a string based cut expression is recommended.
756 
757 RooDataSet::RooDataSet(const char *name, const char *title, TTree *intree,
758  const RooArgSet& vars, const RooFormulaVar& cutVar, const char* wgtVarName) :
759  RooAbsData(name,title,vars)
760 {
761  // Create tree version of datastore
762  RooTreeDataStore* tstore = new RooTreeDataStore(name,title,_vars,*intree,cutVar,wgtVarName) ;
763 
764  // Convert to vector datastore if needed
765  if (defaultStorageType==Tree) {
766  _dstore = tstore ;
767  } else if (defaultStorageType==Vector) {
768  RooVectorDataStore* vstore = new RooVectorDataStore(name,title,_vars,wgtVarName) ;
769  _dstore = vstore ;
770  _dstore->append(*tstore) ;
771  delete tstore ;
772  } else {
773  _dstore = 0 ;
774  }
775 
776  appendToDir(this,kTRUE) ;
777  initialize(wgtVarName) ;
779 }
780 
781 
782 
783 ////////////////////////////////////////////////////////////////////////////////
784 /// Constructor of a data set from (part of) an ROOT TTRee. The dimensions
785 /// of the data set are defined by the 'vars' RooArgSet. For each dimension
786 /// specified, the TTree must have a branch with the same name. For category
787 /// branches, this branch should contain the numeric index value. Real dimensions
788 /// can be constructed from either 'Double_t' or 'Float_t' tree branches. In the
789 /// latter case, an automatic conversion is applied.
790 ///
791 /// The 'cuts' string is an optional
792 /// RooFormula expression and can be used to select the subset of the data points
793 /// in 'dset' to be copied. The cut expression can refer to any variable in the
794 /// vars argset. For cuts involving variables other than those contained in
795 /// the vars argset, such as intermediate formula objects, use the
796 /// equivalent constructor accepting RooFormulaVar reference as cut specification
797 ///
798 
799 RooDataSet::RooDataSet(const char *name, const char *title, TTree *intree,
800  const RooArgSet& vars, const char *selExpr, const char* wgtVarName) :
801  RooAbsData(name,title,vars)
802 {
803  // Create tree version of datastore
804  RooTreeDataStore* tstore = new RooTreeDataStore(name,title,_vars,*intree,selExpr,wgtVarName) ;
805 
806  // Convert to vector datastore if needed
807  if (defaultStorageType==Tree) {
808  _dstore = tstore ;
809  } else if (defaultStorageType==Vector) {
810  RooVectorDataStore* vstore = new RooVectorDataStore(name,title,_vars,wgtVarName) ;
811  _dstore = vstore ;
812  _dstore->append(*tstore) ;
813  delete tstore ;
814  } else {
815  _dstore = 0 ;
816  }
817 
818  appendToDir(this,kTRUE) ;
819 
820  initialize(wgtVarName) ;
822 }
823 
824 
825 
826 ////////////////////////////////////////////////////////////////////////////////
827 /// Copy constructor
828 
829 RooDataSet::RooDataSet(RooDataSet const & other, const char* newname) :
830  RooAbsData(other,newname), RooDirItem()
831 {
832  appendToDir(this,kTRUE) ;
833  initialize(other._wgtVar?other._wgtVar->GetName():0) ;
835 }
836 
837 ////////////////////////////////////////////////////////////////////////////////
838 /// Protected constructor for internal use only
839 
840 RooDataSet::RooDataSet(const char *name, const char *title, RooDataSet *dset,
841  const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
842  Int_t nStart, Int_t nStop, Bool_t copyCache, const char* wgtVarName) :
843  RooAbsData(name,title,vars)
844 {
846  ((RooAbsDataStore*) new RooTreeDataStore(name,title,*dset->_dstore,_vars,cutVar,cutRange,nStart,nStop,copyCache,wgtVarName)) :
847  ((RooAbsDataStore*) new RooVectorDataStore(name,title,*dset->_dstore,_vars,cutVar,cutRange,nStart,nStop,copyCache,wgtVarName)) ;
848 
850 
851  appendToDir(this,kTRUE) ;
852  initialize(dset->_wgtVar?dset->_wgtVar->GetName():0) ;
854 }
855 
856 
857 ////////////////////////////////////////////////////////////////////////////////
858 /// Helper function for constructor that adds optional weight variable to construct
859 /// total set of observables
860 
861 RooArgSet RooDataSet::addWgtVar(const RooArgSet& origVars, const RooAbsArg* wgtVar)
862 {
863  RooArgSet tmp(origVars) ;
864  if (wgtVar) tmp.add(*wgtVar) ;
865  return tmp ;
866 }
867 
868 
869 
870 ////////////////////////////////////////////////////////////////////////////////
871 /// Return a clone of this dataset containing only the cached variables
872 
873 RooAbsData* RooDataSet::cacheClone(const RooAbsArg* newCacheOwner, const RooArgSet* newCacheVars, const char* newName)
874 {
875  RooDataSet* dset = new RooDataSet(newName?newName:GetName(),GetTitle(),this,_vars,(RooFormulaVar*)0,0,0,2000000000,kTRUE,_wgtVar?_wgtVar->GetName():0) ;
876  //if (_wgtVar) dset->setWeightVar(_wgtVar->GetName()) ;
877 
878  RooArgSet* selCacheVars = (RooArgSet*) newCacheVars->selectCommon(dset->_cachedVars) ;
879  dset->attachCache(newCacheOwner, *selCacheVars) ;
880  delete selCacheVars ;
881 
882  return dset ;
883 }
884 
885 
886 
887 ////////////////////////////////////////////////////////////////////////////////
888 /// Return an empty clone of this dataset. If vars is not null, only the variables in vars
889 /// are added to the definition of the empty clone
890 
891 RooAbsData* RooDataSet::emptyClone(const char* newName, const char* newTitle, const RooArgSet* vars, const char* wgtVarName) const
892 {
893  // If variables are given, be sure to include weight variable if it exists and is not included
894  RooArgSet vars2 ;
895  RooRealVar* tmpWgtVar = _wgtVar ;
896  if (wgtVarName && vars && !_wgtVar) {
897  tmpWgtVar = (RooRealVar*) vars->find(wgtVarName) ;
898  }
899 
900  if (vars) {
901  vars2.add(*vars) ;
902  if (_wgtVar && !vars2.find(_wgtVar->GetName())) {
903  vars2.add(*_wgtVar) ;
904  }
905  } else {
906  vars2.add(_vars) ;
907  }
908 
909  RooDataSet* dset = new RooDataSet(newName?newName:GetName(),newTitle?newTitle:GetTitle(),vars2,tmpWgtVar?tmpWgtVar->GetName():0) ;
910  //if (_wgtVar) dset->setWeightVar(_wgtVar->GetName()) ;
911  return dset ;
912 }
913 
914 
915 
916 ////////////////////////////////////////////////////////////////////////////////
917 /// Initialize the dataset. If wgtVarName is not null, interpret the observable
918 /// with that name as event weight
919 
920 void RooDataSet::initialize(const char* wgtVarName)
921 {
923  _varsNoWgt.add(_vars) ;
924  _wgtVar = 0 ;
925  if (wgtVarName) {
926  RooAbsArg* wgt = _varsNoWgt.find(wgtVarName) ;
927  if (!wgt) {
928  coutW(DataHandling) << "RooDataSet::RooDataSet(" << GetName() << ") WARNING: designated weight variable "
929  << wgtVarName << " not found in set of variables, no weighting will be assigned" << endl ;
930  } else if (!dynamic_cast<RooRealVar*>(wgt)) {
931  coutW(DataHandling) << "RooDataSet::RooDataSet(" << GetName() << ") WARNING: designated weight variable "
932  << wgtVarName << " is not of type RooRealVar, no weighting will be assigned" << endl ;
933  } else {
934  _varsNoWgt.remove(*wgt) ;
935  _wgtVar = (RooRealVar*) wgt ;
936  }
937  }
938 }
939 
940 
941 
942 ////////////////////////////////////////////////////////////////////////////////
943 /// Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods
944 
945 RooAbsData* RooDataSet::reduceEng(const RooArgSet& varSubset, const RooFormulaVar* cutVar, const char* cutRange,
946  Int_t nStart, Int_t nStop, Bool_t copyCache)
947 {
948  checkInit() ;
949 
950  RooArgSet tmp(varSubset) ;
951  if (_wgtVar) {
952  tmp.add(*_wgtVar) ;
953  }
954  RooDataSet* ret = new RooDataSet(GetName(), GetTitle(), this, tmp, cutVar, cutRange, nStart, nStop, copyCache,_wgtVar?_wgtVar->GetName():0) ;
955 
956  // WVE - propagate optional weight variable
957  // check behaviour in plotting.
958 // if (_wgtVar) {
959 // ret->setWeightVar(_wgtVar->GetName()) ;
960 // }
961  return ret ;
962 }
963 
964 
965 
966 ////////////////////////////////////////////////////////////////////////////////
967 /// Destructor
968 
970 {
971  removeFromDir(this) ;
973 }
974 
975 
976 
977 ////////////////////////////////////////////////////////////////////////////////
978 /// Return binned clone of this dataset
979 
980 RooDataHist* RooDataSet::binnedClone(const char* newName, const char* newTitle) const
981 {
982  TString title, name ;
983  if (newName) {
984  name = newName ;
985  } else {
986  name = Form("%s_binned",GetName()) ;
987  }
988  if (newTitle) {
989  title = newTitle ;
990  } else {
991  title = Form("%s_binned",GetTitle()) ;
992  }
993 
994  return new RooDataHist(name,title,*get(),*this) ;
995 }
996 
997 
998 
999 ////////////////////////////////////////////////////////////////////////////////
1000 /// Return event weight of current event
1001 
1003 {
1004  return store()->weight() ;
1005 }
1006 
1007 
1008 
1009 
1010 ////////////////////////////////////////////////////////////////////////////////
1011 /// Return event weight of current event
1012 
1014 {
1015  return store()->weight()*store()->weight() ;
1016 }
1017 
1018 
1019 
1020 
1021 ////////////////////////////////////////////////////////////////////////////////
1022 
1024 {
1025  store()->weightError(lo,hi,etype) ;
1026 }
1027 
1028 
1029 
1030 ////////////////////////////////////////////////////////////////////////////////
1031 
1033 {
1034  return store()->weightError(etype) ;
1035 }
1036 
1037 
1038 
1039 ////////////////////////////////////////////////////////////////////////////////
1040 /// Return RooArgSet with coordinates of event 'index'
1041 
1042 const RooArgSet* RooDataSet::get(Int_t index) const
1043 {
1044  const RooArgSet* ret = RooAbsData::get(index) ;
1045  return ret ? &_varsNoWgt : 0 ;
1046 }
1047 
1048 
1049 ////////////////////////////////////////////////////////////////////////////////
1050 
1052 {
1053  return store()->sumEntries() ;
1054 
1055  //---------
1056 
1057  // Shortcut for unweighted unselected datasets
1058  if (!isWeighted()) {
1059  return numEntries() ;
1060  }
1061 
1062  // Otherwise sum the weights in the event
1063  Double_t sumw(0), carry(0);
1064  Int_t i ;
1065  for (i=0 ; i<numEntries() ; i++) {
1066  get(i) ;
1067  Double_t y = weight() - carry;
1068  Double_t t = sumw + y;
1069  carry = (t - sumw) - y;
1070  sumw = t;
1071  }
1072 
1073  return sumw ;
1074 }
1075 
1076 
1077 ////////////////////////////////////////////////////////////////////////////////
1078 /// Return the sum of weights in all entries matching cutSpec (if specified)
1079 /// and in named range cutRange (if specified)
1080 
1081 Double_t RooDataSet::sumEntries(const char* cutSpec, const char* cutRange) const
1082 {
1083  // Setup RooFormulaVar for cutSpec if it is present
1084  RooFormula* select = 0 ;
1085  if (cutSpec) {
1086  select = new RooFormula("select",cutSpec,*get()) ;
1087  }
1088 
1089  // Shortcut for unweighted unselected datasets
1090  if (!select && !cutRange && !isWeighted()) {
1091  return numEntries() ;
1092  }
1093 
1094  // Otherwise sum the weights in the event
1095  Double_t sumw(0), carry(0);
1096  Int_t i ;
1097  for (i=0 ; i<numEntries() ; i++) {
1098  get(i) ;
1099  if (select && select->eval()==0.) continue ;
1100  if (cutRange && !_vars.allInRange(cutRange)) continue ;
1101  Double_t y = weight() - carry;
1102  Double_t t = sumw + y;
1103  carry = (t - sumw) - y;
1104  sumw = t;
1105  }
1106 
1107  if (select) delete select ;
1108 
1109  return sumw ;
1110 }
1111 
1112 
1113 
1114 
1115 ////////////////////////////////////////////////////////////////////////////////
1116 /// Return true if dataset contains weighted events
1117 
1119 {
1120  return store()->isWeighted() ;
1121 }
1122 
1123 
1124 
1125 ////////////////////////////////////////////////////////////////////////////////
1126 /// Returns true if histogram contains bins with entries with a non-integer weight
1127 
1129 {
1130  // Return false if we have no weights
1131  if (!_wgtVar) return kFALSE ;
1132 
1133  // Now examine individual weights
1134  for (int i=0 ; i<numEntries() ; i++) {
1135  get(i) ;
1136  if (fabs(weight()-Int_t(weight()))>1e-10) return kTRUE ;
1137  }
1138  // If sum of weights is less than number of events there are negative (integer) weights
1139  if (sumEntries()<numEntries()) return kTRUE ;
1140 
1141  return kFALSE ;
1142 }
1143 
1144 
1145 
1146 
1147 ////////////////////////////////////////////////////////////////////////////////
1148 /// Return a RooArgSet with the coordinates of the current event
1149 
1151 {
1152  return &_varsNoWgt ;
1153 }
1154 
1155 
1156 
1157 ////////////////////////////////////////////////////////////////////////////////
1158 /// Add a data point, with its coordinates specified in the 'data' argset, to the data set.
1159 /// Any variables present in 'data' but not in the dataset will be silently ignored
1160 ///
1161 
1162 void RooDataSet::add(const RooArgSet& data, Double_t wgt, Double_t wgtError)
1163 {
1164  checkInit() ;
1165  _varsNoWgt = data;
1166  if (_wgtVar) {
1167  _wgtVar->setVal(wgt) ;
1168  if (wgtError!=0.) {
1169  _wgtVar->setError(wgtError) ;
1170  }
1171  }
1172  fill();
1173 }
1174 
1175 
1176 
1177 
1178 ////////////////////////////////////////////////////////////////////////////////
1179 /// Add a data point, with its coordinates specified in the 'data' argset, to the data set.
1180 /// Any variables present in 'data' but not in the dataset will be silently ignored
1181 ///
1182 
1183 void RooDataSet::add(const RooArgSet& indata, Double_t inweight, Double_t weightErrorLo, Double_t weightErrorHi)
1184 {
1185  checkInit() ;
1186 
1187  _varsNoWgt = indata;
1188  if (_wgtVar) {
1189  _wgtVar->setVal(inweight) ;
1190  _wgtVar->setAsymError(weightErrorLo,weightErrorHi) ;
1191  }
1192  fill();
1193 }
1194 
1195 
1196 
1197 
1198 
1199 ////////////////////////////////////////////////////////////////////////////////
1200 /// Add a data point, with its coordinates specified in the 'data' argset, to the data set.
1201 /// Layout and size of input argument data is ASSUMED to be the same as RooArgSet returned
1202 /// RooDataSet::get()
1203 ///
1204 
1205 void RooDataSet::addFast(const RooArgSet& data, Double_t wgt, Double_t wgtError)
1206 {
1207  checkInit() ;
1209  if (_wgtVar) {
1210  _wgtVar->setVal(wgt) ;
1211  if (wgtError!=0.) {
1212  _wgtVar->setError(wgtError) ;
1213  }
1214  }
1215  fill();
1216 }
1217 
1218 
1219 
1220 ////////////////////////////////////////////////////////////////////////////////
1221 
1223  RooDataSet* data4, RooDataSet* data5, RooDataSet* data6)
1224 {
1225  checkInit() ;
1226  list<RooDataSet*> dsetList ;
1227  if (data1) dsetList.push_back(data1) ;
1228  if (data2) dsetList.push_back(data2) ;
1229  if (data3) dsetList.push_back(data3) ;
1230  if (data4) dsetList.push_back(data4) ;
1231  if (data5) dsetList.push_back(data5) ;
1232  if (data6) dsetList.push_back(data6) ;
1233  return merge(dsetList) ;
1234 }
1235 
1236 
1237 
1238 ////////////////////////////////////////////////////////////////////////////////
1239 /// Merge columns of supplied data set(s) with this data set. All
1240 /// data sets must have equal number of entries. In case of
1241 /// duplicate columns the column of the last dataset in the list
1242 /// prevails
1243 
1244 Bool_t RooDataSet::merge(list<RooDataSet*>dsetList)
1245 {
1246 
1247  checkInit() ;
1248  // Sanity checks: data sets must have the same size
1249  for (list<RooDataSet*>::iterator iter = dsetList.begin() ; iter != dsetList.end() ; iter++) {
1250  if (numEntries()!=(*iter)->numEntries()) {
1251  coutE(InputArguments) << "RooDataSet::merge(" << GetName() << ") ERROR: datasets have different size" << endl ;
1252  return kTRUE ;
1253  }
1254  }
1255 
1256  // Extend vars with elements of other dataset
1257  list<RooAbsDataStore*> dstoreList ;
1258  for (list<RooDataSet*>::iterator iter = dsetList.begin() ; iter != dsetList.end() ; iter++) {
1259  _vars.addClone((*iter)->_vars,kTRUE) ;
1260  dstoreList.push_back((*iter)->store()) ;
1261  }
1262 
1263  // Merge data stores
1264  RooAbsDataStore* mergedStore = _dstore->merge(_vars,dstoreList) ;
1265  mergedStore->SetName(_dstore->GetName()) ;
1266  mergedStore->SetTitle(_dstore->GetTitle()) ;
1267 
1268  // Replace current data store with merged store
1269  delete _dstore ;
1270  _dstore = mergedStore ;
1271 
1272  initialize(_wgtVar?_wgtVar->GetName():0) ;
1273  return kFALSE ;
1274 }
1275 
1276 
1277 ////////////////////////////////////////////////////////////////////////////////
1278 /// Add all data points of given data set to this data set.
1279 /// Observable in 'data' that are not in this dataset
1280 /// with not be transferred
1281 
1283 {
1284  checkInit() ;
1285  _dstore->append(*data._dstore) ;
1286 }
1287 
1288 
1289 
1290 ////////////////////////////////////////////////////////////////////////////////
1291 /// Add a column with the values of the given (function) argument
1292 /// to this dataset. The function value is calculated for each
1293 /// event using the observable values of each event in case the
1294 /// function depends on variables with names that are identical
1295 /// to the observable names in the dataset
1296 
1298 {
1299  checkInit() ;
1300  RooAbsArg* ret = _dstore->addColumn(var,adjustRange) ;
1301  _vars.addOwned(*ret) ;
1302  initialize(_wgtVar?_wgtVar->GetName():0) ;
1303  return ret ;
1304 }
1305 
1306 
1307 ////////////////////////////////////////////////////////////////////////////////
1308 /// Add a column with the values of the given list of (function)
1309 /// argument to this dataset. Each function value is calculated for
1310 /// each event using the observable values of the event in case the
1311 /// function depends on variables with names that are identical to
1312 /// the observable names in the dataset
1313 
1315 {
1316  checkInit() ;
1317  RooArgSet* ret = _dstore->addColumns(varList) ;
1318  _vars.addOwned(*ret) ;
1319  initialize(_wgtVar?_wgtVar->GetName():0) ;
1320  return ret ;
1321 }
1322 
1323 
1324 
1325 ////////////////////////////////////////////////////////////////////////////////
1326 /// Create a TH2F histogram of the distribution of the specified variable
1327 /// using this dataset. Apply any cuts to select which events are used.
1328 /// The variable being plotted can either be contained directly in this
1329 /// dataset, or else be a function of the variables in this dataset.
1330 /// The histogram will be created using RooAbsReal::createHistogram() with
1331 /// the name provided (with our dataset name prepended).
1332 
1333 TH2F* RooDataSet::createHistogram(const RooAbsRealLValue& var1, const RooAbsRealLValue& var2, const char* cuts, const char *name) const
1334 {
1335  checkInit() ;
1336  return createHistogram(var1, var2, var1.getBins(), var2.getBins(), cuts, name);
1337 }
1338 
1339 
1340 
1341 ////////////////////////////////////////////////////////////////////////////////
1342 /// Create a TH2F histogram of the distribution of the specified variable
1343 /// using this dataset. Apply any cuts to select which events are used.
1344 /// The variable being plotted can either be contained directly in this
1345 /// dataset, or else be a function of the variables in this dataset.
1346 /// The histogram will be created using RooAbsReal::createHistogram() with
1347 /// the name provided (with our dataset name prepended).
1348 
1350  Int_t nx, Int_t ny, const char* cuts, const char *name) const
1351 {
1352  checkInit() ;
1353  static Int_t counter(0) ;
1354 
1355  Bool_t ownPlotVarX(kFALSE) ;
1356  // Is this variable in our dataset?
1357  RooAbsReal* plotVarX= (RooAbsReal*)_vars.find(var1.GetName());
1358  if(0 == plotVarX) {
1359  // Is this variable a client of our dataset?
1360  if (!var1.dependsOn(_vars)) {
1361  coutE(InputArguments) << GetName() << "::createHistogram: Argument " << var1.GetName()
1362  << " is not in dataset and is also not dependent on data set" << endl ;
1363  return 0 ;
1364  }
1365 
1366  // Clone derived variable
1367  plotVarX = (RooAbsReal*) var1.Clone() ;
1368  ownPlotVarX = kTRUE ;
1369 
1370  //Redirect servers of derived clone to internal ArgSet representing the data in this set
1371  plotVarX->redirectServers(const_cast<RooArgSet&>(_vars)) ;
1372  }
1373 
1374  Bool_t ownPlotVarY(kFALSE) ;
1375  // Is this variable in our dataset?
1376  RooAbsReal* plotVarY= (RooAbsReal*)_vars.find(var2.GetName());
1377  if(0 == plotVarY) {
1378  // Is this variable a client of our dataset?
1379  if (!var2.dependsOn(_vars)) {
1380  coutE(InputArguments) << GetName() << "::createHistogram: Argument " << var2.GetName()
1381  << " is not in dataset and is also not dependent on data set" << endl ;
1382  return 0 ;
1383  }
1384 
1385  // Clone derived variable
1386  plotVarY = (RooAbsReal*) var2.Clone() ;
1387  ownPlotVarY = kTRUE ;
1388 
1389  //Redirect servers of derived clone to internal ArgSet representing the data in this set
1390  plotVarY->redirectServers(const_cast<RooArgSet&>(_vars)) ;
1391  }
1392 
1393  // Create selection formula if selection cuts are specified
1394  RooFormula* select = 0;
1395  if(0 != cuts && strlen(cuts)) {
1396  select=new RooFormula(cuts,cuts,_vars);
1397  if (!select || !select->ok()) {
1398  delete select;
1399  return 0 ;
1400  }
1401  }
1402 
1403  TString histName(name);
1404  histName.Prepend("_");
1405  histName.Prepend(fName);
1406  histName.Append("_") ;
1407  histName.Append(Form("%08x",counter++)) ;
1408 
1409  // create the histogram
1410  TH2F* histogram=new TH2F(histName.Data(), "Events", nx, var1.getMin(), var1.getMax(),
1411  ny, var2.getMin(), var2.getMax());
1412  if(!histogram) {
1413  coutE(DataHandling) << fName << "::createHistogram: unable to create a new histogram" << endl;
1414  return 0;
1415  }
1416 
1417  // Dump contents
1418  Int_t nevent= numEntries() ;
1419  for(Int_t i=0; i < nevent; ++i)
1420  {
1421  get(i);
1422 
1423  if (select && select->eval()==0) continue ;
1424  histogram->Fill(plotVarX->getVal(), plotVarY->getVal(),weight()) ;
1425  }
1426 
1427  if (ownPlotVarX) delete plotVarX ;
1428  if (ownPlotVarY) delete plotVarY ;
1429  if (select) delete select ;
1430 
1431  return histogram ;
1432 }
1433 
1434 
1435 
1436 
1437 
1438 ////////////////////////////////////////////////////////////////////////////////
1439 /// Special plot method for 'X-Y' datasets used in Chi^2 fitting. These datasets
1440 /// have one observable (X) and have weights (Y) and associated errors.
1441 ///
1442 /// Contents options
1443 /// ---------------------
1444 /// YVar(RooRealVar& var) -- Designate specified observable as 'y' variable
1445 /// If not specified, the event weight will be the y variable
1446 /// Histogram drawing options
1447 /// -------------------------
1448 /// DrawOption(const char* opt) -- Select ROOT draw option for resulting TGraph object
1449 /// LineStyle(Int_t style) -- Select line style by ROOT line style code, default is solid
1450 /// LineColor(Int_t color) -- Select line color by ROOT color code, default is black
1451 /// LineWidth(Int_t width) -- Select line with in pixels, default is 3
1452 /// MarkerStyle(Int_t style) -- Select the ROOT marker style, default is 21
1453 /// MarkerColor(Int_t color) -- Select the ROOT marker color, default is black
1454 /// MarkerSize(Double_t size) -- Select the ROOT marker size
1455 /// Rescale(Double_t factor) -- Apply global rescaling factor to histogram
1456 ///
1457 ///
1458 /// Misc. other options
1459 /// -------------------
1460 /// Name(const chat* name) -- Give curve specified name in frame. Useful if curve is to be referenced later
1461 /// Invisible(Bool_t flag) -- Add curve to frame, but do not display. Useful in combination AddTo()
1462 ///
1463 
1464 RooPlot* RooDataSet::plotOnXY(RooPlot* frame, const RooCmdArg& arg1, const RooCmdArg& arg2,
1465  const RooCmdArg& arg3, const RooCmdArg& arg4,
1466  const RooCmdArg& arg5, const RooCmdArg& arg6,
1467  const RooCmdArg& arg7, const RooCmdArg& arg8) const
1468 {
1469  checkInit() ;
1470 
1471  RooLinkedList argList ;
1472  argList.Add((TObject*)&arg1) ; argList.Add((TObject*)&arg2) ;
1473  argList.Add((TObject*)&arg3) ; argList.Add((TObject*)&arg4) ;
1474  argList.Add((TObject*)&arg5) ; argList.Add((TObject*)&arg6) ;
1475  argList.Add((TObject*)&arg7) ; argList.Add((TObject*)&arg8) ;
1476 
1477  // Process named arguments
1478  RooCmdConfig pc(Form("RooDataSet::plotOnXY(%s)",GetName())) ;
1479  pc.defineString("drawOption","DrawOption",0,"P") ;
1480  pc.defineString("histName","Name",0,"") ;
1481  pc.defineInt("lineColor","LineColor",0,-999) ;
1482  pc.defineInt("lineStyle","LineStyle",0,-999) ;
1483  pc.defineInt("lineWidth","LineWidth",0,-999) ;
1484  pc.defineInt("markerColor","MarkerColor",0,-999) ;
1485  pc.defineInt("markerStyle","MarkerStyle",0,8) ;
1486  pc.defineDouble("markerSize","MarkerSize",0,-999) ;
1487  pc.defineInt("fillColor","FillColor",0,-999) ;
1488  pc.defineInt("fillStyle","FillStyle",0,-999) ;
1489  pc.defineInt("histInvisible","Invisible",0,0) ;
1490  pc.defineDouble("scaleFactor","Rescale",0,1.) ;
1491  pc.defineObject("xvar","XVar",0,0) ;
1492  pc.defineObject("yvar","YVar",0,0) ;
1493 
1494 
1495  // Process & check varargs
1496  pc.process(argList) ;
1497  if (!pc.ok(kTRUE)) {
1498  return frame ;
1499  }
1500 
1501  // Extract values from named arguments
1502  const char* drawOptions = pc.getString("drawOption") ;
1503  Int_t histInvisible = pc.getInt("histInvisible") ;
1504  const char* histName = pc.getString("histName",0,kTRUE) ;
1505  Double_t scaleFactor = pc.getDouble("scaleFactor") ;
1506 
1507  RooRealVar* xvar = (RooRealVar*) _vars.find(frame->getPlotVar()->GetName()) ;
1508 
1509  // Determine Y variable (default is weight, if present)
1510  RooRealVar* yvar = (RooRealVar*)(pc.getObject("yvar")) ;
1511 
1512  // Sanity check. XY plotting only applies to weighted datasets if no YVar is specified
1513  if (!_wgtVar && !yvar) {
1514  coutE(InputArguments) << "RooDataSet::plotOnXY(" << GetName() << ") ERROR: no YVar() argument specified and dataset is not weighted" << endl ;
1515  return 0 ;
1516  }
1517 
1518  RooRealVar* dataY = yvar ? (RooRealVar*) _vars.find(yvar->GetName()) : 0 ;
1519  if (yvar && !dataY) {
1520  coutE(InputArguments) << "RooDataSet::plotOnXY(" << GetName() << ") ERROR on YVar() argument, dataset does not contain a variable named " << yvar->GetName() << endl ;
1521  return 0 ;
1522  }
1523 
1524 
1525  // Make RooHist representing XY contents of data
1526  RooHist* graph = new RooHist ;
1527  if (histName) {
1528  graph->SetName(histName) ;
1529  } else {
1530  graph->SetName(Form("hxy_%s",GetName())) ;
1531  }
1532 
1533  for (int i=0 ; i<numEntries() ; i++) {
1534  get(i) ;
1535  Double_t x = xvar->getVal() ;
1536  Double_t exlo = xvar->getErrorLo() ;
1537  Double_t exhi = xvar->getErrorHi() ;
1538  Double_t y,eylo,eyhi ;
1539  if (!dataY) {
1540  y = weight() ;
1541  weightError(eylo,eyhi) ;
1542  } else {
1543  y = dataY->getVal() ;
1544  eylo = dataY->getErrorLo() ;
1545  eyhi = dataY->getErrorHi() ;
1546  }
1547  graph->addBinWithXYError(x,y,-1*exlo,exhi,-1*eylo,eyhi,scaleFactor) ;
1548  }
1549 
1550  // Adjust style options according to named arguments
1551  Int_t lineColor = pc.getInt("lineColor") ;
1552  Int_t lineStyle = pc.getInt("lineStyle") ;
1553  Int_t lineWidth = pc.getInt("lineWidth") ;
1554  Int_t markerColor = pc.getInt("markerColor") ;
1555  Int_t markerStyle = pc.getInt("markerStyle") ;
1556  Size_t markerSize = pc.getDouble("markerSize") ;
1557  Int_t fillColor = pc.getInt("fillColor") ;
1558  Int_t fillStyle = pc.getInt("fillStyle") ;
1559 
1560  if (lineColor!=-999) graph->SetLineColor(lineColor) ;
1561  if (lineStyle!=-999) graph->SetLineStyle(lineStyle) ;
1562  if (lineWidth!=-999) graph->SetLineWidth(lineWidth) ;
1563  if (markerColor!=-999) graph->SetMarkerColor(markerColor) ;
1564  if (markerStyle!=-999) graph->SetMarkerStyle(markerStyle) ;
1565  if (markerSize!=-999) graph->SetMarkerSize(markerSize) ;
1566  if (fillColor!=-999) graph->SetFillColor(fillColor) ;
1567  if (fillStyle!=-999) graph->SetFillStyle(fillStyle) ;
1568 
1569  // Add graph to frame
1570  frame->addPlotable(graph,drawOptions,histInvisible) ;
1571 
1572  return frame ;
1573 }
1574 
1575 
1576 
1577 
1578 ////////////////////////////////////////////////////////////////////////////////
1579 /// Read given list of ascii files, and construct a data set, using the given
1580 /// ArgList as structure definition.
1581 ///
1582 /// Multiple file names in fileList should be comma separated. Each
1583 /// file is optionally prefixed with 'commonPath' if such a path is
1584 /// provided
1585 ///
1586 /// The arglist specifies the dimensions of the dataset to be built
1587 /// and describes the order in which these dimensions appear in the
1588 /// ascii files to be read.
1589 ///
1590 /// Each line in the ascii file should contain N white space separated
1591 /// tokens, with N the number of args in 'variables'. Any text beyond
1592 /// N tokens will be ignored with a warning message.
1593 /// [ NB: This format is written by RooArgList::writeToStream() ]
1594 ///
1595 /// If the value of any of the variables on a given line exceeds the
1596 /// fit range associated with that dimension, the entire line will be
1597 /// ignored. A warning message is printed in each case, unless the
1598 /// 'Q' verbose option is given. (Option 'D' will provide additional
1599 /// debugging information) The number of events read and skipped
1600 /// is always summarized at the end.
1601 ///
1602 /// When multiple files are read, a RooCategory arg in 'variables' can
1603 /// optionally be designated to hold information about the source file
1604 /// of each data point. This feature is enabled by giving the name
1605 /// of the (already existing) category variable in 'indexCatName'
1606 ///
1607 /// If no further information is given a label name 'fileNNN' will
1608 /// be assigned to each event, where NNN is the sequential number of
1609 /// the source file in 'fileList'.
1610 ///
1611 /// Alternatively it is possible to override the default label names
1612 /// of the index category by specifying them in the fileList string:
1613 /// When instead of "file1.txt,file2.txt" the string
1614 /// "file1.txt:FOO,file2.txt:BAR" is specified, a state named "FOO"
1615 /// is assigned to the index category for each event originating from
1616 /// file1.txt. The labels FOO,BAR may be predefined in the index
1617 /// category via defineType(), but don't have to be
1618 ///
1619 /// Finally, one can also assign the same label to multiple files,
1620 /// either by specifying "file1.txt:FOO,file2,txt:FOO,file3.txt:BAR"
1621 /// or "file1.txt,file2.txt:FOO,file3.txt:BAR"
1622 ///
1623 
1624 RooDataSet *RooDataSet::read(const char *fileList, const RooArgList &varList,
1625  const char *verbOpt, const char* commonPath,
1626  const char* indexCatName) {
1627  // Make working copy of variables list
1628  RooArgList variables(varList) ;
1629 
1630  // Append blinding state category to variable list if not already there
1631  Bool_t ownIsBlind(kTRUE) ;
1632  RooAbsArg* blindState = variables.find("blindState") ;
1633  if (!blindState) {
1634  blindState = new RooCategory("blindState","Blinding State") ;
1635  variables.add(*blindState) ;
1636  } else {
1637  ownIsBlind = kFALSE ;
1638  if (blindState->IsA()!=RooCategory::Class()) {
1639  oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: ERROR: variable list already contains"
1640  << "a non-RooCategory blindState member" << endl ;
1641  return 0 ;
1642  }
1643  oocoutW((TObject*)0,DataHandling) << "RooDataSet::read: WARNING: recycling existing "
1644  << "blindState category in variable list" << endl ;
1645  }
1646  RooCategory* blindCat = (RooCategory*) blindState ;
1647 
1648  // Configure blinding state category
1649  blindCat->setAttribute("Dynamic") ;
1650  blindCat->defineType("Normal",0) ;
1651  blindCat->defineType("Blind",1) ;
1652 
1653  // parse the option string
1654  TString opts= verbOpt;
1655  opts.ToLower();
1656  Bool_t verbose= !opts.Contains("q");
1657  Bool_t debug= opts.Contains("d");
1658 
1659  RooDataSet *data= new RooDataSet("dataset", fileList, variables);
1660  if (ownIsBlind) { variables.remove(*blindState) ; delete blindState ; }
1661  if(!data) {
1662  oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: unable to create a new dataset"
1663  << endl;
1664  return 0;
1665  }
1666 
1667  // Redirect blindCat to point to the copy stored in the data set
1668  blindCat = (RooCategory*) data->_vars.find("blindState") ;
1669 
1670  // Find index category, if requested
1671  RooCategory *indexCat = 0;
1672  //RooCategory *indexCatOrig = 0;
1673  if (indexCatName) {
1674  RooAbsArg* tmp = 0;
1675  tmp = data->_vars.find(indexCatName) ;
1676  if (!tmp) {
1677  oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: no index category named "
1678  << indexCatName << " in supplied variable list" << endl ;
1679  return 0 ;
1680  }
1681  if (tmp->IsA()!=RooCategory::Class()) {
1682  oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: variable " << indexCatName
1683  << " is not a RooCategory" << endl ;
1684  return 0 ;
1685  }
1686  indexCat = (RooCategory*)tmp ;
1687 
1688  // Prevent RooArgSet from attempting to read in indexCat
1689  indexCat->setAttribute("Dynamic") ;
1690  }
1691 
1692 
1693  Int_t outOfRange(0) ;
1694 
1695  // Make local copy of file list for tokenizing
1696  char fileList2[10240] ;
1697  strlcpy(fileList2,fileList,10240) ;
1698 
1699  // Loop over all names in comma separated list
1700  char *filename = strtok(fileList2,", ") ;
1701  Int_t fileSeqNum(0) ;
1702  while (filename) {
1703  // Determine index category number, if this option is active
1704  if (indexCat) {
1705 
1706  // Find and detach optional file category name
1707  char *catname = strchr(filename,':') ;
1708 
1709  if (catname) {
1710  // Use user category name if provided
1711  *catname=0 ;
1712  catname++ ;
1713 
1714  const RooCatType* type = indexCat->lookupType(catname,kFALSE) ;
1715  if (type) {
1716  // Use existing category index
1717  indexCat->setIndex(type->getVal()) ;
1718  } else {
1719  // Register cat name
1720  indexCat->defineType(catname,fileSeqNum) ;
1721  indexCat->setIndex(fileSeqNum) ;
1722  }
1723  } else {
1724  // Assign autogenerated name
1725  char newLabel[128] ;
1726  snprintf(newLabel,128,"file%03d",fileSeqNum) ;
1727  if (indexCat->defineType(newLabel,fileSeqNum)) {
1728  oocoutE((TObject*)0,DataHandling) << "RooDataSet::read: Error, cannot register automatic type name " << newLabel
1729  << " in index category " << indexCat->GetName() << endl ;
1730  return 0 ;
1731  }
1732  // Assign new category number
1733  indexCat->setIndex(fileSeqNum) ;
1734  }
1735  }
1736 
1737  oocoutI((TObject*)0,DataHandling) << "RooDataSet::read: reading file " << filename << endl ;
1738 
1739  // Prefix common path
1740  TString fullName(commonPath) ;
1741  fullName.Append(filename) ;
1742  ifstream file(fullName) ;
1743 
1744  if(!file.good()) {
1745  oocoutW((TObject*)0,DataHandling) << "RooDataSet::read: unable to open '"
1746  << filename << "', skipping" << endl;
1747  }
1748 
1749 // Double_t value;
1750  Int_t line(0) ;
1751  Bool_t haveBlindString(false) ;
1752 
1753  while(file.good() && !file.eof()) {
1754  line++;
1755  if(debug) oocxcoutD((TObject*)0,DataHandling) << "reading line " << line << endl;
1756 
1757  // process comment lines
1758  if (file.peek() == '#')
1759  {
1760  if(debug) oocxcoutD((TObject*)0,DataHandling) << "skipping comment on line " << line << endl;
1761  }
1762  else {
1763 
1764  // Skip empty lines
1765  // if(file.peek() == '\n') { file.get(); }
1766 
1767  // Read single line
1768  Bool_t readError = variables.readFromStream(file,kTRUE,verbose) ;
1769  data->_vars = variables ;
1770 // Bool_t readError = data->_vars.readFromStream(file,kTRUE,verbose) ;
1771 
1772  // Stop at end of file or on read error
1773  if(file.eof()) break ;
1774  if(!file.good()) {
1775  oocoutE((TObject*)0,DataHandling) << "RooDataSet::read(static): read error at line " << line << endl ;
1776  break;
1777  }
1778 
1779  if (readError) {
1780  outOfRange++ ;
1781  continue ;
1782  }
1783  blindCat->setIndex(haveBlindString) ;
1784  data->fill(); // store this event
1785  }
1786  }
1787 
1788  file.close();
1789 
1790  // get next file name
1791  filename = strtok(0," ,") ;
1792  fileSeqNum++ ;
1793  }
1794 
1795  if (indexCat) {
1796  // Copy dynamically defined types from new data set to indexCat in original list
1797  RooCategory* origIndexCat = (RooCategory*) variables.find(indexCatName) ;
1798  TIterator* tIter = indexCat->typeIterator() ;
1799  RooCatType* type = 0;
1800  while ((type=(RooCatType*)tIter->Next())) {
1801  origIndexCat->defineType(type->GetName(),type->getVal()) ;
1802  }
1803  }
1804  oocoutI((TObject*)0,DataHandling) << "RooDataSet::read: read " << data->numEntries()
1805  << " events (ignored " << outOfRange << " out of range events)" << endl;
1806  return data;
1807 }
1808 
1809 
1810 
1811 
1812 ////////////////////////////////////////////////////////////////////////////////
1813 /// Write the contents of this dataset to an ASCII file with the specified name
1814 /// Each event will be written as a single line containing the written values
1815 /// of each observable in the order they were declared in the dataset and
1816 /// separated by whitespaces
1817 
1819 {
1820  checkInit() ;
1821 
1822  // Open file for writing
1823  ofstream ofs(filename) ;
1824  if (ofs.fail()) {
1825  coutE(DataHandling) << "RooDataSet::write(" << GetName() << ") cannot create file " << filename << endl ;
1826  return kTRUE ;
1827  }
1828 
1829  // Write all lines as arglist in compact mode
1830  coutI(DataHandling) << "RooDataSet::write(" << GetName() << ") writing ASCII file " << filename << endl ;
1831  Int_t i ;
1832  for (i=0 ; i<numEntries() ; i++) {
1833  RooArgList list(*get(i),"line") ;
1834  list.writeToStream(ofs,kTRUE) ;
1835  }
1836 
1837  if (ofs.fail()) {
1838  coutW(DataHandling) << "RooDataSet::write(" << GetName() << "): WARNING error(s) have occured in writing" << endl ;
1839  }
1840  return ofs.fail() ;
1841 }
1842 
1843 
1844 
1845 ////////////////////////////////////////////////////////////////////////////////
1846 /// Print info about this dataset to the specified output stream.
1847 ///
1848 /// Standard: number of entries
1849 /// Shape: list of variables we define & were generated with
1850 
1851 void RooDataSet::printMultiline(ostream& os, Int_t contents, Bool_t verbose, TString indent) const
1852 {
1853  checkInit() ;
1854  RooAbsData::printMultiline(os,contents,verbose,indent) ;
1855  if (_wgtVar) {
1856  os << indent << " Dataset variable \"" << _wgtVar->GetName() << "\" is interpreted as the event weight" << endl ;
1857  }
1858 }
1859 
1860 
1861 ////////////////////////////////////////////////////////////////////////////////
1862 /// Print value of the dataset, i.e. the sum of weights contained in the dataset
1863 
1864 void RooDataSet::printValue(ostream& os) const
1865 {
1866  os << numEntries() << " entries" ;
1867  if (isWeighted()) {
1868  os << " (" << sumEntries() << " weighted)" ;
1869  }
1870 }
1871 
1872 
1873 
1874 ////////////////////////////////////////////////////////////////////////////////
1875 /// Print argument of dataset, i.e. the observable names
1876 
1877 void RooDataSet::printArgs(ostream& os) const
1878 {
1879  os << "[" ;
1881  RooAbsArg* arg ;
1882  Bool_t first(kTRUE) ;
1883  while((arg=(RooAbsArg*)iter->Next())) {
1884  if (first) {
1885  first=kFALSE ;
1886  } else {
1887  os << "," ;
1888  }
1889  os << arg->GetName() ;
1890  }
1891  if (_wgtVar) {
1892  os << ",weight:" << _wgtVar->GetName() ;
1893  }
1894  os << "]" ;
1895  delete iter ;
1896 }
1897 
1898 
1899 
1900 ////////////////////////////////////////////////////////////////////////////////
1901 /// Change the name of this dataset into the given name
1902 
1903 void RooDataSet::SetName(const char *name)
1904 {
1905  if (_dir) _dir->GetList()->Remove(this);
1906  TNamed::SetName(name) ;
1907  if (_dir) _dir->GetList()->Add(this);
1908 }
1909 
1910 
1911 ////////////////////////////////////////////////////////////////////////////////
1912 /// Change the title of this dataset into the given name
1913 
1914 void RooDataSet::SetNameTitle(const char *name, const char* title)
1915 {
1916  if (_dir) _dir->GetList()->Remove(this);
1917  TNamed::SetNameTitle(name,title) ;
1918  if (_dir) _dir->GetList()->Add(this);
1919 }
1920 
1921 
1922 ////////////////////////////////////////////////////////////////////////////////
1923 /// Stream an object of class RooDataSet.
1924 
1925 void RooDataSet::Streamer(TBuffer &R__b)
1926 {
1927  if (R__b.IsReading()) {
1928 
1929  UInt_t R__s, R__c;
1930  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1931 
1932  if (R__v>1) {
1933 
1934  // Use new-style streaming for version >1
1935  R__b.ReadClassBuffer(RooDataSet::Class(),this,R__v,R__s,R__c);
1936 
1937  } else {
1938 
1939  // Legacy dataset conversion happens here. Legacy RooDataSet inherits from RooTreeData
1940  // which in turn inherits from RooAbsData. Manually stream RooTreeData contents on
1941  // file here and convert it into a RooTreeDataStore which is installed in the
1942  // new-style RooAbsData base class
1943 
1944  // --- This is the contents of the streamer code of RooTreeData version 1 ---
1945  UInt_t R__s1, R__c1;
1946  Version_t R__v1 = R__b.ReadVersion(&R__s1, &R__c1); if (R__v1) { }
1947 
1948  RooAbsData::Streamer(R__b);
1949  TTree* X_tree(0) ; R__b >> X_tree;
1950  RooArgSet X_truth ; X_truth.Streamer(R__b);
1951  TString X_blindString ; X_blindString.Streamer(R__b);
1952  R__b.CheckByteCount(R__s1, R__c1, RooTreeData::Class());
1953  // --- End of RooTreeData-v1 streamer
1954 
1955  // Construct RooTreeDataStore from X_tree and complete initialization of new-style RooAbsData
1956  _dstore = new RooTreeDataStore(X_tree,_vars) ;
1957  _dstore->SetName(GetName()) ;
1958  _dstore->SetTitle(GetTitle()) ;
1959  _dstore->checkInit() ;
1960 
1961  // This is the contents of the streamer code of RooDataSet version 1
1962  RooDirItem::Streamer(R__b);
1963  _varsNoWgt.Streamer(R__b);
1964  R__b >> _wgtVar;
1965  R__b.CheckByteCount(R__s, R__c, RooDataSet::IsA());
1966 
1967 
1968  }
1969  } else {
1970  R__b.WriteClassBuffer(RooDataSet::Class(),this);
1971  }
1972 }
1973 
const int nx
Definition: kalman.C:16
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:265
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
virtual void SetLineWidth(Width_t lwidth)
Definition: TAttLine.h:57
#define coutE(a)
Definition: RooMsgService.h:35
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
void addOwnedComponent(const char *idxlabel, RooAbsData &data)
void SetName(const char *name)
Change the name of this dataset into the given name.
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
static char * _poolBegin
Definition: RooDataSet.h:152
Bool_t ok()
Definition: RooFormula.h:50
Bool_t IsReading() const
Definition: TBuffer.h:81
virtual Bool_t isWeighted() const
Return true if dataset contains weighted events.
virtual Double_t weight() const =0
short Version_t
Definition: RtypesCore.h:61
Bool_t defineDouble(const char *name, const char *argName, Int_t doubleNum, Double_t defValue=0.)
Define Double_t property name 'name' mapped to Double_t in slot 'doubleNum' in RooCmdArg with name ar...
TLine * line
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.
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
float Size_t
Definition: RtypesCore.h:83
THist< 2, float > TH2F
Definition: THist.h:321
void loadValues(const TTree *t, const RooFormulaVar *select=0, const char *rangeName=0, Int_t nStart=0, Int_t nStop=2000000000)
Load values from tree 't' into this data collection, optionally selecting events using 'select' RooFo...
static std::list< POOLDATA > _memPoolList
Definition: RooDataSet.cxx:76
#define coutI(a)
Definition: RooMsgService.h:32
const char * getString(const char *name, const char *defaultValue="", Bool_t convEmptyToNull=kFALSE)
Return string property registered with name 'name'.
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
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:891
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Interface for detailed printing of object.
Definition: RooAbsData.cxx:895
#define assert(cond)
Definition: unittest.h:542
virtual RooArgSet * addColumns(const RooArgList &varList)=0
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
virtual TList * GetList() const
Definition: TDirectory.h:154
virtual void loadValues(const RooAbsDataStore *tds, const RooFormulaVar *select=0, const char *rangeName=0, Int_t nStart=0, Int_t nStop=2000000000)=0
RooArgSet _varsNoWgt
Definition: RooDataSet.h:148
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read the contents of the argset in ASCII form from given stream.
Definition: RooArgList.cxx:327
#define oocoutI(o, a)
Definition: RooMsgService.h:45
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", Bool_t invisible=kFALSE, Bool_t refreshNorm=kFALSE)
Add the specified plotable object to our plot.
Definition: RooPlot.cxx:447
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
static const char * filename()
Bool_t defineSet(const char *name, const char *argName, Int_t setNum, const RooArgSet *set=0)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
RooDataSet()
Default constructor for persistence.
Definition: RooDataSet.cxx:182
Basic string class.
Definition: TString.h:137
virtual Double_t getMin(const char *name=0) const
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1088
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...
virtual void SetFillStyle(Style_t fstyle)
Definition: TAttFill.h:52
STL namespace.
#define coutW(a)
Definition: RooMsgService.h:34
TString & Prepend(const char *cs)
Definition: TString.h:604
TObject * getObject(const char *name, TObject *obj=0)
Return TObject property registered with name 'name'.
virtual void SetNameTitle(const char *name, const char *title)
Change (i.e. set) all the TNamed parameters (name and title).
Definition: TNamed.cxx:142
Bool_t dirtyProp() const
Iterator abstract base class.
Definition: TIterator.h:32
void attachToStore(RooAbsDataStore &store)
Definition: RooAbsArg.cxx:2328
RooAbsArg * createFundamental(const char *newname=0) const
Create a RooRealVar fundamental object with our properties.
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set value by specifying the name of the desired state If printError is set, a message will be printed...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3851
const char * Data() const
Definition: TString.h:349
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
void appendToDir(TObject *obj, Bool_t forceMemoryResident=kFALSE)
Append object to directory.
Definition: RooDirItem.cxx:85
#define TRACE_CREATE
Definition: RooTrace.h:23
Double_t x[n]
Definition: legend1.C:17
virtual void weightError(Double_t &lo, Double_t &hi, ErrorType etype=SumW2) const
Return asymmetric error on weight. (Dummy implementation returning zero)
virtual void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)
Internal method – Attach dataset copied with cache contents to copied instances of functions...
Definition: RooAbsData.cxx:347
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a column with the values of the given (function) argument to this dataset.
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
Definition: memory.h:94
void Class()
Definition: Class.C:29
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add element to an owning set.
Definition: RooArgSet.cxx:461
#define oocoutE(o, a)
Definition: RooMsgService.h:48
const int ny
Definition: kalman.C:17
virtual Int_t getBins(const char *name=0) const
virtual const RooArgSet * get() const
Return a RooArgSet with the coordinates of the current event.
virtual void writeToStream(std::ostream &os, Bool_t compact)
Write the contents of the argset in ASCII form to given stream.
Definition: RooArgList.cxx:301
std::map< std::string, std::string >::const_iterator iter
Definition: TAlienJob.cxx:54
TIterator * createIterator(Bool_t dir=kIterForward) const
static char * _poolEnd
Next free slot in memory pool.
Definition: RooDataSet.h:154
virtual void SetMarkerColor(Color_t mcolor=1)
Definition: TAttMarker.h:51
if on multiple lines(like in C++).**The" * configuration fragment. * * The "import myobject continue
Parses the configuration file.
Definition: HLFactory.cxx:368
Bool_t defineString(const char *name, const char *argName, Int_t stringNum, const char *defValue="", Bool_t appendMode=kFALSE)
Define Double_t property name 'name' mapped to Double_t in slot 'stringNum' in RooCmdArg with name ar...
#define oocxcoutD(o, a)
Definition: RooMsgService.h:82
TString & Append(const char *cs)
Definition: TString.h:492
virtual void append(RooAbsDataStore &other)=0
TIterator * MakeIterator(Bool_t dir=kTRUE) const
Return an iterator over this list.
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
void assignFast(const RooAbsCollection &other, Bool_t setValDirty=kTRUE)
Functional equivalent of operator=() but assumes this and other collection have same layout...
virtual Bool_t isWeighted() const =0
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition: TString.cxx:1437
Bool_t allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range...
const RooArgSet & cachedVars() const
void defineDependency(const char *refArgName, const char *neededArgName)
Define that processing argument name refArgName requires processing of argument named neededArgName t...
Double_t eval(const RooArgSet *nset=0)
Evaluate ROOT::v5::TFormula using given normalization set to be used as observables definition passed...
Definition: RooFormula.cxx:233
Bool_t defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
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:945
virtual const RooArgSet * get() const
Definition: RooAbsData.h:77
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
virtual RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList)=0
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:62
void checkInit() const
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
RooArgSet _cachedVars
Definition: RooAbsData.h:254
void defineMutex(const char *argName1, const char *argName2)
Define arguments named argName1 and argName2 mutually exclusive.
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.
void setAttribAll(const Text_t *name, Bool_t value=kTRUE)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual Double_t weight() const
Return event weight of current event.
virtual Double_t sumEntries() const
return
Definition: TBase64.cxx:62
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
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 TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:674
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:291
TClass * IsA() const
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:873
void initialize(const char *wgtVarName)
Initialize the dataset.
Definition: RooDataSet.cxx:920
unsigned int UInt_t
Definition: RtypesCore.h:42
bool verbose
char * Form(const char *fmt,...)
TLine * l
Definition: textangle.C:4
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual void SetMarkerStyle(Style_t mstyle=1)
Definition: TAttMarker.h:53
Bool_t ok(Bool_t verbose) const
Return true of parsing was successful.
virtual void fill()
Definition: RooAbsData.cxx:280
static void indent(ostringstream &buf, int indent_level)
RooAbsDataStore * store()
Definition: RooAbsData.h:55
RooAbsRealLValue * getPlotVar() const
Definition: RooPlot.h:132
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.
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
Definition: RooDirItem.cxx:70
TString fName
Definition: TNamed.h:36
Double_t getErrorHi() const
Definition: RooRealVar.h:64
virtual void SetMarkerSize(Size_t msize=1)
Definition: TAttMarker.h:54
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
TDirectory * _dir
Definition: RooDirItem.h:33
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...
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
RooArgSet * getSet(const char *name, RooArgSet *set=0)
Return RooArgSet property registered with name 'name'.
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
Definition: RooSentinel.cxx:70
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:861
double f(double x)
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
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...
RooAbsDataStore * _dstore
Iterator over cached variables.
Definition: RooAbsData.h:259
void append(RooDataSet &data)
Add all data points of given data set to this data set.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooAbsArg.h:75
Double_t getDouble(const char *name, Double_t defaultValue=0)
Return Double_t property registered with name 'name'.
int type
Definition: TGX11.cxx:120
ClassImp(RooDataSet)
Double_t y[n]
Definition: legend1.C:17
#define TRACE_DESTROY
Definition: RooTrace.h:24
RooDataHist * binnedClone(const char *newName=0, const char *newTitle=0) const
Return binned clone of this dataset.
Definition: RooDataSet.cxx:980
Int_t getVal() const
Definition: RooCatType.h:80
virtual void SetLineStyle(Style_t lstyle)
Definition: TAttLine.h:56
const RooLinkedList & getObjectList(const char *name)
Return list of objects registered with name 'name'.
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.
#define name(a, b)
Definition: linkTestLib0.cpp:5
void SetNameTitle(const char *name, const char *title)
Change the title of this dataset into the given name.
static StorageType defaultStorageType
Definition: RooAbsData.h:220
#define oocoutW(o, a)
Definition: RooMsgService.h:47
Mother of all ROOT objects.
Definition: TObject.h:58
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
virtual Double_t getMax(const char *name=0) const
Bool_t merge(RooDataSet *data1, RooDataSet *data2=0, RooDataSet *data3=0, RooDataSet *data4=0, RooDataSet *data5=0, RooDataSet *data6=0)
virtual void Add(TObject *obj)
Definition: TList.h:81
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
virtual TObject * Next()=0
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
Definition: RooAbsArg.cxx:743
virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const =0
void addBinWithXYError(Axis_t binCenter, Double_t n, Double_t exlow, Double_t exhigh, Double_t eylow, Double_t eyhigh, Double_t scaleFactor=1.0)
Add a bin to this histogram with the specified bin contents and error.
Definition: RooHist.cxx:443
virtual void checkInit() const
virtual ~RooDataSet()
Destructor.
Definition: RooDataSet.cxx:969
virtual Bool_t isNonPoissonWeighted() const
Returns true if histogram contains bins with entries with a non-integer weight.
bool debug
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index...
RooRealVar * _wgtVar
Definition: RooDataSet.h:149
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add clone of specified element to an owning set.
Definition: RooArgSet.cxx:475
A TTree object has a header with a name and a title.
Definition: TTree.h:94
float type_of_call hi(const int &, const int &)
Bool_t defineObject(const char *name, const char *argName, Int_t setNum, const TObject *obj=0, Bool_t isArray=kFALSE)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
RooArgSet _vars
Definition: RooAbsData.h:253
#define POOLSIZE
Definition: RooDataSet.cxx:69
Double_t getErrorLo() const
Definition: RooRealVar.h:63
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:285
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)=0
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
Bool_t redirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t isRecursionStep=kFALSE)
Iterator over _clientListValue.
Definition: RooAbsArg.cxx:928
Vc_ALWAYS_INLINE_L T *Vc_ALWAYS_INLINE_R malloc(size_t n)
Allocates memory on the Heap with alignment and padding suitable for vectorized access.
Definition: memory.h:67
virtual const Text_t * GetName() const
Returns name of object.
Definition: RooCatType.h:45
TIterator * typeIterator() const
Return iterator over all defined states.
virtual void printArgs(std::ostream &os) const
Print argument of dataset, i.e. the observable names.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
Definition: RooArgSet.cxx:448
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
static void cleanup()
Clear memoery pool on exit to avoid reported memory leaks.
Definition: RooDataSet.cxx:81
virtual const char * getLabel() const
Return label string of current state.
Definition: RooCategory.h:40
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:898
const RooCatType * lookupType(Int_t index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return 0 for no match.