86 _wgtVar(weightVar(vars,wgtVarName))
98 _wgtVar(weightVar(vars,wgtVarName))
109 _wgtVar(weightVar(vars,wgtVarName))
113 if (selExpr && *selExpr) {
128 _wgtVar(weightVar(vars,wgtVarName))
132 if (selExpr && *selExpr) {
148 Int_t nStart,
Int_t nStop,
const char* wgtVarName) :
151 _wgtVar(weightVar(vars,wgtVarName))
176 loadValues(&tds,cloneVar,cutRange,nStart,nStop);
178 if (cloneVar)
delete cloneVar ;
184 std::size_t nStart, std::size_t nStop) {
190 return new RooTreeDataStore(
name, title, *
this, tmp, cutVar, cutRange, nStart, nStop, wgtVarName);
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)
275 RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():0),newname),
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)
344 Bool_t notInMemNow= (pwd!=memDir) ;
379 std::unique_ptr<
TTree,
decltype(deleter)> tClone(
static_cast<TTree*
>(t->
Clone()), deleter);
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;
395 if (missingBranches) {
397 <<
"' because some branches are missing !" << std::endl;
402 for (
const auto sourceArg : *sourceArgSet) {
407 std::unique_ptr<RooFormulaVar> selectClone;
410 selectClone->recursiveRedirectServers(*sourceArgSet) ;
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);
424 for (
unsigned int j=0; j < sourceArgSet->size(); ++j) {
426 const auto sourceArg = (*sourceArgSet)[j];
428 destArg->copyCache(sourceArg) ;
429 sourceArg->copyCache(destArg) ;
430 if (!destArg->isValid()) {
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) {
444 if (!allOK || (selectClone && selectClone->getVal()==0)) {
452 coutW(
DataHandling) <<
"RooTreeDataStore::loadValues(" <<
GetName() <<
") Ignored " << numInvalid <<
" out-of-range events" << endl ;
469 const char* rangeName, std::size_t nStart, std::size_t nStop)
472 std::unique_ptr<RooFormulaVar> selectClone;
475 selectClone->recursiveRedirectServers(*ads->
get()) ;
483 const auto numEntr =
static_cast<std::size_t
>(ads->
numEntries());
484 std::size_t nevent = nStop < numEntr ? nStop : numEntr;
491 std::vector<std::string> ranges;
496 for (
auto i=nStart; i < nevent ; ++i) {
500 if (selectClone && selectClone->getVal()==0) {
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());}) );
561 for (
auto var :
_vars) {
562 var->setValueDirty();
566 var->setValueDirty();
567 var->clearValueDirty();
653 throw string(
Form(
"RooDataHist::weightError(%s) error type Auto not allowed here",
GetName())) ;
657 throw string(
Form(
"RooDataHist::weightError(%s) error type Expected not allowed here",
GetName())) ;
717 coutE(
InputArguments) <<
"RooTreeDataStore::changeObservableName(" <<
GetName() <<
" no observable " << from <<
" in this dataset" << endl ;
789 << valHolder->
GetName() <<
"\"" << endl;
845 Int_t nevt = dstoreList.front()->numEntries() ;
846 for (
int i=0 ; i<nevt ; i++) {
852 for (list<RooAbsDataStore*>::iterator iter = dstoreList.begin() ; iter!=dstoreList.end() ; ++iter) {
857 mergedStore->
fill() ;
871 for (
int i=0 ; i<nevt ; i++) {
890 for (
int i=0 ; i<nevt ; i++) {
895 carry = (t -
sum) -
y;
904 for (
int i=0 ; i<nevt ; i++) {
908 carry = (t -
sum) -
y;
994 delete constExprVarSet ;
1012 <<
") dataset doesn't contain variable " << arg->
GetName() << endl ;
1047 for (
const auto arg :
_varsww) {
1050 if (arg->getAttribute(
"StoreError")) {
1053 if (arg->getAttribute(
"StoreAsymError")) {
1070 while((arg=iter.
next())) {
1083 while((arg=iter.
next())) {
1137 if (!ret1)
return 0 ;
1175 if (
_tree && parent) {
1198 std::replace(title.begin(), title.end(),
' ',
'_');
1199 std::replace(title.begin(), title.end(),
'-',
'_');
1200 return std::string(
"RooTreeDataStore_") +
GetName() +
"_" + title;
1218 for (std::size_t i = 0; i <
GetEntries(); ++i) {
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 * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
virtual RooAbsArg * cloneTree(const char *newname=0) const
Clone tree expression of objects.
void attachDataStore(const RooAbsDataStore &set)
Replace server nodes with names matching the dataset variable names with those data set variables,...
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.
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
virtual void attachToTree(TTree &t, Int_t bufSize=32000)=0
Overloadable function for derived classes to implement attachment as branch to a TTree.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
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...
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.
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.
virtual Int_t numEntries() const =0
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
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.
Double_t getAsymErrorLo() const
void setVal(Double_t value) override
Set value of variable to 'value'.
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
Double_t getAsymErrorHi() const
Double_t getError() const
A simple container to hold a batch of data values.
The RooStringView is a wrapper around a C-syle string that can also be constructed from a std::string...
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.
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...
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 restoreAlternateBuffers()
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.
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.
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.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Describe directory structure in memory.
void GetObject(const char *namecycle, T *&ptr)
Get an object with proper type checking.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Iterator abstract base class.
virtual TObject * Next()=0
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
@ kCanDelete
if object in a list can be deleted
@ kMustCleanup
if object destructor must call RecursiveRemove()
const char * Data() const
TString & Append(const char *cs)
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
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 ...
void Draw(Option_t *opt) override
Default Draw method for all objects.
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.
TDirectory * GetDirectory() const
virtual void SetDirectory(TDirectory *dir)
Change the tree's directory.
virtual Long64_t GetEntries() const
virtual void Reset(Option_t *option="")
Reset baskets, buffers and entries count in all branches and leaves.
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.
static uint64_t sum(uint64_t i)