Logo ROOT   6.16/01
Reference Guide
RooDataHist.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 RooDataHist.cxx
19\class RooDataHist
20\ingroup Roofitcore
21
22RooDataSet is a container class to hold N-dimensional binned data. Each bins central
23coordinates in N-dimensional space are represented by a RooArgSet of RooRealVar, RooCategory
24or RooStringVar objects, thus data can be binned in real and/or discrete dimensions
25**/
26
27#include "RooFit.h"
28#include "Riostream.h"
29
30#include "TH1.h"
31#include "TH1.h"
32#include "TDirectory.h"
33#include "TMath.h"
34#include "RooMsgService.h"
35#include "RooDataHist.h"
37#include "RooAbsLValue.h"
38#include "RooArgList.h"
39#include "RooRealVar.h"
40#include "RooMath.h"
41#include "RooBinning.h"
42#include "RooPlot.h"
43#include "RooHistError.h"
44#include "RooCategory.h"
45#include "RooCmdConfig.h"
46#include "RooLinkedListIter.h"
47#include "RooTreeDataStore.h"
48#include "RooVectorDataStore.h"
49#include "TTree.h"
50#include "RooTrace.h"
51#include "RooTreeData.h"
52
53using namespace std ;
54
56;
57
58
59
60////////////////////////////////////////////////////////////////////////////////
61/// Default constructor
62
63RooDataHist::RooDataHist() : _pbinvCacheMgr(0,10)
64{
65 _arrSize = 0 ;
66 _wgt = 0 ;
67 _errLo = 0 ;
68 _errHi = 0 ;
69 _sumw2 = 0 ;
70 _binv = 0 ;
71 _pbinv = 0 ;
72 _curWeight = 0 ;
73 _curIndex = -1 ;
75 _binValid = 0 ;
76 _curSumW2 = 0 ;
77 _curVolume = 1 ;
78 _curWgtErrHi = 0 ;
79 _curWgtErrLo = 0 ;
82}
83
84
85
86////////////////////////////////////////////////////////////////////////////////
87/// Constructor of an empty data hist from a RooArgSet defining the dimensions
88/// of the data space. The range and number of bins in each dimensions are taken
89/// from getMin()getMax(),getBins() of each RooAbsArg representing that
90/// dimension.
91///
92/// For real dimensions, the fit range and number of bins can be set independently
93/// of the plot range and number of bins, but it is advisable to keep the
94/// ratio of the plot bin width and the fit bin width an integer value.
95/// For category dimensions, the fit ranges always comprises all defined states
96/// and each state is always has its individual bin
97///
98/// To effective achive binning of real dimensions with variable bins sizes,
99/// construct a RooThresholdCategory of the real dimension to be binned variably.
100/// Set the thresholds at the desired bin boundaries, and construct the
101/// data hist as function of the threshold category instead of the real variable.
102
103RooDataHist::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)
105{
106 // Initialize datastore
109
110 initialize(binningName) ;
111
113
114 appendToDir(this,kTRUE) ;
116}
117
118
119
120////////////////////////////////////////////////////////////////////////////////
121/// Constructor of a data hist from an existing data collection (binned or unbinned)
122/// The RooArgSet 'vars' defines the dimensions of the histogram.
123/// The range and number of bins in each dimensions are taken
124/// from getMin()getMax(),getBins() of each RooAbsArg representing that
125/// dimension.
126///
127/// For real dimensions, the fit range and number of bins can be set independently
128/// of the plot range and number of bins, but it is advisable to keep the
129/// ratio of the plot bin width and the fit bin width an integer value.
130/// For category dimensions, the fit ranges always comprises all defined states
131/// and each state is always has its individual bin
132///
133/// To effective achive binning of real dimensions with variable bins sizes,
134/// construct a RooThresholdCategory of the real dimension to be binned variably.
135/// Set the thresholds at the desired bin boundaries, and construct the
136/// data hist as function of the threshold category instead of the real variable.
137///
138/// If the constructed data hist has less dimensions that in source data collection,
139/// all missing dimensions will be projected.
140
141RooDataHist::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)
143{
144 // Initialize datastore
147
148 initialize() ;
150
151 add(data,(const RooFormulaVar*)0,wgt) ;
152 appendToDir(this,kTRUE) ;
154}
155
156
157
158////////////////////////////////////////////////////////////////////////////////
159/// Constructor of a data hist from a map of TH1,TH2 or TH3 that are collated into a x+1 dimensional
160/// RooDataHist where the added dimension is a category that labels the input source as defined
161/// in the histMap argument. The state names used in histMap must correspond to predefined states
162/// 'indexCat'
163///
164/// The RooArgList 'vars' defines the dimensions of the histogram.
165/// The ranges and number of bins are taken from the input histogram and must be the same in all histograms
166
167RooDataHist::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)
171{
172 // Initialize datastore
175
176 importTH1Set(vars, indexCat, histMap, wgt, kFALSE) ;
177
180}
181
182
183
184////////////////////////////////////////////////////////////////////////////////
185/// Constructor of a data hist from a map of RooDataHists that are collated into a x+1 dimensional
186/// RooDataHist where the added dimension is a category that labels the input source as defined
187/// in the histMap argument. The state names used in histMap must correspond to predefined states
188/// 'indexCat'
189///
190/// The RooArgList 'vars' defines the dimensions of the histogram.
191/// The ranges and number of bins are taken from the input histogram and must be the same in all histograms
192
193RooDataHist::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)
197{
198 // Initialize datastore
201
202 importDHistSet(vars, indexCat, dhistMap, wgt) ;
203
206}
207
208
209
210////////////////////////////////////////////////////////////////////////////////
211/// Constructor of a data hist from an TH1,TH2 or TH3
212/// The RooArgSet 'vars' defines the dimensions of the histogram. The ranges
213/// and number of bins are taken from the input histogram, and the corresponding
214/// values are set accordingly on the arguments in 'vars'
215
216RooDataHist::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)
218{
219 // Initialize datastore
222
223 // Check consistency in number of dimensions
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 ;
227 assert(0) ;
228 }
229
230 importTH1(vars,*hist,wgt, kFALSE) ;
231
234}
235
236
237
238////////////////////////////////////////////////////////////////////////////////
239/// Constructor of a binned dataset from a RooArgSet defining the dimensions
240/// of the data space. The range and number of bins in each dimensions are taken
241/// from getMin() getMax(),getBins() of each RooAbsArg representing that
242/// dimension.
243///
244/// This constructor takes the following optional arguments
245///
246/// Import(TH1&, Bool_t impDens) -- Import contents of the given TH1/2/3 into this binned dataset. The
247/// ranges and binning of the binned dataset are automatically adjusted to
248/// match those of the imported histogram.
249///
250/// Please note: for TH1& with unequal binning _only_,
251/// you should decide if you want to import the absolute bin content,
252/// or the bin content expressed as density. The latter is default and will
253/// result in the same histogram as the original TH1. For certain type of
254/// bin contents (containing efficiencies, asymmetries, or ratio is general)
255/// you should import the absolute value and set impDens to kFALSE
256///
257///
258/// Weight(Double_t) -- Apply given weight factor when importing histograms
259///
260/// Index(RooCategory&) -- Prepare import of multiple TH1/1/2/3 into a N+1 dimensional RooDataHist
261/// where the extra discrete dimension labels the source of the imported histogram
262/// If the index category defines states for which no histogram is be imported
263/// the corresponding bins will be left empty.
264///
265/// Import(const char*, TH1&) -- Import a THx to be associated with the given state name of the index category
266/// specified in Index(). If the given state name is not yet defined in the index
267/// category it will be added on the fly. The import command can be specified
268/// multiple times.
269/// Import(map<string,TH1*>&) -- As above, but allows specification of many imports in a single operation
270///
271
272RooDataHist::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)
276{
277 // Initialize datastore
280
281 // Define configuration for this method
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) ; // array
287 pc.defineString("impSliceState","ImportHistoSlice",0,"",kTRUE) ; // array
288 pc.defineObject("impSliceDHist","ImportDataHistSlice",0,0,kTRUE) ; // array
289 pc.defineString("impSliceDState","ImportDataHistSlice",0,"",kTRUE) ; // array
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") ;
296
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) ;
302
303 // Process & check varargs
304 pc.process(l) ;
305 if (!pc.ok(kTRUE)) {
306 assert(0) ;
307 return ;
308 }
309
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") ;
318
319
320 if (impHist) {
321
322 // Initialize importing contents from TH1
323 importTH1(vars,*impHist,initWgt, impDens) ;
324
325 } else if (indexCat) {
326
327
328 if (impSliceHistos.GetSize()>0) {
329
330 // Initialize importing mapped set of TH1s
331 map<string,TH1*> hmap ;
332 char tmp[1024] ;
333 strlcpy(tmp,impSliceNames,1024) ;
334 char* token = strtok(tmp,",") ;
335 TIterator* hiter = impSliceHistos.MakeIterator() ;
336 while(token) {
337 hmap[token] = (TH1*) hiter->Next() ;
338 token = strtok(0,",") ;
339 }
340 importTH1Set(vars,*indexCat,hmap,initWgt,kFALSE) ;
341 } else {
342
343 // Initialize importing mapped set of RooDataHists
344 map<string,RooDataHist*> dmap ;
345 char tmp[1024] ;
346 strlcpy(tmp,impSliceDNames,1024) ;
347 char* token = strtok(tmp,",") ;
348 TIterator* hiter = impSliceDHistos.MakeIterator() ;
349 while(token) {
350 dmap[token] = (RooDataHist*) hiter->Next() ;
351 token = strtok(0,",") ;
352 }
353 importDHistSet(vars,*indexCat,dmap,initWgt) ;
354
355 }
356
357
358 } else {
359
360 // Initialize empty
361 initialize() ;
362 appendToDir(this,kTRUE) ;
363
364 }
365
368
369}
370
371
372
373
374////////////////////////////////////////////////////////////////////////////////
375/// Import data from given TH1/2/3 into this RooDataHist
376
377void RooDataHist::importTH1(const RooArgList& vars, const TH1& histo, Double_t wgt, Bool_t doDensityCorrection)
378{
379 // Adjust binning of internal observables to match that of input THx
380 Int_t offset[3]{0, 0, 0};
381 adjustBinning(vars, histo, offset) ;
382
383 // Initialize internal data structure
384 initialize() ;
385 appendToDir(this,kTRUE) ;
386
387 // Define x,y,z as 1st, 2nd and 3rd observable
388 RooRealVar* xvar = (RooRealVar*) _vars.find(vars.at(0)->GetName()) ;
389 RooRealVar* yvar = (RooRealVar*) (vars.at(1) ? _vars.find(vars.at(1)->GetName()) : 0 ) ;
390 RooRealVar* zvar = (RooRealVar*) (vars.at(2) ? _vars.find(vars.at(2)->GetName()) : 0 ) ;
391
392 // Transfer contents
393 Int_t xmin(0),ymin(0),zmin(0) ;
394 RooArgSet vset(*xvar) ;
395 Double_t volume = xvar->getMax()-xvar->getMin() ;
396 xmin = offset[0] ;
397 if (yvar) {
398 vset.add(*yvar) ;
399 ymin = offset[1] ;
400 volume *= (yvar->getMax()-yvar->getMin()) ;
401 }
402 if (zvar) {
403 vset.add(*zvar) ;
404 zmin = offset[2] ;
405 volume *= (zvar->getMax()-zvar->getMin()) ;
406 }
407 //Double_t avgBV = volume / numEntries() ;
408// cout << "average bin volume = " << avgBV << endl ;
409
410 Int_t ix(0),iy(0),iz(0) ;
411 for (ix=0 ; ix < xvar->getBins() ; ix++) {
412 xvar->setBin(ix) ;
413 if (yvar) {
414 for (iy=0 ; iy < yvar->getBins() ; iy++) {
415 yvar->setBin(iy) ;
416 if (zvar) {
417 for (iz=0 ; iz < zvar->getBins() ; iz++) {
418 zvar->setBin(iz) ;
419 Double_t bv = doDensityCorrection ? binVolume(vset) : 1;
420 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)) ;
421 }
422 } else {
423 Double_t bv = doDensityCorrection ? binVolume(vset) : 1;
424 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)) ;
425 }
426 }
427 } else {
428 Double_t bv = doDensityCorrection ? binVolume(vset) : 1 ;
429 add(vset,bv*histo.GetBinContent(ix+1+xmin)*wgt,bv*TMath::Power(histo.GetBinError(ix+1+xmin)*wgt,2)) ;
430 }
431 }
432
433}
434
435
436
437
438
439////////////////////////////////////////////////////////////////////////////////
440/// Import data from given set of TH1/2/3 into this RooDataHist. The category indexCat labels the sources
441/// in the constructed RooDataHist. The stl map provides the mapping between the indexCat state labels
442/// and the import source
443
444void RooDataHist::importTH1Set(const RooArgList& vars, RooCategory& indexCat, map<string,TH1*> hmap, Double_t wgt, Bool_t doDensityCorrection)
445{
446 RooCategory* icat = (RooCategory*) _vars.find(indexCat.GetName()) ;
447
448 TH1* histo(0) ;
450 for (map<string,TH1*>::iterator hiter = hmap.begin() ; hiter!=hmap.end() ; ++hiter) {
451 // Store pointer to first histogram from which binning specification will be taken
452 if (!histo) {
453 histo = hiter->second ;
454 }
455 // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
456 if (!indexCat.lookupType(hiter->first.c_str())) {
457 indexCat.defineType(hiter->first.c_str()) ;
458 coutI(InputArguments) << "RooDataHist::importTH1Set(" << GetName() << ") defining state \"" << hiter->first << "\" in index category " << indexCat.GetName() << endl ;
459 }
460 if (!icat->lookupType(hiter->first.c_str())) {
461 icat->defineType(hiter->first.c_str()) ;
462 }
463 }
464
465 // Check consistency in number of dimensions
466 if (histo && (vars.getSize() != histo->GetDimension())) {
467 coutE(InputArguments) << "RooDataHist::ctor(" << GetName() << ") ERROR: dimension of input histogram must match "
468 << "number of continuous variables" << endl ;
469 assert(0) ;
470 }
471
472 // Copy bins and ranges from THx to dimension observables
473 Int_t offset[3] ;
474 adjustBinning(vars,*histo,offset) ;
475
476 // Initialize internal data structure
477 if (!init) {
478 initialize() ;
479 appendToDir(this,kTRUE) ;
480 init = kTRUE ;
481 }
482
483 // Define x,y,z as 1st, 2nd and 3rd observable
484 RooRealVar* xvar = (RooRealVar*) _vars.find(vars.at(0)->GetName()) ;
485 RooRealVar* yvar = (RooRealVar*) (vars.at(1) ? _vars.find(vars.at(1)->GetName()) : 0 ) ;
486 RooRealVar* zvar = (RooRealVar*) (vars.at(2) ? _vars.find(vars.at(2)->GetName()) : 0 ) ;
487
488 // Transfer contents
489 Int_t xmin(0),ymin(0),zmin(0) ;
490 RooArgSet vset(*xvar) ;
491 Double_t volume = xvar->getMax()-xvar->getMin() ;
492 xmin = offset[0] ;
493 if (yvar) {
494 vset.add(*yvar) ;
495 ymin = offset[1] ;
496 volume *= (yvar->getMax()-yvar->getMin()) ;
497 }
498 if (zvar) {
499 vset.add(*zvar) ;
500 zmin = offset[2] ;
501 volume *= (zvar->getMax()-zvar->getMin()) ;
502 }
503 Double_t avgBV = volume / numEntries() ;
504
505 Int_t ic(0),ix(0),iy(0),iz(0) ;
506 for (ic=0 ; ic < icat->numBins(0) ; ic++) {
507 icat->setBin(ic) ;
508 histo = hmap[icat->getLabel()] ;
509 for (ix=0 ; ix < xvar->getBins() ; ix++) {
510 xvar->setBin(ix) ;
511 if (yvar) {
512 for (iy=0 ; iy < yvar->getBins() ; iy++) {
513 yvar->setBin(iy) ;
514 if (zvar) {
515 for (iz=0 ; iz < zvar->getBins() ; iz++) {
516 zvar->setBin(iz) ;
517 Double_t bv = doDensityCorrection ? binVolume(vset)/avgBV : 1;
518 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)) ;
519 }
520 } else {
521 Double_t bv = doDensityCorrection ? binVolume(vset)/avgBV : 1;
522 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)) ;
523 }
524 }
525 } else {
526 Double_t bv = doDensityCorrection ? binVolume(vset)/avgBV : 1;
527 add(vset,bv*histo->GetBinContent(ix+1+xmin)*wgt,bv*TMath::Power(histo->GetBinError(ix+1+xmin)*wgt,2)) ;
528 }
529 }
530 }
531
532}
533
534
535
536////////////////////////////////////////////////////////////////////////////////
537/// Import data from given set of TH1/2/3 into this RooDataHist. The category indexCat labels the sources
538/// in the constructed RooDataHist. The stl map provides the mapping between the indexCat state labels
539/// and the import source
540
541void RooDataHist::importDHistSet(const RooArgList& /*vars*/, RooCategory& indexCat, std::map<std::string,RooDataHist*> dmap, Double_t initWgt)
542{
543 RooCategory* icat = (RooCategory*) _vars.find(indexCat.GetName()) ;
544
545 for (map<string,RooDataHist*>::iterator diter = dmap.begin() ; diter!=dmap.end() ; ++diter) {
546
547 // Define state labels in index category (both in provided indexCat and in internal copy in dataset)
548 if (!indexCat.lookupType(diter->first.c_str())) {
549 indexCat.defineType(diter->first.c_str()) ;
550 coutI(InputArguments) << "RooDataHist::importDHistSet(" << GetName() << ") defining state \"" << diter->first << "\" in index category " << indexCat.GetName() << endl ;
551 }
552 if (!icat->lookupType(diter->first.c_str())) {
553 icat->defineType(diter->first.c_str()) ;
554 }
555 }
556
557 initialize() ;
558 appendToDir(this,kTRUE) ;
559
560
561 for (map<string,RooDataHist*>::iterator diter = dmap.begin() ; diter!=dmap.end() ; ++diter) {
562
563 RooDataHist* dhist = diter->second ;
564
565 icat->setLabel(diter->first.c_str()) ;
566
567 // Transfer contents
568 for (Int_t i=0 ; i<dhist->numEntries() ; i++) {
569 _vars = *dhist->get(i) ;
570 add(_vars,dhist->weight()*initWgt, pow(dhist->weightError(SumW2),2) ) ;
571 }
572
573 }
574}
575
576////////////////////////////////////////////////////////////////////////////////
577/// Helper doing the actual work of adjustBinning().
578
579void RooDataHist::_adjustBinning(RooRealVar &theirVar, const TAxis &axis,
580 RooRealVar *ourVar, Int_t *offset)
581{
582 if (!dynamic_cast<RooRealVar*>(ourVar)) {
583 coutE(InputArguments) << "RooDataHist::adjustBinning(" << GetName() << ") ERROR: dimension " << ourVar->GetName() << " must be real" << endl ;
584 assert(0) ;
585 }
586
587 const double xlo = theirVar.getMin();
588 const double xhi = theirVar.getMax();
589
590 if (axis.GetXbins()->GetArray()) {
591 RooBinning xbins(axis.GetNbins(), axis.GetXbins()->GetArray());
592
593 const double tolerance = 1e-6 * xbins.averageBinWidth();
594
595 // Adjust xlo/xhi to nearest boundary
596 const double xloAdj = xbins.binLow(xbins.binNumber(xlo + tolerance));
597 const double xhiAdj = xbins.binHigh(xbins.binNumber(xhi - tolerance));
598 xbins.setRange(xloAdj, xhiAdj);
599
600 theirVar.setBinning(xbins);
601
602 if (true || fabs(xloAdj - xlo) > tolerance || fabs(xhiAdj - xhi) > tolerance) {
603 coutI(DataHandling)<< "RooDataHist::adjustBinning(" << GetName() << "): fit range of variable " << ourVar->GetName() << " expanded to nearest bin boundaries: [" << xlo << "," << xhi << "] --> [" << xloAdj << "," << xhiAdj << "]" << endl;
604 }
605
606 ourVar->setBinning(xbins);
607
608 if (offset) {
609 *offset = xbins.rawBinNumber(xloAdj + tolerance);
610 }
611 } else {
612 RooBinning xbins(axis.GetXmin(), axis.GetXmax());
613 xbins.addUniform(axis.GetNbins(), axis.GetXmin(), axis.GetXmax());
614
615 const double tolerance = 1e-6 * xbins.averageBinWidth();
616
617 // Adjust xlo/xhi to nearest boundary
618 const double xloAdj = xbins.binLow(xbins.binNumber(xlo + tolerance));
619 const double xhiAdj = xbins.binHigh(xbins.binNumber(xhi - tolerance));
620 xbins.setRange(xloAdj, xhiAdj);
621 theirVar.setRange(xloAdj, xhiAdj);
622
623 if (fabs(xloAdj - xlo) > tolerance || fabs(xhiAdj - xhi) > tolerance) {
624 coutI(DataHandling)<< "RooDataHist::adjustBinning(" << GetName() << "): fit range of variable " << ourVar->GetName() << " expanded to nearest bin boundaries: [" << xlo << "," << xhi << "] --> [" << xloAdj << "," << xhiAdj << "]" << endl;
625 }
626
627 RooUniformBinning xbins2(xloAdj, xhiAdj, xbins.numBins());
628 ourVar->setBinning(xbins2);
629
630 if (offset) {
631 *offset = xbins.rawBinNumber(xloAdj + tolerance);
632 }
633 }
634}
635
636////////////////////////////////////////////////////////////////////////////////
637/// Adjust binning specification on first and optionally second and third
638/// observable to binning in given reference TH1. Used by constructors
639/// that import data from an external TH1.
640/// Both the variables in vars and in this RooDataHist are adjusted.
641/// @param List with variables that are supposed to have their binning adjusted.
642/// @param Reference histogram that dictates the binning
643/// @param offset If not nullptr, a possible bin count offset for the axes x,y,z is saved here as Int_t[3]
644
645void RooDataHist::adjustBinning(const RooArgList& vars, const TH1& href, Int_t* offset)
646{
647 auto xvar = static_cast<RooRealVar*>( _vars.find(*vars.at(0)) );
648 _adjustBinning(*static_cast<RooRealVar*>(vars.at(0)), *href.GetXaxis(), xvar, offset ? &offset[0] : nullptr);
649
650 if (vars.at(1)) {
651 auto yvar = static_cast<RooRealVar*>(_vars.find(*vars.at(1)));
652 if (yvar)
653 _adjustBinning(*static_cast<RooRealVar*>(vars.at(1)), *href.GetYaxis(), yvar, offset ? &offset[1] : nullptr);
654 }
655
656 if (vars.at(2)) {
657 auto zvar = static_cast<RooRealVar*>(_vars.find(*vars.at(2)));
658 if (zvar)
659 _adjustBinning(*static_cast<RooRealVar*>(vars.at(2)), *href.GetZaxis(), zvar, offset ? &offset[2] : nullptr);
660 }
661
662}
663
664
665
666
667
668////////////////////////////////////////////////////////////////////////////////
669/// Initialization procedure: allocate weights array, calculate
670/// multipliers needed for N-space to 1-dim array jump table,
671/// and fill the internal tree with all bin center coordinates
672
673void RooDataHist::initialize(const char* binningName, Bool_t fillTree)
674{
675
676 // Save real dimensions of dataset separately
677 RooAbsArg* real ;
678 _iterator->Reset() ;
679 while((real=(RooAbsArg*)_iterator->Next())) {
680 if (dynamic_cast<RooAbsReal*>(real)) _realVars.add(*real);
681 }
683
684 // Fill array of LValue pointers to variables
685 _iterator->Reset();
686 RooAbsArg* rvarg;
687 while((rvarg=(RooAbsArg*)_iterator->Next())) {
688 if (binningName) {
689 RooRealVar* rrv = dynamic_cast<RooRealVar*>(rvarg);
690 if (rrv) {
691 rrv->setBinning(rrv->getBinning(binningName));
692 }
693 }
694 // coverity[FORWARD_NULL]
695 _lvvars.push_back(dynamic_cast<RooAbsLValue*>(rvarg));
696 // coverity[FORWARD_NULL]
697 const RooAbsBinning* binning = dynamic_cast<RooAbsLValue*>(rvarg)->getBinningPtr(0);
698 _lvbins.push_back(binning ? binning->clone() : 0);
699 }
700
701
702 // Allocate coefficients array
703 _idxMult.resize(_vars.getSize()) ;
704
705 _arrSize = 1 ;
706 _iterator->Reset() ;
707 RooAbsLValue* arg ;
708 Int_t n(0), i ;
709 while((arg=dynamic_cast<RooAbsLValue*>(_iterator->Next()))) {
710
711 // Calculate sub-index multipliers for master index
712 for (i=0 ; i<n ; i++) {
713 _idxMult[i] *= arg->numBins() ;
714 }
715 _idxMult[n++] = 1 ;
716
717 // Calculate dimension of weight array
718 _arrSize *= arg->numBins() ;
719 }
720
721 // Allocate and initialize weight array if necessary
722 if (!_wgt) {
723 _wgt = new Double_t[_arrSize] ;
724 _errLo = new Double_t[_arrSize] ;
725 _errHi = new Double_t[_arrSize] ;
726 _sumw2 = new Double_t[_arrSize] ;
727 _binv = new Double_t[_arrSize] ;
728
729 // Refill array pointers in data store when reading
730 // from Streamer
731 if (fillTree==kFALSE) {
733 }
734
735 for (i=0 ; i<_arrSize ; i++) {
736 _wgt[i] = 0 ;
737 _errLo[i] = -1 ;
738 _errHi[i] = -1 ;
739 _sumw2[i] = 0 ;
740 }
741 }
742
743 if (!fillTree) return ;
744
745 // Fill TTree with bin center coordinates
746 // Calculate plot bins of components from master index
747
748 Int_t ibin ;
749 for (ibin=0 ; ibin<_arrSize ; ibin++) {
750 _iterator->Reset() ;
751 RooAbsLValue* arg2 ;
752 Int_t j(0), idx(0), tmp(ibin) ;
753 Double_t theBinVolume(1) ;
754 while((arg2=dynamic_cast<RooAbsLValue*>(_iterator->Next()))) {
755 idx = tmp / _idxMult[j] ;
756 tmp -= idx*_idxMult[j++] ;
757 RooAbsLValue* arglv = dynamic_cast<RooAbsLValue*>(arg2) ;
758 arglv->setBin(idx) ;
759 theBinVolume *= arglv->getBinWidth(idx) ;
760// cout << "init: bin width at idx=" << idx << " = " << arglv->getBinWidth(idx) << " binv[" << idx << "] = " << theBinVolume << endl ;
761 }
762 _binv[ibin] = theBinVolume ;
763// cout << "binv[" << ibin << "] = " << theBinVolume << endl ;
764 fill() ;
765 }
766
767
768}
769
770
771////////////////////////////////////////////////////////////////////////////////
772
774{
775 if (!_binbounds.empty()) return;
776 for (std::vector<const RooAbsBinning*>::const_iterator it = _lvbins.begin();
777 _lvbins.end() != it; ++it) {
778 _binbounds.push_back(std::vector<Double_t>());
779 if (*it) {
780 std::vector<Double_t>& bounds = _binbounds.back();
781 bounds.reserve(2 * (*it)->numBins());
782 for (Int_t i = 0; i < (*it)->numBins(); ++i) {
783 bounds.push_back((*it)->binLow(i));
784 bounds.push_back((*it)->binHigh(i));
785 }
786 }
787 }
788}
789
790////////////////////////////////////////////////////////////////////////////////
791/// Copy constructor
792
793RooDataHist::RooDataHist(const RooDataHist& other, const char* newname) :
794 RooAbsData(other,newname), RooDirItem(), _idxMult(other._idxMult), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(other._pbinvCacheMgr,0), _cache_sum_valid(0)
795{
796 Int_t i ;
797
798 // Allocate and initialize weight array
799 _arrSize = other._arrSize ;
800 _wgt = new Double_t[_arrSize] ;
801 _errLo = new Double_t[_arrSize] ;
802 _errHi = new Double_t[_arrSize] ;
803 _binv = new Double_t[_arrSize] ;
804 _sumw2 = new Double_t[_arrSize] ;
805 for (i=0 ; i<_arrSize ; i++) {
806 _wgt[i] = other._wgt[i] ;
807 _errLo[i] = other._errLo[i] ;
808 _errHi[i] = other._errHi[i] ;
809 _sumw2[i] = other._sumw2[i] ;
810 _binv[i] = other._binv[i] ;
811 }
812
813 // Save real dimensions of dataset separately
814 RooAbsArg* arg ;
815 _iterator->Reset() ;
816 while((arg=(RooAbsArg*)_iterator->Next())) {
817 if (dynamic_cast<RooAbsReal*>(arg)) _realVars.add(*arg) ;
818 }
820
821 // Fill array of LValue pointers to variables
822 _iterator->Reset() ;
823 RooAbsArg* rvarg ;
824 while((rvarg=(RooAbsArg*)_iterator->Next())) {
825 // coverity[FORWARD_NULL]
826 _lvvars.push_back(dynamic_cast<RooAbsLValue*>(rvarg)) ;
827 // coverity[FORWARD_NULL]
828 const RooAbsBinning* binning = dynamic_cast<RooAbsLValue*>(rvarg)->getBinningPtr(0) ;
829 _lvbins.push_back(binning ? binning->clone() : 0) ;
830 }
831
833
834 appendToDir(this,kTRUE) ;
835}
836
837
838
839////////////////////////////////////////////////////////////////////////////////
840/// Constructor of a data hist from (part of) an existing data hist. The dimensions
841/// of the data set are defined by the 'vars' RooArgSet, which can be identical
842/// to 'dset' dimensions, or a subset thereof. Reduced dimensions will be projected
843/// in the output data hist. The optional 'cutVar' formula variable can used to
844/// select the subset of bins to be copied.
845///
846/// For most uses the RooAbsData::reduce() wrapper function, which uses this constructor,
847/// is the most convenient way to create a subset of an existing data
848
849RooDataHist::RooDataHist(const char* name, const char* title, RooDataHist* h, const RooArgSet& varSubset,
850 const RooFormulaVar* cutVar, const char* cutRange, Int_t nStart, Int_t nStop, Bool_t copyCache) :
851 RooAbsData(name,title,varSubset),
852 _wgt(0), _binValid(0), _curWeight(0), _curVolume(1), _pbinv(0), _pbinvCacheMgr(0,10), _cache_sum_valid(0)
853{
854 // Initialize datastore
855 _dstore = new RooTreeDataStore(name,title,*h->_dstore,_vars,cutVar,cutRange,nStart,nStop,copyCache) ;
856
857 initialize(0,kFALSE) ;
858
860
861 // Copy weight array etc
862 Int_t i ;
863 for (i=0 ; i<_arrSize ; i++) {
864 _wgt[i] = h->_wgt[i] ;
865 _errLo[i] = h->_errLo[i] ;
866 _errHi[i] = h->_errHi[i] ;
867 _sumw2[i] = h->_sumw2[i] ;
868 _binv[i] = h->_binv[i] ;
869 }
870
871
872 appendToDir(this,kTRUE) ;
874}
875
876
877////////////////////////////////////////////////////////////////////////////////
878/// Construct a clone of this dataset that contains only the cached variables
879
880RooAbsData* RooDataHist::cacheClone(const RooAbsArg* newCacheOwner, const RooArgSet* newCacheVars, const char* newName)
881{
882 checkInit() ;
883
884 RooDataHist* dhist = new RooDataHist(newName?newName:GetName(),GetTitle(),this,*get(),0,0,0,2000000000,kTRUE) ;
885
886 RooArgSet* selCacheVars = (RooArgSet*) newCacheVars->selectCommon(dhist->_cachedVars) ;
887 dhist->attachCache(newCacheOwner, *selCacheVars) ;
888 delete selCacheVars ;
889
890 return dhist ;
891}
892
893
894
895////////////////////////////////////////////////////////////////////////////////
896/// Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods
897
898RooAbsData* RooDataHist::reduceEng(const RooArgSet& varSubset, const RooFormulaVar* cutVar, const char* cutRange,
899 Int_t nStart, Int_t nStop, Bool_t /*copyCache*/)
900{
901 checkInit() ;
902 RooArgSet* myVarSubset = (RooArgSet*) _vars.selectCommon(varSubset) ;
903 RooDataHist *rdh = new RooDataHist(GetName(), GetTitle(), *myVarSubset) ;
904 delete myVarSubset ;
905
906 RooFormulaVar* cloneVar = 0;
907 RooArgSet* tmp(0) ;
908 if (cutVar) {
909 // Deep clone cutVar and attach clone to this dataset
910 tmp = (RooArgSet*) RooArgSet(*cutVar).snapshot() ;
911 if (!tmp) {
912 coutE(DataHandling) << "RooDataHist::reduceEng(" << GetName() << ") Couldn't deep-clone cut variable, abort," << endl ;
913 return 0 ;
914 }
915 cloneVar = (RooFormulaVar*) tmp->find(*cutVar) ;
916 cloneVar->attachDataSet(*this) ;
917 }
918
919 Int_t i ;
920 Double_t lo,hi ;
921 Int_t nevt = nStop < numEntries() ? nStop : numEntries() ;
922 TIterator* vIter = get()->createIterator() ;
923 for (i=nStart ; i<nevt ; i++) {
924 const RooArgSet* row = get(i) ;
925
926 Bool_t doSelect(kTRUE) ;
927 if (cutRange) {
928 RooAbsArg* arg ;
929 vIter->Reset() ;
930 while((arg=(RooAbsArg*)vIter->Next())) {
931 if (!arg->inRange(cutRange)) {
932 doSelect = kFALSE ;
933 break ;
934 }
935 }
936 }
937 if (!doSelect) continue ;
938
939 if (!cloneVar || cloneVar->getVal()) {
940 weightError(lo,hi,SumW2) ;
941 rdh->add(*row,weight(),lo*lo) ;
942 }
943 }
944 delete vIter ;
945
946 if (cloneVar) {
947 delete tmp ;
948 }
949
950 return rdh ;
951 }
952
953
954
955////////////////////////////////////////////////////////////////////////////////
956/// Destructor
957
959{
960 if (_wgt) delete[] _wgt ;
961 if (_errLo) delete[] _errLo ;
962 if (_errHi) delete[] _errHi ;
963 if (_sumw2) delete[] _sumw2 ;
964 if (_binv) delete[] _binv ;
965 if (_realIter) delete _realIter ;
966 if (_binValid) delete[] _binValid ;
967 vector<const RooAbsBinning*>::iterator iter = _lvbins.begin() ;
968 while(iter!=_lvbins.end()) {
969 delete *iter ;
970 ++iter ;
971 }
972
973 removeFromDir(this) ;
975}
976
977
978
979
980////////////////////////////////////////////////////////////////////////////////
981
983{
984 checkInit() ;
985 if (fast) {
986 _vars.assignFast(coord,kFALSE) ;
987 } else {
988 _vars.assignValueOnly(coord) ;
989 }
990 return calcTreeIndex() ;
991}
992
993
994
995
996////////////////////////////////////////////////////////////////////////////////
997/// Calculate the index for the weights array corresponding to
998/// to the bin enclosing the current coordinates of the internal argset
999
1001{
1002 Int_t masterIdx(0), i(0) ;
1003 vector<RooAbsLValue*>::const_iterator iter = _lvvars.begin() ;
1004 vector<const RooAbsBinning*>::const_iterator biter = _lvbins.begin() ;
1005 for (;iter!=_lvvars.end() ; ++iter) {
1006 const RooAbsBinning* binning = (*biter) ;
1007 masterIdx += _idxMult[i++]*(*iter)->getBin(binning) ;
1008 ++biter ;
1009 }
1010 return masterIdx ;
1011}
1012
1013
1014
1015////////////////////////////////////////////////////////////////////////////////
1016/// Debug stuff, should go...
1017
1019{
1020 cout << "_arrSize = " << _arrSize << endl ;
1021 for (Int_t i=0 ; i<_arrSize ; i++) {
1022 cout << "wgt[" << i << "] = " << _wgt[i] << "sumw2[" << i << "] = " << _sumw2[i] << " vol[" << i << "] = " << _binv[i] << endl ;
1023 }
1024}
1025
1026
1027
1028////////////////////////////////////////////////////////////////////////////////
1029/// Back end function to plotting functionality. Plot RooDataHist on given
1030/// frame in mode specified by plot options 'o'. The main purpose of
1031/// this function is to match the specified binning on 'o' to the
1032/// internal binning of the plot observable in this RooDataHist.
1033
1035{
1036 checkInit() ;
1037 if (o.bins) return RooAbsData::plotOn(frame,o) ;
1038
1039 if(0 == frame) {
1040 coutE(InputArguments) << ClassName() << "::" << GetName() << ":plotOn: frame is null" << endl;
1041 return 0;
1042 }
1044 if(0 == var) {
1045 coutE(InputArguments) << ClassName() << "::" << GetName()
1046 << ":plotOn: frame does not specify a plot variable" << endl;
1047 return 0;
1048 }
1049
1050 RooRealVar* dataVar = (RooRealVar*) _vars.find(*var) ;
1051 if (!dataVar) {
1052 coutE(InputArguments) << ClassName() << "::" << GetName()
1053 << ":plotOn: dataset doesn't contain plot frame variable" << endl;
1054 return 0;
1055 }
1056
1057 o.bins = &dataVar->getBinning() ;
1059 return RooAbsData::plotOn(frame,o) ;
1060}
1061
1062
1063
1064
1065////////////////////////////////////////////////////////////////////////////////
1066
1068 return _curSumW2 ;
1069}
1070
1071
1072
1073////////////////////////////////////////////////////////////////////////////////
1074/// Return the weight at given coordinates with optional
1075/// interpolation. If intOrder is zero, the weight
1076/// for the bin enclosing the coordinates
1077/// contained in 'bin' is returned. For higher values,
1078/// the result is interpolated in the real dimensions
1079/// of the dataset
1080
1081Double_t RooDataHist::weight(const RooArgSet& bin, Int_t intOrder, Bool_t correctForBinSize, Bool_t cdfBoundaries, Bool_t oneSafe)
1082{
1083 //cout << "RooDataHist::weight(" << bin << "," << intOrder << "," << correctForBinSize << "," << cdfBoundaries << "," << oneSafe << ")" << endl ;
1084
1085 checkInit() ;
1086
1087 // Handle illegal intOrder values
1088 if (intOrder<0) {
1089 coutE(InputArguments) << "RooDataHist::weight(" << GetName() << ") ERROR: interpolation order must be positive" << endl ;
1090 return 0 ;
1091 }
1092
1093 // Handle no-interpolation case
1094 if (intOrder==0) {
1095 _vars.assignValueOnly(bin,oneSafe) ;
1096 Int_t idx = calcTreeIndex() ;
1097 //cout << "intOrder 0, idx = " << idx << endl ;
1098 if (correctForBinSize) {
1099 //calculatePartialBinVolume(*get()) ;
1100 //cout << "binw[" << idx << "] = " << _wgt[idx] << " / " << _binv[idx] << endl ;
1101 return get_wgt(idx) / _binv[idx];
1102 } else {
1103 //cout << "binw[" << idx << "] = " << _wgt[idx] << endl ;
1104 return get_wgt(idx);
1105 }
1106 }
1107
1108 // Handle all interpolation cases
1109 _vars.assignValueOnly(bin) ;
1110
1111 Double_t wInt(0) ;
1112 if (_realVars.getSize()==1) {
1113
1114 // 1-dimensional interpolation
1115 RooFIter realIter = _realVars.fwdIterator() ;
1116 RooRealVar* real=(RooRealVar*)realIter.next() ;
1117 const RooAbsBinning* binning = real->getBinningPtr(0) ;
1118 wInt = interpolateDim(*real,binning,((RooAbsReal*)bin.find(*real))->getVal(), intOrder, correctForBinSize, cdfBoundaries) ;
1119
1120 } else if (_realVars.getSize()==2) {
1121
1122 // 2-dimensional interpolation
1123 RooFIter realIter = _realVars.fwdIterator() ;
1124 RooRealVar* realX=(RooRealVar*)realIter.next() ;
1125 RooRealVar* realY=(RooRealVar*)realIter.next() ;
1126 Double_t xval = ((RooAbsReal*)bin.find(*realX))->getVal() ;
1127 Double_t yval = ((RooAbsReal*)bin.find(*realY))->getVal() ;
1128
1129 Int_t ybinC = realY->getBin() ;
1130 Int_t ybinLo = ybinC-intOrder/2 - ((yval<realY->getBinning().binCenter(ybinC))?1:0) ;
1131 Int_t ybinM = realY->numBins() ;
1132
1133 Int_t i ;
1134 Double_t yarr[10] ;
1135 Double_t xarr[10] ;
1136 const RooAbsBinning* binning = realX->getBinningPtr(0) ;
1137 for (i=ybinLo ; i<=intOrder+ybinLo ; i++) {
1138 Int_t ibin ;
1139 if (i>=0 && i<ybinM) {
1140 // In range
1141 ibin = i ;
1142 realY->setBin(ibin) ;
1143 xarr[i-ybinLo] = realY->getVal() ;
1144 } else if (i>=ybinM) {
1145 // Overflow: mirror
1146 ibin = 2*ybinM-i-1 ;
1147 realY->setBin(ibin) ;
1148 xarr[i-ybinLo] = 2*realY->getMax()-realY->getVal() ;
1149 } else {
1150 // Underflow: mirror
1151 ibin = -i -1;
1152 realY->setBin(ibin) ;
1153 xarr[i-ybinLo] = 2*realY->getMin()-realY->getVal() ;
1154 }
1155 yarr[i-ybinLo] = interpolateDim(*realX,binning,xval,intOrder,correctForBinSize,kFALSE) ;
1156 }
1157
1158 if (gDebug>7) {
1159 cout << "RooDataHist interpolating data is" << endl ;
1160 cout << "xarr = " ;
1161 for (int q=0; q<=intOrder ; q++) cout << xarr[q] << " " ;
1162 cout << " yarr = " ;
1163 for (int q=0; q<=intOrder ; q++) cout << yarr[q] << " " ;
1164 cout << endl ;
1165 }
1166 wInt = RooMath::interpolate(xarr,yarr,intOrder+1,yval) ;
1167
1168 } else {
1169
1170 // Higher dimensional scenarios not yet implemented
1171 coutE(InputArguments) << "RooDataHist::weight(" << GetName() << ") interpolation in "
1172 << _realVars.getSize() << " dimensions not yet implemented" << endl ;
1173 return weight(bin,0) ;
1174
1175 }
1176
1177 // Cut off negative values
1178// if (wInt<=0) {
1179// wInt=0 ;
1180// }
1181
1182 //cout << "RooDataHist wInt = " << wInt << endl ;
1183 return wInt ;
1184}
1185
1186
1187
1188
1189////////////////////////////////////////////////////////////////////////////////
1190/// Return the error on current weight
1191
1193{
1194 checkInit() ;
1195
1196 switch (etype) {
1197
1198 case Auto:
1199 throw string(Form("RooDataHist::weightError(%s) error type Auto not allowed here",GetName())) ;
1200 break ;
1201
1202 case Expected:
1203 throw string(Form("RooDataHist::weightError(%s) error type Expected not allowed here",GetName())) ;
1204 break ;
1205
1206 case Poisson:
1207 if (_curWgtErrLo>=0) {
1208 // Weight is preset or precalculated
1209 lo = _curWgtErrLo ;
1210 hi = _curWgtErrHi ;
1211 return ;
1212 }
1213
1214 // Calculate poisson errors
1215 Double_t ym,yp ;
1217 _curWgtErrLo = weight()-ym ;
1218 _curWgtErrHi = yp-weight() ;
1221 lo = _curWgtErrLo ;
1222 hi = _curWgtErrHi ;
1223 return ;
1224
1225 case SumW2:
1226 lo = sqrt(_curSumW2) ;
1227 hi = sqrt(_curSumW2) ;
1228 return ;
1229
1230 case None:
1231 lo = 0 ;
1232 hi = 0 ;
1233 return ;
1234 }
1235}
1236
1237
1238// wve adjust for variable bin sizes
1239
1240////////////////////////////////////////////////////////////////////////////////
1241/// Perform boundary safe 'intOrder'-th interpolation of weights in dimension 'dim'
1242/// at current value 'xval'
1243
1244Double_t RooDataHist::interpolateDim(RooRealVar& dim, const RooAbsBinning* binning, Double_t xval, Int_t intOrder, Bool_t correctForBinSize, Bool_t cdfBoundaries)
1245{
1246 // Fill workspace arrays spanning interpolation area
1247 Int_t fbinC = dim.getBin(*binning) ;
1248 Int_t fbinLo = fbinC-intOrder/2 - ((xval<binning->binCenter(fbinC))?1:0) ;
1249 Int_t fbinM = dim.numBins(*binning) ;
1250
1251
1252 Int_t i ;
1253 Double_t yarr[10] ;
1254 Double_t xarr[10] ;
1255 for (i=fbinLo ; i<=intOrder+fbinLo ; i++) {
1256 Int_t ibin ;
1257 if (i>=0 && i<fbinM) {
1258 // In range
1259 ibin = i ;
1260 dim.setBinFast(ibin,*binning) ;
1261 //cout << "INRANGE: dim.getVal(ibin=" << ibin << ") = " << dim.getVal() << endl ;
1262 xarr[i-fbinLo] = dim.getVal() ;
1263 Int_t idx = calcTreeIndex();
1264 yarr[i - fbinLo] = get_wgt(idx);
1265 if (correctForBinSize) yarr[i-fbinLo] /= _binv[idx] ;
1266 } else if (i>=fbinM) {
1267 // Overflow: mirror
1268 ibin = 2*fbinM-i-1 ;
1269 dim.setBinFast(ibin,*binning) ;
1270 //cout << "OVERFLOW: dim.getVal(ibin=" << ibin << ") = " << dim.getVal() << endl ;
1271 if (cdfBoundaries) {
1272 xarr[i-fbinLo] = dim.getMax()+1e-10*(i-fbinM+1) ;
1273 yarr[i-fbinLo] = 1.0 ;
1274 } else {
1275 Int_t idx = calcTreeIndex() ;
1276 xarr[i-fbinLo] = 2*dim.getMax()-dim.getVal() ;
1277 yarr[i - fbinLo] = get_wgt(idx);
1278 if (correctForBinSize)
1279 yarr[i - fbinLo] /= _binv[idx];
1280 }
1281 } else {
1282 // Underflow: mirror
1283 ibin = -i - 1 ;
1284 dim.setBinFast(ibin,*binning) ;
1285 //cout << "UNDERFLOW: dim.getVal(ibin=" << ibin << ") = " << dim.getVal() << endl ;
1286 if (cdfBoundaries) {
1287 xarr[i-fbinLo] = dim.getMin()-ibin*(1e-10) ; ;
1288 yarr[i-fbinLo] = 0.0 ;
1289 } else {
1290 Int_t idx = calcTreeIndex() ;
1291 xarr[i-fbinLo] = 2*dim.getMin()-dim.getVal() ;
1292 yarr[i - fbinLo] = get_wgt(idx);
1293 if (correctForBinSize)
1294 yarr[i - fbinLo] /= _binv[idx];
1295 }
1296 }
1297 //cout << "ibin = " << ibin << endl ;
1298 }
1299// for (int k=0 ; k<=intOrder ; k++) {
1300// cout << "k=" << k << " x = " << xarr[k] << " y = " << yarr[k] << endl ;
1301// }
1302 dim.setBinFast(fbinC,*binning) ;
1303 Double_t ret = RooMath::interpolate(xarr,yarr,intOrder+1,xval) ;
1304 return ret ;
1305}
1306
1307
1308
1309
1310////////////////////////////////////////////////////////////////////////////////
1311/// Increment the weight of the bin enclosing the coordinates given
1312/// by 'row' by the specified amount. Add the sum of weights squared
1313/// for the bin by 'sumw2' rather than wgt^2
1314
1315void RooDataHist::add(const RooArgSet& row, Double_t wgt, Double_t sumw2)
1316{
1317 checkInit() ;
1318
1319// cout << "RooDataHist::add() accepted coordinate is " << endl ;
1320// _vars.Print("v") ;
1321
1322 _vars = row ;
1323 Int_t idx = calcTreeIndex() ;
1324 _wgt[idx] += wgt ;
1325 _sumw2[idx] += (sumw2>0?sumw2:wgt*wgt) ;
1326 _errLo[idx] = -1 ;
1327 _errHi[idx] = -1 ;
1328
1330}
1331
1332
1333
1334////////////////////////////////////////////////////////////////////////////////
1335/// Increment the weight of the bin enclosing the coordinates
1336/// given by 'row' by the specified amount. Associate errors
1337/// [wgtErrLo,wgtErrHi] with the event weight on this bin.
1338
1339void RooDataHist::set(const RooArgSet& row, Double_t wgt, Double_t wgtErrLo, Double_t wgtErrHi)
1340{
1341 checkInit() ;
1342
1343 _vars = row ;
1344 Int_t idx = calcTreeIndex() ;
1345 _wgt[idx] = wgt ;
1346 _errLo[idx] = wgtErrLo ;
1347 _errHi[idx] = wgtErrHi ;
1348
1350}
1351
1352
1353
1354////////////////////////////////////////////////////////////////////////////////
1355/// Increment the weight of the bin enclosing the coordinates
1356/// given by 'row' by the specified amount. Associate errors
1357/// [wgtErrLo,wgtErrHi] with the event weight on this bin.
1358
1360{
1361 checkInit() ;
1362
1363 if (_curIndex<0) {
1365 }
1366
1367 _wgt[_curIndex] = wgt ;
1368 _errLo[_curIndex] = wgtErr ;
1369 _errHi[_curIndex] = wgtErr ;
1370 _sumw2[_curIndex] = wgtErr*wgtErr ;
1371
1373}
1374
1375
1376
1377////////////////////////////////////////////////////////////////////////////////
1378/// Increment the weight of the bin enclosing the coordinates
1379/// given by 'row' by the specified amount. Associate errors
1380/// [wgtErrLo,wgtErrHi] with the event weight on this bin.
1381
1382void RooDataHist::set(const RooArgSet& row, Double_t wgt, Double_t wgtErr)
1383{
1384 checkInit() ;
1385
1386 _vars = row ;
1387 Int_t idx = calcTreeIndex() ;
1388 _wgt[idx] = wgt ;
1389 _errLo[idx] = wgtErr ;
1390 _errHi[idx] = wgtErr ;
1391 _sumw2[idx] = wgtErr*wgtErr ;
1392
1394}
1395
1396
1397
1398////////////////////////////////////////////////////////////////////////////////
1399/// Add all data points contained in 'dset' to this data set with given weight.
1400/// Optional cut string expression selects the data points to be added and can
1401/// reference any variable contained in this data set
1402
1403void RooDataHist::add(const RooAbsData& dset, const char* cut, Double_t wgt)
1404{
1405 RooFormulaVar cutVar("select",cut,*dset.get()) ;
1406 add(dset,&cutVar,wgt) ;
1407}
1408
1409
1410
1411////////////////////////////////////////////////////////////////////////////////
1412/// Add all data points contained in 'dset' to this data set with given weight.
1413/// Optional RooFormulaVar pointer selects the data points to be added.
1414
1415void RooDataHist::add(const RooAbsData& dset, const RooFormulaVar* cutVar, Double_t wgt)
1416{
1417 checkInit() ;
1418
1419 RooFormulaVar* cloneVar = 0;
1420 RooArgSet* tmp(0) ;
1421 if (cutVar) {
1422 // Deep clone cutVar and attach clone to this dataset
1423 tmp = (RooArgSet*) RooArgSet(*cutVar).snapshot() ;
1424 if (!tmp) {
1425 coutE(DataHandling) << "RooDataHist::add(" << GetName() << ") Couldn't deep-clone cut variable, abort," << endl ;
1426 return ;
1427 }
1428
1429 cloneVar = (RooFormulaVar*) tmp->find(*cutVar) ;
1430 cloneVar->attachDataSet(dset) ;
1431 }
1432
1433
1434 Int_t i ;
1435 for (i=0 ; i<dset.numEntries() ; i++) {
1436 const RooArgSet* row = dset.get(i) ;
1437 if (!cloneVar || cloneVar->getVal()) {
1438 add(*row,wgt*dset.weight(), wgt*wgt*dset.weightSquared()) ;
1439 }
1440 }
1441
1442 if (cloneVar) {
1443 delete tmp ;
1444 }
1445
1447}
1448
1449
1450
1451////////////////////////////////////////////////////////////////////////////////
1452/// Return the sum of the weights of all hist bins.
1453///
1454/// If correctForBinSize is specified, the sum of weights
1455/// is multiplied by the N-dimensional bin volume,
1456/// making the return value the integral over the function
1457/// represented by this histogram
1458
1459Double_t RooDataHist::sum(Bool_t correctForBinSize, Bool_t inverseBinCor) const
1460{
1461 checkInit() ;
1462
1463 // Check if result was cached
1464 Int_t cache_code = 1 + (correctForBinSize?1:0) + ((correctForBinSize&&inverseBinCor)?1:0) ;
1465 if (_cache_sum_valid==cache_code) {
1466 return _cache_sum ;
1467 }
1468
1469 Int_t i ;
1470 Double_t total(0), carry(0);
1471 for (i=0 ; i<_arrSize ; i++) {
1472
1473 Double_t theBinVolume = correctForBinSize ? (inverseBinCor ? 1/_binv[i] : _binv[i]) : 1.0 ;
1474 // cout << "total += " << _wgt[i] << "*" << theBinVolume << endl ;
1475 // Double_t y = _wgt[i]*theBinVolume - carry;
1476 Double_t y = get_wgt(i) * theBinVolume - carry;
1477 Double_t t = total + y;
1478 carry = (t - total) - y;
1479 total = t;
1480 }
1481
1482 // Store result in cache
1483 _cache_sum_valid=cache_code ;
1484 _cache_sum = total ;
1485
1486 return total ;
1487}
1488
1489
1490
1491////////////////////////////////////////////////////////////////////////////////
1492/// Return the sum of the weights of a multi-dimensional slice of the histogram
1493/// by summing only over the dimensions specified in sumSet.
1494///
1495/// The coordinates of all other dimensions are fixed to those given in sliceSet
1496///
1497/// If correctForBinSize is specified, the sum of weights
1498/// is multiplied by the M-dimensional bin volume, (M = N(sumSet)),
1499/// making the return value the integral over the function
1500/// represented by this histogram
1501
1502Double_t RooDataHist::sum(const RooArgSet& sumSet, const RooArgSet& sliceSet, Bool_t correctForBinSize, Bool_t inverseBinCor)
1503{
1504 checkInit() ;
1505
1506 RooArgSet varSave ;
1507 varSave.addClone(_vars) ;
1508
1509 RooArgSet* sliceOnlySet = new RooArgSet(sliceSet) ;
1510 sliceOnlySet->remove(sumSet,kTRUE,kTRUE) ;
1511
1512 _vars = *sliceOnlySet ;
1513 calculatePartialBinVolume(*sliceOnlySet) ;
1514 delete sliceOnlySet ;
1515
1516 TIterator* ssIter = sumSet.createIterator() ;
1517
1518 // Calculate mask and refence plot bins for non-iterating variables
1519 RooAbsArg* arg ;
1520 Bool_t* mask = new Bool_t[_vars.getSize()] ;
1521 Int_t* refBin = new Int_t[_vars.getSize()] ;
1522
1523 Int_t i(0) ;
1524 _iterator->Reset() ;
1525 while((arg=(RooAbsArg*)_iterator->Next())) {
1526 if (sumSet.find(*arg)) {
1527 mask[i] = kFALSE ;
1528 } else {
1529 mask[i] = kTRUE ;
1530 // coverity[FORWARD_NULL]
1531 refBin[i] = (dynamic_cast<RooAbsLValue*>(arg))->getBin() ;
1532 }
1533 i++ ;
1534 }
1535
1536 // Loop over entire data set, skipping masked entries
1537 Double_t total(0), carry(0);
1538 Int_t ibin ;
1539 for (ibin=0 ; ibin<_arrSize ; ibin++) {
1540
1541 Int_t idx(0), tmp(ibin), ivar(0) ;
1542 Bool_t skip(kFALSE) ;
1543
1544 // Check if this bin belongs in selected slice
1545 _iterator->Reset() ;
1546 // coverity[UNUSED_VALUE]
1547 while((!skip && (arg=(RooAbsArg*)_iterator->Next()))) {
1548 idx = tmp / _idxMult[ivar] ;
1549 tmp -= idx*_idxMult[ivar] ;
1550 if (mask[ivar] && idx!=refBin[ivar]) skip=kTRUE ;
1551 ivar++ ;
1552 }
1553
1554 if (!skip) {
1555 Double_t theBinVolume = correctForBinSize ? (inverseBinCor ? 1/(*_pbinv)[i] : (*_pbinv)[i] ) : 1.0 ;
1556 // cout << "adding bin[" << ibin << "] to sum wgt = " << _wgt[ibin] << " binv = " << theBinVolume << endl ;
1557 // Double_t y = _wgt[ibin]*theBinVolume - carry;
1558 Double_t y = get_wgt(ibin) * theBinVolume - carry;
1559 Double_t t = total + y;
1560 carry = (t - total) - y;
1561 total = t;
1562 }
1563 }
1564 delete ssIter ;
1565
1566 delete[] mask ;
1567 delete[] refBin ;
1568
1569 _vars = varSave ;
1570
1571 return total ;
1572}
1573
1574////////////////////////////////////////////////////////////////////////////////
1575/// Return the sum of the weights of a multi-dimensional slice of the histogram
1576/// by summing only over the dimensions specified in sumSet.
1577///
1578/// The coordinates of all other dimensions are fixed to those given in sliceSet
1579///
1580/// If correctForBinSize is specified, the sum of weights
1581/// is multiplied by the M-dimensional bin volume, (M = N(sumSet)),
1582/// or the fraction of it that falls inside the range rangeName,
1583/// making the return value the integral over the function
1584/// represented by this histogram
1585///
1586/// If correctForBinSize is not specified, the weights are multiplied by the
1587/// fraction of the bin volume that falls inside the range, i.e. a factor or
1588/// binVolumeInRange/totalBinVolume.
1589
1590Double_t RooDataHist::sum(const RooArgSet& sumSet, const RooArgSet& sliceSet,
1591 Bool_t correctForBinSize, Bool_t inverseBinCor,
1592 const std::map<const RooAbsArg*, std::pair<Double_t, Double_t> >& ranges)
1593{
1594 checkInit();
1596 RooArgSet varSave;
1597 varSave.addClone(_vars);
1598 {
1599 RooArgSet sliceOnlySet(sliceSet);
1600 sliceOnlySet.remove(sumSet,kTRUE,kTRUE);
1601 _vars = sliceOnlySet;
1602 }
1603
1604 // Calculate mask and refence plot bins for non-iterating variables,
1605 // and get ranges for iterating variables
1606 std::vector<bool> mask(_vars.getSize());
1607 std::vector<Int_t> refBin(_vars.getSize());
1608 std::vector<Double_t> rangeLo(_vars.getSize(), -std::numeric_limits<Double_t>::infinity());
1609 std::vector<Double_t> rangeHi(_vars.getSize(), +std::numeric_limits<Double_t>::infinity());
1610
1611 _iterator->Reset();
1612 RooAbsArg* arg;
1613 for (Int_t i = 0; (arg=(RooAbsArg*)_iterator->Next()); ++i) {
1614 RooAbsArg* sumsetv = sumSet.find(*arg);
1615 RooAbsArg* slicesetv = sliceSet.find(*arg);
1616 mask[i] = !sumsetv;
1617 if (mask[i]) {
1618 // coverity[FORWARD_NULL]
1619 refBin[i] = (dynamic_cast<RooAbsLValue*>(arg))->getBin();
1620 }
1621 std::map<const RooAbsArg*, std::pair<Double_t, Double_t> >::const_iterator
1622 it = ranges.find(sumsetv ? sumsetv : slicesetv);
1623 if (ranges.end() != it) {
1624 rangeLo[i] = it->second.first;
1625 rangeHi[i] = it->second.second;
1626 }
1627 }
1628
1629 // Loop over entire data set, skipping masked entries
1630 Double_t total(0), carry(0);
1631 for (Int_t ibin = 0; ibin < _arrSize; ++ibin) {
1632 // Check if this bin belongs in selected slice
1633 _iterator->Reset();
1634 Bool_t skip(kFALSE);
1635 // coverity[UNUSED_VALUE]
1636 for (Int_t ivar = 0, tmp = ibin;
1637 (!skip && (arg=(RooAbsArg*)_iterator->Next())); ++ivar) {
1638 const Int_t idx = tmp / _idxMult[ivar];
1639 tmp -= idx*_idxMult[ivar];
1640 if (mask[ivar] && idx!=refBin[ivar]) skip=kTRUE;
1641 }
1642 if (skip) continue;
1643 _iterator->Reset();
1644 // work out bin volume
1645 Double_t theBinVolume = 1.;
1646 for (Int_t ivar = 0, tmp = ibin;
1647 (arg=(RooAbsArg*)_iterator->Next()); ++ivar) {
1648 const Int_t idx = tmp / _idxMult[ivar];
1649 tmp -= idx*_idxMult[ivar];
1650 if (_binbounds[ivar].empty()) continue;
1651 const Double_t binLo = _binbounds[ivar][2 * idx];
1652 const Double_t binHi = _binbounds[ivar][2 * idx + 1];
1653 if (binHi < rangeLo[ivar] || binLo > rangeHi[ivar]) {
1654 // bin is outside of allowed range - effective bin volume is zero
1655 theBinVolume = 0.;
1656 break;
1657 }
1658 theBinVolume *=
1659 (std::min(rangeHi[ivar], binHi) - std::max(rangeLo[ivar], binLo));
1660 }
1661 const Double_t corrPartial = theBinVolume / _binv[ibin];
1662 if (0. == corrPartial) continue;
1663 const Double_t corr = correctForBinSize ? (inverseBinCor ? 1. / _binv[ibin] : _binv[ibin] ) : 1.0;
1664 //cout << "adding bin[" << ibin << "] to sum wgt = " << _wgt[ibin] << " binv = " << theBinVolume << " _binv[" << ibin << "] " << _binv[ibin] << endl;
1665 // const Double_t y = _wgt[ibin] * corr * corrPartial - carry;
1666 const Double_t y = get_wgt(ibin) * corr * corrPartial - carry;
1667 const Double_t t = total + y;
1668 carry = (t - total) - y;
1669 total = t;
1670 }
1671
1672 _vars = varSave;
1673
1674 return total;
1675}
1676
1677
1678
1679////////////////////////////////////////////////////////////////////////////////
1680/// Fill the transient cache with partial bin volumes with up-to-date
1681/// values for the partial volume specified by observables 'dimSet'
1682
1684{
1685 // Allocate cache if not yet existing
1686 vector<Double_t> *pbinv = _pbinvCacheMgr.getObj(&dimSet) ;
1687 if (pbinv) {
1688 _pbinv = pbinv ;
1689 return ;
1690 }
1691
1692 pbinv = new vector<Double_t>(_arrSize) ;
1693
1694 // Calculate plot bins of components from master index
1695 Bool_t* selDim = new Bool_t[_vars.getSize()] ;
1696 _iterator->Reset() ;
1697 RooAbsArg* v ;
1698 Int_t i(0) ;
1699 while((v=(RooAbsArg*)_iterator->Next())) {
1700 selDim[i++] = dimSet.find(*v) ? kTRUE : kFALSE ;
1701 }
1702
1703 // Recalculate partial bin volume cache
1704 Int_t ibin ;
1705 for (ibin=0 ; ibin<_arrSize ; ibin++) {
1706 _iterator->Reset() ;
1707 RooAbsLValue* arg ;
1708 Int_t j(0), idx(0), tmp(ibin) ;
1709 Double_t theBinVolume(1) ;
1710 while((arg=dynamic_cast<RooAbsLValue*>(_iterator->Next()))) {
1711 idx = tmp / _idxMult[j] ;
1712 tmp -= idx*_idxMult[j++] ;
1713 if (selDim[j-1]) {
1714 RooAbsLValue* arglv = dynamic_cast<RooAbsLValue*>(arg) ;
1715 theBinVolume *= arglv->getBinWidth(idx) ;
1716 }
1717 }
1718 (*pbinv)[ibin] = theBinVolume ;
1719 }
1720
1721 delete[] selDim ;
1722
1723 // Put in cache (which takes ownership)
1724 _pbinvCacheMgr.setObj(&dimSet,pbinv) ;
1725
1726 // Publicize the array
1727 _pbinv = pbinv ;
1728}
1729
1730
1731
1732////////////////////////////////////////////////////////////////////////////////
1733/// Return the number of bins
1734
1736{
1737 return RooAbsData::numEntries() ;
1738}
1739
1740
1741
1742////////////////////////////////////////////////////////////////////////////////
1743
1745{
1746 Int_t i ;
1747 Double_t n(0), carry(0);
1748 for (i=0 ; i<_arrSize ; i++) {
1749 if (!_binValid || _binValid[i]) {
1750 // Double_t y = _wgt[i] - carry;
1751 Double_t y = get_wgt(i) - carry;
1752 Double_t t = n + y;
1753 carry = (t - n) - y;
1754 n = t;
1755 }
1756 }
1757 return n ;
1758}
1759
1760
1761
1762////////////////////////////////////////////////////////////////////////////////
1763/// Return the sum of weights in all entries matching cutSpec (if specified)
1764/// and in named range cutRange (if specified)
1765/// Return the
1766
1767Double_t RooDataHist::sumEntries(const char* cutSpec, const char* cutRange) const
1768{
1769 checkInit() ;
1770
1771 if (cutSpec==0 && cutRange==0) {
1772 return sumEntries();
1773 } else {
1774
1775 // Setup RooFormulaVar for cutSpec if it is present
1776 RooFormula* select = 0 ;
1777 if (cutSpec) {
1778 select = new RooFormula("select",cutSpec,*get()) ;
1779 }
1780
1781 // Otherwise sum the weights in the event
1782 Double_t sumw(0), carry(0);
1783 Int_t i ;
1784 for (i=0 ; i<numEntries() ; i++) {
1785 get(i) ;
1786 if (select && select->eval()==0.) continue ;
1787 if (cutRange && !_vars.allInRange(cutRange)) continue ;
1788
1789 if (!_binValid || _binValid[i]) {
1790 Double_t y = weight() - carry;
1791 Double_t t = sumw + y;
1792 carry = (t - sumw) - y;
1793 sumw = t;
1794 }
1795 }
1796
1797 if (select) delete select ;
1798
1799 return sumw ;
1800 }
1801}
1802
1803
1804
1805////////////////////////////////////////////////////////////////////////////////
1806/// Reset all bin weights to zero
1807
1809{
1810 // WVE DO NOT CALL RooTreeData::reset() for binned
1811 // datasets as this will delete the bin definitions
1812
1813 Int_t i ;
1814 for (i=0 ; i<_arrSize ; i++) {
1815 _wgt[i] = 0. ;
1816 _errLo[i] = -1 ;
1817 _errHi[i] = -1 ;
1818 }
1819 _curWeight = 0 ;
1820 _curWgtErrLo = -1 ;
1821 _curWgtErrHi = -1 ;
1822 _curVolume = 1 ;
1823
1825
1826}
1827
1828
1829
1830////////////////////////////////////////////////////////////////////////////////
1831/// Return an argset with the bin center coordinates for
1832/// bin sequential number 'masterIdx'. For iterative use.
1833
1834const RooArgSet* RooDataHist::get(Int_t masterIdx) const
1835{
1836 checkInit() ;
1837 _curWeight = _wgt[masterIdx] ;
1838 _curWgtErrLo = _errLo[masterIdx] ;
1839 _curWgtErrHi = _errHi[masterIdx] ;
1840 _curSumW2 = _sumw2[masterIdx] ;
1841 _curVolume = _binv[masterIdx] ;
1842 _curIndex = masterIdx ;
1843 return RooAbsData::get(masterIdx) ;
1844}
1845
1846
1847
1848////////////////////////////////////////////////////////////////////////////////
1849/// Return a RooArgSet with center coordinates of the bin
1850/// enclosing the point 'coord'
1851
1852const RooArgSet* RooDataHist::get(const RooArgSet& coord) const
1853{
1854 ((RooDataHist*)this)->_vars = coord ;
1855 return get(calcTreeIndex()) ;
1856}
1857
1858
1859
1860////////////////////////////////////////////////////////////////////////////////
1861/// Return the volume of the bin enclosing coordinates 'coord'
1862
1864{
1865 checkInit() ;
1866 ((RooDataHist*)this)->_vars = coord ;
1867 return _binv[calcTreeIndex()] ;
1868}
1869
1870
1871////////////////////////////////////////////////////////////////////////////////
1872/// Set all the event weight of all bins to the specified value
1873
1875{
1876 for (Int_t i=0 ; i<_arrSize ; i++) {
1877 _wgt[i] = value ;
1878 }
1879
1881}
1882
1883
1884
1885////////////////////////////////////////////////////////////////////////////////
1886/// Create an iterator over all bins in a slice defined by the subset of observables
1887/// listed in sliceArg. The position of the slice is given by otherArgs
1888
1890{
1891 // Update to current position
1892 _vars = otherArgs ;
1894
1895 RooAbsArg* intArg = _vars.find(sliceArg) ;
1896 if (!intArg) {
1897 coutE(InputArguments) << "RooDataHist::sliceIterator() variable " << sliceArg.GetName() << " is not part of this RooDataHist" << endl ;
1898 return 0 ;
1899 }
1900 return new RooDataHistSliceIter(*this,*intArg) ;
1901}
1902
1903
1904////////////////////////////////////////////////////////////////////////////////
1905/// Change the name of the RooDataHist
1906
1907void RooDataHist::SetName(const char *name)
1908{
1909 if (_dir) _dir->GetList()->Remove(this);
1911 if (_dir) _dir->GetList()->Add(this);
1912}
1913
1914
1915////////////////////////////////////////////////////////////////////////////////
1916/// Change the title of this RooDataHist
1917
1918void RooDataHist::SetNameTitle(const char *name, const char* title)
1919{
1920 if (_dir) _dir->GetList()->Remove(this);
1921 TNamed::SetNameTitle(name,title) ;
1922 if (_dir) _dir->GetList()->Add(this);
1923}
1924
1925
1926////////////////////////////////////////////////////////////////////////////////
1927/// Print value of the dataset, i.e. the sum of weights contained in the dataset
1928
1929void RooDataHist::printValue(ostream& os) const
1930{
1931 os << numEntries() << " bins (" << sumEntries() << " weights)" ;
1932}
1933
1934
1935
1936
1937////////////////////////////////////////////////////////////////////////////////
1938/// Print argument of dataset, i.e. the observable names
1939
1940void RooDataHist::printArgs(ostream& os) const
1941{
1942 os << "[" ;
1943 _iterator->Reset() ;
1944 RooAbsArg* arg ;
1945 Bool_t first(kTRUE) ;
1946 while((arg=(RooAbsArg*)_iterator->Next())) {
1947 if (first) {
1948 first=kFALSE ;
1949 } else {
1950 os << "," ;
1951 }
1952 os << arg->GetName() ;
1953 }
1954 os << "]" ;
1955}
1956
1957
1958
1959////////////////////////////////////////////////////////////////////////////////
1960/// Cache the datahist entries with bin centers that are inside/outside the
1961/// current observable definitio
1962
1964{
1965 checkInit() ;
1966
1967 if (!_binValid) {
1968 _binValid = new Bool_t[_arrSize] ;
1969 }
1970 TIterator* iter = _vars.createIterator() ;
1971 RooAbsArg* arg ;
1972 for (Int_t i=0 ; i<_arrSize ; i++) {
1973 get(i) ;
1974 _binValid[i] = kTRUE ;
1975 iter->Reset() ;
1976 while((arg=(RooAbsArg*)iter->Next())) {
1977 // coverity[CHECKED_RETURN]
1978 _binValid[i] &= arg->inRange(0) ;
1979 }
1980 }
1981 delete iter ;
1982
1983}
1984
1985
1986////////////////////////////////////////////////////////////////////////////////
1987/// Return true if currently loaded coordinate is considered valid within
1988/// the current range definitions of all observables
1989
1991{
1992 // If caching is enabled, use the precached result
1993 if (_binValid) {
1994 return _binValid[_curIndex] ;
1995 }
1996
1997 return kTRUE ;
1998}
1999
2000
2001
2002////////////////////////////////////////////////////////////////////////////////
2003/// Returns true if datasets contains entries with a non-integer weight
2004
2006{
2007 for (int i=0 ; i<numEntries() ; i++) {
2008 if (fabs(_wgt[i]-Int_t(_wgt[i]))>1e-10) return kTRUE ;
2009 }
2010 return kFALSE ;
2011}
2012
2013
2014
2015
2016////////////////////////////////////////////////////////////////////////////////
2017/// Print the details on the dataset contents
2018
2019void RooDataHist::printMultiline(ostream& os, Int_t content, Bool_t verbose, TString indent) const
2020{
2021 RooAbsData::printMultiline(os,content,verbose,indent) ;
2022
2023 os << indent << "Binned Dataset " << GetName() << " (" << GetTitle() << ")" << endl ;
2024 os << indent << " Contains " << numEntries() << " bins with a total weight of " << sumEntries() << endl;
2025
2026 if (!verbose) {
2027 os << indent << " Observables " << _vars << endl ;
2028 } else {
2029 os << indent << " Observables: " ;
2031 }
2032
2033 if(verbose) {
2034 if (_cachedVars.getSize()>0) {
2035 os << indent << " Caches " << _cachedVars << endl ;
2036 }
2037 }
2038}
2039
2040
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Stream an object of class RooDataHist.
2044
2045void RooDataHist::Streamer(TBuffer &R__b)
2046{
2047 if (R__b.IsReading()) {
2048
2049 UInt_t R__s, R__c;
2050 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
2051
2052 if (R__v>2) {
2053
2054 R__b.ReadClassBuffer(RooDataHist::Class(),this,R__v,R__s,R__c);
2055 initialize(0,kFALSE) ;
2056
2057 } else {
2058
2059 // Legacy dataset conversion happens here. Legacy RooDataHist inherits from RooTreeData
2060 // which in turn inherits from RooAbsData. Manually stream RooTreeData contents on
2061 // file here and convert it into a RooTreeDataStore which is installed in the
2062 // new-style RooAbsData base class
2063
2064 // --- This is the contents of the streamer code of RooTreeData version 2 ---
2065 UInt_t R__s1, R__c1;
2066 Version_t R__v1 = R__b.ReadVersion(&R__s1, &R__c1); if (R__v1) { }
2067
2068 RooAbsData::Streamer(R__b);
2069 TTree* X_tree(0) ; R__b >> X_tree;
2070 RooArgSet X_truth ; X_truth.Streamer(R__b);
2071 TString X_blindString ; X_blindString.Streamer(R__b);
2072 R__b.CheckByteCount(R__s1, R__c1, RooTreeData::Class());
2073 // --- End of RooTreeData-v1 streamer
2074
2075 // Construct RooTreeDataStore from X_tree and complete initialization of new-style RooAbsData
2076 _dstore = new RooTreeDataStore(X_tree,_vars) ;
2077 _dstore->SetName(GetName()) ;
2079 _dstore->checkInit() ;
2080
2081 RooDirItem::Streamer(R__b);
2082 R__b >> _arrSize;
2083 delete [] _wgt;
2084 _wgt = new Double_t[_arrSize];
2086 delete [] _errLo;
2087 _errLo = new Double_t[_arrSize];
2089 delete [] _errHi;
2090 _errHi = new Double_t[_arrSize];
2092 delete [] _sumw2;
2093 _sumw2 = new Double_t[_arrSize];
2095 delete [] _binv;
2096 _binv = new Double_t[_arrSize];
2098 _realVars.Streamer(R__b);
2099 R__b >> _curWeight;
2100 R__b >> _curWgtErrLo;
2101 R__b >> _curWgtErrHi;
2102 R__b >> _curSumW2;
2103 R__b >> _curVolume;
2104 R__b >> _curIndex;
2105 R__b.CheckByteCount(R__s, R__c, RooDataHist::IsA());
2106
2107 }
2108
2109 } else {
2110
2112 }
2113}
2114
2115
void Class()
Definition: Class.C:29
SVector< double, 2 > v
Definition: Dict.h:5
#define h(i)
Definition: RSha256.hxx:106
#define e(i)
Definition: RSha256.hxx:103
static Int_t init()
#define coutI(a)
Definition: RooMsgService.h:31
#define coutE(a)
Definition: RooMsgService.h:34
#define TRACE_DESTROY
Definition: RooTrace.h:23
#define TRACE_CREATE
Definition: RooTrace.h:22
int Int_t
Definition: RtypesCore.h:41
short Version_t
Definition: RtypesCore.h:61
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:363
R__EXTERN Int_t gDebug
Definition: Rtypes.h:90
static unsigned int total
float xmin
Definition: THbookFile.cxx:93
float * q
Definition: THbookFile.cxx:87
float ymin
Definition: THbookFile.cxx:93
float type_of_call hi(const int &, const int &)
double pow(double, double)
double sqrt(double)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
virtual Bool_t inRange(const char *) const
Definition: RooAbsArg.h:289
void attachDataSet(const RooAbsData &set)
Replace server nodes with names matching the dataset variable names with those data set variables,...
Definition: RooAbsArg.cxx:1489
RooAbsBinning is the abstract base class for RooRealVar binning definitions This class defines the in...
Definition: RooAbsBinning.h:26
virtual RooAbsBinning * clone(const char *name=0) const =0
Int_t numBins() const
Definition: RooAbsBinning.h:37
virtual Double_t binCenter(Int_t bin) const =0
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set category to i-th fit bin, which is the i-th registered state.
virtual Int_t numBins(const char *rangeName) const
Returm the number of fit bins ( = number of types )
const RooCatType * lookupType(Int_t index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return 0 for no match.
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
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.
Int_t getSize() const
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
RooFIter fwdIterator() const
void assignFast(const RooAbsCollection &other, Bool_t setValDirty=kTRUE)
Functional equivalent of operator=() but assumes this and other collection have same layout.
Bool_t allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range.
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
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 void checkInit() const
virtual void setExternalWeightArray(Double_t *, Double_t *, Double_t *, Double_t *)
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
virtual const RooArgSet * get() const
Definition: RooAbsData.h:79
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Interface for detailed printing of object.
Definition: RooAbsData.cxx:786
void checkInit() const
TIterator * _iterator
External variables cached with this data set.
Definition: RooAbsData.h:262
virtual Double_t weight() const =0
static StorageType defaultStorageType
Definition: RooAbsData.h:224
virtual Double_t weightSquared() const =0
virtual void fill()
Definition: RooAbsData.cxx:278
RooArgSet _vars
Definition: RooAbsData.h:259
virtual void attachCache(const RooAbsArg *newOwner, const RooArgSet &cachedVars)
Internal method – Attach dataset copied with cache contents to copied instances of functions.
Definition: RooAbsData.cxx:325
RooArgSet _cachedVars
Definition: RooAbsData.h:260
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:285
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Calls RooPlot* plotOn(RooPlot* frame, const RooLinkedList& cmdList) const ;.
Definition: RooAbsData.cxx:531
RooAbsDataStore * _dstore
Iterator over cached variables.
Definition: RooAbsData.h:265
Abstract base class for objects that are lvalues, i.e.
Definition: RooAbsLValue.h:26
virtual Double_t getBinWidth(Int_t i, const char *rangeName=0) const =0
virtual Int_t numBins(const char *rangeName=0) const =0
virtual void setBin(Int_t ibin, const char *rangeName=0)=0
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
virtual Int_t numBins(const char *rangeName=0) const
virtual const RooAbsBinning * getBinningPtr(const char *rangeName) const
virtual Int_t getBins(const char *name=0) const
virtual Double_t getMin(const char *name=0) const
virtual Int_t getBin(const char *rangeName=0) const
virtual void setBinFast(Int_t ibin, const RooAbsBinning &binning)
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
Double_t getVal(const RooArgSet *set=0) const
Evaluate object. Returns either cached value or triggers a recalculation.
Definition: RooAbsReal.h:64
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
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...
Definition: RooArgSet.h:88
virtual void addClone(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:96
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
Definition: RooBinning.h:29
virtual void setRange(Double_t xlo, Double_t xhi)
Change the defined range associated with this binning.
Definition: RooBinning.cxx:233
virtual Int_t binNumber(Double_t x) const
Return sequential bin number that contains value x where bin zero is the first bin with an upper boun...
Definition: RooBinning.cxx:186
virtual Double_t averageBinWidth() const
Definition: RooBinning.h:57
virtual Double_t binLow(Int_t bin) const
Return the lower bound of the requested bin.
Definition: RooBinning.cxx:304
virtual Int_t rawBinNumber(Double_t x) const
Return sequential bin number that contains value x where bin zero is the first bin that is defined,...
Definition: RooBinning.cxx:196
void addUniform(Int_t nBins, Double_t xlo, Double_t xhi)
Add array of nbins uniformly sized bins in range [xlo,xhi].
Definition: RooBinning.cxx:173
virtual Double_t binHigh(Int_t bin) const
Return the upper bound of the requested bin.
Definition: RooBinning.cxx:314
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
virtual const char * getLabel() const
Return label string of current state.
Definition: RooCategory.h:39
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set value by specifying the name of the desired state If printError is set, a message will be printed...
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Definition: RooCmdConfig.h:27
RooDataSet is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
std::vector< Double_t > * _pbinv
Definition: RooDataHist.h:193
Double_t sum(Bool_t correctForBinSize, Bool_t inverseCorr=kFALSE) const
Return the sum of the weights of all hist bins.
virtual void printArgs(std::ostream &os) const
Print argument of dataset, i.e. the observable names.
virtual void reset()
Reset all bin weights to zero.
Int_t _curIndex
Definition: RooDataHist.h:191
void dump2()
Debug stuff, should go...
void initialize(const char *binningName=0, Bool_t fillTree=kTRUE)
Initialization procedure: allocate weights array, calculate multipliers needed for N-space to 1-dim a...
virtual Double_t weight() const
Definition: RooDataHist.h:96
Int_t _cache_sum_valid
list of bin bounds per dimension
Definition: RooDataHist.h:199
void SetNameTitle(const char *name, const char *title)
Change the title of this RooDataHist.
Double_t _curWeight
Valid bins with current range definition.
Definition: RooDataHist.h:186
friend class RooDataHistSliceIter
Definition: RooDataHist.h:137
Double_t _curWgtErrLo
Definition: RooDataHist.h:187
RooAbsData * reduceEng(const RooArgSet &varSubset, const RooFormulaVar *cutVar, const char *cutRange=0, Int_t nStart=0, Int_t nStop=2000000000, Bool_t copyCache=kTRUE)
Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods.
void set(Double_t weight, Double_t wgtErr=-1)
Increment the weight of the bin enclosing the coordinates given by 'row' by the specified amount.
Double_t * _sumw2
Definition: RooDataHist.h:179
virtual Double_t sumEntries() const
Double_t weightSquared() const
RooCacheManager< std::vector< Double_t > > _pbinvCacheMgr
Partial bin volume array.
Definition: RooDataHist.h:194
void checkBinBounds() const
virtual void weightError(Double_t &lo, Double_t &hi, ErrorType etype=Poisson) const
Return the error on current weight.
virtual Int_t numEntries() const
Return the number of bins.
virtual RooAbsData * cacheClone(const RooAbsArg *newCacheOwner, const RooArgSet *newCacheVars, const char *newName=0)
Construct a clone of this dataset that contains only the cached variables.
virtual Double_t get_wgt(const Int_t &idx) const
Definition: RooDataHist.h:161
virtual void add(const RooArgSet &row, Double_t wgt=1.0)
Definition: RooDataHist.h:65
std::vector< const RooAbsBinning * > _lvbins
List of observables casted as RooAbsLValue.
Definition: RooDataHist.h:196
RooDataHist()
Default constructor.
Definition: RooDataHist.cxx:63
Bool_t * _binValid
Iterator over realVars.
Definition: RooDataHist.h:184
void importTH1Set(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, TH1 * > hmap, Double_t initWgt, Bool_t doDensityCorrection)
Import data from given set of TH1/2/3 into this RooDataHist.
Double_t _curWgtErrHi
Definition: RooDataHist.h:188
virtual void printValue(std::ostream &os) const
Print value of the dataset, i.e. the sum of weights contained in the dataset.
virtual Bool_t isNonPoissonWeighted() const
Returns true if datasets contains entries with a non-integer weight.
Int_t getIndex(const RooArgSet &coord, Bool_t fast=kFALSE)
Double_t * _wgt
Definition: RooDataHist.h:176
Double_t * _errLo
Definition: RooDataHist.h:177
TIterator * _realIter
Definition: RooDataHist.h:183
Double_t interpolateDim(RooRealVar &dim, const RooAbsBinning *binning, Double_t xval, Int_t intOrder, Bool_t correctForBinSize, Bool_t cdfBoundaries)
Perform boundary safe 'intOrder'-th interpolation of weights in dimension 'dim' at current value 'xva...
void _adjustBinning(RooRealVar &theirVar, const TAxis &axis, RooRealVar *ourVar, Int_t *offset)
Cache for sum of entries ;.
std::vector< std::vector< Double_t > > _binbounds
List of used binnings associated with lvalues.
Definition: RooDataHist.h:197
TIterator * sliceIterator(RooAbsArg &sliceArg, const RooArgSet &otherArgs)
Create an iterator over all bins in a slice defined by the subset of observables listed in sliceArg.
void importTH1(const RooArgList &vars, const TH1 &histo, Double_t initWgt, Bool_t doDensityCorrection)
Import data from given TH1/2/3 into this RooDataHist.
virtual const RooArgSet * get() const
Definition: RooDataHist.h:77
Double_t * _errHi
Definition: RooDataHist.h:178
Int_t calcTreeIndex() const
Calculate the index for the weights array corresponding to to the bin enclosing the current coordinat...
virtual void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const
Print the details on the dataset contents.
void setAllWeights(Double_t value)
Set all the event weight of all bins to the specified value.
virtual ~RooDataHist()
Destructor.
virtual RooPlot * plotOn(RooPlot *frame, PlotOpt o) const
Back end function to plotting functionality.
void importDHistSet(const RooArgList &vars, RooCategory &indexCat, std::map< std::string, RooDataHist * > dmap, Double_t initWgt)
Import data from given set of TH1/2/3 into this RooDataHist.
Int_t _arrSize
Definition: RooDataHist.h:173
std::vector< RooAbsLValue * > _lvvars
Cache manager for arrays of partial bin volumes.
Definition: RooDataHist.h:195
virtual Bool_t valid() const
Return true if currently loaded coordinate is considered valid within the current range definitions o...
Double_t * _binv
Definition: RooDataHist.h:180
void cacheValidEntries()
Cache the datahist entries with bin centers that are inside/outside the current observable definitio.
RooArgSet _realVars
Definition: RooDataHist.h:182
std::vector< Int_t > _idxMult
Definition: RooDataHist.h:174
void adjustBinning(const RooArgList &vars, const TH1 &href, Int_t *offset=0)
Adjust binning specification on first and optionally second and third observable to binning in given ...
Double_t _curSumW2
Definition: RooDataHist.h:189
void SetName(const char *name)
Change the name of the RooDataHist.
Double_t _curVolume
Definition: RooDataHist.h:190
Double_t _cache_sum
Is cache sum valid.
Definition: RooDataHist.h:200
Double_t binVolume() const
Definition: RooDataHist.h:102
void calculatePartialBinVolume(const RooArgSet &dimSet) const
Fill the transient cache with partial bin volumes with up-to-date values for the partial volume speci...
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
Definition: RooDirItem.h:22
void appendToDir(TObject *obj, Bool_t forceMemoryResident=kFALSE)
Append object to directory.
Definition: RooDirItem.cxx:86
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
Definition: RooDirItem.cxx:71
TDirectory * _dir
Definition: RooDirItem.h:33
RooAbsArg * next()
RooFormula an implementation of ROOT::v5::TFormula that interfaces it to RooAbsArg value objects.
Definition: RooFormula.h:27
Double_t eval(const RooArgSet *nset=0)
Evaluate ROOT::v5::TFormula using given normalization set to be used as observables definition passed...
Definition: RooFormula.cxx:234
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.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
Int_t GetSize() const
Definition: RooLinkedList.h:60
TIterator * MakeIterator(Bool_t dir=kTRUE) const
Return an iterator over this list.
static Double_t interpolate(Double_t yArr[], Int_t nOrder, Double_t x)
Definition: RooMath.cxx:605
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:41
RooAbsRealLValue * getPlotVar() const
Definition: RooPlot.h:132
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
void setRange(const char *name, Double_t min, Double_t max)
Set range named 'name to [min,max].
Definition: RooRealVar.cxx:448
const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const
Return binning definition with name.
Definition: RooRealVar.cxx:266
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name 'name' with this variable.
Definition: RooRealVar.cxx:345
RooTreeDataStore is the abstract base class for data collection that use a TTree as internal storage ...
RooUniformBinning is an implementation of RooAbsBinning that provides a uniform binning in 'n' bins b...
RooVectorDataStore is the abstract base class for data collection that use a TTree as internal storag...
const Double_t * GetArray() const
Definition: TArrayD.h:43
Class to manage histogram axis.
Definition: TAxis.h:30
const TArrayD * GetXbins() const
Definition: TAxis.h:130
Double_t GetXmax() const
Definition: TAxis.h:134
Double_t GetXmin() const
Definition: TAxis.h:133
Int_t GetNbins() const
Definition: TAxis.h:121
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
Bool_t IsReading() const
Definition: TBuffer.h:83
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual TList * GetList() const
Definition: TDirectory.h:149
The TH1 histogram class.
Definition: TH1.h:56
TAxis * GetZaxis()
Definition: TH1.h:318
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition: TH1.cxx:8384
virtual Int_t GetDimension() const
Definition: TH1.h:278
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:316
TAxis * GetYaxis()
Definition: TH1.h:317
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4790
Iterator abstract base class.
Definition: TIterator.h:30
virtual void Reset()=0
virtual TObject * Next()=0
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:818
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TNamed.cxx:154
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
Double_t y[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
@ DataHandling
Definition: RooGlobalFunc.h:59
@ InputArguments
Definition: RooGlobalFunc.h:58
static constexpr double pc
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:723
Definition: first.py:1
STL namespace.
RooAbsBinning * bins
Definition: RooAbsData.h:126
Bool_t correctForBinWidth
Definition: RooAbsData.h:136
auto * l
Definition: textangle.C:4