99 _wgtVar(weightVar(vars,wgtVarName)),
116 _wgtVar(weightVar(vars,wgtVarName)),
137 _wgtVar(weightVar(vars,wgtVarName)),
158 _wgtVar(weightVar(vars,wgtVarName)),
166 if (selExpr && *selExpr) {
186 _wgtVar(weightVar(vars,wgtVarName)),
207 _wgtVar(weightVar(vars,wgtVarName)),
215 if (selExpr && *selExpr) {
234 _wgtVar(weightVar(vars,wgtVarName)),
263 loadValues(&tds,cloneVar,cutRange,nStart,nStop);
265 if (cloneVar)
delete cloneVar ;
335 _varsww(other._varsww),
336 _wgtVar(other._wgtVar),
337 _extWgtArray(other._extWgtArray),
338 _extWgtErrLoArray(other._extWgtErrLoArray),
339 _extWgtErrHiArray(other._extWgtErrHiArray),
340 _extSumW2Array(other._extSumW2Array),
341 _curWgt(other._curWgt),
342 _curWgtErrLo(other._curWgtErrLo),
343 _curWgtErrHi(other._curWgtErrHi),
344 _curWgtErr(other._curWgtErr)
354 RooAbsDataStore(other,varsNoWeight(vars,other._wgtVar?other._wgtVar->GetName():0),newname),
359 _wgtVar(other._wgtVar?weightVar(vars,other._wgtVar->GetName()):0),
360 _extWgtArray(other._extWgtArray),
361 _extWgtErrLoArray(other._extWgtErrLoArray),
362 _extWgtErrHiArray(other._extWgtErrHiArray),
363 _extSumW2Array(other._extSumW2Array),
364 _curWgt(other._curWgt),
365 _curWgtErrLo(other._curWgtErrLo),
366 _curWgtErrHi(other._curWgtErrHi),
367 _curWgtErr(other._curWgtErr)
426 Bool_t notInMemNow= (pwd!=memDir) ;
461 std::unique_ptr<
TTree,
decltype(deleter)> tClone(
static_cast<TTree*
>(t->
Clone()), deleter);
468 for (
const auto var : *sourceArgSet) {
469 if (!tClone->GetBranch(var->GetName())) {
471 <<
"' to read variable '" << var->GetName() <<
"' from."
472 <<
"\n\tNote: Name the RooFit variable the same as the branch." << std::endl;
477 for (
const auto sourceArg : *sourceArgSet) {
482 std::unique_ptr<RooFormulaVar> selectClone;
485 selectClone->recursiveRedirectServers(*sourceArgSet) ;
490 Int_t numInvalid(0) ;
491 const Long64_t nevent = tClone->GetEntries();
492 for(
Long64_t i=0; i < nevent; ++i) {
493 const auto entryNumber = tClone->GetEntryNumber(i);
494 if (entryNumber<0)
break;
495 tClone->GetEntry(entryNumber,1);
499 for (
unsigned int j=0; j < sourceArgSet->size(); ++j) {
501 const auto sourceArg = (*sourceArgSet)[j];
503 destArg->copyCache(sourceArg) ;
504 sourceArg->copyCache(destArg) ;
505 if (!destArg->isValid()) {
508 if (numInvalid < 5) {
509 coutI(
DataHandling) <<
"RooTreeDataStore::loadValues(" <<
GetName() <<
") Skipping event #" << i <<
" because " << destArg->GetName()
510 <<
" cannot accommodate the value " <<
static_cast<RooAbsReal*
>(sourceArg)->getVal() << std::endl;
511 }
else if (numInvalid == 5) {
519 if (!allOK || (selectClone && selectClone->getVal()==0)) {
527 coutW(
DataHandling) <<
"RooTreeDataStore::loadValues(" <<
GetName() <<
") Ignored " << numInvalid <<
" out-of-range events" << endl ;
544 const char* rangeName, std::size_t nStart, std::size_t nStop)
547 std::unique_ptr<RooFormulaVar> selectClone;
550 selectClone->recursiveRedirectServers(*ads->
get()) ;
558 const auto numEntr =
static_cast<std::size_t
>(ads->
numEntries());
559 std::size_t nevent = nStop < numEntr ? nStop : numEntr;
566 std::vector<std::string> ranges;
571 for (
auto i=nStart; i < nevent ; ++i) {
575 if (selectClone && selectClone->getVal()==0) {
587 bool allValid =
true;
588 for (
const auto arg :
_varsww) {
589 allValid = arg->isValid() && (ranges.empty() || std::any_of(ranges.begin(), ranges.end(),
590 [arg](
const std::string& range){return arg->inRange(range.c_str());}) );
649 for (
auto var :
_vars) {
650 var->setValueDirty();
654 var->setValueDirty();
655 var->clearValueDirty();
753 throw string(
Form(
"RooDataHist::weightError(%s) error type Auto not allowed here",
GetName())) ;
757 throw string(
Form(
"RooDataHist::weightError(%s) error type Expected not allowed here",
GetName())) ;
817 coutE(
InputArguments) <<
"RooTreeDataStore::changeObservableName(" <<
GetName() <<
" no observable " << from <<
" in this dataset" << endl ;
889 << valHolder->
GetName() <<
"\"" << endl;
958 holderSet->
add(*valHolder) ;
963 << valHolder->
GetName() <<
"\"" << endl;
969 if (!newVarCloneList) {
971 <<
") Couldn't deep-clone variable " << var->
GetName() <<
", abort." << endl ;
978 cloneSetList.
Add(newVarCloneList) ;
979 cloneSet.
add(*newVarClone) ;
1029 Int_t nevt = dstoreList.front()->numEntries() ;
1030 for (
int i=0 ; i<nevt ; i++) {
1036 for (list<RooAbsDataStore*>::iterator iter = dstoreList.begin() ; iter!=dstoreList.end() ; ++iter) {
1037 const RooArgSet* partSet = (*iter)->get(i) ;
1038 mergedStore->
_vars = *partSet ;
1041 mergedStore->
fill() ;
1043 return mergedStore ;
1055 for (
int i=0 ; i<nevt ; i++) {
1074 for (
int i=0 ; i<nevt ; i++) {
1079 carry = (t -
sum) -
y;
1088 for (
int i=0 ; i<nevt ; i++) {
1092 carry = (t -
sum) -
y;
1178 delete constExprVarSet ;
1196 <<
") dataset doesn't contain variable " << arg->
GetName() << endl ;
1231 for (
const auto arg :
_varsww) {
1234 if (arg->getAttribute(
"StoreError")) {
1237 if (arg->getAttribute(
"StoreAsymError")) {
1254 while((arg=iter.
next())) {
1267 while((arg=iter.
next())) {
1321 if (!ret1)
return 0 ;
1337void RooTreeDataStore::Streamer(
TBuffer &R__b)
1359 if (
_tree && parent) {
1382 std::replace(title.begin(), title.end(),
' ',
'_');
1383 std::replace(title.begin(), title.end(),
'-',
'_');
1384 return std::string(
"RooTreeDataStore_") +
GetName() +
"_" + title;
float type_of_call hi(const int &, const int &)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
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
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)
void SetName(const char *name)
Set the name of the TNamed.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, Bool_t oneSafe=kFALSE)
The assignment operator sets the value of any argument in our set that also appears in the other set.
RooFIter fwdIterator() const
One-time forward iterator.
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
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.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
virtual Bool_t addOwned(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
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
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
Double_t getAsymErrorHi() const
Double_t getError() const
virtual void setVal(Double_t value)
Set value of variable to 'value'.
RooTreeDataStore is a TTree-backed data storage.
const Double_t * _extSumW2Array
External weight array - high error.
const Double_t * _extWgtArray
virtual Double_t weight() const
Return the weight of the n-th data point (n='index') in memory.
void initialize()
One-time initialization common to all constructor forms.
virtual void append(RooAbsDataStore &other)
RooArgSet varsNoWeight(const RooArgSet &allVars, const char *wgtName=0)
Utility function for constructors Return RooArgSet that is copy of allVars minus variable matching wg...
virtual Bool_t changeObservableName(const char *from, const char *to)
Change name of internal observable named 'from' into 'to'.
virtual void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kFALSE)
Cache given RooAbsArgs with this tree: The tree is given direct write access of the args internal cac...
virtual Bool_t valid() const
Return true if currently loaded coordinate is considered valid within the current range definitions o...
virtual void attachBuffers(const RooArgSet &extObs)
std::string makeTreeName() const
Generate a name for the storage tree from the name and title of this instance.
RooRealVar * weightVar(const RooArgSet &allVars, const char *wgtName=0)
Utility function for constructors Return pointer to weight variable if it is defined.
const Double_t * _extWgtErrLoArray
External weight array.
virtual Int_t fill()
Interface function to TTree::Fill.
Stat_t GetEntries() const
Interface function to TTree::GetEntries.
void createTree(const char *name, const char *title)
Create TTree object that lives in memory, independent of current location of gDirectory.
Int_t GetEntry(Int_t entry=0, Int_t getall=0)
Interface function to TTree::GetEntry.
Double_t _curWgt
External sum of weights array.
virtual void checkInit() const
static Int_t _defTreeBufSize
RooArgSet _attachedBuffers
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...
const Double_t * _extWgtErrHiArray
External weight array - low error.
void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)
Initialize cache of dataset: attach variables of cache ArgSet to the corresponding TTree branches.
virtual void resetCache()
Remove tree with values of cached observables and clear list of cached observables.
Bool_t _defCtor
Object owning cache contents.
void restoreAlternateBuffers()
virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const
RooAbsDataStore * merge(const RooArgSet &allvars, std::list< RooAbsDataStore * > dstoreList)
Merge columns of supplied data set(s) with this data set.
virtual void resetBuffers()
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a new column to the data set which holds the pre-calculated values of 'newVar'.
virtual RooArgSet * addColumns(const RooArgList &varList)
Utility function to add multiple columns in one call See addColumn() for details.
Int_t Fill()
Interface function to TTree::Fill.
virtual ~RooTreeDataStore()
Destructor.
void Reset(Option_t *option=0)
Interface function to TTree::Reset.
virtual Double_t sumEntries() const
virtual const RooArgSet * get() const
const RooAbsArg * _cacheOwner
TTree holding the cached function values.
RooArgSet _varsww
Was object constructed with default ctor?
virtual Int_t numEntries() const
virtual void setArgStatus(const RooArgSet &set, Bool_t active)
Activate or deactivate the branch status of the TTree branch associated with the given set of dataset...
void Draw(Option_t *option="")
Default Draw method for all objects.
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.
Int_t WriteObject(void *obj, const char *name, Option_t *option="", Int_t bufsize=0)
void GetObject(const char *namecycle, T *&ptr)
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
virtual void Add(TObject *obj)
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual const char * GetName() const
Returns name of object.
@ 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 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 ...
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.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
std::vector< std::string > tokenise(const std::string &str, const std::string &delims, bool returnEmptyToken=true)
Tokenise the string by splitting at the characters in delims.
static long int sum(long int i)