ROOT  6.06/09
Reference Guide
RooTreeDataStore.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 //////////////////////////////////////////////////////////////////////////////
18 //
19 // BEGIN_HTML
20 // RooTreeDataStore is the abstract base class for data collection that
21 // use a TTree as internal storage mechanism
22 // END_HTML
23 //
24 
25 #include "RooFit.h"
26 #include "RooMsgService.h"
27 #include "RooTreeDataStore.h"
28 
29 #include "Riostream.h"
30 #include "TTree.h"
31 #include "TChain.h"
32 #include "TDirectory.h"
33 #include "TROOT.h"
34 #include "RooFormulaVar.h"
35 #include "RooRealVar.h"
36 #include "RooHistError.h"
37 
38 #include <iomanip>
39 using namespace std ;
40 
42 ;
43 
44 
46 
47 
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 
52  _tree(0),
53  _cacheTree(0),
54  _cacheOwner(0),
55  _defCtor(kTRUE),
56  _wgtVar(0),
57  _extWgtArray(0),
58  _extWgtErrLoArray(0),
59  _extWgtErrHiArray(0),
60  _extSumW2Array(0),
61  _curWgt(1),
62  _curWgtErrLo(0),
63  _curWgtErrHi(0),
64  _curWgtErr(0)
65 {
66 }
67 
68 
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Constructor to facilitate reading of legacy RooDataSets
72 
73 RooTreeDataStore::RooTreeDataStore(TTree* t, const RooArgSet& vars, const char* wgtVarName) :
74  RooAbsDataStore("blah","blah",varsNoWeight(vars,wgtVarName)),
75  _tree(t),
76  _cacheTree(0),
77  _cacheOwner(0),
78  _defCtor(kTRUE),
79  _varsww(vars),
80  _wgtVar(weightVar(vars,wgtVarName)),
81  _extWgtArray(0),
82  _extWgtErrLoArray(0),
83  _extWgtErrHiArray(0),
84  _extSumW2Array(0),
85  _curWgt(1)
86 {
87 }
88 
89 
90 
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 
94 RooTreeDataStore::RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, const char* wgtVarName) :
95  RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
96  _tree(0),
97  _cacheTree(0),
98  _cacheOwner(0),
99  _defCtor(kFALSE),
100  _varsww(vars),
101  _wgtVar(weightVar(vars,wgtVarName)),
102  _extWgtArray(0),
103  _extWgtErrLoArray(0),
104  _extWgtErrHiArray(0),
105  _extSumW2Array(0),
106  _curWgt(1),
107  _curWgtErrLo(0),
108  _curWgtErrHi(0),
109  _curWgtErr(0)
110 {
111  initialize() ;
112 }
113 
114 
115 
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 
119 RooTreeDataStore::RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, TTree& t, const RooFormulaVar& select, const char* wgtVarName) :
120  RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
121  _tree(0),
122  _cacheTree(0),
123  _cacheOwner(0),
124  _defCtor(kFALSE),
125  _varsww(vars),
126  _wgtVar(weightVar(vars,wgtVarName)),
127  _extWgtArray(0),
128  _extWgtErrLoArray(0),
129  _extWgtErrHiArray(0),
130  _extSumW2Array(0),
131  _curWgt(1),
132  _curWgtErrLo(0),
133  _curWgtErrHi(0),
134  _curWgtErr(0)
135 {
136  initialize() ;
137  loadValues(&t,&select) ;
138 }
139 
140 
141 
142 ////////////////////////////////////////////////////////////////////////////////
143 
144 RooTreeDataStore::RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, TTree& t, const char* selExpr, const char* wgtVarName) :
145  RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
146  _tree(0),
147  _cacheTree(0),
148  _cacheOwner(0),
149  _defCtor(kFALSE),
150  _varsww(vars),
151  _wgtVar(weightVar(vars,wgtVarName)),
152  _extWgtArray(0),
153  _extWgtErrLoArray(0),
154  _extWgtErrHiArray(0),
155  _extSumW2Array(0),
156  _curWgt(1),
157  _curWgtErrLo(0),
158  _curWgtErrHi(0),
159  _curWgtErr(0)
160 {
161  initialize() ;
162 
163  if (selExpr && *selExpr) {
164  // Create a RooFormulaVar cut from given cut expression
165  RooFormulaVar select(selExpr,selExpr,_vars) ;
166  loadValues(&t,&select);
167  } else {
168  loadValues(&t);
169  }
170 }
171 
172 
173 
174 ////////////////////////////////////////////////////////////////////////////////
175 
176 RooTreeDataStore::RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, const RooAbsDataStore& tds, const RooFormulaVar& select, const char* wgtVarName) :
177  RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
178  _tree(0),
179  _cacheTree(0),
180  _cacheOwner(0),
181  _defCtor(kFALSE),
182  _varsww(vars),
183  _wgtVar(weightVar(vars,wgtVarName)),
184  _extWgtArray(0),
185  _extWgtErrLoArray(0),
186  _extWgtErrHiArray(0),
187  _extSumW2Array(0),
188  _curWgt(1),
189  _curWgtErrLo(0),
190  _curWgtErrHi(0),
191  _curWgtErr(0)
192 {
193  initialize() ;
194  loadValues(&tds,&select) ;
195 }
196 
197 
198 
199 ////////////////////////////////////////////////////////////////////////////////
200 
201 RooTreeDataStore::RooTreeDataStore(const char* name, const char* title, const RooArgSet& vars, const RooAbsDataStore& ads, const char* selExpr, const char* wgtVarName) :
202  RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
203  _tree(0),
204  _cacheTree(0),
205  _cacheOwner(0),
206  _defCtor(kFALSE),
207  _varsww(vars),
208  _wgtVar(weightVar(vars,wgtVarName)),
209  _extWgtArray(0),
210  _extWgtErrLoArray(0),
211  _extWgtErrHiArray(0),
212  _extSumW2Array(0),
213  _curWgt(1),
214  _curWgtErrLo(0),
215  _curWgtErrHi(0),
216  _curWgtErr(0)
217 {
218  initialize() ;
219 
220  if (selExpr && *selExpr) {
221  // Create a RooFormulaVar cut from given cut expression
222  RooFormulaVar select(selExpr,selExpr,_vars) ;
223  loadValues(&ads,&select);
224  } else {
225  loadValues(&ads);
226  }
227 }
228 
229 
230 
231 
232 ////////////////////////////////////////////////////////////////////////////////
233 
234 RooTreeDataStore::RooTreeDataStore(const char *name, const char *title, RooAbsDataStore& tds,
235  const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
236  Int_t nStart, Int_t nStop, Bool_t /*copyCache*/, const char* wgtVarName) :
237  RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)), _defCtor(kFALSE),
238  _varsww(vars),
239  _wgtVar(weightVar(vars,wgtVarName)),
240  _extWgtArray(0),
241  _extWgtErrLoArray(0),
242  _extWgtErrHiArray(0),
243  _extSumW2Array(0),
244  _curWgt(1),
245  _curWgtErrLo(0),
246  _curWgtErrHi(0),
247  _curWgtErr(0)
248 {
249  // WVE NEED TO ADJUST THIS FOR WEIGHTS
250 
251  // Protected constructor for internal use only
252  _tree = 0 ;
253  _cacheTree = 0 ;
254  createTree(name,title) ;
255 
256  // Deep clone cutVar and attach clone to this dataset
257  RooFormulaVar* cloneVar = 0;
258  if (cutVar) {
259  cloneVar = (RooFormulaVar*) cutVar->cloneTree() ;
260  cloneVar->attachDataStore(tds) ;
261  }
262 
263  // Constructor from existing data set with list of variables that preserves the cache
264  initialize();
265 
267 
268  // WVE copy values of cached variables here!!!
270  _cacheOwner = 0 ;
271 
272  loadValues(&tds,cloneVar,cutRange,nStart,nStop);
273 
274  if (cloneVar) delete cloneVar ;
275 }
276 
277 
278 
279 ////////////////////////////////////////////////////////////////////////////////
280 /// Utility function for constructors
281 /// Return RooArgSet that is copy of allVars minus variable matching wgtName if specified
282 
283 RooArgSet RooTreeDataStore::varsNoWeight(const RooArgSet& allVars, const char* wgtName)
284 {
285  RooArgSet ret(allVars) ;
286  if(wgtName) {
287  RooAbsArg* wgt = allVars.find(wgtName) ;
288  if (wgt) {
289  ret.remove(*wgt,kTRUE,kTRUE) ;
290  }
291  }
292  return ret ;
293 }
294 
295 
296 
297 ////////////////////////////////////////////////////////////////////////////////
298 /// Utility function for constructors
299 /// Return pointer to weight variable if it is defined
300 
301 RooRealVar* RooTreeDataStore::weightVar(const RooArgSet& allVars, const char* wgtName)
302 {
303  if(wgtName) {
304  RooRealVar* wgt = dynamic_cast<RooRealVar*>(allVars.find(wgtName)) ;
305  return wgt ;
306  }
307  return 0 ;
308 }
309 
310 
311 
312 
313 ////////////////////////////////////////////////////////////////////////////////
314 /// Initialize cache of dataset: attach variables of cache ArgSet
315 /// to the corresponding TTree branches
316 
317 void RooTreeDataStore::attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVarsIn)
318 {
319  // iterate over the cache variables for this dataset
321  TIterator* iter = cachedVarsIn.createIterator() ;
322  RooAbsArg *var;
323  while((0 != (var= (RooAbsArg*)iter->Next()))) {
325  _cachedVars.add(*var) ;
326  }
327  delete iter ;
328  _cacheOwner = newOwner ;
329 
330 }
331 
332 
333 
334 
335 
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 
339 RooTreeDataStore::RooTreeDataStore(const RooTreeDataStore& other, const char* newname) :
340  RooAbsDataStore(other,newname),
341  _tree(0),
342  _cacheTree(0),
343  _defCtor(kFALSE),
344  _varsww(other._varsww),
345  _wgtVar(other._wgtVar),
346  _extWgtArray(other._extWgtArray),
347  _extWgtErrLoArray(other._extWgtErrLoArray),
348  _extWgtErrHiArray(other._extWgtErrHiArray),
349  _extSumW2Array(other._extSumW2Array),
350  _curWgt(other._curWgt),
351  _curWgtErrLo(other._curWgtErrLo),
352  _curWgtErrHi(other._curWgtErrHi),
353  _curWgtErr(other._curWgtErr)
354 {
355  initialize() ;
356  loadValues(&other) ;
357 }
358 
359 
360 ////////////////////////////////////////////////////////////////////////////////
361 
362 RooTreeDataStore::RooTreeDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname) :
363  RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():0),newname),
364  _tree(0),
365  _cacheTree(0),
366  _defCtor(kFALSE),
367  _varsww(vars),
368  _wgtVar(other._wgtVar?weightVar(vars,other._wgtVar->GetName()):0),
369  _extWgtArray(other._extWgtArray),
370  _extWgtErrLoArray(other._extWgtErrLoArray),
371  _extWgtErrHiArray(other._extWgtErrHiArray),
372  _extSumW2Array(other._extSumW2Array),
373  _curWgt(other._curWgt),
374  _curWgtErrLo(other._curWgtErrLo),
375  _curWgtErrHi(other._curWgtErrHi),
376  _curWgtErr(other._curWgtErr)
377 {
378  initialize() ;
379  loadValues(&other) ;
380 }
381 
382 
383 
384 
385 ////////////////////////////////////////////////////////////////////////////////
386 /// Destructor
387 
389 {
390  if (_tree) {
391  delete _tree ;
392  }
393  if (_cacheTree) {
394  delete _cacheTree ;
395  }
396 }
397 
398 
399 
400 ////////////////////////////////////////////////////////////////////////////////
401 /// One-time initialization common to all constructor forms. Attach
402 /// variables of internal ArgSet to the corresponding TTree branches
403 
405 {
406  // Recreate (empty) cache tree
408 
409  // Attach each variable to the dataset
411  RooAbsArg *var;
412  while((0 != (var= (RooAbsArg*)iter->Next()))) {
414  }
415  delete iter ;
416 }
417 
418 
419 
420 
421 
422 ////////////////////////////////////////////////////////////////////////////////
423 /// Create TTree object that lives in memory, independent of current
424 /// location of gDirectory
425 
426 void RooTreeDataStore::createTree(const char* name, const char* title)
427 {
428  TString pwd(gDirectory->GetPath()) ;
429  TString memDir(gROOT->GetName()) ;
430  memDir.Append(":/") ;
431  Bool_t notInMemNow= (pwd!=memDir) ;
432 
433  // cout << "RooTreeData::createTree pwd=" << pwd << " memDir=" << memDir << " notInMemNow = " << (notInMemNow?"T":"F") << endl ;
434 
435  if (notInMemNow) {
436  gDirectory->cd(memDir) ;
437  }
438 
439  if (!_tree) {
440  _tree = new TTree(name,title) ;
441  _tree->SetDirectory(0) ;
442  gDirectory->RecursiveRemove(_tree) ;
443  }
444  if (!_cacheTree) {
445  _cacheTree = new TTree(name,title) ;
447  gDirectory->RecursiveRemove(_cacheTree) ;
448  }
449 
450  if (notInMemNow) {
451  gDirectory->cd(pwd) ;
452  }
453 
454 }
455 
456 
457 
458 
459 ////////////////////////////////////////////////////////////////////////////////
460 /// Load values from tree 't' into this data collection, optionally
461 /// selecting events using 'select' RooFormulaVar
462 ///
463 /// The source tree 't' is first clone as not disturb its branch
464 /// structure when retrieving information from it.
465 
466 void RooTreeDataStore::loadValues(const TTree *t, const RooFormulaVar* select, const char* /*rangeName*/, Int_t /*nStart*/, Int_t /*nStop*/)
467 {
468  // Clone source tree
469  // WVE Clone() crashes on trees, CloneTree() crashes on tchains :-(
470 
471  // Change directory to memory dir before cloning tree to avoid ROOT errors
472  TString pwd(gDirectory->GetPath()) ;
473  TString memDir(gROOT->GetName()) ;
474  memDir.Append(":/") ;
475  Bool_t notInMemNow= (pwd!=memDir) ;
476 
477  if (notInMemNow) {
478  gDirectory->cd(memDir) ;
479  }
480 
481  TTree* tClone ;
482  if (dynamic_cast<const TChain*>(t)) {
483  tClone = (TTree*) t->Clone() ;
484  } else {
485  tClone = ((TTree*)t)->CloneTree() ;
486  }
487 
488  // Change directory back to original directory
489  tClone->SetDirectory(0) ;
490 
491  if (notInMemNow) {
492  gDirectory->cd(pwd) ;
493  }
494 
495  // Clone list of variables
496  RooArgSet *sourceArgSet = (RooArgSet*) _varsww.snapshot(kFALSE) ;
497 
498  // Attach args in cloned list to cloned source tree
499  TIterator* sourceIter = sourceArgSet->createIterator() ;
500  RooAbsArg* sourceArg = 0;
501  while ((sourceArg=(RooAbsArg*)sourceIter->Next())) {
502  sourceArg->attachToTree(*tClone,_defTreeBufSize) ;
503  }
504 
505  // Redirect formula servers to sourceArgSet
506  RooFormulaVar* selectClone(0) ;
507  if (select) {
508  selectClone = (RooFormulaVar*) select->cloneTree() ;
509  selectClone->recursiveRedirectServers(*sourceArgSet) ;
510  selectClone->setOperMode(RooAbsArg::ADirty,kTRUE) ;
511  }
512 
513  // Loop over events in source tree
514  RooAbsArg* destArg = 0;
515  TIterator* destIter = _varsww.createIterator() ;
516  Int_t numInvalid(0) ;
517  Int_t nevent= (Int_t)tClone->GetEntries();
518  for(Int_t i=0; i < nevent; ++i) {
519  Int_t entryNumber=tClone->GetEntryNumber(i);
520  if (entryNumber<0) break;
521  tClone->GetEntry(entryNumber,1);
522 
523  // Copy from source to destination
524  destIter->Reset() ;
525  sourceIter->Reset() ;
526  Bool_t allOK(kTRUE) ;
527  while ((destArg = (RooAbsArg*)destIter->Next())) {
528  sourceArg = (RooAbsArg*) sourceIter->Next() ;
529  destArg->copyCache(sourceArg) ;
530  sourceArg->copyCache(destArg) ;
531  if (!destArg->isValid()) {
532  numInvalid++ ;
533  allOK=kFALSE ;
534  break ;
535  }
536  }
537 
538  // Does this event pass the cuts?
539  if (!allOK || (selectClone && selectClone->getVal()==0)) {
540  continue ;
541  }
542 
543  fill() ;
544  }
545  delete destIter ;
546 
547  if (numInvalid>0) {
548  coutI(Eval) << "RooTreeDataStore::loadValues(" << GetName() << ") Ignored " << numInvalid << " out of range events" << endl ;
549  }
550 
551  SetTitle(t->GetTitle());
552 
553  delete sourceIter ;
554  delete sourceArgSet ;
555  delete selectClone ;
556  delete tClone ;
557 }
558 
559 
560 
561 
562 
563 
564 ////////////////////////////////////////////////////////////////////////////////
565 /// Load values from dataset 't' into this data collection, optionally
566 /// selecting events using 'select' RooFormulaVar
567 ///
568 
570  const char* rangeName, Int_t nStart, Int_t nStop)
571 {
572  // Redirect formula servers to source data row
573  RooFormulaVar* selectClone(0) ;
574  if (select) {
575  selectClone = (RooFormulaVar*) select->cloneTree() ;
576  selectClone->recursiveRedirectServers(*ads->get()) ;
577  selectClone->setOperMode(RooAbsArg::ADirty,kTRUE) ;
578  }
579 
580  // Force RDS internal initialization
581  ads->get(0) ;
582 
583  // Loop over events in source tree
584  RooAbsArg* arg = 0;
585  TIterator* destIter = _varsww.createIterator() ;
586  Int_t nevent = nStop < ads->numEntries() ? nStop : ads->numEntries() ;
587  Bool_t allValid ;
588 
589  Bool_t isTDS = dynamic_cast<const RooTreeDataStore*>(ads) ;
590  if (isTDS) {
591  ((RooTreeDataStore*)(ads))->resetBuffers() ;
592  }
593  for(Int_t i=nStart; i < nevent ; ++i) {
594  ads->get(i) ;
595 
596  // Does this event pass the cuts?
597  if (selectClone && selectClone->getVal()==0) {
598  continue ;
599  }
600 
601 
602  if (isTDS) {
604  } else {
605  _varsww.assignValueOnly(*ads->get()) ;
606  }
607 
608  destIter->Reset() ;
609  // Check that all copied values are valid
610  allValid=kTRUE ;
611  while((arg=(RooAbsArg*)destIter->Next())) {
612  if (!arg->isValid() || (rangeName && !arg->inRange(rangeName))) {
613  //cout << "arg " << arg->GetName() << " is not valid" << endl ;
614  //arg->Print("v") ;
615  allValid=kFALSE ;
616  break ;
617  }
618  }
619  //cout << "RooTreeData::loadValues(" << GetName() << ") allValid = " << (allValid?"T":"F") << endl ;
620  if (!allValid) {
621  continue ;
622  }
623 
624  _cachedVars = ((RooTreeDataStore*)ads)->_cachedVars ;
625  fill() ;
626  }
627  delete destIter ;
628  if (isTDS) {
630  }
631 
632  delete selectClone ;
633  SetTitle(ads->GetTitle());
634 }
635 
636 
637 
638 ////////////////////////////////////////////////////////////////////////////////
639 /// Return true if currently loaded coordinate is considered valid within
640 /// the current range definitions of all observables
641 
643 {
644  return kTRUE ;
645 }
646 
647 
648 
649 
650 ////////////////////////////////////////////////////////////////////////////////
651 /// Interface function to TTree::Fill
652 
654 {
655  return _tree->Fill() ;
656 }
657 
658 
659 
660 ////////////////////////////////////////////////////////////////////////////////
661 /// Load the n-th data point (n='index') in memory
662 /// and return a pointer to the internal RooArgSet
663 /// holding its coordinates.
664 
666 {
667  checkInit() ;
668 
669  Int_t ret = ((RooTreeDataStore*)this)->GetEntry(index, 1) ;
670 
671  if(!ret) return 0;
672 
673  if (_doDirtyProp) {
674  // Raise all dirty flags
675  _iterator->Reset() ;
676  RooAbsArg* var = 0;
677  while ((var=(RooAbsArg*)_iterator->Next())) {
678  var->setValueDirty() ; // This triggers recalculation of all clients
679  }
680 
681  _cacheIter->Reset() ;
682  while ((var=(RooAbsArg*)_cacheIter->Next())) {
683  var->setValueDirty() ; // This triggers recalculation of all clients, but doesn't recalculate self
684  var->clearValueDirty() ;
685  }
686  }
687 
688  // Update current weight cache
689  if (_extWgtArray) {
690 
691  // If external array is specified use that
692  _curWgt = _extWgtArray[index] ;
695  _curWgtErr = sqrt(_extSumW2Array[index]) ;
696 
697  } else if (_wgtVar) {
698 
699  // Otherwise look for weight variable
700  _curWgt = _wgtVar->getVal() ;
704 
705  } else {
706 
707  // Otherwise return 1
708  _curWgt=1.0 ;
709  _curWgtErrLo = 0 ;
710  _curWgtErrHi = 0 ;
711  _curWgtErr = 0 ;
712 
713  }
714 
715  return &_vars;
716 }
717 
718 
719 
720 ////////////////////////////////////////////////////////////////////////////////
721 /// Return the weight of the n-th data point (n='index') in memory
722 
724 {
725  get(index) ;
726  return weight() ;
727 }
728 
729 
730 
731 ////////////////////////////////////////////////////////////////////////////////
732 /// Return the weight of the n-th data point (n='index') in memory
733 
735 {
736  return _curWgt ;
737 }
738 
739 
740 ////////////////////////////////////////////////////////////////////////////////
741 
743 {
744  if (_extWgtArray) {
745 
746  // We have a weight array, use that info
747 
748  // Return symmetric error on current bin calculated either from Poisson statistics or from SumOfWeights
749  Double_t lo,hi ;
750  weightError(lo,hi,etype) ;
751  return (lo+hi)/2 ;
752 
753  } else if (_wgtVar) {
754 
755  // We have a a weight variable, use that info
756  if (_wgtVar->hasAsymError()) {
757  return ( _wgtVar->getAsymErrorHi() - _wgtVar->getAsymErrorLo() ) / 2 ;
758  } else {
759  return _wgtVar->getError() ;
760  }
761 
762  } else {
763 
764  // We have no weights
765  return 0 ;
766 
767  }
768 }
769 
770 
771 
772 ////////////////////////////////////////////////////////////////////////////////
773 
775 {
776  if (_extWgtArray) {
777 
778  // We have a weight array, use that info
779  switch (etype) {
780 
781  case RooAbsData::Auto:
782  throw string(Form("RooDataHist::weightError(%s) error type Auto not allowed here",GetName())) ;
783  break ;
784 
786  throw string(Form("RooDataHist::weightError(%s) error type Expected not allowed here",GetName())) ;
787  break ;
788 
789  case RooAbsData::Poisson:
790  // Weight may be preset or precalculated
791  if (_curWgtErrLo>=0) {
792  lo = _curWgtErrLo ;
793  hi = _curWgtErrHi ;
794  return ;
795  }
796 
797  // Otherwise Calculate poisson errors
798  Double_t ym,yp ;
800  lo = weight()-ym ;
801  hi = yp-weight() ;
802  return ;
803 
804  case RooAbsData::SumW2:
805  lo = _curWgtErr ;
806  hi = _curWgtErr ;
807  return ;
808 
809  case RooAbsData::None:
810  lo = 0 ;
811  hi = 0 ;
812  return ;
813  }
814 
815  } else if (_wgtVar) {
816 
817  // We have a a weight variable, use that info
818  if (_wgtVar->hasAsymError()) {
819  hi = _wgtVar->getAsymErrorHi() ;
820  lo = _wgtVar->getAsymErrorLo() ;
821  } else {
822  hi = _wgtVar->getError() ;
823  lo = _wgtVar->getError() ;
824  }
825 
826  } else {
827 
828  // We are unweighted
829  lo=0 ;
830  hi=0 ;
831 
832  }
833 }
834 
835 
836 ////////////////////////////////////////////////////////////////////////////////
837 /// Change name of internal observable named 'from' into 'to'
838 
839 Bool_t RooTreeDataStore::changeObservableName(const char* from, const char* to)
840 {
841  // Find observable to be changed
842  RooAbsArg* var = _vars.find(from) ;
843 
844  // Check that we found it
845  if (!var) {
846  coutE(InputArguments) << "RooTreeDataStore::changeObservableName(" << GetName() << " no observable " << from << " in this dataset" << endl ;
847  return kTRUE ;
848  }
849 
850  // Process name change
851  TString oldBranchName = var->cleanBranchName() ;
852  var->SetName(to) ;
853 
854  // Change the branch name as well
855  if (_tree->GetBranch(oldBranchName.Data())) {
856 
857  // Simple case varName = branchName
858  _tree->GetBranch(oldBranchName.Data())->SetName(var->cleanBranchName().Data()) ;
859 
860  // Process any error branch if existing
861  if (_tree->GetBranch(Form("%s_err",oldBranchName.Data()))) {
862  _tree->GetBranch(Form("%s_err",oldBranchName.Data()))->SetName(Form("%s_err",var->cleanBranchName().Data())) ;
863  }
864  if (_tree->GetBranch(Form("%s_aerr_lo",oldBranchName.Data()))) {
865  _tree->GetBranch(Form("%s_aerr_lo",oldBranchName.Data()))->SetName(Form("%s_aerr_lo",var->cleanBranchName().Data())) ;
866  }
867  if (_tree->GetBranch(Form("%s_aerr_hi",oldBranchName.Data()))) {
868  _tree->GetBranch(Form("%s_aerr_hi",oldBranchName.Data()))->SetName(Form("%s_aerr_hi",var->cleanBranchName().Data())) ;
869  }
870 
871  } else {
872 
873  // Native category case branchNames = varName_idx and varName_lbl
874  if (_tree->GetBranch(Form("%s_idx",oldBranchName.Data()))) {
875  _tree->GetBranch(Form("%s_idx",oldBranchName.Data()))->SetName(Form("%s_idx",var->cleanBranchName().Data())) ;
876  }
877  if (_tree->GetBranch(Form("%s_lbl",oldBranchName.Data()))) {
878  _tree->GetBranch(Form("%s_lbl",oldBranchName.Data()))->SetName(Form("%s_lb",var->cleanBranchName().Data())) ;
879  }
880 
881  }
882 
883  return kFALSE ;
884 }
885 
886 
887 
888 ////////////////////////////////////////////////////////////////////////////////
889 /// Add a new column to the data set which holds the pre-calculated values
890 /// of 'newVar'. This operation is only meaningful if 'newVar' is a derived
891 /// value.
892 ///
893 /// The return value points to the added element holding 'newVar's value
894 /// in the data collection. The element is always the corresponding fundamental
895 /// type of 'newVar' (e.g. a RooRealVar if 'newVar' is a RooFormulaVar)
896 ///
897 /// Note: This function is explicitly NOT intended as a speed optimization
898 /// opportunity for the user. Components of complex PDFs that can be
899 /// precalculated with the dataset are automatically identified as such
900 /// and will be precalculated when fitting to a dataset
901 ///
902 /// By forcibly precalculating functions with non-trivial Jacobians,
903 /// or functions of multiple variables occurring in the data set,
904 /// using addColumn(), you may alter the outcome of the fit.
905 ///
906 /// Only in cases where such a modification of fit behaviour is intentional,
907 /// this function should be used.
908 
910 {
911  checkInit() ;
912 
913  // Create a fundamental object of the right type to hold newVar values
914  RooAbsArg* valHolder= newVar.createFundamental();
915  // Sanity check that the holder really is fundamental
916  if(!valHolder->isFundamental()) {
917  coutE(InputArguments) << GetName() << "::addColumn: holder argument is not fundamental: \""
918  << valHolder->GetName() << "\"" << endl;
919  return 0;
920  }
921 
922  // WVE need to reset TTRee buffers to original datamembers here
923  resetBuffers() ;
924 
925  // Clone variable and attach to cloned tree
926  RooAbsArg* newVarClone = newVar.cloneTree() ;
927  newVarClone->recursiveRedirectServers(_vars,kFALSE) ;
928 
929  // Attach value place holder to this tree
930  ((RooAbsArg*)valHolder)->attachToTree(*_tree,_defTreeBufSize) ;
931  _vars.add(*valHolder) ;
932  _varsww.add(*valHolder) ;
933 
934 
935  // Fill values of of placeholder
936  for (int i=0 ; i<GetEntries() ; i++) {
937  get(i) ;
938 
939  newVarClone->syncCache(&_vars) ;
940  valHolder->copyCache(newVarClone) ;
941  valHolder->fillTreeBranch(*_tree) ;
942  }
943 
944  // WVE need to restore TTRee buffers to previous values here
946 
947  if (adjustRange) {
948 // // Set range of valHolder to (just) bracket all values stored in the dataset
949 // Double_t vlo,vhi ;
950 // RooRealVar* rrvVal = dynamic_cast<RooRealVar*>(valHolder) ;
951 // if (rrvVal) {
952 // getRange(*rrvVal,vlo,vhi,0.05) ;
953 // rrvVal->setRange(vlo,vhi) ;
954 // }
955  }
956 
957 
958 
959  delete newVarClone ;
960  return valHolder ;
961 }
962 
963 
964 
965 ////////////////////////////////////////////////////////////////////////////////
966 /// Utility function to add multiple columns in one call
967 /// See addColumn() for details
968 
970 {
971  TIterator* vIter = varList.createIterator() ;
972  RooAbsArg* var ;
973 
974  checkInit() ;
975 
976  TList cloneSetList ;
977  RooArgSet cloneSet ;
978  RooArgSet* holderSet = new RooArgSet ;
979 
980  // WVE need to reset TTRee buffers to original datamembers here
981  resetBuffers() ;
982 
983 
984  while((var=(RooAbsArg*)vIter->Next())) {
985  // Create a fundamental object of the right type to hold newVar values
986  RooAbsArg* valHolder= var->createFundamental();
987  holderSet->add(*valHolder) ;
988 
989  // Sanity check that the holder really is fundamental
990  if(!valHolder->isFundamental()) {
991  coutE(InputArguments) << GetName() << "::addColumn: holder argument is not fundamental: \""
992  << valHolder->GetName() << "\"" << endl;
993  return 0;
994  }
995 
996  // Clone variable and attach to cloned tree
997  RooArgSet* newVarCloneList = (RooArgSet*) RooArgSet(*var).snapshot() ;
998  if (!newVarCloneList) {
999  coutE(InputArguments) << "RooTreeDataStore::RooTreeData(" << GetName()
1000  << ") Couldn't deep-clone variable " << var->GetName() << ", abort." << endl ;
1001  return 0 ;
1002  }
1003  RooAbsArg* newVarClone = newVarCloneList->find(var->GetName()) ;
1004  newVarClone->recursiveRedirectServers(_vars,kFALSE) ;
1005  newVarClone->recursiveRedirectServers(*holderSet,kFALSE) ;
1006 
1007  cloneSetList.Add(newVarCloneList) ;
1008  cloneSet.add(*newVarClone) ;
1009 
1010  // Attach value place holder to this tree
1011  ((RooAbsArg*)valHolder)->attachToTree(*_tree,_defTreeBufSize) ;
1012  _vars.addOwned(*valHolder) ;
1013  }
1014  delete vIter ;
1015 
1016 
1017  TIterator* cIter = cloneSet.createIterator() ;
1018  TIterator* hIter = holderSet->createIterator() ;
1019  RooAbsArg *cloneArg, *holder ;
1020  // Fill values of of placeholder
1021  for (int i=0 ; i<GetEntries() ; i++) {
1022  get(i) ;
1023 
1024  cIter->Reset() ;
1025  hIter->Reset() ;
1026  while((cloneArg=(RooAbsArg*)cIter->Next())) {
1027  holder = (RooAbsArg*)hIter->Next() ;
1028 
1029  cloneArg->syncCache(&_vars) ;
1030  holder->copyCache(cloneArg) ;
1031  holder->fillTreeBranch(*_tree) ;
1032  }
1033  }
1034 
1035  // WVE need to restore TTRee buffers to previous values here
1037 
1038  delete cIter ;
1039  delete hIter ;
1040 
1041  cloneSetList.Delete() ;
1042  return holderSet ;
1043 }
1044 
1045 
1046 
1047 
1048 ////////////////////////////////////////////////////////////////////////////////
1049 /// Merge columns of supplied data set(s) with this data set. All
1050 /// data sets must have equal number of entries. In case of
1051 /// duplicate columns the column of the last dataset in the list
1052 /// prevails
1053 
1054 RooAbsDataStore* RooTreeDataStore::merge(const RooArgSet& allVars, list<RooAbsDataStore*> dstoreList)
1055 {
1056  RooTreeDataStore* mergedStore = new RooTreeDataStore("merged","merged",allVars) ;
1057 
1058  Int_t nevt = dstoreList.front()->numEntries() ;
1059  for (int i=0 ; i<nevt ; i++) {
1060 
1061  // Cope data from self
1062  mergedStore->_vars = *get(i) ;
1063 
1064  // Copy variables from merge sets
1065  for (list<RooAbsDataStore*>::iterator iter = dstoreList.begin() ; iter!=dstoreList.end() ; iter++) {
1066  const RooArgSet* partSet = (*iter)->get(i) ;
1067  mergedStore->_vars = *partSet ;
1068  }
1069 
1070  mergedStore->fill() ;
1071  }
1072  return mergedStore ;
1073 }
1074 
1075 
1076 
1077 
1078 
1079 ////////////////////////////////////////////////////////////////////////////////
1080 
1082 {
1083  Int_t nevt = other.numEntries() ;
1084  for (int i=0 ; i<nevt ; i++) {
1085  _vars = *other.get(i) ;
1086  if (_wgtVar) {
1087  _wgtVar->setVal(other.weight()) ;
1088  }
1089 
1090  fill() ;
1091  }
1092 }
1093 
1094 
1095 ////////////////////////////////////////////////////////////////////////////////
1096 
1098 {
1099  if (_wgtVar) {
1100 
1101  Double_t sum(0), carry(0);
1102  Int_t nevt = numEntries() ;
1103  for (int i=0 ; i<nevt ; i++) {
1104  get(i) ;
1105  // Kahan's algorithm for summing to avoid loss of precision
1106  Double_t y = _wgtVar->getVal() - carry;
1107  Double_t t = sum + y;
1108  carry = (t - sum) - y;
1109  sum = t;
1110  }
1111  return sum ;
1112 
1113  } else if (_extWgtArray) {
1114 
1115  Double_t sum(0) , carry(0);
1116  Int_t nevt = numEntries() ;
1117  for (int i=0 ; i<nevt ; i++) {
1118  // Kahan's algorithm for summing to avoid loss of precision
1119  Double_t y = _extWgtArray[i] - carry;
1120  Double_t t = sum + y;
1121  carry = (t - sum) - y;
1122  sum = t;
1123  }
1124  return sum ;
1125 
1126  } else {
1127 
1128  return numEntries() ;
1129 
1130  }
1131 }
1132 
1133 
1134 
1135 
1136 ////////////////////////////////////////////////////////////////////////////////
1137 
1139 {
1140  return _tree->GetEntries() ;
1141 }
1142 
1143 
1144 
1145 ////////////////////////////////////////////////////////////////////////////////
1146 
1148 {
1149  Reset() ;
1150 }
1151 
1152 
1153 
1154 ////////////////////////////////////////////////////////////////////////////////
1155 /// Cache given RooAbsArgs with this tree: The tree is
1156 /// given direct write access of the args internal cache
1157 /// the args values is pre-calculated for all data points
1158 /// in this data collection. Upon a get() call, the
1159 /// internal cache of 'newVar' will be loaded with the
1160 /// precalculated value and it's dirty flag will be cleared.
1161 
1162 void RooTreeDataStore::cacheArgs(const RooAbsArg* owner, RooArgSet& newVarSet, const RooArgSet* nset, Bool_t /*skipZeroWeights*/)
1163 {
1164  checkInit() ;
1165 
1166  _cacheOwner = owner ;
1167 
1168  RooArgSet* constExprVarSet = (RooArgSet*) newVarSet.selectByAttrib("ConstantExpression",kTRUE) ;
1169  TIterator *iter = constExprVarSet->createIterator() ;
1170  RooAbsArg *arg ;
1171 
1172  Bool_t doTreeFill = (_cachedVars.getSize()==0) ;
1173 
1174  while ((arg=(RooAbsArg*)iter->Next())) {
1175  // Attach original newVar to this tree
1177  //arg->recursiveRedirectServers(_vars) ;
1178  _cachedVars.add(*arg) ;
1179  }
1180 
1181  // WVE need to reset TTRee buffers to original datamembers here
1182  //resetBuffers() ;
1183 
1184  // Refill regular and cached variables of current tree from clone
1185  for (int i=0 ; i<GetEntries() ; i++) {
1186  get(i) ;
1187 
1188  // Evaluate the cached variables and store the results
1189  iter->Reset() ;
1190  while ((arg=(RooAbsArg*)iter->Next())) {
1191  arg->setValueDirty() ;
1192  arg->syncCache(nset) ;
1193  if (!doTreeFill) {
1194  arg->fillTreeBranch(*_cacheTree) ;
1195  }
1196  }
1197 
1198  if (doTreeFill) {
1199  _cacheTree->Fill() ;
1200  }
1201  }
1202 
1203  // WVE need to restore TTRee buffers to previous values here
1204  //restoreAlternateBuffers() ;
1205 
1206  delete iter ;
1207  delete constExprVarSet ;
1208 }
1209 
1210 
1211 
1212 
1213 ////////////////////////////////////////////////////////////////////////////////
1214 /// Activate or deactivate the branch status of the TTree branch associated
1215 /// with the given set of dataset observables
1216 
1218 {
1219  TIterator* iter = set.createIterator() ;
1220  RooAbsArg* arg ;
1221  while ((arg=(RooAbsArg*)iter->Next())) {
1222  RooAbsArg* depArg = _vars.find(arg->GetName()) ;
1223  if (!depArg) {
1224  coutE(InputArguments) << "RooTreeDataStore::setArgStatus(" << GetName()
1225  << ") dataset doesn't contain variable " << arg->GetName() << endl ;
1226  continue ;
1227  }
1228  depArg->setTreeBranchStatus(*_tree,active) ;
1229  }
1230  delete iter ;
1231 }
1232 
1233 
1234 
1235 ////////////////////////////////////////////////////////////////////////////////
1236 /// Remove tree with values of cached observables
1237 /// and clear list of cached observables
1238 
1240 {
1241  // Empty list of cached functions
1243 
1244  // Delete & recreate cache tree
1245  delete _cacheTree ;
1246  _cacheTree = 0 ;
1247  createTree(GetName(),GetTitle()) ;
1248 
1249  return ;
1250 }
1251 
1252 
1253 
1254 
1255 ////////////////////////////////////////////////////////////////////////////////
1256 
1258 {
1261  RooAbsArg* arg ;
1262  while((arg=iter.next())) {
1263  RooAbsArg* extArg = extObs.find(arg->GetName()) ;
1264  if (extArg) {
1265  if (arg->getAttribute("StoreError")) {
1266  extArg->setAttribute("StoreError") ;
1267  }
1268  if (arg->getAttribute("StoreAsymError")) {
1269  extArg->setAttribute("StoreAsymError") ;
1270  }
1271  extArg->attachToTree(*_tree) ;
1272  _attachedBuffers.add(*extArg) ;
1273  }
1274  }
1275 }
1276 
1277 
1278 
1279 ////////////////////////////////////////////////////////////////////////////////
1280 
1282 {
1284  RooAbsArg* arg ;
1285  while((arg=iter.next())) {
1286  arg->attachToTree(*_tree) ;
1287  }
1288 }
1289 
1290 
1291 
1292 ////////////////////////////////////////////////////////////////////////////////
1293 
1295 {
1297  RooAbsArg* arg ;
1298  while((arg=iter.next())) {
1299  arg->attachToTree(*_tree) ;
1300  }
1301 }
1302 
1303 
1304 
1305 ////////////////////////////////////////////////////////////////////////////////
1306 
1308 {
1309  if (_defCtor) {
1310  const_cast<RooTreeDataStore*>(this)->initialize() ;
1311  _defCtor = kFALSE ;
1312  }
1313 }
1314 
1315 
1316 
1317 
1318 
1319 ////////////////////////////////////////////////////////////////////////////////
1320 /// Interface function to TTree::GetEntries
1321 
1323 {
1324  return _tree->GetEntries() ;
1325 }
1326 
1327 
1328 ////////////////////////////////////////////////////////////////////////////////
1329 /// Interface function to TTree::Reset
1330 
1332 {
1333  _tree->Reset(option) ;
1334 }
1335 
1336 
1337 ////////////////////////////////////////////////////////////////////////////////
1338 /// Interface function to TTree::Fill
1339 
1341 {
1342  return _tree->Fill() ;
1343 }
1344 
1345 
1346 ////////////////////////////////////////////////////////////////////////////////
1347 /// Interface function to TTree::GetEntry
1348 
1350 {
1351  Int_t ret1 = _tree->GetEntry(entry,getall) ;
1352  if (!ret1) return 0 ;
1353  _cacheTree->GetEntry(entry,getall) ;
1354  return ret1 ;
1355 }
1356 
1357 
1358 ////////////////////////////////////////////////////////////////////////////////
1359 
1361 {
1362  _tree->Draw(option) ;
1363 }
1364 
1365 ////////////////////////////////////////////////////////////////////////////////
1366 /// Stream an object of class RooTreeDataStore.
1367 
1368 void RooTreeDataStore::Streamer(TBuffer &R__b)
1369 {
1370  if (R__b.IsReading()) {
1372  initialize() ;
1373  } else {
1375  }
1376 }
1377 
virtual Bool_t changeObservableName(const char *from, const char *to)
Change name of internal observable named 'from' into 'to'.
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:265
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
virtual RooArgSet * addColumns(const RooArgList &varList)
Utility function to add multiple columns in one call See addColumn() for details. ...
#define coutE(a)
Definition: RooMsgService.h:35
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:404
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
virtual void Reset()=0
Bool_t IsReading() const
Definition: TBuffer.h:81
virtual Double_t weight() const =0
virtual void attachBuffers(const RooArgSet &extObs)
void loadValues(const TTree *t, const RooFormulaVar *select=0, const char *rangeName=0, Int_t nStart=0, Int_t nStop=2000000000)
Load values from tree 't' into this data collection, optionally selecting events using 'select' RooFo...
TString cleanBranchName() const
Construct a mangled name from the actual name that is free of any math symbols that might be interpre...
Definition: RooAbsArg.cxx:1871
const char Option_t
Definition: RtypesCore.h:62
#define coutI(a)
Definition: RooMsgService.h:32
RooFIter fwdIterator() const
#define gDirectory
Definition: TDirectory.h:218
virtual Int_t Fill()
Fill all branches.
Definition: TTree.cxx:4328
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
virtual Bool_t isFundamental() const
Definition: RooAbsArg.h:157
virtual const RooArgSet * get() const
virtual RooAbsArg * cloneTree(const char *newname=0) const
Clone tree expression of objects.
Definition: RooAbsArg.cxx:2295
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
void Reset(Option_t *option=0)
Interface function to TTree::Reset.
#define gROOT
Definition: TROOT.h:340
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
Definition: TTree.cxx:5163
virtual const RooArgSet * get(Int_t index) const =0
Bool_t _defCtor
Object owning cache contents.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t GetEntry(Int_t entry=0, Int_t getall=0)
Interface function to TTree::GetEntry.
virtual void fillTreeBranch(TTree &t)=0
virtual Long64_t GetEntryNumber(Long64_t entry) const
Return entry number corresponding to entry.
Definition: TTree.cxx:5224
STL namespace.
virtual TTree * CloneTree(Long64_t nentries=-1, Option_t *option="")
Create a clone of this tree and copy nentries.
Definition: TTree.cxx:2961
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
Definition: RooAbsArg.cxx:288
ClassImp(RooTreeDataStore)
Iterator abstract base class.
Definition: TIterator.h:32
Bool_t _doDirtyProp
Iterator over cached variables.
virtual void attachToTree(TTree &t, Int_t bufSize=32000)=0
Overloadable function for derived classes to implement attachment as branch to a TTree.
Definition: RooAbsArg.cxx:1292
virtual void syncCache(const RooArgSet *nset=0)=0
const char * Data() const
Definition: TString.h:349
virtual Int_t numEntries() const =0
double sqrt(double)
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a new column to the data set which holds the pre-calculated values of 'newVar'.
Double_t * _extWgtErrLoArray
External weight array.
void Class()
Definition: Class.C:29
virtual Long64_t CopyEntries(TTree *tree, Long64_t nentries=-1, Option_t *option="")
Copy nentries from given tree to this tree.
Definition: TTree.cxx:3323
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add element to an owning set.
Definition: RooArgSet.cxx:461
virtual Double_t sumEntries() const
Double_t * _extWgtArray
virtual Bool_t valid() const
Return true if currently loaded coordinate is considered valid within the current range definitions o...
Bool_t getPoissonInterval(Int_t n, Double_t &mu1, Double_t &mu2, Double_t nSigma=1) const
Return a confidence interval for the expected number of events given n observed (unweighted) events...
std::map< std::string, std::string >::const_iterator iter
Definition: TAlienJob.cxx:54
TIterator * _cacheIter
Iterator over dimension variables.
TIterator * createIterator(Bool_t dir=kIterForward) const
if on multiple lines(like in C++).**The" * configuration fragment. * * The "import myobject continue
Parses the configuration file.
Definition: HLFactory.cxx:368
TString & Append(const char *cs)
Definition: TString.h:492
Double_t * _extWgtErrHiArray
External weight array - low error.
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
const RooAbsArg * _cacheOwner
TTree holding the cached function values.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TNamed.cxx:63
virtual ~RooTreeDataStore()
Destructor.
RooArgSet _cachedVars
virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const
virtual void setArgStatus(const RooArgSet &set, Bool_t active)
Activate or deactivate the branch status of the TTree branch associated with the given set of dataset...
virtual RooAbsArg * createFundamental(const char *newname=0) const =0
virtual void append(RooAbsDataStore &other)
A doubly linked list.
Definition: TList.h:47
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition: TTree.cxx:4822
virtual void setTreeBranchStatus(TTree &t, Bool_t active)=0
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Definition: RooRealVar.cxx:202
RooAbsArg * find(const char *name) const
Find object with given name in list.
return
Definition: TBase64.cxx:62
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
Definition: RooRealVar.h:60
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)=0
virtual Int_t fill()
Interface function to TTree::Fill.
static Int_t _defTreeBufSize
void SetName(const char *name)
Change (i.e.
Definition: RooAbsArg.cxx:2389
char * Form(const char *fmt,...)
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called...
void attachDataStore(const RooAbsDataStore &set)
Replace server nodes with names matching the dataset variable names with those data set variables...
Definition: RooAbsArg.cxx:1515
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual Bool_t inRange(const char *) const
Definition: RooAbsArg.h:289
Int_t Fill()
Interface function to TTree::Fill.
Long64_t entry
Double_t getAsymErrorHi() const
Definition: RooRealVar.h:59
virtual Int_t numEntries() const
RooAbsArg * next()
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
Double_t * _extSumW2Array
External weight array - high error.
virtual void SetDirectory(TDirectory *dir)
Change the tree's directory.
Definition: TTree.cxx:8095
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, Bool_t oneSafe=kFALSE)
The assignment operator sets the value of any argument in our set that also appears in the other set...
double Double_t
Definition: RtypesCore.h:55
RooArgSet varsNoWeight(const RooArgSet &allVars, const char *wgtName=0)
Utility function for constructors Return RooArgSet that is copy of allVars minus variable matching wg...
RooArgSet _attachedBuffers
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TTree.h:356
Double_t y[n]
Definition: legend1.C:17
void initialize()
One-time initialization common to all constructor forms.
void setValueDirty() const
Definition: RooAbsArg.h:439
RooRealVar * _wgtVar
RooArgSet _varsww
Was object constructed with default ctor?
Double_t _curWgt
External sum of weights array.
double Stat_t
Definition: RtypesCore.h:73
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual Bool_t isValid() const
WVE (08/21/01) Probably obsolete now.
Definition: RooAbsArg.cxx:1303
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)
Initialize cache of dataset: attach variables of cache ArgSet to the corresponding TTree branches...
Double_t getAsymErrorLo() const
Definition: RooRealVar.h:58
virtual void Add(TObject *obj)
Definition: TList.h:81
Stat_t GetEntries() const
Interface function to TTree::GetEntries.
virtual TObject * Next()=0
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList)
Merge columns of supplied data set(s) with this data set.
virtual void resetCache()
Remove tree with values of cached observables and clear list of cached observables.
virtual void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kFALSE)
Cache given RooAbsArgs with this tree: The tree is given direct write access of the args internal cac...
void setOperMode(OperMode mode, Bool_t recurseADirty=kTRUE)
Change cache operation mode to given mode.
Definition: RooAbsArg.cxx:1753
virtual void Reset(Option_t *option="")
Reset baskets, buffers and entries count in all branches and leaves.
Definition: TTree.cxx:7213
virtual Long64_t GetEntries() const
Definition: TTree.h:382
A TTree object has a header with a name and a title.
Definition: TTree.h:94
float type_of_call hi(const int &, const int &)
void clearValueDirty() const
Definition: RooAbsArg.h:447
Int_t getSize() const
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
virtual void checkInit() const
void createTree(const char *name, const char *title)
Create TTree object that lives in memory, independent of current location of gDirectory.
void Draw(Option_t *option="")
Default Draw method for all objects.
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Definition: RooAbsArg.cxx:1087
virtual Double_t weight() const
Return the weight of the n-th data point (n='index') in memory.
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
virtual void reset()
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName=0)
Utility function for constructors Return pointer to weight variable if it is defined.
virtual void resetBuffers()
TIterator * _iterator
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
Definition: RooArgSet.cxx:448
RooAbsCollection * selectByAttrib(const char *name, Bool_t value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
Double_t getError() const
Definition: RooRealVar.h:54