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
26 static bool _enabled;
27
28public:
29 static void enableClass();
30 static void disableClass();
31 static bool isClassEnabled();
32
33 /// Create an empty instance.
35 _histFunc("HistFuncForBinWidth", "Handle to a RooHistFunc, whose bin volumes should be returned.", this,
36 /*valueServer=*/true, /*shapeServer=*/true) { }
37
38 /// Create an instance.
39 /// \param name Name to identify the object.
40 /// \param title Title for e.g. plotting.
41 /// \param histFunc RooHistFunc object whose bin widths should be returned.
42 /// \param divideByBinWidth If true, return inverse bin width.
43 RooBinWidthFunction(const char* name, const char* title, const RooHistFunc& histFunc, bool divideByBinWidth) :
44 RooAbsReal(name, title),
45 _histFunc("HistFuncForBinWidth", "Handle to a RooHistFunc, whose bin volumes should be returned.", this, histFunc, /*valueServer=*/true, /*shapeServer=*/true),
47
48 /// Copy an existing object.
49 RooBinWidthFunction(const RooBinWidthFunction& other, const char* newname = nullptr) :
50 RooAbsReal(other, newname),
51 _histFunc("HistFuncForBinWidth", this, other._histFunc),
53
54 ~RooBinWidthFunction() override { }
55
56 std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const 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:341
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:62
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
RooBinWidthFunction is a class that returns the bin width (or volume) given a RooHistFunc.
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
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.
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:31
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...
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...
bool isBinnedDistribution(const RooArgSet &) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition RooHistFunc.h:93
Mother of all ROOT objects.
Definition TObject.h:41
static void output()