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