Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooCBShape.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$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/** \class RooCBShape
18 \ingroup Roofit
19
20PDF implementing the Crystal Ball line shape.
21**/
22
23#include "RooCBShape.h"
24
25#include "RooRealVar.h"
26#include "RooMath.h"
27#include "RooBatchCompute.h"
28
30
31#include "TMath.h"
32
33#include <cmath>
34
36
37////////////////////////////////////////////////////////////////////////////////
38
39RooCBShape::RooCBShape(const char *name, const char *title,
40 RooAbsReal& _m, RooAbsReal& _m0, RooAbsReal& _sigma,
41 RooAbsReal& _alpha, RooAbsReal& _n) :
42 RooAbsPdf(name, title),
43 m("m", "Dependent", this, _m),
44 m0("m0", "M0", this, _m0),
45 sigma("sigma", "Sigma", this, _sigma),
46 alpha("alpha", "Alpha", this, _alpha),
47 n("n", "Order", this, _n)
48{
49}
50
51////////////////////////////////////////////////////////////////////////////////
52
53RooCBShape::RooCBShape(const RooCBShape& other, const char* name) :
54 RooAbsPdf(other, name), m("m", this, other.m), m0("m0", this, other.m0),
55 sigma("sigma", this, other.sigma), alpha("alpha", this, other.alpha),
56 n("n", this, other.n)
57{
58}
59
60////////////////////////////////////////////////////////////////////////////////
61
63{
65}
66
68{
69 ctx.addResult(this, ctx.buildCall("RooFit::Detail::MathFuncs::cbShape", m, m0, sigma, alpha, n));
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Compute multiple values of Crystal ball Shape distribution.
75{
77 {ctx.at(m), ctx.at(m0), ctx.at(sigma), ctx.at(alpha), ctx.at(n)});
78}
79
80////////////////////////////////////////////////////////////////////////////////
81
82Int_t RooCBShape::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
83{
84 if( matchArgs(allVars,analVars,m) )
85 return 1 ;
86
87 return 0;
88}
89
90////////////////////////////////////////////////////////////////////////////////
91
92double RooCBShape::analyticalIntegral(Int_t /*code*/, const char *rangeName) const
93{
94 using namespace RooFit::Detail::MathFuncs;
95 return cbShapeIntegral(m.min(rangeName), m.max(rangeName), m0, sigma, alpha, n);
96}
97
98std::string
100{
101 return ctx.buildCall("RooFit::Detail::MathFuncs::cbShapeIntegral",
102 m.min(rangeName), m.max(rangeName), m0, sigma, alpha, n);
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Advertise that we know the maximum of self for given (m0,alpha,n,sigma)
107
109{
110 RooArgSet dummy ;
111
112 if (matchArgs(vars,dummy,m)) {
113 return 1 ;
114 }
115 return 0 ;
116}
117
118////////////////////////////////////////////////////////////////////////////////
119
120double RooCBShape::maxVal(Int_t code) const
121{
122 R__ASSERT(code==1) ;
123
124 // The maximum value for given (m0,alpha,n,sigma)
125 // is 1./ Integral in the variable range
126 return 1.0/analyticalIntegral(1) ;
127}
#define ClassImp(name)
Definition Rtypes.h:382
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
char name[80]
Definition TGX11.cxx:110
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
bool matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
PDF implementing the Crystal Ball line shape.
Definition RooCBShape.h:24
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
void doEval(RooFit::EvalContext &) const override
Compute multiple values of Crystal ball Shape distribution.
double analyticalIntegral(Int_t, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
RooRealProxy n
Definition RooCBShape.h:53
RooRealProxy m0
Definition RooCBShape.h:50
RooRealProxy m
Definition RooCBShape.h:49
RooRealProxy sigma
Definition RooCBShape.h:51
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
RooRealProxy alpha
Definition RooCBShape.h:52
Int_t getMaxVal(const RooArgSet &vars) const override
Advertise that we know the maximum of self for given (m0,alpha,n,sigma)
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
std::string buildCallToAnalyticIntegral(Int_t code, const char *rangeName, RooFit::Detail::CodeSquashContext &ctx) const override
This function defines the analytical integral translation for the class.
A class to maintain the context for squashing of RooFit models into code.
std::string buildCall(std::string const &funcname, Args_t const &...args)
Build the code to call the function with name funcname, passing some arguments.
void addResult(RooAbsArg const *key, std::string const &value)
A function to save an expression that includes/depends on the result of the input node.
std::span< double > output()
RooBatchCompute::Config config(RooAbsArg const *arg) const
const Double_t sigma
const Int_t n
Definition legend1.C:16
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})
double cbShape(double m, double m0, double sigma, double alpha, double n)
Definition MathFuncs.h:382
TMarker m
Definition textangle.C:8