Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
57
58 /// Copy the object and return as TObject*.
59 virtual 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_t>* binBoundaries(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const override {
70 return _histFunc->binBoundaries(obs, xlo, xhi);
71 }
72 /// Return plotSamplingHint of internal RooHistFunc.
73 std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t 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
double Double_t
Definition RtypesCore.h:59
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:35
RooBinWidthFunction is a class that returns the bin width (or volume) given a RooHistFunc.
std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Return plotSamplingHint of internal RooHistFunc.
std::list< Double_t > * binBoundaries(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const override
Return bin boundaries of internal RooHistFunc.
RooBinWidthFunction(const char *name, const char *title, const RooHistFunc &histFunc, bool divideByBinWidth)
Create an instance.
virtual TObject * clone(const char *newname=nullptr) const override
Copy the object and return as TObject*.
const RooHistFunc & histFunc() const
RooBinWidthFunction(const RooBinWidthFunction &other, const char *newname=nullptr)
Copy an existing object.
ClassDefOverride(RooBinWidthFunction, 1)
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
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Return sampling hint for making curves of (projections) of this function as the recursive division st...
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition RooHistFunc.h:84
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Return sampling hint for making curves of (projections) of this function as the recursive division st...
Mother of all ROOT objects.
Definition TObject.h:41
static void output(int code)
Definition gifencode.c:226