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