56 ClassImp(RooDataHist);
64 RooDataHist::RooDataHist() : _pbinvCacheMgr(0,10)
80 _cache_sum_valid = 0 ;
103 RooDataHist::RooDataHist(
const char *name,
const char *title,
const RooArgSet& vars,
const char* binningName) :
104 RooAbsData(name,title,vars), _wgt(0), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(0,10), _cache_sum_valid(0)
107 _dstore = (defaultStorageType==Tree) ? ((RooAbsDataStore*)
new RooTreeDataStore(name,title,_vars)) :
108 ((RooAbsDataStore*)
new RooVectorDataStore(name,title,_vars)) ;
110 initialize(binningName) ;
112 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
114 appendToDir(
this,kTRUE) ;
141 RooDataHist::RooDataHist(
const char *name,
const char *title,
const RooArgSet& vars,
const RooAbsData& data, Double_t wgt) :
142 RooAbsData(name,title,vars), _wgt(0), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(0,10), _cache_sum_valid(0)
145 _dstore = (defaultStorageType==Tree) ? ((RooAbsDataStore*)
new RooTreeDataStore(name,title,_vars)) :
146 ((RooAbsDataStore*)
new RooVectorDataStore(name,title,_vars)) ;
149 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
151 add(data,(
const RooFormulaVar*)0,wgt) ;
152 appendToDir(
this,kTRUE) ;
167 RooDataHist::RooDataHist(
const char *name,
const char *title,
const RooArgList& vars, RooCategory& indexCat,
168 map<string,TH1*> histMap, Double_t wgt) :
169 RooAbsData(name,title,RooArgSet(vars,&indexCat)),
170 _wgt(0), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(0,10), _cache_sum_valid(0)
173 _dstore = (defaultStorageType==Tree) ? ((RooAbsDataStore*)
new RooTreeDataStore(name,title,_vars)) :
174 ((RooAbsDataStore*)
new RooVectorDataStore(name,title,_vars)) ;
176 importTH1Set(vars, indexCat, histMap, wgt, kFALSE) ;
178 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
193 RooDataHist::RooDataHist(
const char *name,
const char *title,
const RooArgList& vars, RooCategory& indexCat,
194 map<string,RooDataHist*> dhistMap, Double_t wgt) :
195 RooAbsData(name,title,RooArgSet(vars,&indexCat)),
196 _wgt(0), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(0,10), _cache_sum_valid(0)
199 _dstore = (defaultStorageType==Tree) ? ((RooAbsDataStore*)
new RooTreeDataStore(name,title,_vars)) :
200 ((RooAbsDataStore*)
new RooVectorDataStore(name,title,_vars)) ;
202 importDHistSet(vars, indexCat, dhistMap, wgt) ;
204 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
216 RooDataHist::RooDataHist(
const char *name,
const char *title,
const RooArgList& vars,
const TH1* hist, Double_t wgt) :
217 RooAbsData(name,title,vars), _wgt(0), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(0,10), _cache_sum_valid(0)
220 _dstore = (defaultStorageType==Tree) ? ((RooAbsDataStore*)
new RooTreeDataStore(name,title,_vars)) :
221 ((RooAbsDataStore*)
new RooVectorDataStore(name,title,_vars)) ;
224 if (vars.getSize() != hist->GetDimension()) {
225 coutE(InputArguments) <<
"RooDataHist::ctor(" << GetName() <<
") ERROR: dimension of input histogram must match "
226 <<
"number of dimension variables" << endl ;
230 importTH1(vars,*hist,wgt, kFALSE) ;
232 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
272 RooDataHist::RooDataHist(
const char *name,
const char *title,
const RooArgList& vars,
const RooCmdArg& arg1,
const RooCmdArg& arg2,
const RooCmdArg& arg3,
273 const RooCmdArg& arg4,
const RooCmdArg& arg5,
const RooCmdArg& arg6,
const RooCmdArg& arg7,
const RooCmdArg& arg8) :
274 RooAbsData(name,title,RooArgSet(vars,(RooAbsArg*)RooCmdConfig::decodeObjOnTheFly(
"RooDataHist::RooDataHist",
"IndexCat",0,0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8))),
275 _wgt(0), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(0,10), _cache_sum_valid(0)
278 _dstore = (defaultStorageType==Tree) ? ((RooAbsDataStore*)
new RooTreeDataStore(name,title,_vars)) :
279 ((RooAbsDataStore*)
new RooVectorDataStore(name,title,_vars)) ;
282 RooCmdConfig pc(Form(
"RooDataHist::ctor(%s)",GetName())) ;
283 pc.defineObject(
"impHist",
"ImportHisto",0) ;
284 pc.defineInt(
"impDens",
"ImportHisto",0) ;
285 pc.defineObject(
"indexCat",
"IndexCat",0) ;
286 pc.defineObject(
"impSliceHist",
"ImportHistoSlice",0,0,kTRUE) ;
287 pc.defineString(
"impSliceState",
"ImportHistoSlice",0,
"",kTRUE) ;
288 pc.defineObject(
"impSliceDHist",
"ImportDataHistSlice",0,0,kTRUE) ;
289 pc.defineString(
"impSliceDState",
"ImportDataHistSlice",0,
"",kTRUE) ;
290 pc.defineDouble(
"weight",
"Weight",0,1) ;
291 pc.defineObject(
"dummy1",
"ImportDataHistSliceMany",0) ;
292 pc.defineObject(
"dummy2",
"ImportHistoSliceMany",0) ;
293 pc.defineMutex(
"ImportHisto",
"ImportHistoSlice",
"ImportDataHistSlice") ;
294 pc.defineDependency(
"ImportHistoSlice",
"IndexCat") ;
295 pc.defineDependency(
"ImportDataHistSlice",
"IndexCat") ;
298 l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
299 l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
300 l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
301 l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
310 TH1* impHist =
static_cast<TH1*
>(pc.getObject(
"impHist")) ;
311 Bool_t impDens = pc.getInt(
"impDens") ;
312 Double_t initWgt = pc.getDouble(
"weight") ;
313 const char* impSliceNames = pc.getString(
"impSliceState",
"",kTRUE) ;
314 const RooLinkedList& impSliceHistos = pc.getObjectList(
"impSliceHist") ;
315 RooCategory* indexCat =
static_cast<RooCategory*
>(pc.getObject(
"indexCat")) ;
316 const char* impSliceDNames = pc.getString(
"impSliceDState",
"",kTRUE) ;
317 const RooLinkedList& impSliceDHistos = pc.getObjectList(
"impSliceDHist") ;
323 importTH1(vars,*impHist,initWgt, impDens) ;
325 }
else if (indexCat) {
328 if (impSliceHistos.GetSize()>0) {
331 map<string,TH1*> hmap ;
332 TIterator* hiter = impSliceHistos.MakeIterator() ;
333 for (
const auto& token : RooHelpers::tokenise(impSliceNames,
",")) {
334 auto histo =
static_cast<TH1*
>(hiter->Next());
338 importTH1Set(vars,*indexCat,hmap,initWgt,kFALSE) ;
342 map<string,RooDataHist*> dmap ;
343 TIterator* hiter = impSliceDHistos.MakeIterator() ;
344 for (
const auto& token : RooHelpers::tokenise(impSliceDNames,
",")) {
345 dmap[token] = (RooDataHist*) hiter->Next() ;
347 importDHistSet(vars,*indexCat,dmap,initWgt) ;
355 appendToDir(
this,kTRUE) ;
359 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
370 void RooDataHist::importTH1(
const RooArgList& vars,
const TH1& histo, Double_t wgt, Bool_t doDensityCorrection)
373 Int_t offset[3]{0, 0, 0};
374 adjustBinning(vars, histo, offset) ;
378 appendToDir(
this,kTRUE) ;
381 RooRealVar* xvar = (RooRealVar*) _vars.find(vars.at(0)->GetName()) ;
382 RooRealVar* yvar = (RooRealVar*) (vars.at(1) ? _vars.find(vars.at(1)->GetName()) : 0 ) ;
383 RooRealVar* zvar = (RooRealVar*) (vars.at(2) ? _vars.find(vars.at(2)->GetName()) : 0 ) ;
386 Int_t xmin(0),ymin(0),zmin(0) ;
387 RooArgSet vset(*xvar) ;
388 Double_t volume = xvar->getMax()-xvar->getMin() ;
393 volume *= (yvar->getMax()-yvar->getMin()) ;
398 volume *= (zvar->getMax()-zvar->getMin()) ;
403 Int_t ix(0),iy(0),iz(0) ;
404 for (ix=0 ; ix < xvar->getBins() ; ix++) {
407 for (iy=0 ; iy < yvar->getBins() ; iy++) {
410 for (iz=0 ; iz < zvar->getBins() ; iz++) {
412 Double_t bv = doDensityCorrection ? binVolume(vset) : 1;
413 add(vset,bv*histo.GetBinContent(ix+1+xmin,iy+1+ymin,iz+1+zmin)*wgt,bv*TMath::Power(histo.GetBinError(ix+1+xmin,iy+1+ymin,iz+1+zmin)*wgt,2)) ;
416 Double_t bv = doDensityCorrection ? binVolume(vset) : 1;
417 add(vset,bv*histo.GetBinContent(ix+1+xmin,iy+1+ymin)*wgt,bv*TMath::Power(histo.GetBinError(ix+1+xmin,iy+1+ymin)*wgt,2)) ;
421 Double_t bv = doDensityCorrection ? binVolume(vset) : 1 ;
422 add(vset,bv*histo.GetBinContent(ix+1+xmin)*wgt,bv*TMath::Power(histo.GetBinError(ix+1+xmin)*wgt,2)) ;
437 void RooDataHist::importTH1Set(
const RooArgList& vars, RooCategory& indexCat, map<string,TH1*> hmap, Double_t wgt, Bool_t doDensityCorrection)
439 RooCategory* icat = (RooCategory*) _vars.find(indexCat.GetName()) ;
442 Bool_t init(kFALSE) ;
443 for (map<string,TH1*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
446 histo = hiter->second ;
449 if (!indexCat.lookupType(hiter->first.c_str())) {
450 indexCat.defineType(hiter->first.c_str()) ;
451 coutI(InputArguments) <<
"RooDataHist::importTH1Set(" << GetName() <<
") defining state \"" << hiter->first <<
"\" in index category " << indexCat.GetName() << endl ;
453 if (!icat->lookupType(hiter->first.c_str())) {
454 icat->defineType(hiter->first.c_str()) ;
459 if (histo && (vars.getSize() != histo->GetDimension())) {
460 coutE(InputArguments) <<
"RooDataHist::ctor(" << GetName() <<
") ERROR: dimension of input histogram must match "
461 <<
"number of continuous variables" << endl ;
467 adjustBinning(vars,*histo,offset) ;
472 appendToDir(
this,kTRUE) ;
477 RooRealVar* xvar = (RooRealVar*) _vars.find(vars.at(0)->GetName()) ;
478 RooRealVar* yvar = (RooRealVar*) (vars.at(1) ? _vars.find(vars.at(1)->GetName()) : 0 ) ;
479 RooRealVar* zvar = (RooRealVar*) (vars.at(2) ? _vars.find(vars.at(2)->GetName()) : 0 ) ;
482 Int_t xmin(0),ymin(0),zmin(0) ;
483 RooArgSet vset(*xvar) ;
484 Double_t volume = xvar->getMax()-xvar->getMin() ;
489 volume *= (yvar->getMax()-yvar->getMin()) ;
494 volume *= (zvar->getMax()-zvar->getMin()) ;
496 Double_t avgBV = volume / numEntries() ;
498 Int_t ic(0),ix(0),iy(0),iz(0) ;
499 for (ic=0 ; ic < icat->numBins(0) ; ic++) {
501 histo = hmap[icat->getLabel()] ;
502 for (ix=0 ; ix < xvar->getBins() ; ix++) {
505 for (iy=0 ; iy < yvar->getBins() ; iy++) {
508 for (iz=0 ; iz < zvar->getBins() ; iz++) {
510 Double_t bv = doDensityCorrection ? binVolume(vset)/avgBV : 1;
511 add(vset,bv*histo->GetBinContent(ix+1+xmin,iy+1+ymin,iz+1+zmin)*wgt,bv*TMath::Power(histo->GetBinError(ix+1+xmin,iy+1+ymin,iz+1+zmin)*wgt,2)) ;
514 Double_t bv = doDensityCorrection ? binVolume(vset)/avgBV : 1;
515 add(vset,bv*histo->GetBinContent(ix+1+xmin,iy+1+ymin)*wgt,bv*TMath::Power(histo->GetBinError(ix+1+xmin,iy+1+ymin)*wgt,2)) ;
519 Double_t bv = doDensityCorrection ? binVolume(vset)/avgBV : 1;
520 add(vset,bv*histo->GetBinContent(ix+1+xmin)*wgt,bv*TMath::Power(histo->GetBinError(ix+1+xmin)*wgt,2)) ;
534 void RooDataHist::importDHistSet(
const RooArgList& , RooCategory& indexCat, std::map<std::string,RooDataHist*> dmap, Double_t initWgt)
536 RooCategory* icat = (RooCategory*) _vars.find(indexCat.GetName()) ;
538 for (map<string,RooDataHist*>::iterator diter = dmap.begin() ; diter!=dmap.end() ; ++diter) {
541 if (!indexCat.lookupType(diter->first.c_str())) {
542 indexCat.defineType(diter->first.c_str()) ;
543 coutI(InputArguments) <<
"RooDataHist::importDHistSet(" << GetName() <<
") defining state \"" << diter->first <<
"\" in index category " << indexCat.GetName() << endl ;
545 if (!icat->lookupType(diter->first.c_str())) {
546 icat->defineType(diter->first.c_str()) ;
551 appendToDir(
this,kTRUE) ;
554 for (map<string,RooDataHist*>::iterator diter = dmap.begin() ; diter!=dmap.end() ; ++diter) {
556 RooDataHist* dhist = diter->second ;
558 icat->setLabel(diter->first.c_str()) ;
561 for (Int_t i=0 ; i<dhist->numEntries() ; i++) {
562 _vars = *dhist->get(i) ;
563 add(_vars,dhist->weight()*initWgt, pow(dhist->weightError(SumW2),2) ) ;
572 void RooDataHist::_adjustBinning(RooRealVar &theirVar,
const TAxis &axis,
573 RooRealVar *ourVar, Int_t *offset)
575 if (!dynamic_cast<RooRealVar*>(ourVar)) {
576 coutE(InputArguments) <<
"RooDataHist::adjustBinning(" << GetName() <<
") ERROR: dimension " << ourVar->GetName() <<
" must be real" << endl ;
580 const double xlo = theirVar.getMin();
581 const double xhi = theirVar.getMax();
583 if (axis.GetXbins()->GetArray()) {
584 RooBinning xbins(axis.GetNbins(), axis.GetXbins()->GetArray());
586 const double tolerance = 1e-6 * xbins.averageBinWidth();
589 const double xloAdj = xbins.binLow(xbins.binNumber(xlo + tolerance));
590 const double xhiAdj = xbins.binHigh(xbins.binNumber(xhi - tolerance));
591 xbins.setRange(xloAdj, xhiAdj);
593 theirVar.setBinning(xbins);
595 if (
true || fabs(xloAdj - xlo) > tolerance || fabs(xhiAdj - xhi) > tolerance) {
596 coutI(DataHandling)<<
"RooDataHist::adjustBinning(" << GetName() <<
"): fit range of variable " << ourVar->GetName() <<
" expanded to nearest bin boundaries: [" << xlo <<
"," << xhi <<
"] --> [" << xloAdj <<
"," << xhiAdj <<
"]" << endl;
599 ourVar->setBinning(xbins);
602 *offset = xbins.rawBinNumber(xloAdj + tolerance);
605 RooBinning xbins(axis.GetXmin(), axis.GetXmax());
606 xbins.addUniform(axis.GetNbins(), axis.GetXmin(), axis.GetXmax());
608 const double tolerance = 1e-6 * xbins.averageBinWidth();
611 const double xloAdj = xbins.binLow(xbins.binNumber(xlo + tolerance));
612 const double xhiAdj = xbins.binHigh(xbins.binNumber(xhi - tolerance));
613 xbins.setRange(xloAdj, xhiAdj);
614 theirVar.setRange(xloAdj, xhiAdj);
616 if (fabs(xloAdj - xlo) > tolerance || fabs(xhiAdj - xhi) > tolerance) {
617 coutI(DataHandling)<<
"RooDataHist::adjustBinning(" << GetName() <<
"): fit range of variable " << ourVar->GetName() <<
" expanded to nearest bin boundaries: [" << xlo <<
"," << xhi <<
"] --> [" << xloAdj <<
"," << xhiAdj <<
"]" << endl;
620 RooUniformBinning xbins2(xloAdj, xhiAdj, xbins.numBins());
621 ourVar->setBinning(xbins2);
624 *offset = xbins.rawBinNumber(xloAdj + tolerance);
638 void RooDataHist::adjustBinning(
const RooArgList& vars,
const TH1& href, Int_t* offset)
640 auto xvar =
static_cast<RooRealVar*
>( _vars.find(*vars.at(0)) );
641 _adjustBinning(*static_cast<RooRealVar*>(vars.at(0)), *href.GetXaxis(), xvar, offset ? &offset[0] :
nullptr);
644 auto yvar =
static_cast<RooRealVar*
>(_vars.find(*vars.at(1)));
646 _adjustBinning(*static_cast<RooRealVar*>(vars.at(1)), *href.GetYaxis(), yvar, offset ? &offset[1] :
nullptr);
650 auto zvar =
static_cast<RooRealVar*
>(_vars.find(*vars.at(2)));
652 _adjustBinning(*static_cast<RooRealVar*>(vars.at(2)), *href.GetZaxis(), zvar, offset ? &offset[2] :
nullptr);
666 void RooDataHist::initialize(
const char* binningName, Bool_t fillTree)
670 for (
const auto real : _vars) {
671 if (dynamic_cast<RooAbsReal*>(real)) _realVars.add(*real);
675 for (
const auto rvarg : _vars) {
677 RooRealVar* rrv =
dynamic_cast<RooRealVar*
>(rvarg);
679 rrv->setBinning(rrv->getBinning(binningName));
683 _lvvars.push_back(dynamic_cast<RooAbsLValue*>(rvarg));
685 const RooAbsBinning* binning =
dynamic_cast<RooAbsLValue*
>(rvarg)->getBinningPtr(0);
686 _lvbins.push_back(binning ? binning->clone() : 0);
691 _idxMult.resize(_vars.getSize()) ;
695 for (
const auto var : _vars) {
696 auto arg =
dynamic_cast<const RooAbsLValue*
>(var);
699 for (i=0 ; i<n ; i++) {
700 _idxMult[i] *= arg->numBins() ;
705 _arrSize *= arg->numBins() ;
710 _wgt =
new Double_t[_arrSize] ;
711 _errLo =
new Double_t[_arrSize] ;
712 _errHi =
new Double_t[_arrSize] ;
713 _sumw2 =
new Double_t[_arrSize] ;
714 _binv =
new Double_t[_arrSize] ;
718 if (fillTree==kFALSE) {
719 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
722 for (i=0 ; i<_arrSize ; i++) {
730 if (!fillTree) return ;
736 for (ibin=0 ; ibin<_arrSize ; ibin++) {
737 Int_t j(0), idx(0), tmp(ibin) ;
738 Double_t theBinVolume(1) ;
739 for (
auto arg2 : _vars) {
740 idx = tmp / _idxMult[j] ;
741 tmp -= idx*_idxMult[j++] ;
742 auto arglv =
dynamic_cast<RooAbsLValue*
>(arg2);
744 theBinVolume *= arglv->getBinWidth(idx) ;
747 _binv[ibin] = theBinVolume ;
758 void RooDataHist::checkBinBounds()
const
760 if (!_binbounds.empty())
return;
761 for (std::vector<const RooAbsBinning*>::const_iterator it = _lvbins.begin();
762 _lvbins.end() != it; ++it) {
763 _binbounds.push_back(std::vector<Double_t>());
765 std::vector<Double_t>& bounds = _binbounds.back();
766 bounds.reserve(2 * (*it)->numBins());
767 for (Int_t i = 0; i < (*it)->numBins(); ++i) {
768 bounds.push_back((*it)->binLow(i));
769 bounds.push_back((*it)->binHigh(i));
778 RooDataHist::RooDataHist(
const RooDataHist& other,
const char* newname) :
779 RooAbsData(other,newname), RooDirItem(), _idxMult(other._idxMult), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(other._pbinvCacheMgr,0), _cache_sum_valid(0)
784 _arrSize = other._arrSize ;
785 _wgt =
new Double_t[_arrSize] ;
786 _errLo =
new Double_t[_arrSize] ;
787 _errHi =
new Double_t[_arrSize] ;
788 _binv =
new Double_t[_arrSize] ;
789 _sumw2 =
new Double_t[_arrSize] ;
790 for (i=0 ; i<_arrSize ; i++) {
791 _wgt[i] = other._wgt[i] ;
792 _errLo[i] = other._errLo[i] ;
793 _errHi[i] = other._errHi[i] ;
794 _sumw2[i] = other._sumw2[i] ;
795 _binv[i] = other._binv[i] ;
799 for (
const auto arg : _vars) {
800 if (dynamic_cast<RooAbsReal*>(arg) !=
nullptr) _realVars.add(*arg) ;
804 for (
const auto rvarg : _vars) {
806 _lvvars.push_back(dynamic_cast<RooAbsLValue*>(rvarg)) ;
808 const RooAbsBinning* binning =
dynamic_cast<RooAbsLValue*
>(rvarg)->getBinningPtr(0) ;
809 _lvbins.push_back(binning ? binning->clone() : 0) ;
812 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
814 appendToDir(
this,kTRUE) ;
829 RooDataHist::RooDataHist(
const char* name,
const char* title, RooDataHist* h,
const RooArgSet& varSubset,
830 const RooFormulaVar* cutVar,
const char* cutRange, Int_t nStart, Int_t nStop, Bool_t copyCache) :
831 RooAbsData(name,title,varSubset),
832 _wgt(0), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(0,10), _cache_sum_valid(0)
835 _dstore =
new RooTreeDataStore(name,title,*h->_dstore,_vars,cutVar,cutRange,nStart,nStop,copyCache) ;
837 initialize(0,kFALSE) ;
839 _dstore->setExternalWeightArray(_wgt,_errLo,_errHi,_sumw2) ;
843 for (i=0 ; i<_arrSize ; i++) {
844 _wgt[i] = h->_wgt[i] ;
845 _errLo[i] = h->_errLo[i] ;
846 _errHi[i] = h->_errHi[i] ;
847 _sumw2[i] = h->_sumw2[i] ;
848 _binv[i] = h->_binv[i] ;
852 appendToDir(
this,kTRUE) ;
860 RooAbsData* RooDataHist::cacheClone(
const RooAbsArg* newCacheOwner,
const RooArgSet* newCacheVars,
const char* newName)
864 RooDataHist* dhist =
new RooDataHist(newName?newName:GetName(),GetTitle(),
this,*
get(),0,0,0,2000000000,kTRUE) ;
866 RooArgSet* selCacheVars = (RooArgSet*) newCacheVars->selectCommon(dhist->_cachedVars) ;
867 dhist->attachCache(newCacheOwner, *selCacheVars) ;
868 delete selCacheVars ;
878 RooAbsData* RooDataHist::reduceEng(
const RooArgSet& varSubset,
const RooFormulaVar* cutVar,
const char* cutRange,
879 Int_t nStart, Int_t nStop, Bool_t )
882 RooArgSet* myVarSubset = (RooArgSet*) _vars.selectCommon(varSubset) ;
883 RooDataHist *rdh =
new RooDataHist(GetName(), GetTitle(), *myVarSubset) ;
886 RooFormulaVar* cloneVar = 0;
890 tmp = (RooArgSet*) RooArgSet(*cutVar).snapshot() ;
892 coutE(DataHandling) <<
"RooDataHist::reduceEng(" << GetName() <<
") Couldn't deep-clone cut variable, abort," << endl ;
895 cloneVar = (RooFormulaVar*) tmp->find(*cutVar) ;
896 cloneVar->attachDataSet(*
this) ;
901 Int_t nevt = nStop < numEntries() ? nStop : numEntries() ;
902 TIterator* vIter =
get()->createIterator() ;
903 for (i=nStart ; i<nevt ; i++) {
904 const RooArgSet* row =
get(i) ;
906 Bool_t doSelect(kTRUE) ;
910 while((arg=(RooAbsArg*)vIter->Next())) {
911 if (!arg->inRange(cutRange)) {
917 if (!doSelect) continue ;
919 if (!cloneVar || cloneVar->getVal()) {
920 weightError(lo,hi,SumW2) ;
921 rdh->add(*row,weight(),lo*lo) ;
938 RooDataHist::~RooDataHist()
940 if (_wgt)
delete[] _wgt ;
941 if (_errLo)
delete[] _errLo ;
942 if (_errHi)
delete[] _errHi ;
943 if (_sumw2)
delete[] _sumw2 ;
944 if (_binv)
delete[] _binv ;
945 if (_binValid)
delete[] _binValid ;
946 vector<const RooAbsBinning*>::iterator iter = _lvbins.begin() ;
947 while(iter!=_lvbins.end()) {
952 removeFromDir(
this) ;
961 Int_t RooDataHist::getIndex(
const RooArgSet& coord, Bool_t fast)
965 _vars.assignFast(coord,kFALSE) ;
967 _vars.assignValueOnly(coord) ;
969 return calcTreeIndex() ;
979 Int_t RooDataHist::calcTreeIndex()
const
982 for (
unsigned int i=0; i < _lvvars.size(); ++i) {
983 const RooAbsLValue* lvvar = _lvvars[i];
984 const RooAbsBinning* binning = _lvbins[i];
985 masterIdx += _idxMult[i] * lvvar->getBin(binning);
996 void RooDataHist::dump2()
998 cout <<
"_arrSize = " << _arrSize << endl ;
999 for (Int_t i=0 ; i<_arrSize ; i++) {
1000 cout <<
"wgt[" << i <<
"] = " << _wgt[i] <<
"sumw2[" << i <<
"] = " << _sumw2[i] <<
" vol[" << i <<
"] = " << _binv[i] << endl ;
1012 RooPlot *RooDataHist::plotOn(RooPlot *frame, PlotOpt o)
const
1015 if (o.bins)
return RooAbsData::plotOn(frame,o) ;
1018 coutE(InputArguments) << ClassName() <<
"::" << GetName() <<
":plotOn: frame is null" << endl;
1021 RooAbsRealLValue *var= (RooAbsRealLValue*) frame->getPlotVar();
1023 coutE(InputArguments) << ClassName() <<
"::" << GetName()
1024 <<
":plotOn: frame does not specify a plot variable" << endl;
1028 RooRealVar* dataVar = (RooRealVar*) _vars.find(*var) ;
1030 coutE(InputArguments) << ClassName() <<
"::" << GetName()
1031 <<
":plotOn: dataset doesn't contain plot frame variable" << endl;
1035 o.bins = &dataVar->getBinning() ;
1036 o.correctForBinWidth = kFALSE ;
1037 return RooAbsData::plotOn(frame,o) ;
1045 Double_t RooDataHist::weightSquared()
const {
1059 Double_t RooDataHist::weight(
const RooArgSet& bin, Int_t intOrder, Bool_t correctForBinSize, Bool_t cdfBoundaries, Bool_t oneSafe)
1067 coutE(InputArguments) <<
"RooDataHist::weight(" << GetName() <<
") ERROR: interpolation order must be positive" << endl ;
1073 _vars.assignValueOnly(bin,oneSafe) ;
1074 Int_t idx = calcTreeIndex() ;
1076 if (correctForBinSize) {
1079 return get_wgt(idx) / _binv[idx];
1082 return get_wgt(idx);
1087 _vars.assignValueOnly(bin) ;
1090 if (_realVars.getSize()==1) {
1093 const auto real =
static_cast<RooRealVar*
>(_realVars[
static_cast<std::size_t
>(0)]);
1094 const RooAbsBinning* binning = real->getBinningPtr(0) ;
1095 wInt = interpolateDim(*real,binning,((RooAbsReal*)bin.find(*real))->getVal(), intOrder, correctForBinSize, cdfBoundaries) ;
1097 }
else if (_realVars.getSize()==2) {
1100 const auto realX =
static_cast<RooRealVar*
>(_realVars[
static_cast<std::size_t
>(0)]);
1101 const auto realY =
static_cast<RooRealVar*
>(_realVars[
static_cast<std::size_t
>(1)]);
1102 Double_t xval = ((RooAbsReal*)bin.find(*realX))->getVal() ;
1103 Double_t yval = ((RooAbsReal*)bin.find(*realY))->getVal() ;
1105 Int_t ybinC = realY->getBin() ;
1106 Int_t ybinLo = ybinC-intOrder/2 - ((yval<realY->getBinning().binCenter(ybinC))?1:0) ;
1107 Int_t ybinM = realY->numBins() ;
1112 const RooAbsBinning* binning = realX->getBinningPtr(0) ;
1113 for (i=ybinLo ; i<=intOrder+ybinLo ; i++) {
1115 if (i>=0 && i<ybinM) {
1118 realY->setBin(ibin) ;
1119 xarr[i-ybinLo] = realY->getVal() ;
1120 }
else if (i>=ybinM) {
1122 ibin = 2*ybinM-i-1 ;
1123 realY->setBin(ibin) ;
1124 xarr[i-ybinLo] = 2*realY->getMax()-realY->getVal() ;
1128 realY->setBin(ibin) ;
1129 xarr[i-ybinLo] = 2*realY->getMin()-realY->getVal() ;
1131 yarr[i-ybinLo] = interpolateDim(*realX,binning,xval,intOrder,correctForBinSize,kFALSE) ;
1135 cout <<
"RooDataHist interpolating data is" << endl ;
1137 for (
int q=0; q<=intOrder ; q++) cout << xarr[q] <<
" " ;
1138 cout <<
" yarr = " ;
1139 for (
int q=0; q<=intOrder ; q++) cout << yarr[q] <<
" " ;
1142 wInt = RooMath::interpolate(xarr,yarr,intOrder+1,yval) ;
1147 coutE(InputArguments) <<
"RooDataHist::weight(" << GetName() <<
") interpolation in "
1148 << _realVars.getSize() <<
" dimensions not yet implemented" << endl ;
1149 return weight(bin,0) ;
1168 void RooDataHist::weightError(Double_t& lo, Double_t& hi, ErrorType etype)
const
1175 throw string(Form(
"RooDataHist::weightError(%s) error type Auto not allowed here",GetName())) ;
1179 throw string(Form(
"RooDataHist::weightError(%s) error type Expected not allowed here",GetName())) ;
1183 if (_curWgtErrLo>=0) {
1192 RooHistError::instance().getPoissonInterval(Int_t(weight()+0.5),ym,yp,1) ;
1193 _curWgtErrLo = weight()-ym ;
1194 _curWgtErrHi = yp-weight() ;
1195 _errLo[_curIndex] = _curWgtErrLo ;
1196 _errHi[_curIndex] = _curWgtErrHi ;
1202 lo = sqrt(_curSumW2) ;
1203 hi = sqrt(_curSumW2) ;
1220 Double_t RooDataHist::interpolateDim(RooRealVar& dim,
const RooAbsBinning* binning, Double_t xval, Int_t intOrder, Bool_t correctForBinSize, Bool_t cdfBoundaries)
1223 Int_t fbinC = dim.getBin(*binning) ;
1224 Int_t fbinLo = fbinC-intOrder/2 - ((xval<binning->binCenter(fbinC))?1:0) ;
1225 Int_t fbinM = dim.numBins(*binning) ;
1231 for (i=fbinLo ; i<=intOrder+fbinLo ; i++) {
1233 if (i>=0 && i<fbinM) {
1236 dim.setBinFast(ibin,*binning) ;
1238 xarr[i-fbinLo] = dim.getVal() ;
1239 Int_t idx = calcTreeIndex();
1240 yarr[i - fbinLo] = get_wgt(idx);
1241 if (correctForBinSize) yarr[i-fbinLo] /= _binv[idx] ;
1242 }
else if (i>=fbinM) {
1244 ibin = 2*fbinM-i-1 ;
1245 dim.setBinFast(ibin,*binning) ;
1247 if (cdfBoundaries) {
1248 xarr[i-fbinLo] = dim.getMax()+1e-10*(i-fbinM+1) ;
1249 yarr[i-fbinLo] = 1.0 ;
1251 Int_t idx = calcTreeIndex() ;
1252 xarr[i-fbinLo] = 2*dim.getMax()-dim.getVal() ;
1253 yarr[i - fbinLo] = get_wgt(idx);
1254 if (correctForBinSize)
1255 yarr[i - fbinLo] /= _binv[idx];
1260 dim.setBinFast(ibin,*binning) ;
1262 if (cdfBoundaries) {
1263 xarr[i-fbinLo] = dim.getMin()-ibin*(1e-10) ; ;
1264 yarr[i-fbinLo] = 0.0 ;
1266 Int_t idx = calcTreeIndex() ;
1267 xarr[i-fbinLo] = 2*dim.getMin()-dim.getVal() ;
1268 yarr[i - fbinLo] = get_wgt(idx);
1269 if (correctForBinSize)
1270 yarr[i - fbinLo] /= _binv[idx];
1278 dim.setBinFast(fbinC,*binning) ;
1279 Double_t ret = RooMath::interpolate(xarr,yarr,intOrder+1,xval) ;
1291 void RooDataHist::add(
const RooArgSet& row, Double_t wgt, Double_t sumw2)
1299 Int_t idx = calcTreeIndex() ;
1301 _sumw2[idx] += (sumw2>0?sumw2:wgt*wgt) ;
1305 _cache_sum_valid = kFALSE ;
1315 void RooDataHist::set(
const RooArgSet& row, Double_t wgt, Double_t wgtErrLo, Double_t wgtErrHi)
1320 Int_t idx = calcTreeIndex() ;
1322 _errLo[idx] = wgtErrLo ;
1323 _errHi[idx] = wgtErrHi ;
1325 _cache_sum_valid = kFALSE ;
1335 void RooDataHist::set(Double_t wgt, Double_t wgtErr)
1340 _curIndex = calcTreeIndex() ;
1343 _wgt[_curIndex] = wgt ;
1344 _errLo[_curIndex] = wgtErr ;
1345 _errHi[_curIndex] = wgtErr ;
1346 _sumw2[_curIndex] = wgtErr*wgtErr ;
1348 _cache_sum_valid = kFALSE ;
1358 void RooDataHist::set(
const RooArgSet& row, Double_t wgt, Double_t wgtErr)
1363 Int_t idx = calcTreeIndex() ;
1365 _errLo[idx] = wgtErr ;
1366 _errHi[idx] = wgtErr ;
1367 _sumw2[idx] = wgtErr*wgtErr ;
1369 _cache_sum_valid = kFALSE ;
1379 void RooDataHist::add(
const RooAbsData& dset,
const char* cut, Double_t wgt)
1381 RooFormulaVar cutVar(
"select",cut,*dset.get()) ;
1382 add(dset,&cutVar,wgt) ;
1391 void RooDataHist::add(
const RooAbsData& dset,
const RooFormulaVar* cutVar, Double_t wgt)
1395 RooFormulaVar* cloneVar = 0;
1399 tmp = (RooArgSet*) RooArgSet(*cutVar).snapshot() ;
1401 coutE(DataHandling) <<
"RooDataHist::add(" << GetName() <<
") Couldn't deep-clone cut variable, abort," << endl ;
1405 cloneVar = (RooFormulaVar*) tmp->find(*cutVar) ;
1406 cloneVar->attachDataSet(dset) ;
1411 for (i=0 ; i<dset.numEntries() ; i++) {
1412 const RooArgSet* row = dset.get(i) ;
1413 if (!cloneVar || cloneVar->getVal()) {
1414 add(*row,wgt*dset.weight(), wgt*wgt*dset.weightSquared()) ;
1422 _cache_sum_valid = kFALSE ;
1435 Double_t RooDataHist::sum(Bool_t correctForBinSize, Bool_t inverseBinCor)
const
1440 Int_t cache_code = 1 + (correctForBinSize?1:0) + ((correctForBinSize&&inverseBinCor)?1:0) ;
1441 if (_cache_sum_valid==cache_code) {
1446 Double_t total(0), carry(0);
1447 for (i=0 ; i<_arrSize ; i++) {
1449 Double_t theBinVolume = correctForBinSize ? (inverseBinCor ? 1/_binv[i] : _binv[i]) : 1.0 ;
1452 Double_t y = get_wgt(i) * theBinVolume - carry;
1453 Double_t t = total + y;
1454 carry = (t - total) - y;
1459 _cache_sum_valid=cache_code ;
1460 _cache_sum = total ;
1478 Double_t RooDataHist::sum(
const RooArgSet& sumSet,
const RooArgSet& sliceSet, Bool_t correctForBinSize, Bool_t inverseBinCor)
1483 varSave.addClone(_vars) ;
1485 RooArgSet* sliceOnlySet =
new RooArgSet(sliceSet) ;
1486 sliceOnlySet->remove(sumSet,kTRUE,kTRUE) ;
1488 _vars = *sliceOnlySet ;
1489 calculatePartialBinVolume(*sliceOnlySet) ;
1490 delete sliceOnlySet ;
1493 Bool_t* mask =
new Bool_t[_vars.getSize()] ;
1494 Int_t* refBin =
new Int_t[_vars.getSize()] ;
1496 for (
unsigned int i = 0; i < _vars.size(); ++i) {
1497 const auto arg = _vars[i];
1499 if (sumSet.find(*arg)) {
1503 refBin[i] =
dynamic_cast<RooAbsLValue*
>(arg)->getBin();
1508 Double_t total(0), carry(0);
1510 for (ibin=0 ; ibin<_arrSize ; ibin++) {
1512 Int_t idx(0), tmp(ibin), ivar(0) ;
1513 Bool_t skip(kFALSE) ;
1516 for (
unsigned int i = 0; !skip && i < _vars.size(); ++i) {
1517 idx = tmp / _idxMult[ivar] ;
1518 tmp -= idx*_idxMult[ivar] ;
1519 if (mask[ivar] && idx!=refBin[ivar]) skip=kTRUE ;
1524 Double_t theBinVolume = correctForBinSize ? (inverseBinCor ? 1/(*_pbinv)[_vars.size()] : (*_pbinv)[_vars.size()] ) : 1.0 ;
1527 Double_t y = get_wgt(ibin) * theBinVolume - carry;
1528 Double_t t = total + y;
1529 carry = (t - total) - y;
1558 Double_t RooDataHist::sum(
const RooArgSet& sumSet,
const RooArgSet& sliceSet,
1559 Bool_t correctForBinSize, Bool_t inverseBinCor,
1560 const std::map<
const RooAbsArg*, std::pair<Double_t, Double_t> >& ranges)
1565 varSave.addClone(_vars);
1567 RooArgSet sliceOnlySet(sliceSet);
1568 sliceOnlySet.remove(sumSet,kTRUE,kTRUE);
1569 _vars = sliceOnlySet;
1574 std::vector<bool> mask(_vars.getSize());
1575 std::vector<Int_t> refBin(_vars.getSize());
1576 std::vector<Double_t> rangeLo(_vars.getSize(), -std::numeric_limits<Double_t>::infinity());
1577 std::vector<Double_t> rangeHi(_vars.getSize(), +std::numeric_limits<Double_t>::infinity());
1579 for (std::size_t i = 0; i < _vars.size(); ++i) {
1580 const auto arg = _vars[i];
1581 RooAbsArg* sumsetv = sumSet.find(*arg);
1582 RooAbsArg* slicesetv = sliceSet.find(*arg);
1585 auto argLV =
dynamic_cast<const RooAbsLValue*
>(arg);
1587 refBin[i] = argLV->getBin();
1590 auto it = ranges.find(sumsetv ? sumsetv : slicesetv);
1591 if (ranges.end() != it) {
1592 rangeLo[i] = it->second.first;
1593 rangeHi[i] = it->second.second;
1598 Double_t total(0), carry(0);
1599 for (Int_t ibin = 0; ibin < _arrSize; ++ibin) {
1601 Bool_t skip(kFALSE);
1602 for (
int ivar = 0, tmp = ibin; !skip && ivar < int(_vars.size()); ++ivar) {
1603 const Int_t idx = tmp / _idxMult[ivar];
1604 tmp -= idx*_idxMult[ivar];
1605 if (mask[ivar] && idx!=refBin[ivar]) skip=kTRUE;
1611 Double_t theBinVolume = 1.;
1612 for (Int_t ivar = 0, tmp = ibin; ivar < (int)_vars.size(); ++ivar) {
1613 const Int_t idx = tmp / _idxMult[ivar];
1614 tmp -= idx*_idxMult[ivar];
1615 if (_binbounds[ivar].empty())
continue;
1616 const Double_t binLo = _binbounds[ivar][2 * idx];
1617 const Double_t binHi = _binbounds[ivar][2 * idx + 1];
1618 if (binHi < rangeLo[ivar] || binLo > rangeHi[ivar]) {
1624 (std::min(rangeHi[ivar], binHi) - std::max(rangeLo[ivar], binLo));
1626 const Double_t corrPartial = theBinVolume / _binv[ibin];
1627 if (0. == corrPartial)
continue;
1628 const Double_t corr = correctForBinSize ? (inverseBinCor ? 1. / _binv[ibin] : _binv[ibin] ) : 1.0;
1631 const Double_t y = get_wgt(ibin) * corr * corrPartial - carry;
1632 const Double_t t = total + y;
1633 carry = (t - total) - y;
1648 void RooDataHist::calculatePartialBinVolume(
const RooArgSet& dimSet)
const
1651 vector<Double_t> *pbinv = _pbinvCacheMgr.getObj(&dimSet) ;
1657 pbinv =
new vector<Double_t>(_arrSize) ;
1660 Bool_t* selDim =
new Bool_t[_vars.getSize()] ;
1662 for (
const auto v : _vars) {
1663 selDim[i++] = dimSet.find(*v) ? kTRUE : kFALSE ;
1668 for (ibin=0 ; ibin<_arrSize ; ibin++) {
1669 Int_t j(0), idx(0), tmp(ibin) ;
1670 Double_t theBinVolume(1) ;
1671 for (
const auto absArg : _vars) {
1672 auto arg =
dynamic_cast<const RooAbsLValue*
>(absArg);
1676 idx = tmp / _idxMult[j] ;
1677 tmp -= idx*_idxMult[j++] ;
1679 theBinVolume *= arg->getBinWidth(idx) ;
1682 (*pbinv)[ibin] = theBinVolume ;
1688 _pbinvCacheMgr.setObj(&dimSet,pbinv) ;
1699 Int_t RooDataHist::numEntries()
const
1701 return RooAbsData::numEntries() ;
1708 Double_t RooDataHist::sumEntries()
const
1711 Double_t n(0), carry(0);
1712 for (i=0 ; i<_arrSize ; i++) {
1713 if (!_binValid || _binValid[i]) {
1715 Double_t y = get_wgt(i) - carry;
1717 carry = (t - n) - y;
1731 Double_t RooDataHist::sumEntries(
const char* cutSpec,
const char* cutRange)
const
1735 if (cutSpec==0 && cutRange==0) {
1736 return sumEntries();
1740 RooFormula* select = 0 ;
1742 select =
new RooFormula(
"select",cutSpec,*
get()) ;
1746 Double_t sumw(0), carry(0);
1748 for (i=0 ; i<numEntries() ; i++) {
1750 if (select && select->eval()==0.) continue ;
1751 if (cutRange && !_vars.allInRange(cutRange))
continue ;
1753 if (!_binValid || _binValid[i]) {
1754 Double_t y = weight() - carry;
1755 Double_t t = sumw + y;
1756 carry = (t - sumw) - y;
1761 if (select)
delete select ;
1772 void RooDataHist::reset()
1778 for (i=0 ; i<_arrSize ; i++) {
1788 _cache_sum_valid = kFALSE ;
1798 const RooArgSet* RooDataHist::get(Int_t masterIdx)
const
1801 _curWeight = _wgt[masterIdx] ;
1802 _curWgtErrLo = _errLo[masterIdx] ;
1803 _curWgtErrHi = _errHi[masterIdx] ;
1804 _curSumW2 = _sumw2[masterIdx] ;
1805 _curVolume = _binv[masterIdx] ;
1806 _curIndex = masterIdx ;
1807 return RooAbsData::get(masterIdx) ;
1816 const RooArgSet* RooDataHist::get(
const RooArgSet& coord)
const
1818 ((RooDataHist*)
this)->_vars = coord ;
1819 return get(calcTreeIndex()) ;
1827 Double_t RooDataHist::binVolume(
const RooArgSet& coord)
1830 ((RooDataHist*)
this)->_vars = coord ;
1831 return _binv[calcTreeIndex()] ;
1838 void RooDataHist::setAllWeights(Double_t value)
1840 for (Int_t i=0 ; i<_arrSize ; i++) {
1844 _cache_sum_valid = kFALSE ;
1853 TIterator* RooDataHist::sliceIterator(RooAbsArg& sliceArg,
const RooArgSet& otherArgs)
1857 _curIndex = calcTreeIndex() ;
1859 RooAbsArg* intArg = _vars.find(sliceArg) ;
1861 coutE(InputArguments) <<
"RooDataHist::sliceIterator() variable " << sliceArg.GetName() <<
" is not part of this RooDataHist" << endl ;
1864 return new RooDataHistSliceIter(*
this,*intArg) ;
1871 void RooDataHist::SetName(
const char *name)
1873 if (_dir) _dir->GetList()->Remove(
this);
1874 TNamed::SetName(name) ;
1875 if (_dir) _dir->GetList()->Add(
this);
1882 void RooDataHist::SetNameTitle(
const char *name,
const char* title)
1884 if (_dir) _dir->GetList()->Remove(
this);
1885 TNamed::SetNameTitle(name,title) ;
1886 if (_dir) _dir->GetList()->Add(
this);
1893 void RooDataHist::printValue(ostream& os)
const
1895 os << numEntries() <<
" bins (" << sumEntries() <<
" weights)" ;
1904 void RooDataHist::printArgs(ostream& os)
const
1907 Bool_t first(kTRUE) ;
1908 for (
const auto arg : _vars) {
1914 os << arg->GetName() ;
1925 void RooDataHist::cacheValidEntries()
1930 _binValid =
new Bool_t[_arrSize] ;
1932 TIterator* iter = _vars.createIterator() ;
1934 for (Int_t i=0 ; i<_arrSize ; i++) {
1936 _binValid[i] = kTRUE ;
1938 while((arg=(RooAbsArg*)iter->Next())) {
1940 _binValid[i] &= arg->inRange(0) ;
1952 Bool_t RooDataHist::valid()
const
1956 return _binValid[_curIndex] ;
1967 Bool_t RooDataHist::isNonPoissonWeighted()
const
1969 for (
int i=0 ; i<numEntries() ; i++) {
1970 if (fabs(_wgt[i]-Int_t(_wgt[i]))>1e-10)
return kTRUE ;
1981 void RooDataHist::printMultiline(ostream& os, Int_t content, Bool_t verbose, TString indent)
const
1983 RooAbsData::printMultiline(os,content,verbose,indent) ;
1985 os << indent <<
"Binned Dataset " << GetName() <<
" (" << GetTitle() <<
")" << endl ;
1986 os << indent <<
" Contains " << numEntries() <<
" bins with a total weight of " << sumEntries() << endl;
1989 os << indent <<
" Observables " << _vars << endl ;
1991 os << indent <<
" Observables: " ;
1992 _vars.printStream(os,kName|kValue|kExtras|kTitle,kVerbose,indent+
" ") ;
1996 if (_cachedVars.getSize()>0) {
1997 os << indent <<
" Caches " << _cachedVars << endl ;
2007 void RooDataHist::Streamer(TBuffer &R__b)
2009 if (R__b.IsReading()) {
2012 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
2016 R__b.ReadClassBuffer(RooDataHist::Class(),
this,R__v,R__s,R__c);
2017 initialize(0,kFALSE) ;
2027 UInt_t R__s1, R__c1;
2028 Version_t R__v1 = R__b.ReadVersion(&R__s1, &R__c1);
if (R__v1) { }
2030 RooAbsData::Streamer(R__b);
2031 TTree* X_tree(0) ; R__b >> X_tree;
2032 RooArgSet X_truth ; X_truth.Streamer(R__b);
2033 TString X_blindString ; X_blindString.Streamer(R__b);
2034 R__b.CheckByteCount(R__s1, R__c1, RooTreeData::Class());
2038 _dstore =
new RooTreeDataStore(X_tree,_vars) ;
2039 _dstore->SetName(GetName()) ;
2040 _dstore->SetTitle(GetTitle()) ;
2041 _dstore->checkInit() ;
2043 RooDirItem::Streamer(R__b);
2046 _wgt =
new Double_t[_arrSize];
2047 R__b.ReadFastArray(_wgt,_arrSize);
2049 _errLo =
new Double_t[_arrSize];
2050 R__b.ReadFastArray(_errLo,_arrSize);
2052 _errHi =
new Double_t[_arrSize];
2053 R__b.ReadFastArray(_errHi,_arrSize);
2055 _sumw2 =
new Double_t[_arrSize];
2056 R__b.ReadFastArray(_sumw2,_arrSize);
2058 _binv =
new Double_t[_arrSize];
2059 R__b.ReadFastArray(_binv,_arrSize);
2060 _realVars.Streamer(R__b);
2062 R__b >> _curWgtErrLo;
2063 R__b >> _curWgtErrHi;
2067 R__b.CheckByteCount(R__s, R__c, RooDataHist::IsA());
2073 R__b.WriteClassBuffer(RooDataHist::Class(),
this);