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(false),
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 std::unique_ptr<RooFormulaVar> cloneVar;
162 if (cutVar) {
163 cloneVar.reset(static_cast<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.get(),cutRange,nStart,nStop);
177}
178
179
181 const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
182 std::size_t nStart, std::size_t nStop) {
183 RooArgSet tmp(vars) ;
184 if(_wgtVar && !tmp.contains(*_wgtVar)) {
185 tmp.add(*_wgtVar) ;
186 }
187 const char* wgtVarName = _wgtVar ? _wgtVar->GetName() : nullptr;
188 return new RooTreeDataStore(name, title, *this, tmp, cutVar, cutRange, nStart, nStop, wgtVarName);
189}
190
191
192////////////////////////////////////////////////////////////////////////////////
193/// Utility function for constructors
194/// Return RooArgSet that is copy of allVars minus variable matching wgtName if specified
195
196RooArgSet RooTreeDataStore::varsNoWeight(const RooArgSet& allVars, const char* wgtName)
197{
198 RooArgSet ret(allVars) ;
199 if(wgtName) {
200 RooAbsArg* wgt = allVars.find(wgtName) ;
201 if (wgt) {
202 ret.remove(*wgt,true,true) ;
203 }
204 }
205 return ret ;
206}
207
208
209
210////////////////////////////////////////////////////////////////////////////////
211/// Utility function for constructors
212/// Return pointer to weight variable if it is defined
213
214RooRealVar* RooTreeDataStore::weightVar(const RooArgSet& allVars, const char* wgtName)
215{
216 if(wgtName) {
217 RooRealVar* wgt = dynamic_cast<RooRealVar*>(allVars.find(wgtName)) ;
218 return wgt ;
219 }
220 return 0 ;
221}
222
223
224
225
226////////////////////////////////////////////////////////////////////////////////
227/// Initialize cache of dataset: attach variables of cache ArgSet
228/// to the corresponding TTree branches
229
230void RooTreeDataStore::attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVarsIn)
231{
232 // iterate over the cache variables for this dataset
234 for (RooAbsArg * var : cachedVarsIn) {
235 var->attachToTree(*_cacheTree,_defTreeBufSize) ;
236 _cachedVars.add(*var) ;
237 }
238 _cacheOwner = newOwner ;
239
240}
241
242
243
244
245
246
247////////////////////////////////////////////////////////////////////////////////
248
249RooTreeDataStore::RooTreeDataStore(const RooTreeDataStore& other, const char* newname) :
250 RooAbsDataStore(other,newname),
251 _varsww(other._varsww),
252 _wgtVar(other._wgtVar),
253 _extWgtArray(other._extWgtArray),
254 _extWgtErrLoArray(other._extWgtErrLoArray),
255 _extWgtErrHiArray(other._extWgtErrHiArray),
256 _extSumW2Array(other._extSumW2Array),
257 _curWgt(other._curWgt),
258 _curWgtErrLo(other._curWgtErrLo),
259 _curWgtErrHi(other._curWgtErrHi),
260 _curWgtErr(other._curWgtErr)
261{
262 initialize() ;
263 loadValues(&other) ;
264}
265
266
267////////////////////////////////////////////////////////////////////////////////
268
269RooTreeDataStore::RooTreeDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname) :
270 RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():0),newname),
271 _varsww(vars),
272 _wgtVar(other._wgtVar?weightVar(vars,other._wgtVar->GetName()):0),
273 _extWgtArray(other._extWgtArray),
274 _extWgtErrLoArray(other._extWgtErrLoArray),
275 _extWgtErrHiArray(other._extWgtErrHiArray),
276 _extSumW2Array(other._extSumW2Array),
277 _curWgt(other._curWgt),
278 _curWgtErrLo(other._curWgtErrLo),
279 _curWgtErrHi(other._curWgtErrHi),
280 _curWgtErr(other._curWgtErr)
281{
282 initialize() ;
283 loadValues(&other) ;
284}
285
286
287
288
289////////////////////////////////////////////////////////////////////////////////
290/// Destructor
291
293{
294 if (_tree) {
295 delete _tree ;
296 }
297 if (_cacheTree) {
298 delete _cacheTree ;
299 }
300}
301
302
303
304////////////////////////////////////////////////////////////////////////////////
305/// One-time initialization common to all constructor forms. Attach
306/// variables of internal ArgSet to the corresponding TTree branches
307
309{
310 // Recreate (empty) cache tree
312
313 // Attach each variable to the dataset
314 for (auto var : _varsww) {
315 var->attachToTree(*_tree,_defTreeBufSize) ;
316 }
317}
318
319
320
321
322
323////////////////////////////////////////////////////////////////////////////////
324/// Create TTree object that lives in memory, independent of current
325/// location of gDirectory
326
328{
329 if (!_tree) {
330 _tree = new TTree(name,title);
333 _tree->SetDirectory(nullptr);
334 }
335
336 TString pwd(gDirectory->GetPath()) ;
337 TString memDir(gROOT->GetName()) ;
338 memDir.Append(":/") ;
339 bool notInMemNow= (pwd!=memDir) ;
340
341 // cout << "RooTreeData::createTree pwd=" << pwd << " memDir=" << memDir << " notInMemNow = " << (notInMemNow?"T":"F") << endl ;
342
343 if (notInMemNow) {
344 gDirectory->cd(memDir) ;
345 }
346
347 if (!_cacheTree) {
348 _cacheTree = new TTree(TString{static_cast<const char*>(name)} + "_cacheTree", TString{static_cast<const char*>(title)});
350 gDirectory->RecursiveRemove(_cacheTree) ;
351 }
352
353 if (notInMemNow) {
354 gDirectory->cd(pwd) ;
355 }
356
357}
358
359
360
361
362////////////////////////////////////////////////////////////////////////////////
363/// Load values from tree 't' into this data collection, optionally
364/// selecting events using the RooFormulaVar 'select'.
365///
366/// The source tree 't' is cloned to not disturb its branch
367/// structure when retrieving information from it.
368void RooTreeDataStore::loadValues(const TTree *t, const RooFormulaVar* select, const char* /*rangeName*/, Int_t /*nStart*/, Int_t /*nStop*/)
369{
370 // Make our local copy of the tree, so we can safely loop through it.
371 // We need a custom deleter, because if we don't deregister the Tree from the directory
372 // of the original, it tears it down at destruction time!
373 auto deleter = [](TTree* tree){tree->SetDirectory(nullptr); delete tree;};
374 std::unique_ptr<TTree, decltype(deleter)> tClone(static_cast<TTree*>(t->Clone()), deleter);
375 tClone->SetDirectory(t->GetDirectory());
376
377 // Clone list of variables
378 std::unique_ptr<RooArgSet> sourceArgSet( _varsww.snapshot(false) );
379
380 // Check that we have the branches:
381 bool missingBranches = false;
382 for (const auto var : *sourceArgSet) {
383 if (!tClone->GetBranch(var->GetName())) {
384 missingBranches = true;
385 coutE(InputArguments) << "Didn't find a branch in Tree '" << tClone->GetName() << "' to read variable '"
386 << var->GetName() << "' from."
387 << "\n\tNote: Name the RooFit variable the same as the branch." << std::endl;
388 }
389 }
390 if (missingBranches) {
391 coutE(InputArguments) << "Cannot import data from TTree '" << tClone->GetName()
392 << "' because some branches are missing !" << std::endl;
393 return;
394 }
395
396 // Attach args in cloned list to cloned source tree
397 for (const auto sourceArg : *sourceArgSet) {
398 sourceArg->attachToTree(*tClone,_defTreeBufSize) ;
399 }
400
401 // Redirect formula servers to sourceArgSet
402 std::unique_ptr<RooFormulaVar> selectClone;
403 if (select) {
404 selectClone.reset( static_cast<RooFormulaVar*>(select->cloneTree()) );
405 selectClone->recursiveRedirectServers(*sourceArgSet) ;
406 selectClone->setOperMode(RooAbsArg::ADirty,true) ;
407 }
408
409 // Loop over events in source tree
410 Int_t numInvalid(0) ;
411 const Long64_t nevent = tClone->GetEntries();
412 for(Long64_t i=0; i < nevent; ++i) {
413 const auto entryNumber = tClone->GetEntryNumber(i);
414 if (entryNumber<0) break;
415 tClone->GetEntry(entryNumber,1);
416
417 // Copy from source to destination
418 bool allOK(true) ;
419 for (unsigned int j=0; j < sourceArgSet->size(); ++j) {
420 auto destArg = _varsww[j];
421 const auto sourceArg = (*sourceArgSet)[j];
422
423 destArg->copyCache(sourceArg) ;
424 sourceArg->copyCache(destArg) ;
425 if (!destArg->isValid()) {
426 numInvalid++ ;
427 allOK=false ;
428 if (numInvalid < 5) {
429 coutI(DataHandling) << "RooTreeDataStore::loadValues(" << GetName() << ") Skipping event #" << i << " because " << destArg->GetName()
430 << " cannot accommodate the value " << static_cast<RooAbsReal*>(sourceArg)->getVal() << std::endl;
431 } else if (numInvalid == 5) {
432 coutI(DataHandling) << "RooTreeDataStore::loadValues(" << GetName() << ") Skipping ..." << std::endl;
433 }
434 break ;
435 }
436 }
437
438 // Does this event pass the cuts?
439 if (!allOK || (selectClone && selectClone->getVal()==0)) {
440 continue ;
441 }
442
443 fill() ;
444 }
445
446 if (numInvalid>0) {
447 coutW(DataHandling) << "RooTreeDataStore::loadValues(" << GetName() << ") Ignored " << numInvalid << " out-of-range events" << endl ;
448 }
449
450 SetTitle(t->GetTitle());
451}
452
453
454
455
456
457
458////////////////////////////////////////////////////////////////////////////////
459/// Load values from dataset 't' into this data collection, optionally
460/// selecting events using 'select' RooFormulaVar
461///
462
464 const char* rangeName, std::size_t nStart, std::size_t nStop)
465{
466 // Redirect formula servers to source data row
467 std::unique_ptr<RooFormulaVar> selectClone;
468 if (select) {
469 selectClone.reset( static_cast<RooFormulaVar*>(select->cloneTree()) );
470 selectClone->recursiveRedirectServers(*ads->get()) ;
471 selectClone->setOperMode(RooAbsArg::ADirty,true) ;
472 }
473
474 // Force RDS internal initialization
475 ads->get(0) ;
476
477 // Loop over events in source tree
478 const auto numEntr = static_cast<std::size_t>(ads->numEntries());
479 std::size_t nevent = nStop < numEntr ? nStop : numEntr;
480
481 auto TDS = dynamic_cast<const RooTreeDataStore*>(ads) ;
482 if (TDS) {
483 const_cast<RooTreeDataStore*>(TDS)->resetBuffers();
484 }
485
486 std::vector<std::string> ranges;
487 if (rangeName) {
488 ranges = ROOT::Split(rangeName, ",");
489 }
490
491 for (auto i=nStart; i < nevent ; ++i) {
492 ads->get(i) ;
493
494 // Does this event pass the cuts?
495 if (selectClone && selectClone->getVal()==0) {
496 continue ;
497 }
498
499
500 if (TDS) {
501 _varsww.assignValueOnly(TDS->_varsww) ;
502 } else {
503 _varsww.assignValueOnly(*ads->get()) ;
504 }
505
506 // Check that all copied values are valid
507 bool allValid = true;
508 for (const auto arg : _varsww) {
509 allValid = arg->isValid() && (ranges.empty() || std::any_of(ranges.begin(), ranges.end(),
510 [arg](const std::string& range){return arg->inRange(range.c_str());}) );
511 if (!allValid)
512 break ;
513 }
514
515 if (!allValid) {
516 continue ;
517 }
518
519 _cachedVars.assign(((RooTreeDataStore*)ads)->_cachedVars) ;
520 fill() ;
521 }
522
523 if (TDS) {
524 const_cast<RooTreeDataStore*>(TDS)->restoreAlternateBuffers();
525 }
526
527 SetTitle(ads->GetTitle());
528}
529
530
531////////////////////////////////////////////////////////////////////////////////
532/// Interface function to TTree::Fill
533
535{
536 return _tree->Fill() ;
537}
538
539
540
541////////////////////////////////////////////////////////////////////////////////
542/// Load the n-th data point (n='index') in memory
543/// and return a pointer to the internal RooArgSet
544/// holding its coordinates.
545
547{
548 checkInit() ;
549
550 Int_t ret = ((RooTreeDataStore*)this)->GetEntry(index, 1) ;
551
552 if(!ret) return 0;
553
554 if (_doDirtyProp) {
555 // Raise all dirty flags
556 for (auto var : _vars) {
557 var->setValueDirty(); // This triggers recalculation of all clients
558 }
559
560 for (auto var : _cachedVars) {
561 var->setValueDirty(); // This triggers recalculation of all clients, but doesn't recalculate self
562 var->clearValueDirty();
563 }
564 }
565
566 // Update current weight cache
567 if (_extWgtArray) {
568
569 // If external array is specified use that
574
575 } else if (_wgtVar) {
576
577 // Otherwise look for weight variable
578 _curWgt = _wgtVar->getVal() ;
582
583 } else {
584
585 // Otherwise return 1
586 _curWgt=1.0 ;
587 _curWgtErrLo = 0 ;
588 _curWgtErrHi = 0 ;
589 _curWgtErr = 0 ;
590
591 }
592
593 return &_vars;
594}
595
596
597////////////////////////////////////////////////////////////////////////////////
598/// Return the weight of the n-th data point (n='index') in memory
599
601{
602 return _curWgt ;
603}
604
605
606////////////////////////////////////////////////////////////////////////////////
607
609{
610 if (_extWgtArray) {
611
612 // We have a weight array, use that info
613
614 // Return symmetric error on current bin calculated either from Poisson statistics or from SumOfWeights
615 double lo = 0, hi =0;
616 weightError(lo,hi,etype) ;
617 return (lo+hi)/2 ;
618
619 } else if (_wgtVar) {
620
621 // We have a a weight variable, use that info
622 if (_wgtVar->hasAsymError()) {
623 return ( _wgtVar->getAsymErrorHi() - _wgtVar->getAsymErrorLo() ) / 2 ;
624 } else {
625 return _wgtVar->getError() ;
626 }
627
628 } else {
629
630 // We have no weights
631 return 0 ;
632
633 }
634}
635
636
637
638////////////////////////////////////////////////////////////////////////////////
639
640void RooTreeDataStore::weightError(double& lo, double& hi, RooAbsData::ErrorType etype) const
641{
642 if (_extWgtArray) {
643
644 // We have a weight array, use that info
645 switch (etype) {
646
647 case RooAbsData::Auto:
648 throw string(Form("RooDataHist::weightError(%s) error type Auto not allowed here",GetName())) ;
649 break ;
650
652 throw string(Form("RooDataHist::weightError(%s) error type Expected not allowed here",GetName())) ;
653 break ;
654
656 // Weight may be preset or precalculated
657 if (_curWgtErrLo>=0) {
658 lo = _curWgtErrLo ;
659 hi = _curWgtErrHi ;
660 return ;
661 }
662
663 // Otherwise Calculate poisson errors
664 double ym,yp ;
666 lo = weight()-ym ;
667 hi = yp-weight() ;
668 return ;
669
671 lo = _curWgtErr ;
672 hi = _curWgtErr ;
673 return ;
674
675 case RooAbsData::None:
676 lo = 0 ;
677 hi = 0 ;
678 return ;
679 }
680
681 } else if (_wgtVar) {
682
683 // We have a a weight variable, use that info
684 if (_wgtVar->hasAsymError()) {
686 lo = _wgtVar->getAsymErrorLo() ;
687 } else {
688 hi = _wgtVar->getError() ;
689 lo = _wgtVar->getError() ;
690 }
691
692 } else {
693
694 // We are unweighted
695 lo=0 ;
696 hi=0 ;
697
698 }
699}
700
701
702////////////////////////////////////////////////////////////////////////////////
703/// Change name of internal observable named 'from' into 'to'
704
705bool RooTreeDataStore::changeObservableName(const char* from, const char* to)
706{
707 // Find observable to be changed
708 RooAbsArg* var = _vars.find(from) ;
709
710 // Check that we found it
711 if (!var) {
712 coutE(InputArguments) << "RooTreeDataStore::changeObservableName(" << GetName() << " no observable " << from << " in this dataset" << endl ;
713 return true ;
714 }
715
716 // Process name change
717 TString oldBranchName = var->cleanBranchName() ;
718 var->SetName(to) ;
719
720 // Change the branch name as well
721 if (_tree->GetBranch(oldBranchName.Data())) {
722
723 // Simple case varName = branchName
724 _tree->GetBranch(oldBranchName.Data())->SetName(var->cleanBranchName().Data()) ;
725
726 // Process any error branch if existing
727 if (_tree->GetBranch(Form("%s_err",oldBranchName.Data()))) {
728 _tree->GetBranch(Form("%s_err",oldBranchName.Data()))->SetName(Form("%s_err",var->cleanBranchName().Data())) ;
729 }
730 if (_tree->GetBranch(Form("%s_aerr_lo",oldBranchName.Data()))) {
731 _tree->GetBranch(Form("%s_aerr_lo",oldBranchName.Data()))->SetName(Form("%s_aerr_lo",var->cleanBranchName().Data())) ;
732 }
733 if (_tree->GetBranch(Form("%s_aerr_hi",oldBranchName.Data()))) {
734 _tree->GetBranch(Form("%s_aerr_hi",oldBranchName.Data()))->SetName(Form("%s_aerr_hi",var->cleanBranchName().Data())) ;
735 }
736
737 } else {
738
739 // Native category case branchNames = varName_idx and varName_lbl
740 if (_tree->GetBranch(Form("%s_idx",oldBranchName.Data()))) {
741 _tree->GetBranch(Form("%s_idx",oldBranchName.Data()))->SetName(Form("%s_idx",var->cleanBranchName().Data())) ;
742 }
743 if (_tree->GetBranch(Form("%s_lbl",oldBranchName.Data()))) {
744 _tree->GetBranch(Form("%s_lbl",oldBranchName.Data()))->SetName(Form("%s_lb",var->cleanBranchName().Data())) ;
745 }
746
747 }
748
749 return false ;
750}
751
752
753
754////////////////////////////////////////////////////////////////////////////////
755/// Add a new column to the data set which holds the pre-calculated values
756/// of 'newVar'. This operation is only meaningful if 'newVar' is a derived
757/// value.
758///
759/// The return value points to the added element holding 'newVar's value
760/// in the data collection. The element is always the corresponding fundamental
761/// type of 'newVar' (e.g. a RooRealVar if 'newVar' is a RooFormulaVar)
762///
763/// Note: This function is explicitly NOT intended as a speed optimization
764/// opportunity for the user. Components of complex PDFs that can be
765/// precalculated with the dataset are automatically identified as such
766/// and will be precalculated when fitting to a dataset
767///
768/// By forcibly precalculating functions with non-trivial Jacobians,
769/// or functions of multiple variables occurring in the data set,
770/// using addColumn(), you may alter the outcome of the fit.
771///
772/// Only in cases where such a modification of fit behaviour is intentional,
773/// this function should be used.
774
776{
777 checkInit() ;
778
779 // Create a fundamental object of the right type to hold newVar values
780 RooAbsArg* valHolder= newVar.createFundamental();
781 // Sanity check that the holder really is fundamental
782 if(!valHolder->isFundamental()) {
783 coutE(InputArguments) << GetName() << "::addColumn: holder argument is not fundamental: \""
784 << valHolder->GetName() << "\"" << endl;
785 return 0;
786 }
787
788 // WVE need to reset TTRee buffers to original datamembers here
789 resetBuffers() ;
790
791 // Clone variable and attach to cloned tree
792 RooAbsArg* newVarClone = newVar.cloneTree() ;
793 newVarClone->recursiveRedirectServers(_vars,false) ;
794
795 // Attach value place holder to this tree
796 ((RooAbsArg*)valHolder)->attachToTree(*_tree,_defTreeBufSize) ;
797 _vars.add(*valHolder) ;
798 _varsww.add(*valHolder) ;
799
800
801 // Fill values of of placeholder
802 for (int i=0 ; i<GetEntries() ; i++) {
803 get(i) ;
804
805 newVarClone->syncCache(&_vars) ;
806 valHolder->copyCache(newVarClone) ;
807 valHolder->fillTreeBranch(*_tree) ;
808 }
809
810 // WVE need to restore TTRee buffers to previous values here
812
813 if (adjustRange) {
814// // Set range of valHolder to (just) bracket all values stored in the dataset
815// double vlo,vhi ;
816// RooRealVar* rrvVal = dynamic_cast<RooRealVar*>(valHolder) ;
817// if (rrvVal) {
818// getRange(*rrvVal,vlo,vhi,0.05) ;
819// rrvVal->setRange(vlo,vhi) ;
820// }
821 }
822
823
824
825 delete newVarClone ;
826 return valHolder ;
827}
828
829
830////////////////////////////////////////////////////////////////////////////////
831/// Merge columns of supplied data set(s) with this data set. All
832/// data sets must have equal number of entries. In case of
833/// duplicate columns the column of the last dataset in the list
834/// prevails
835
836RooAbsDataStore* RooTreeDataStore::merge(const RooArgSet& allVars, list<RooAbsDataStore*> dstoreList)
837{
838 RooTreeDataStore* mergedStore = new RooTreeDataStore("merged","merged",allVars) ;
839
840 Int_t nevt = dstoreList.front()->numEntries() ;
841 for (int i=0 ; i<nevt ; i++) {
842
843 // Cope data from self
844 mergedStore->_vars.assign(*get(i)) ;
845
846 // Copy variables from merge sets
847 for (list<RooAbsDataStore*>::iterator iter = dstoreList.begin() ; iter!=dstoreList.end() ; ++iter) {
848 const RooArgSet* partSet = (*iter)->get(i) ;
849 mergedStore->_vars.assign(*partSet) ;
850 }
851
852 mergedStore->fill() ;
853 }
854 return mergedStore ;
855}
856
857
858
859
860
861////////////////////////////////////////////////////////////////////////////////
862
864{
865 Int_t nevt = other.numEntries() ;
866 for (int i=0 ; i<nevt ; i++) {
867 _vars.assign(*other.get(i)) ;
868 if (_wgtVar) {
869 _wgtVar->setVal(other.weight()) ;
870 }
871
872 fill() ;
873 }
874}
875
876
877////////////////////////////////////////////////////////////////////////////////
878
880{
881 if (_wgtVar) {
882
883 double sum(0), carry(0);
884 Int_t nevt = numEntries() ;
885 for (int i=0 ; i<nevt ; i++) {
886 get(i) ;
887 // Kahan's algorithm for summing to avoid loss of precision
888 double y = _wgtVar->getVal() - carry;
889 double t = sum + y;
890 carry = (t - sum) - y;
891 sum = t;
892 }
893 return sum ;
894
895 } else if (_extWgtArray) {
896
897 double sum(0) , carry(0);
898 Int_t nevt = numEntries() ;
899 for (int i=0 ; i<nevt ; i++) {
900 // Kahan's algorithm for summing to avoid loss of precision
901 double y = _extWgtArray[i] - carry;
902 double t = sum + y;
903 carry = (t - sum) - y;
904 sum = t;
905 }
906 return sum ;
907
908 } else {
909
910 return numEntries() ;
911
912 }
913}
914
915
916
917
918////////////////////////////////////////////////////////////////////////////////
919
921{
922 return _tree->GetEntries() ;
923}
924
925
926
927////////////////////////////////////////////////////////////////////////////////
928
930{
931 Reset() ;
932}
933
934
935
936////////////////////////////////////////////////////////////////////////////////
937/// Cache given RooAbsArgs with this tree: The tree is
938/// given direct write access of the args internal cache
939/// the args values is pre-calculated for all data points
940/// in this data collection. Upon a get() call, the
941/// internal cache of 'newVar' will be loaded with the
942/// precalculated value and it's dirty flag will be cleared.
943
944void RooTreeDataStore::cacheArgs(const RooAbsArg* owner, RooArgSet& newVarSet, const RooArgSet* nset, bool /*skipZeroWeights*/)
945{
946 checkInit() ;
947
948 _cacheOwner = owner ;
949
950 std::unique_ptr<RooArgSet> constExprVarSet{static_cast<RooArgSet*>(newVarSet.selectByAttrib("ConstantExpression",true))};
951
952 bool doTreeFill = (_cachedVars.empty()) ;
953
954 for (RooAbsArg * arg : *constExprVarSet) {
955 // Attach original newVar to this tree
956 arg->attachToTree(*_cacheTree,_defTreeBufSize) ;
957 //arg->recursiveRedirectServers(_vars) ;
958 _cachedVars.add(*arg) ;
959 }
960
961 // WVE need to reset TTRee buffers to original datamembers here
962 //resetBuffers() ;
963
964 // Refill regular and cached variables of current tree from clone
965 for (int i=0 ; i<GetEntries() ; i++) {
966 get(i) ;
967
968 // Evaluate the cached variables and store the results
969 for (RooAbsArg * arg : *constExprVarSet) {
970 arg->setValueDirty() ;
971 arg->syncCache(nset) ;
972 if (!doTreeFill) {
973 arg->fillTreeBranch(*_cacheTree) ;
974 }
975 }
976
977 if (doTreeFill) {
978 _cacheTree->Fill() ;
979 }
980 }
981
982 // WVE need to restore TTRee buffers to previous values here
983 //restoreAlternateBuffers() ;
984}
985
986
987
988
989////////////////////////////////////////////////////////////////////////////////
990/// Activate or deactivate the branch status of the TTree branch associated
991/// with the given set of dataset observables
992
993void RooTreeDataStore::setArgStatus(const RooArgSet& set, bool active)
994{
995 for (RooAbsArg * arg : set) {
996 RooAbsArg* depArg = _vars.find(arg->GetName()) ;
997 if (!depArg) {
998 coutE(InputArguments) << "RooTreeDataStore::setArgStatus(" << GetName()
999 << ") dataset doesn't contain variable " << arg->GetName() << endl ;
1000 continue ;
1001 }
1002 depArg->setTreeBranchStatus(*_tree,active) ;
1003 }
1004}
1005
1006
1007
1008////////////////////////////////////////////////////////////////////////////////
1009/// Remove tree with values of cached observables
1010/// and clear list of cached observables
1011
1013{
1014 // Empty list of cached functions
1016
1017 // Delete & recreate cache tree
1018 delete _cacheTree ;
1019 _cacheTree = 0 ;
1020 createTree(makeTreeName().c_str(), GetTitle());
1021
1022 return ;
1023}
1024
1025
1026
1027
1028////////////////////////////////////////////////////////////////////////////////
1029
1031{
1033 for (const auto arg : _varsww) {
1034 RooAbsArg* extArg = extObs.find(arg->GetName()) ;
1035 if (extArg) {
1036 if (arg->getAttribute("StoreError")) {
1037 extArg->setAttribute("StoreError") ;
1038 }
1039 if (arg->getAttribute("StoreAsymError")) {
1040 extArg->setAttribute("StoreAsymError") ;
1041 }
1042 extArg->attachToTree(*_tree) ;
1043 _attachedBuffers.add(*extArg) ;
1044 }
1045 }
1046}
1047
1048
1049
1050////////////////////////////////////////////////////////////////////////////////
1051
1053{
1054 for(RooAbsArg * arg : _varsww) {
1055 arg->attachToTree(*_tree) ;
1056 }
1057}
1058
1059
1060
1061////////////////////////////////////////////////////////////////////////////////
1062
1064{
1065 for(RooAbsArg * arg : _attachedBuffers) {
1066 arg->attachToTree(*_tree) ;
1067 }
1068}
1069
1070
1071
1072////////////////////////////////////////////////////////////////////////////////
1073
1075{
1076 if (_defCtor) {
1077 const_cast<RooTreeDataStore*>(this)->initialize() ;
1078 _defCtor = false ;
1079 }
1080}
1081
1082
1083
1084
1085
1086////////////////////////////////////////////////////////////////////////////////
1087/// Interface function to TTree::GetEntries
1088
1090{
1091 return _tree->GetEntries() ;
1092}
1093
1094
1095////////////////////////////////////////////////////////////////////////////////
1096/// Interface function to TTree::Reset
1097
1099{
1100 _tree->Reset(option) ;
1101}
1102
1103
1104////////////////////////////////////////////////////////////////////////////////
1105/// Interface function to TTree::Fill
1106
1108{
1109 return _tree->Fill() ;
1110}
1111
1112
1113////////////////////////////////////////////////////////////////////////////////
1114/// Interface function to TTree::GetEntry
1115
1117{
1118 Int_t ret1 = _tree->GetEntry(entry,getall) ;
1119 if (!ret1) return 0 ;
1120 _cacheTree->GetEntry(entry,getall) ;
1121 return ret1 ;
1122}
1123
1124
1125////////////////////////////////////////////////////////////////////////////////
1126
1128{
1129 _tree->Draw(option) ;
1130}
1131
1132////////////////////////////////////////////////////////////////////////////////
1133/// Stream an object of class RooTreeDataStore.
1134
1136{
1137 if (R__b.IsReading()) {
1138 UInt_t R__s, R__c;
1139 const Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1140
1141 R__b.ReadClassBuffer(RooTreeDataStore::Class(), this, R__v, R__s, R__c);
1142
1143 if (!_tree) {
1144 // If the tree has not been deserialised automatically, it is time to load
1145 // it now.
1146 TFile* parent = dynamic_cast<TFile*>(R__b.GetParent());
1147 assert(parent);
1148 parent->GetObject(makeTreeName().c_str(), _tree);
1149 }
1150
1151 initialize();
1152
1153 } else {
1154
1155 TTree* tmpTree = _tree;
1156 auto parent = dynamic_cast<TDirectory*>(R__b.GetParent());
1157 if (_tree && parent) {
1158 // Large trees cannot be written because of the 1Gb I/O limitation.
1159 // Here, we take the tree away from our instance, write it, and continue
1160 // to write the rest of the class normally
1161 auto tmpDir = _tree->GetDirectory();
1162
1163 _tree->SetDirectory(parent);
1164 _tree->FlushBaskets(false);
1165 parent->WriteObject(_tree, makeTreeName().c_str());
1166 _tree->SetDirectory(tmpDir);
1167 _tree = nullptr;
1168 }
1169
1171
1172 _tree = tmpTree;
1173 }
1174}
1175
1176////////////////////////////////////////////////////////////////////////////////
1177/// Generate a name for the storage tree from the name and title of this instance.
1179 std::string title = GetTitle();
1180 std::replace(title.begin(), title.end(), ' ', '_');
1181 std::replace(title.begin(), title.end(), '-', '_');
1182 return std::string("RooTreeDataStore_") + GetName() + "_" + title;
1183}
1184
1185
1186////////////////////////////////////////////////////////////////////////////////
1187/// Get the weights of the events in the range [first, first+len).
1188/// This implementation will fill a vector with every event retrieved one by one
1189/// (even if the weight is constant). Then, it returns a span.
1191
1192 if (_extWgtArray) {
1193 return {_extWgtArray + first, len};
1194 }
1195
1196 if (!_weightBuffer) {
1197 _weightBuffer.reset(new std::vector<double>());
1198 _weightBuffer->reserve(len);
1199
1200 for (std::size_t i = 0; i < GetEntries(); ++i) {
1201 _weightBuffer->push_back(weight(i));
1202 }
1203 }
1204
1205 return {_weightBuffer->data() + first, len};
1206}
#define coutI(a)
Definition: RooMsgService.h:34
#define coutW(a)
Definition: RooMsgService.h:36
#define coutE(a)
Definition: RooMsgService.h:37
int Int_t
Definition: RtypesCore.h:45
short Version_t
Definition: RtypesCore.h:65
long long Long64_t
Definition: RtypesCore.h:80
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:2452
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:71
virtual void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true)=0
bool recursiveRedirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true)
Recursively replace all servers with the new servers in newSet.
Definition: RooAbsArg.cxx:1165
virtual void syncCache(const RooArgSet *nset=nullptr)=0
void SetName(const char *name) override
Set the name of the TNamed.
Definition: RooAbsArg.cxx:2292
virtual RooAbsArg * createFundamental(const char *newname=nullptr) const =0
Create a fundamental-type object that stores our type of value.
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:1379
virtual void setTreeBranchStatus(TTree &t, bool active)=0
virtual RooAbsArg * cloneTree(const char *newname=nullptr) const
Clone tree expression of objects.
Definition: RooAbsArg.cxx:2198
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:1956
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:246
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Definition: RooAbsArg.h:241
virtual void fillTreeBranch(TTree &t)=0
RooAbsCollection * selectByAttrib(const char *name, bool value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
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.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
bool empty() const
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
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...
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
bool _doDirtyProp
Switch do (de)activate dirty state propagation when loading a data point.
RooArgSet _cachedVars
virtual double weight() const =0
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:62
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:179
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:30
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called.
bool getPoissonInterval(Int_t n, double &mu1, double &mu2, double nSigma=1) const
Return a confidence interval for the expected number of events given n observed (unweighted) events.
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
void setVal(double value) override
Set value of variable to 'value'.
Definition: RooRealVar.cxx:254
double getError() const
Definition: RooRealVar.h:62
bool hasAsymError(bool allowZero=true) const
Definition: RooRealVar.h:68
double getAsymErrorHi() const
Definition: RooRealVar.h:67
double getAsymErrorLo() const
Definition: RooRealVar.h:66
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.
void initialize()
One-time initialization common to all constructor forms.
double _curWgtErr
Weight of current event.
double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const override
void resetBuffers() override
double _curWgt
Buffer for weights in case a batch of values is requested.
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.
double _curWgtErrHi
Weight of current event.
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.
RooArgSet varsNoWeight(const RooArgSet &allVars, const char *wgtName=nullptr)
Utility function for constructors Return RooArgSet that is copy of allVars minus variable matching wg...
~RooTreeDataStore() override
Destructor.
void createTree(RooStringView name, RooStringView title)
Create TTree object that lives in memory, independent of current location of gDirectory.
const double * _extWgtErrHiArray
! External weight array - high 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.
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.
double sumEntries() const override
bool _defCtor
Object owning cache contents.
RooAbsArg * addColumn(RooAbsArg &var, bool adjustRange=true) override
Add a new column to the data set which holds the pre-calculated values of 'newVar'.
double weight() const override
Return the weight of the n-th data point (n='index') in memory.
void Reset(Option_t *option=nullptr)
Interface function to TTree::Reset.
void loadValues(const TTree *t, const RooFormulaVar *select=nullptr, const char *rangeName=nullptr, Int_t nStart=0, Int_t nStop=2000000000)
Load values from tree 't' into this data collection, optionally selecting events using the RooFormula...
void append(RooAbsDataStore &other) override
const double * _extWgtErrLoArray
! External weight array - low error
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
const double * _extSumW2Array
! External sum of weights array
void Streamer(TBuffer &) override
Stream an object of class RooTreeDataStore.
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName=nullptr)
Utility function for constructors Return pointer to weight variable if it is defined.
const double * _extWgtArray
! External weight array
double _curWgtErrLo
Weight of current event.
bool changeObservableName(const char *from, const char *to) override
Change name of internal observable named 'from' into 'to'.
RooRealVar * _wgtVar
void resetCache() override
Remove tree with values of cached observables and clear list of cached observables.
void setArgStatus(const RooArgSet &set, bool active) override
Activate or deactivate the branch status of the TTree branch associated with the given set of dataset...
void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=nullptr, bool skipZeroWeights=false) override
Cache given RooAbsArgs with this tree: The tree is given direct write access of the args internal cac...
virtual const RooArgSet * get() const
const RooAbsArg * _cacheOwner
TTree holding the cached function values.
RooArgSet _varsww
Was object constructed with default ctor?
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
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:5262
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:5612
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:5097
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:8930
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:7977
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