Logo ROOT  
Reference Guide
RooBinWidthFunction.h
Go to the documentation of this file.
1// Author Stephan Hageboeck, CERN, 6/2020
2/*****************************************************************************
3 * Project: RooFit *
4 * Package: RooFitCore *
5 * File: $Id$
6 * Authors: *
7 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
8 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
9 * *
10 * Copyright (c) 2000-2020, Regents of the University of California *
11 * and Stanford University. All rights reserved. *
12 * *
13 * Redistribution and use in source and binary forms, *
14 * with or without modification, are permitted according to the terms *
15 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
16 *****************************************************************************/
17
18#ifndef ROOFIT_ROOFITCORE_INC_BINWIDTHFUNCTION_H_
19#define ROOFIT_ROOFITCORE_INC_BINWIDTHFUNCTION_H_
20
21#include "RooAbsReal.h"
22#include "RooTemplateProxy.h"
23#include "RooHistFunc.h"
24
25namespace BatchHelpers { struct RunContext; }
26
28 static bool _enabled;
29
30public:
31 static void enableClass();
32 static void disableClass();
33 static bool isClassEnabled();
34
35 /// Create an empty instance.
37 _histFunc("HistFuncForBinWidth", "Handle to a RooHistFunc, whose bin volumes should be returned.", this,
38 /*valueServer=*/true, /*shapeServer=*/true) { }
39
40 /// Create an instance.
41 /// \param name Name to identify the object.
42 /// \param title Title for e.g. plotting.
43 /// \param histFunc RooHistFunc object whose bin widths should be returned.
44 /// \param divideByBinWidth If true, return inverse bin width.
45 RooBinWidthFunction(const char* name, const char* title, const RooHistFunc& histFunc, bool divideByBinWidth) :
46 RooAbsReal(name, title),
47 _histFunc("HistFuncForBinWidth", "Handle to a RooHistFunc, whose bin volumes should be returned.", this, histFunc, /*valueServer=*/true, /*shapeServer=*/true),
49
50 /// Copy an existing object.
51 RooBinWidthFunction(const RooBinWidthFunction& other, const char* newname = nullptr) :
52 RooAbsReal(other, newname),
53 _histFunc("HistFuncForBinWidth", this, other._histFunc),
55
56 ~RooBinWidthFunction() override { }
57
58 /// Copy the object and return as TObject*.
59 TObject* clone(const char* newname = nullptr) const override {
60 return new RooBinWidthFunction(*this, newname);
61 }
62
63 // Plotting and binning hints
64 /// Test if internal RooHistFunc is binned.
65 bool isBinnedDistribution(const RooArgSet& obs) const override {
67 }
68 /// Return bin boundaries of internal RooHistFunc.
69 std::list<double>* binBoundaries(RooAbsRealLValue& obs, double xlo, double xhi) const override {
70 return _histFunc->binBoundaries(obs, xlo, xhi);
71 }
72 /// Return plotSamplingHint of internal RooHistFunc.
73 std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override {
74 return _histFunc->plotSamplingHint(obs, xlo, xhi);
75 }
76
77 bool divideByBinWidth() const { return _divideByBinWidth; }
78 const RooHistFunc& histFunc() const { return (*_histFunc); }
79 double evaluate() const override;
80 void computeBatch(cudaStream_t*, double* output, size_t size, RooFit::Detail::DataMap const&) const override;
81
82private:
84 bool _divideByBinWidth{false};
85
87};
88
89#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
char name[80]
Definition: TGX11.cxx:110
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:64
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:57
RooBinWidthFunction is a class that returns the bin width (or volume) given a RooHistFunc.
TObject * clone(const char *newname=nullptr) const override
Copy the object and return as TObject*.
RooBinWidthFunction(const char *name, const char *title, const RooHistFunc &histFunc, bool divideByBinWidth)
Create an instance.
bool divideByBinWidth() const
std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return bin boundaries of internal RooHistFunc.
const RooHistFunc & histFunc() const
RooBinWidthFunction(const RooBinWidthFunction &other, const char *newname=nullptr)
Copy an existing object.
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return plotSamplingHint of internal RooHistFunc.
RooBinWidthFunction()
Create an empty instance.
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const override
Compute bin index for all values of the observable(s) in evalData, and return their volumes or invers...
bool isBinnedDistribution(const RooArgSet &obs) const override
Test if internal RooHistFunc is binned.
static void disableClass()
Globally disable bin-width corrections by this class.
double evaluate() const override
Compute current bin of observable, and return its volume or inverse volume, depending on configuratio...
RooTemplateProxy< const RooHistFunc > _histFunc
static bool isClassEnabled()
Returns true if bin-width corrections by this class are globally enabled, false otherwise.
static void enableClass()
Globally enable bin-width corrections by this class.
RooHistFunc implements a real-valued function sampled from a multidimensional histogram.
Definition: RooHistFunc.h:30
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Return sampling hint for making curves of (projections) of this function as the recursive division st...
bool isBinnedDistribution(const RooArgSet &) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition: RooHistFunc.h:84
Mother of all ROOT objects.
Definition: TObject.h:37
static void output()