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