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