Logo ROOT  
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
22RooTreeDataStore is a TTree-backed data storage. When a file is opened before
23creating the data storage, the storage will be file-backed. This reduces memory
24pressure because it allows storing the data in the file and reading it on demand.
25For a completely memory-backed storage, which is faster than the file-backed storage,
26RooVectorDataStore can be used.
27
28With tree-backed storage, the tree can be found in the file with the name
29`RooTreeDataStore_name_title` for a dataset created as
30`RooDataSet("name", "title", ...)`.
31
32\note A file needs to be opened **before** creating the data storage to enable file-backed
33storage.
34```
35TFile outputFile("filename.root", "RECREATE");
36RooAbsData::setDefaultStorageType(RooAbsData::Tree);
37RooDataSet mydata(...);
38```
39
40One can also change between TTree- and std::vector-backed storage using
41RooAbsData::convertToTreeStore() and
42RooAbsData::convertToVectorStore().
43**/
44
45#include "RooTreeDataStore.h"
46
47#include "RooMsgService.h"
48#include "RooFormulaVar.h"
49#include "RooRealVar.h"
50#include "RooHistError.h"
51
52#include "ROOT/StringUtils.hxx"
53
54#include "TTree.h"
55#include "TFile.h"
56#include "TChain.h"
57#include "TDirectory.h"
58#include "TBuffer.h"
59#include "TBranch.h"
60#include "TROOT.h"
61
62#include <iomanip>
63using namespace std ;
64
66
67
69
70
71
72////////////////////////////////////////////////////////////////////////////////
73
75
76
77
78////////////////////////////////////////////////////////////////////////////////
79/// Constructor to facilitate reading of legacy RooDataSets
80
81RooTreeDataStore::RooTreeDataStore(TTree* t, const RooArgSet& vars, const char* wgtVarName) :
82 RooAbsDataStore("blah","blah",varsNoWeight(vars,wgtVarName)),
83 _tree(t),
84 _defCtor(true),
85 _varsww(vars),
86 _wgtVar(weightVar(vars,wgtVarName))
87{
88}
89
90
91
92
93////////////////////////////////////////////////////////////////////////////////
94
95RooTreeDataStore::RooTreeDataStore(RooStringView name, RooStringView title, const RooArgSet& vars, const char* wgtVarName) :
96 RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
97 _varsww(vars),
98 _wgtVar(weightVar(vars,wgtVarName))
99{
100 initialize() ;
101}
102
103
104////////////////////////////////////////////////////////////////////////////////
105
106RooTreeDataStore::RooTreeDataStore(RooStringView name, RooStringView title, const RooArgSet& vars, TTree& t, const char* selExpr, const char* wgtVarName) :
107 RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
108 _varsww(vars),
109 _wgtVar(weightVar(vars,wgtVarName))
110{
111 initialize() ;
112
113 if (selExpr && *selExpr) {
114 // Create a RooFormulaVar cut from given cut expression
115 RooFormulaVar select(selExpr, selExpr, _vars, /*checkVariables=*/false);
116 loadValues(&t,&select);
117 } else {
118 loadValues(&t);
119 }
120}
121
122
123////////////////////////////////////////////////////////////////////////////////
124
125RooTreeDataStore::RooTreeDataStore(RooStringView name, RooStringView title, const RooArgSet& vars, const RooAbsDataStore& ads, const char* selExpr, const char* wgtVarName) :
126 RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)),
127 _varsww(vars),
128 _wgtVar(weightVar(vars,wgtVarName))
129{
130 initialize() ;
131
132 if (selExpr && *selExpr) {
133 // Create a RooFormulaVar cut from given cut expression
134 RooFormulaVar select(selExpr, selExpr, _vars, /*checkVariables=*/false);
135 loadValues(&ads,&select);
136 } else {
137 loadValues(&ads);
138 }
139}
140
141
142
143
144////////////////////////////////////////////////////////////////////////////////
145
147 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
148 Int_t nStart, Int_t nStop, const char* wgtVarName) :
149 RooAbsDataStore(name,title,varsNoWeight(vars,wgtVarName)), _defCtor(kFALSE),
150 _varsww(vars),
151 _wgtVar(weightVar(vars,wgtVarName))
152{
153 // WVE NEED TO ADJUST THIS FOR WEIGHTS
154
155 // Protected constructor for internal use only
156 _tree = 0 ;
157 _cacheTree = 0 ;
158 createTree(makeTreeName(), title);
159
160 // Deep clone cutVar and attach clone to this dataset
161 RooFormulaVar* cloneVar = 0;
162 if (cutVar) {
163 cloneVar = (RooFormulaVar*) cutVar->cloneTree() ;
164 cloneVar->attachDataStore(tds) ;
165 }
166
167 // Constructor from existing data set with list of variables that preserves the cache
168 initialize();
169
171
172 // WVE copy values of cached variables here!!!
174 _cacheOwner = 0 ;
175
176 loadValues(&tds,cloneVar,cutRange,nStart,nStop);
177
178 if (cloneVar) delete cloneVar ;
179}
180
181
183 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
184 std::size_t nStart, std::size_t nStop) {
185 RooArgSet tmp(vars) ;
186 if(_wgtVar && !tmp.contains(*_wgtVar)) {
187 tmp.add(*_wgtVar) ;
188 }
189 const char* wgtVarName = _wgtVar ? _wgtVar->GetName() : nullptr;
190 return new RooTreeDataStore(name, title, *this, tmp, cutVar, cutRange, nStart, nStop, wgtVarName);
191}
192
193
194////////////////////////////////////////////////////////////////////////////////
195/// Utility function for constructors
196/// Return RooArgSet that is copy of allVars minus variable matching wgtName if specified
197
198RooArgSet RooTreeDataStore::varsNoWeight(const RooArgSet& allVars, const char* wgtName)
199{
200 RooArgSet ret(allVars) ;
201 if(wgtName) {
202 RooAbsArg* wgt = allVars.find(wgtName) ;
203 if (wgt) {
204 ret.remove(*wgt,kTRUE,kTRUE) ;
205 }
206 }
207 return ret ;
208}
209
210
211
212////////////////////////////////////////////////////////////////////////////////
213/// Utility function for constructors
214/// Return pointer to weight variable if it is defined
215
216RooRealVar* RooTreeDataStore::weightVar(const RooArgSet& allVars, const char* wgtName)
217{
218 if(wgtName) {
219 RooRealVar* wgt = dynamic_cast<RooRealVar*>(allVars.find(wgtName)) ;
220 return wgt ;
221 }
222 return 0 ;
223}
224
225
226
227
228////////////////////////////////////////////////////////////////////////////////
229/// Initialize cache of dataset: attach variables of cache ArgSet
230/// to the corresponding TTree branches
231
232void RooTreeDataStore::attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVarsIn)
233{
234 // iterate over the cache variables for this dataset
236 TIterator* iter = cachedVarsIn.createIterator() ;
237 RooAbsArg *var;
238 while((0 != (var= (RooAbsArg*)iter->Next()))) {
240 _cachedVars.add(*var) ;
241 }
242 delete iter ;
243 _cacheOwner = newOwner ;
244
245}
246
247
248
249
250
251
252////////////////////////////////////////////////////////////////////////////////
253
254RooTreeDataStore::RooTreeDataStore(const RooTreeDataStore& other, const char* newname) :
255 RooAbsDataStore(other,newname),
256 _varsww(other._varsww),
257 _wgtVar(other._wgtVar),
258 _extWgtArray(other._extWgtArray),
259 _extWgtErrLoArray(other._extWgtErrLoArray),
260 _extWgtErrHiArray(other._extWgtErrHiArray),
261 _extSumW2Array(other._extSumW2Array),
262 _curWgt(other._curWgt),
263 _curWgtErrLo(other._curWgtErrLo),
264 _curWgtErrHi(other._curWgtErrHi),
265 _curWgtErr(other._curWgtErr)
266{
267 initialize() ;
268 loadValues(&other) ;
269}
270
271
272////////////////////////////////////////////////////////////////////////////////
273
274RooTreeDataStore::RooTreeDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname) :
275 RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():0),newname),
276 _varsww(vars),
277 _wgtVar(other._wgtVar?weightVar(vars,other._wgtVar->GetName()):0),
278 _extWgtArray(other._extWgtArray),
279 _extWgtErrLoArray(other._extWgtErrLoArray),
280 _extWgtErrHiArray(other._extWgtErrHiArray),
281 _extSumW2Array(other._extSumW2Array),
282 _curWgt(other._curWgt),
283 _curWgtErrLo(other._curWgtErrLo),
284 _curWgtErrHi(other._curWgtErrHi),
285 _curWgtErr(other._curWgtErr)
286{
287 initialize() ;
288 loadValues(&other) ;
289}
290
291
292
293
294////////////////////////////////////////////////////////////////////////////////
295/// Destructor
296
298{
299 if (_tree) {
300 delete _tree ;
301 }
302 if (_cacheTree) {
303 delete _cacheTree ;
304 }
305}
306
307
308
309////////////////////////////////////////////////////////////////////////////////
310/// One-time initialization common to all constructor forms. Attach
311/// variables of internal ArgSet to the corresponding TTree branches
312
314{
315 // Recreate (empty) cache tree
317
318 // Attach each variable to the dataset
319 for (auto var : _varsww) {
320 var->attachToTree(*_tree,_defTreeBufSize) ;
321 }
322}
323
324
325
326
327
328////////////////////////////////////////////////////////////////////////////////
329/// Create TTree object that lives in memory, independent of current
330/// location of gDirectory
331
333{
334 if (!_tree) {
335 _tree = new TTree(name,title);
338 _tree->SetDirectory(nullptr);
339 }
340
341 TString pwd(gDirectory->GetPath()) ;
342 TString memDir(gROOT->GetName()) ;
343 memDir.Append(":/") ;
344 Bool_t notInMemNow= (pwd!=memDir) ;
345
346 // cout << "RooTreeData::createTree pwd=" << pwd << " memDir=" << memDir << " notInMemNow = " << (notInMemNow?"T":"F") << endl ;
347
348 if (notInMemNow) {
349 gDirectory->cd(memDir) ;
350 }
351
352 if (!_cacheTree) {
353 _cacheTree = new TTree(TString{static_cast<const char*>(name)} + "_cacheTree", TString{static_cast<const char*>(title)});
355 gDirectory->RecursiveRemove(_cacheTree) ;
356 }
357
358 if (notInMemNow) {
359 gDirectory->cd(pwd) ;
360 }
361
362}
363
364
365
366
367////////////////////////////////////////////////////////////////////////////////
368/// Load values from tree 't' into this data collection, optionally
369/// selecting events using the RooFormulaVar 'select'.
370///
371/// The source tree 't' is cloned to not disturb its branch
372/// structure when retrieving information from it.
373void RooTreeDataStore::loadValues(const TTree *t, const RooFormulaVar* select, const char* /*rangeName*/, Int_t /*nStart*/, Int_t /*nStop*/)
374{
375 // Make our local copy of the tree, so we can safely loop through it.
376 // We need a custom deleter, because if we don't deregister the Tree from the directory
377 // of the original, it tears it down at destruction time!
378 auto deleter = [](TTree* tree){tree->SetDirectory(nullptr); delete tree;};
379 std::unique_ptr<TTree, decltype(deleter)> tClone(static_cast<TTree*>(t->Clone()), deleter);
380 tClone->SetDirectory(t->GetDirectory());
381
382 // Clone list of variables
383 std::unique_ptr<RooArgSet> sourceArgSet( _varsww.snapshot(kFALSE) );
384
385 // Check that we have the branches:
386 Bool_t missingBranches = kFALSE;
387 for (const auto var : *sourceArgSet) {
388 if (!tClone->GetBranch(var->GetName())) {
389 missingBranches = kTRUE;
390 coutE(InputArguments) << "Didn't find a branch in Tree '" << tClone->GetName() << "' to read variable '"
391 << var->GetName() << "' from."
392 << "\n\tNote: Name the RooFit variable the same as the branch." << std::endl;
393 }
394 }
395 if (missingBranches) {
396 coutE(InputArguments) << "Cannot import data from TTree '" << tClone->GetName()
397 << "' because some branches are missing !" << std::endl;
398 return;
399 }
400
401 // Attach args in cloned list to cloned source tree
402 for (const auto sourceArg : *sourceArgSet) {
403 sourceArg->attachToTree(*tClone,_defTreeBufSize) ;
404 }
405
406 // Redirect formula servers to sourceArgSet
407 std::unique_ptr<RooFormulaVar> selectClone;
408 if (select) {
409 selectClone.reset( static_cast<RooFormulaVar*>(select->cloneTree()) );
410 selectClone->recursiveRedirectServers(*sourceArgSet) ;
411 selectClone->setOperMode(RooAbsArg::ADirty,kTRUE) ;
412 }
413
414 // Loop over events in source tree
415 Int_t numInvalid(0) ;
416 const Long64_t nevent = tClone->GetEntries();
417 for(Long64_t i=0; i < nevent; ++i) {
418 const auto entryNumber = tClone->GetEntryNumber(i);
419 if (entryNumber<0) break;
420 tClone->GetEntry(entryNumber,1);
421
422 // Copy from source to destination
423 Bool_t allOK(kTRUE) ;
424 for (unsigned int j=0; j < sourceArgSet->size(); ++j) {
425 auto destArg = _varsww[j];
426 const auto sourceArg = (*sourceArgSet)[j];
427
428 destArg->copyCache(sourceArg) ;
429 sourceArg->copyCache(destArg) ;
430 if (!destArg->isValid()) {
431 numInvalid++ ;
432 allOK=kFALSE ;
433 if (numInvalid < 5) {
434 coutI(DataHandling) << "RooTreeDataStore::loadValues(" << GetName() << ") Skipping event #" << i << " because " << destArg->GetName()
435 << " cannot accommodate the value " << static_cast<RooAbsReal*>(sourceArg)->getVal() << std::endl;
436 } else if (numInvalid == 5) {
437 coutI(DataHandling) << "RooTreeDataStore::loadValues(" << GetName() << ") Skipping ..." << std::endl;
438 }
439 break ;
440 }
441 }
442
443 // Does this event pass the cuts?
444 if (!allOK || (selectClone && selectClone->getVal()==0)) {
445 continue ;
446 }
447
448 fill() ;
449 }
450
451 if (numInvalid>0) {
452 coutW(DataHandling) << "RooTreeDataStore::loadValues(" << GetName() << ") Ignored " << numInvalid << " out-of-range events" << endl ;
453 }
454
455 SetTitle(t->GetTitle());
456}
457
458
459
460
461
462
463////////////////////////////////////////////////////////////////////////////////
464/// Load values from dataset 't' into this data collection, optionally
465/// selecting events using 'select' RooFormulaVar
466///
467
469 const char* rangeName, std::size_t nStart, std::size_t nStop)
470{
471 // Redirect formula servers to source data row
472 std::unique_ptr<RooFormulaVar> selectClone;
473 if (select) {
474 selectClone.reset( static_cast<RooFormulaVar*>(select->cloneTree()) );
475 selectClone->recursiveRedirectServers(*ads->get()) ;
476 selectClone->setOperMode(RooAbsArg::ADirty,kTRUE) ;
477 }
478
479 // Force RDS internal initialization
480 ads->get(0) ;
481
482 // Loop over events in source tree
483 const auto numEntr = static_cast<std::size_t>(ads->numEntries());
484 std::size_t nevent = nStop < numEntr ? nStop : numEntr;
485
486 auto TDS = dynamic_cast<const RooTreeDataStore*>(ads) ;
487 if (TDS) {
488 const_cast<RooTreeDataStore*>(TDS)->resetBuffers();
489 }
490
491 std::vector<std::string> ranges;
492 if (rangeName) {
493 ranges = ROOT::Split(rangeName, ",");
494 }
495
496 for (auto i=nStart; i < nevent ; ++i) {
497 ads->get(i) ;
498
499 // Does this event pass the cuts?
500 if (selectClone && selectClone->getVal()==0) {
501 continue ;
502 }
503
504
505 if (TDS) {
506 _varsww.assignValueOnly(TDS->_varsww) ;
507 } else {
508 _varsww.assignValueOnly(*ads->get()) ;
509 }
510
511 // Check that all copied values are valid
512 bool allValid = true;
513 for (const auto arg : _varsww) {
514 allValid = arg->isValid() && (ranges.empty() || std::any_of(ranges.begin(), ranges.end(),
515 [arg](const std::string& range){return arg->inRange(range.c_str());}) );
516 if (!allValid)
517 break ;
518 }
519
520 if (!allValid) {
521 continue ;
522 }
523
524 _cachedVars.assign(((RooTreeDataStore*)ads)->_cachedVars) ;
525 fill() ;
526 }
527
528 if (TDS) {
529 const_cast<RooTreeDataStore*>(TDS)->restoreAlternateBuffers();
530 }
531
532 SetTitle(ads->GetTitle());
533}
534
535
536////////////////////////////////////////////////////////////////////////////////
537/// Interface function to TTree::Fill
538
540{
541 return _tree->Fill() ;
542}
543
544
545
546////////////////////////////////////////////////////////////////////////////////
547/// Load the n-th data point (n='index') in memory
548/// and return a pointer to the internal RooArgSet
549/// holding its coordinates.
550
552{
553 checkInit() ;
554
555 Int_t ret = ((RooTreeDataStore*)this)->GetEntry(index, 1) ;
556
557 if(!ret) return 0;
558
559 if (_doDirtyProp) {
560 // Raise all dirty flags
561 for (auto var : _vars) {
562 var->setValueDirty(); // This triggers recalculation of all clients
563 }
564
565 for (auto var : _cachedVars) {
566 var->setValueDirty(); // This triggers recalculation of all clients, but doesn't recalculate self
567 var->clearValueDirty();
568 }
569 }
570
571 // Update current weight cache
572 if (_extWgtArray) {
573
574 // If external array is specified use that
579
580 } else if (_wgtVar) {
581
582 // Otherwise look for weight variable
583 _curWgt = _wgtVar->getVal() ;
587
588 } else {
589
590 // Otherwise return 1
591 _curWgt=1.0 ;
592 _curWgtErrLo = 0 ;
593 _curWgtErrHi = 0 ;
594 _curWgtErr = 0 ;
595
596 }
597
598 return &_vars;
599}
600
601
602////////////////////////////////////////////////////////////////////////////////
603/// Return the weight of the n-th data point (n='index') in memory
604
606{
607 return _curWgt ;
608}
609
610
611////////////////////////////////////////////////////////////////////////////////
612
614{
615 if (_extWgtArray) {
616
617 // We have a weight array, use that info
618
619 // Return symmetric error on current bin calculated either from Poisson statistics or from SumOfWeights
620 Double_t lo = 0, hi =0;
621 weightError(lo,hi,etype) ;
622 return (lo+hi)/2 ;
623
624 } else if (_wgtVar) {
625
626 // We have a a weight variable, use that info
627 if (_wgtVar->hasAsymError()) {
628 return ( _wgtVar->getAsymErrorHi() - _wgtVar->getAsymErrorLo() ) / 2 ;
629 } else {
630 return _wgtVar->getError() ;
631 }
632
633 } else {
634
635 // We have no weights
636 return 0 ;
637
638 }
639}
640
641
642
643////////////////////////////////////////////////////////////////////////////////
644
646{
647 if (_extWgtArray) {
648
649 // We have a weight array, use that info
650 switch (etype) {
651
652 case RooAbsData::Auto:
653 throw string(Form("RooDataHist::weightError(%s) error type Auto not allowed here",GetName())) ;
654 break ;
655
657 throw string(Form("RooDataHist::weightError(%s) error type Expected not allowed here",GetName())) ;
658 break ;
659
661 // Weight may be preset or precalculated
662 if (_curWgtErrLo>=0) {
663 lo = _curWgtErrLo ;
664 hi = _curWgtErrHi ;
665 return ;
666 }
667
668 // Otherwise Calculate poisson errors
669 Double_t ym,yp ;
671 lo = weight()-ym ;
672 hi = yp-weight() ;
673 return ;
674
676 lo = _curWgtErr ;
677 hi = _curWgtErr ;
678 return ;
679
680 case RooAbsData::None:
681 lo = 0 ;
682 hi = 0 ;
683 return ;
684 }
685
686 } else if (_wgtVar) {
687
688 // We have a a weight variable, use that info
689 if (_wgtVar->hasAsymError()) {
691 lo = _wgtVar->getAsymErrorLo() ;
692 } else {
693 hi = _wgtVar->getError() ;
694 lo = _wgtVar->getError() ;
695 }
696
697 } else {
698
699 // We are unweighted
700 lo=0 ;
701 hi=0 ;
702
703 }
704}
705
706
707////////////////////////////////////////////////////////////////////////////////
708/// Change name of internal observable named 'from' into 'to'
709
710Bool_t RooTreeDataStore::changeObservableName(const char* from, const char* to)
711{
712 // Find observable to be changed
713 RooAbsArg* var = _vars.find(from) ;
714
715 // Check that we found it
716 if (!var) {
717 coutE(InputArguments) << "RooTreeDataStore::changeObservableName(" << GetName() << " no observable " << from << " in this dataset" << endl ;
718 return kTRUE ;
719 }
720
721 // Process name change
722 TString oldBranchName = var->cleanBranchName() ;
723 var->SetName(to) ;
724
725 // Change the branch name as well
726 if (_tree->GetBranch(oldBranchName.Data())) {
727
728 // Simple case varName = branchName
729 _tree->GetBranch(oldBranchName.Data())->SetName(var->cleanBranchName().Data()) ;
730
731 // Process any error branch if existing
732 if (_tree->GetBranch(Form("%s_err",oldBranchName.Data()))) {
733 _tree->GetBranch(Form("%s_err",oldBranchName.Data()))->SetName(Form("%s_err",var->cleanBranchName().Data())) ;
734 }
735 if (_tree->GetBranch(Form("%s_aerr_lo",oldBranchName.Data()))) {
736 _tree->GetBranch(Form("%s_aerr_lo",oldBranchName.Data()))->SetName(Form("%s_aerr_lo",var->cleanBranchName().Data())) ;
737 }
738 if (_tree->GetBranch(Form("%s_aerr_hi",oldBranchName.Data()))) {
739 _tree->GetBranch(Form("%s_aerr_hi",oldBranchName.Data()))->SetName(Form("%s_aerr_hi",var->cleanBranchName().Data())) ;
740 }
741
742 } else {
743
744 // Native category case branchNames = varName_idx and varName_lbl
745 if (_tree->GetBranch(Form("%s_idx",oldBranchName.Data()))) {
746 _tree->GetBranch(Form("%s_idx",oldBranchName.Data()))->SetName(Form("%s_idx",var->cleanBranchName().Data())) ;
747 }
748 if (_tree->GetBranch(Form("%s_lbl",oldBranchName.Data()))) {
749 _tree->GetBranch(Form("%s_lbl",oldBranchName.Data()))->SetName(Form("%s_lb",var->cleanBranchName().Data())) ;
750 }
751
752 }
753
754 return kFALSE ;
755}
756
757
758
759////////////////////////////////////////////////////////////////////////////////
760/// Add a new column to the data set which holds the pre-calculated values
761/// of 'newVar'. This operation is only meaningful if 'newVar' is a derived
762/// value.
763///
764/// The return value points to the added element holding 'newVar's value
765/// in the data collection. The element is always the corresponding fundamental
766/// type of 'newVar' (e.g. a RooRealVar if 'newVar' is a RooFormulaVar)
767///
768/// Note: This function is explicitly NOT intended as a speed optimization
769/// opportunity for the user. Components of complex PDFs that can be
770/// precalculated with the dataset are automatically identified as such
771/// and will be precalculated when fitting to a dataset
772///
773/// By forcibly precalculating functions with non-trivial Jacobians,
774/// or functions of multiple variables occurring in the data set,
775/// using addColumn(), you may alter the outcome of the fit.
776///
777/// Only in cases where such a modification of fit behaviour is intentional,
778/// this function should be used.
779
781{
782 checkInit() ;
783
784 // Create a fundamental object of the right type to hold newVar values
785 RooAbsArg* valHolder= newVar.createFundamental();
786 // Sanity check that the holder really is fundamental
787 if(!valHolder->isFundamental()) {
788 coutE(InputArguments) << GetName() << "::addColumn: holder argument is not fundamental: \""
789 << valHolder->GetName() << "\"" << endl;
790 return 0;
791 }
792
793 // WVE need to reset TTRee buffers to original datamembers here
794 resetBuffers() ;
795
796 // Clone variable and attach to cloned tree
797 RooAbsArg* newVarClone = newVar.cloneTree() ;
799
800 // Attach value place holder to this tree
801 ((RooAbsArg*)valHolder)->attachToTree(*_tree,_defTreeBufSize) ;
802 _vars.add(*valHolder) ;
803 _varsww.add(*valHolder) ;
804
805
806 // Fill values of of placeholder
807 for (int i=0 ; i<GetEntries() ; i++) {
808 get(i) ;
809
810 newVarClone->syncCache(&_vars) ;
811 valHolder->copyCache(newVarClone) ;
812 valHolder->fillTreeBranch(*_tree) ;
813 }
814
815 // WVE need to restore TTRee buffers to previous values here
817
818 if (adjustRange) {
819// // Set range of valHolder to (just) bracket all values stored in the dataset
820// Double_t vlo,vhi ;
821// RooRealVar* rrvVal = dynamic_cast<RooRealVar*>(valHolder) ;
822// if (rrvVal) {
823// getRange(*rrvVal,vlo,vhi,0.05) ;
824// rrvVal->setRange(vlo,vhi) ;
825// }
826 }
827
828
829
830 delete newVarClone ;
831 return valHolder ;
832}
833
834
835////////////////////////////////////////////////////////////////////////////////
836/// Merge columns of supplied data set(s) with this data set. All
837/// data sets must have equal number of entries. In case of
838/// duplicate columns the column of the last dataset in the list
839/// prevails
840
841RooAbsDataStore* RooTreeDataStore::merge(const RooArgSet& allVars, list<RooAbsDataStore*> dstoreList)
842{
843 RooTreeDataStore* mergedStore = new RooTreeDataStore("merged","merged",allVars) ;
844
845 Int_t nevt = dstoreList.front()->numEntries() ;
846 for (int i=0 ; i<nevt ; i++) {
847
848 // Cope data from self
849 mergedStore->_vars.assign(*get(i)) ;
850
851 // Copy variables from merge sets
852 for (list<RooAbsDataStore*>::iterator iter = dstoreList.begin() ; iter!=dstoreList.end() ; ++iter) {
853 const RooArgSet* partSet = (*iter)->get(i) ;
854 mergedStore->_vars.assign(*partSet) ;
855 }
856
857 mergedStore->fill() ;
858 }
859 return mergedStore ;
860}
861
862
863
864
865
866////////////////////////////////////////////////////////////////////////////////
867
869{
870 Int_t nevt = other.numEntries() ;
871 for (int i=0 ; i<nevt ; i++) {
872 _vars.assign(*other.get(i)) ;
873 if (_wgtVar) {
874 _wgtVar->setVal(other.weight()) ;
875 }
876
877 fill() ;
878 }
879}
880
881
882////////////////////////////////////////////////////////////////////////////////
883
885{
886 if (_wgtVar) {
887
888 Double_t sum(0), carry(0);
889 Int_t nevt = numEntries() ;
890 for (int i=0 ; i<nevt ; i++) {
891 get(i) ;
892 // Kahan's algorithm for summing to avoid loss of precision
893 Double_t y = _wgtVar->getVal() - carry;
894 Double_t t = sum + y;
895 carry = (t - sum) - y;
896 sum = t;
897 }
898 return sum ;
899
900 } else if (_extWgtArray) {
901
902 Double_t sum(0) , carry(0);
903 Int_t nevt = numEntries() ;
904 for (int i=0 ; i<nevt ; i++) {
905 // Kahan's algorithm for summing to avoid loss of precision
906 Double_t y = _extWgtArray[i] - carry;
907 Double_t t = sum + y;
908 carry = (t - sum) - y;
909 sum = t;
910 }
911 return sum ;
912
913 } else {
914
915 return numEntries() ;
916
917 }
918}
919
920
921
922
923////////////////////////////////////////////////////////////////////////////////
924
926{
927 return _tree->GetEntries() ;
928}
929
930
931
932////////////////////////////////////////////////////////////////////////////////
933
935{
936 Reset() ;
937}
938
939
940
941////////////////////////////////////////////////////////////////////////////////
942/// Cache given RooAbsArgs with this tree: The tree is
943/// given direct write access of the args internal cache
944/// the args values is pre-calculated for all data points
945/// in this data collection. Upon a get() call, the
946/// internal cache of 'newVar' will be loaded with the
947/// precalculated value and it's dirty flag will be cleared.
948
949void RooTreeDataStore::cacheArgs(const RooAbsArg* owner, RooArgSet& newVarSet, const RooArgSet* nset, Bool_t /*skipZeroWeights*/)
950{
951 checkInit() ;
952
953 _cacheOwner = owner ;
954
955 RooArgSet* constExprVarSet = (RooArgSet*) newVarSet.selectByAttrib("ConstantExpression",kTRUE) ;
956 TIterator *iter = constExprVarSet->createIterator() ;
957 RooAbsArg *arg ;
958
959 Bool_t doTreeFill = (_cachedVars.getSize()==0) ;
960
961 while ((arg=(RooAbsArg*)iter->Next())) {
962 // Attach original newVar to this tree
964 //arg->recursiveRedirectServers(_vars) ;
965 _cachedVars.add(*arg) ;
966 }
967
968 // WVE need to reset TTRee buffers to original datamembers here
969 //resetBuffers() ;
970
971 // Refill regular and cached variables of current tree from clone
972 for (int i=0 ; i<GetEntries() ; i++) {
973 get(i) ;
974
975 // Evaluate the cached variables and store the results
976 iter->Reset() ;
977 while ((arg=(RooAbsArg*)iter->Next())) {
978 arg->setValueDirty() ;
979 arg->syncCache(nset) ;
980 if (!doTreeFill) {
982 }
983 }
984
985 if (doTreeFill) {
986 _cacheTree->Fill() ;
987 }
988 }
989
990 // WVE need to restore TTRee buffers to previous values here
991 //restoreAlternateBuffers() ;
992
993 delete iter ;
994 delete constExprVarSet ;
995}
996
997
998
999
1000////////////////////////////////////////////////////////////////////////////////
1001/// Activate or deactivate the branch status of the TTree branch associated
1002/// with the given set of dataset observables
1003
1005{
1006 TIterator* iter = set.createIterator() ;
1007 RooAbsArg* arg ;
1008 while ((arg=(RooAbsArg*)iter->Next())) {
1009 RooAbsArg* depArg = _vars.find(arg->GetName()) ;
1010 if (!depArg) {
1011 coutE(InputArguments) << "RooTreeDataStore::setArgStatus(" << GetName()
1012 << ") dataset doesn't contain variable " << arg->GetName() << endl ;
1013 continue ;
1014 }
1015 depArg->setTreeBranchStatus(*_tree,active) ;
1016 }
1017 delete iter ;
1018}
1019
1020
1021
1022////////////////////////////////////////////////////////////////////////////////
1023/// Remove tree with values of cached observables
1024/// and clear list of cached observables
1025
1027{
1028 // Empty list of cached functions
1030
1031 // Delete & recreate cache tree
1032 delete _cacheTree ;
1033 _cacheTree = 0 ;
1034 createTree(makeTreeName().c_str(), GetTitle());
1035
1036 return ;
1037}
1038
1039
1040
1041
1042////////////////////////////////////////////////////////////////////////////////
1043
1045{
1047 for (const auto arg : _varsww) {
1048 RooAbsArg* extArg = extObs.find(arg->GetName()) ;
1049 if (extArg) {
1050 if (arg->getAttribute("StoreError")) {
1051 extArg->setAttribute("StoreError") ;
1052 }
1053 if (arg->getAttribute("StoreAsymError")) {
1054 extArg->setAttribute("StoreAsymError") ;
1055 }
1056 extArg->attachToTree(*_tree) ;
1057 _attachedBuffers.add(*extArg) ;
1058 }
1059 }
1060}
1061
1062
1063
1064////////////////////////////////////////////////////////////////////////////////
1065
1067{
1068 RooFIter iter = _varsww.fwdIterator() ;
1069 RooAbsArg* arg ;
1070 while((arg=iter.next())) {
1071 arg->attachToTree(*_tree) ;
1072 }
1073}
1074
1075
1076
1077////////////////////////////////////////////////////////////////////////////////
1078
1080{
1082 RooAbsArg* arg ;
1083 while((arg=iter.next())) {
1084 arg->attachToTree(*_tree) ;
1085 }
1086}
1087
1088
1089
1090////////////////////////////////////////////////////////////////////////////////
1091
1093{
1094 if (_defCtor) {
1095 const_cast<RooTreeDataStore*>(this)->initialize() ;
1096 _defCtor = kFALSE ;
1097 }
1098}
1099
1100
1101
1102
1103
1104////////////////////////////////////////////////////////////////////////////////
1105/// Interface function to TTree::GetEntries
1106
1108{
1109 return _tree->GetEntries() ;
1110}
1111
1112
1113////////////////////////////////////////////////////////////////////////////////
1114/// Interface function to TTree::Reset
1115
1117{
1118 _tree->Reset(option) ;
1119}
1120
1121
1122////////////////////////////////////////////////////////////////////////////////
1123/// Interface function to TTree::Fill
1124
1126{
1127 return _tree->Fill() ;
1128}
1129
1130
1131////////////////////////////////////////////////////////////////////////////////
1132/// Interface function to TTree::GetEntry
1133
1135{
1136 Int_t ret1 = _tree->GetEntry(entry,getall) ;
1137 if (!ret1) return 0 ;
1138 _cacheTree->GetEntry(entry,getall) ;
1139 return ret1 ;
1140}
1141
1142
1143////////////////////////////////////////////////////////////////////////////////
1144
1146{
1147 _tree->Draw(option) ;
1148}
1149
1150////////////////////////////////////////////////////////////////////////////////
1151/// Stream an object of class RooTreeDataStore.
1152
1154{
1155 if (R__b.IsReading()) {
1156 UInt_t R__s, R__c;
1157 const Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1158
1159 R__b.ReadClassBuffer(RooTreeDataStore::Class(), this, R__v, R__s, R__c);
1160
1161 if (!_tree) {
1162 // If the tree has not been deserialised automatically, it is time to load
1163 // it now.
1164 TFile* parent = dynamic_cast<TFile*>(R__b.GetParent());
1165 assert(parent);
1166 parent->GetObject(makeTreeName().c_str(), _tree);
1167 }
1168
1169 initialize();
1170
1171 } else {
1172
1173 TTree* tmpTree = _tree;
1174 auto parent = dynamic_cast<TDirectory*>(R__b.GetParent());
1175 if (_tree && parent) {
1176 // Large trees cannot be written because of the 1Gb I/O limitation.
1177 // Here, we take the tree away from our instance, write it, and continue
1178 // to write the rest of the class normally
1179 auto tmpDir = _tree->GetDirectory();
1180
1181 _tree->SetDirectory(parent);
1182 _tree->FlushBaskets(false);
1183 parent->WriteObject(_tree, makeTreeName().c_str());
1184 _tree->SetDirectory(tmpDir);
1185 _tree = nullptr;
1186 }
1187
1189
1190 _tree = tmpTree;
1191 }
1192}
1193
1194////////////////////////////////////////////////////////////////////////////////
1195/// Generate a name for the storage tree from the name and title of this instance.
1197 std::string title = GetTitle();
1198 std::replace(title.begin(), title.end(), ' ', '_');
1199 std::replace(title.begin(), title.end(), '-', '_');
1200 return std::string("RooTreeDataStore_") + GetName() + "_" + title;
1201}
1202
1203
1204////////////////////////////////////////////////////////////////////////////////
1205/// Get the weights of the events in the range [first, first+len).
1206/// This implementation will fill a vector with every event retrieved one by one
1207/// (even if the weight is constant). Then, it returns a span.
1209
1210 if (_extWgtArray) {
1211 return {_extWgtArray + first, len};
1212 }
1213
1214 if (!_weightBuffer) {
1215 _weightBuffer.reset(new std::vector<double>());
1216 _weightBuffer->reserve(len);
1217
1218 for (std::size_t i = 0; i < GetEntries(); ++i) {
1219 _weightBuffer->push_back(weight(i));
1220 }
1221 }
1222
1223 return {_weightBuffer->data() + first, len};
1224}
#define coutI(a)
Definition: RooMsgService.h:30
#define coutW(a)
Definition: RooMsgService.h:32
#define coutE(a)
Definition: RooMsgService.h:33
int Int_t
Definition: RtypesCore.h:45
short Version_t
Definition: RtypesCore.h:65
const Bool_t kFALSE
Definition: RtypesCore.h:101
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:375
#define gDirectory
Definition: TDirectory.h:348
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition: TGX11.cxx:110
#define hi
Definition: THbookFile.cxx:128
#define gROOT
Definition: TROOT.h:404
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition: TString.cxx:2447
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:78
virtual RooAbsArg * cloneTree(const char *newname=0) const
Clone tree expression of objects.
Definition: RooAbsArg.cxx:2310
void attachDataStore(const RooAbsDataStore &set)
Replace server nodes with names matching the dataset variable names with those data set variables,...
Definition: RooAbsArg.cxx:1640
virtual void setTreeBranchStatus(TTree &t, Bool_t active)=0
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)=0
void SetName(const char *name) override
Set the name of the TNamed.
Definition: RooAbsArg.cxx:2399
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Definition: RooAbsArg.h:248
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:282
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:1407
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition: RooAbsArg.h:514
virtual void syncCache(const RooArgSet *nset=0)=0
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:1988
virtual RooAbsArg * createFundamental(const char *newname=0) const =0
Create a fundamental-type object that stores our type of value.
virtual void fillTreeBranch(TTree &t)=0
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Recursively replace all servers with the new servers in newSet.
Definition: RooAbsArg.cxx:1197
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Storage_t const & get() const
Const access to the underlying stl container.
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, bool forceIfSizeOne=false)
Sets the value of any argument in our set that also appears in the other set.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Int_t getSize() const
Return the number of elements in the collection.
Bool_t contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
RooFIter fwdIterator() const
One-time forward iterator.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
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...
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsDataStore is the abstract base class for data collection that use a TTree as internal storage m...
virtual const RooArgSet * get(Int_t index) const =0
virtual Double_t weight() const =0
Bool_t _doDirtyProp
Switch do (de)activate dirty state propagation when loading a data point.
RooArgSet _cachedVars
virtual Int_t numEntries() const =0
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:63
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:93
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:57
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:180
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:30
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.
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called.
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
Double_t getAsymErrorLo() const
Definition: RooRealVar.h:65
void setVal(Double_t value) override
Set value of variable to 'value'.
Definition: RooRealVar.cxx:281
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
Definition: RooRealVar.h:67
Double_t getAsymErrorHi() const
Definition: RooRealVar.h:66
Double_t getError() const
Definition: RooRealVar.h:61
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
The RooStringView is a wrapper around a C-syle string that can also be constructed from a std::string...
Definition: RooStringView.h:27
RooTreeDataStore is a TTree-backed data storage.
Bool_t changeObservableName(const char *from, const char *to) override
Change name of internal observable named 'from' into 'to'.
const Double_t * _extSumW2Array
! External sum of weights array
const Double_t * _extWgtArray
! External weight array
void initialize()
One-time initialization common to all constructor forms.
void resetBuffers() override
RooArgSet varsNoWeight(const RooArgSet &allVars, const char *wgtName=0)
Utility function for constructors Return RooArgSet that is copy of allVars minus variable matching wg...
void Draw(Option_t *option="") override
Default Draw method for all objects.
void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars) override
Initialize cache of dataset: attach variables of cache ArgSet to the corresponding TTree branches.
static TClass * Class()
Int_t numEntries() const override
std::string makeTreeName() const
Generate a name for the storage tree from the name and title of this instance.
Double_t weight() const override
Return the weight of the n-th data point (n='index') in memory.
~RooTreeDataStore() override
Destructor.
void createTree(RooStringView name, RooStringView title)
Create TTree object that lives in memory, independent of current location of gDirectory.
Double_t _curWgtErr
Weight of current event.
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName=0)
Utility function for constructors Return pointer to weight variable if it is defined.
Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override
const Double_t * _extWgtErrLoArray
! External weight array - low error
Stat_t GetEntries() const
Interface function to TTree::GetEntries.
void attachBuffers(const RooArgSet &extObs) override
Int_t GetEntry(Int_t entry=0, Int_t getall=0)
Interface function to TTree::GetEntry.
Double_t _curWgt
Buffer for weights in case a batch of values is requested.
void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kFALSE) override
Cache given RooAbsArgs with this tree: The tree is given direct write access of the args internal cac...
void reset() override
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList) override
Merge columns of supplied data set(s) with this data set.
static Int_t _defTreeBufSize
RooSpan< const double > getWeightBatch(std::size_t first, std::size_t len) const override
Get the weights of the events in the range [first, first+len).
RooArgSet _attachedBuffers
! Currently attached buffers (if different from _varsww)
Int_t fill() override
Interface function to TTree::Fill.
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 the RooFormula...
Double_t _curWgtErrHi
Weight of current event.
RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE) override
Add a new column to the data set which holds the pre-calculated values of 'newVar'.
const Double_t * _extWgtErrHiArray
! External weight array - high error
Bool_t _defCtor
Object owning cache contents.
void append(RooAbsDataStore &other) override
void setArgStatus(const RooArgSet &set, Bool_t active) override
Activate or deactivate the branch status of the TTree branch associated with the given set of dataset...
Double_t _curWgtErrLo
Weight of current event.
void checkInit() const override
std::unique_ptr< std::vector< double > > _weightBuffer
Int_t Fill()
Interface function to TTree::Fill.
RooAbsDataStore * reduce(RooStringView name, RooStringView title, const RooArgSet &vars, const RooFormulaVar *cutVar, const char *cutRange, std::size_t nStart, std::size_t nStop) override
void Streamer(TBuffer &) override
Stream an object of class RooTreeDataStore.
RooRealVar * _wgtVar
void Reset(Option_t *option=0)
Interface function to TTree::Reset.
void resetCache() override
Remove tree with values of cached observables and clear list of cached observables.
virtual const RooArgSet * get() const
const RooAbsArg * _cacheOwner
TTree holding the cached function values.
RooArgSet _varsww
Was object constructed with default ctor?
Double_t sumEntries() const override
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
TObject * GetParent() const
Return pointer to parent of this buffer.
Definition: TBuffer.cxx:262
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Bool_t IsReading() const
Definition: TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Describe directory structure in memory.
Definition: TDirectory.h:45
void GetObject(const char *namecycle, T *&ptr)
Get an object with proper type checking.
Definition: TDirectory.h:203
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
Iterator abstract base class.
Definition: TIterator.h:30
virtual void Reset()=0
virtual TObject * Next()=0
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition: TNamed.cxx:74
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition: TNamed.h:48
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
void ResetBit(UInt_t f)
Definition: TObject.h:186
@ kCanDelete
if object in a list can be deleted
Definition: TObject.h:58
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition: TObject.h:60
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
TString & Append(const char *cs)
Definition: TString.h:564
A TTree represents a columnar dataset.
Definition: TTree.h:79
virtual Int_t Fill()
Fill all branches.
Definition: TTree.cxx:4571
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition: TTree.cxx:5256
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
Definition: TTree.cxx:5605
virtual Int_t FlushBaskets(Bool_t create_cluster=true) const
Write to disk all the basket that have not yet been individually written and create an event cluster ...
Definition: TTree.cxx:5091
void Draw(Option_t *opt) override
Default Draw method for all objects.
Definition: TTree.h:428
virtual Long64_t CopyEntries(TTree *tree, Long64_t nentries=-1, Option_t *option="", Bool_t needCopyAddresses=false)
Copy nentries from given tree to this tree.
Definition: TTree.cxx:3505
TDirectory * GetDirectory() const
Definition: TTree.h:458
virtual void SetDirectory(TDirectory *dir)
Change the tree's directory.
Definition: TTree.cxx:8915
virtual Long64_t GetEntries() const
Definition: TTree.h:459
virtual void Reset(Option_t *option="")
Reset baskets, buffers and entries count in all branches and leaves.
Definition: TTree.cxx:7965
Double_t y[n]
Definition: legend1.C:17
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
Definition: StringUtils.cxx:23
@ DataHandling
Definition: RooGlobalFunc.h:65
@ InputArguments
Definition: RooGlobalFunc.h:64
Definition: first.py:1
Definition: tree.py:1
static uint64_t sum(uint64_t i)
Definition: Factory.cxx:2345