Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooLandau.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 RooLandau
18 \ingroup Roofit
19
20Landau distribution p.d.f
21\image html RF_Landau.png "PDF of the Landau distribution."
22**/
23
24#include "RooLandau.h"
25#include "RooHelpers.h"
26#include "RooRandom.h"
27#include "RooBatchCompute.h"
28
29#include "TMath.h"
30#include "Math/ProbFunc.h"
31
33
34////////////////////////////////////////////////////////////////////////////////
35
36RooLandau::RooLandau(const char *name, const char *title, RooAbsReal& _x, RooAbsReal& _mean, RooAbsReal& _sigma) :
37 RooAbsPdf(name,title),
38 x("x","Dependent",this,_x),
39 mean("mean","Mean",this,_mean),
40 sigma("sigma","Width",this,_sigma)
41{
42 RooHelpers::checkRangeOfParameters(this, {&_sigma}, 0.0);
43}
44
45////////////////////////////////////////////////////////////////////////////////
46
47RooLandau::RooLandau(const RooLandau& other, const char* name) :
48 RooAbsPdf(other,name),
49 x("x",this,other.x),
50 mean("mean",this,other.mean),
51 sigma("sigma",this,other.sigma)
52{
53}
54
55////////////////////////////////////////////////////////////////////////////////
56
57double RooLandau::evaluate() const
58{
59 return TMath::Landau(x, mean, sigma);
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Compute multiple values of Landau distribution.
64void RooLandau::computeBatch(cudaStream_t* stream, double* output, size_t nEvents, RooFit::Detail::DataMap const& dataMap) const
65{
67 dispatch->compute(stream, RooBatchCompute::Landau, output, nEvents,
68 {dataMap.at(x), dataMap.at(mean), dataMap.at(sigma)});
69}
70
71////////////////////////////////////////////////////////////////////////////////
72
73Int_t RooLandau::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool /*staticInitOK*/) const
74{
75 if (matchArgs(directVars,generateVars,x)) return 1 ;
76 return 0;
77}
78
79Int_t RooLandau::getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char * /*rangeName*/) const
80{
81 if (matchArgs(allVars, analVars, x))
82 return 1;
83 return 0;
84}
85
86Double_t RooLandau::analyticalIntegral(Int_t /*code*/, const char *rangeName) const
87{
88 // Don't do anything with "code". It can only be "1" anyway (see
89 // implementation of getAnalyticalIntegral).
90
91 const double max = x.max(rangeName);
92 const double min = x.min(rangeName);
93
94 const double meanVal = mean;
95 const double sigmaVal = sigma;
96
98 return sigmaVal * (landau_cdf(max, sigmaVal, meanVal) - landau_cdf(min, sigmaVal, meanVal));
99}
100
101////////////////////////////////////////////////////////////////////////////////
102
104{
105 assert(1 == code); (void)code;
106 double xgen ;
107 while(1) {
109 if (xgen<x.max() && xgen>x.min()) {
110 x = xgen ;
111 break;
112 }
113 }
114 return;
115}
#define ClassImp(name)
Definition Rtypes.h:377
char name[80]
Definition TGX11.cxx:110
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:62
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:55
virtual void compute(cudaStream_t *, Computer, RestrictArr, size_t, const VarVector &, ArgVector &)=0
RooSpan< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
Definition DataMap.cxx:21
Landau distribution p.d.f.
Definition RooLandau.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.
Definition RooLandau.cxx:79
void generateEvent(Int_t code) override
Interface for generation of an event using the algorithm corresponding to the specified code.
RooRealProxy x
Definition RooLandau.h:40
RooRealProxy sigma
Definition RooLandau.h:42
void computeBatch(cudaStream_t *, double *output, size_t nEvents, RooFit::Detail::DataMap const &) const override
Compute multiple values of Landau distribution.
Definition RooLandau.cxx:64
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition RooLandau.cxx:57
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
Definition RooLandau.cxx:73
RooRealProxy mean
Definition RooLandau.h:41
double analyticalIntegral(Int_t code, const char *rangeName) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition RooLandau.cxx:86
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Definition RooRandom.cxx:51
double max(const char *rname=nullptr) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
double min(const char *rname=nullptr) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
virtual Double_t Landau(Double_t mean=0, Double_t sigma=1)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
Definition TRandom.cxx:380
double landau_cdf(double x, double xi=1, double x0=0)
Cumulative distribution function of the Landau distribution (lower tail).
const Double_t sigma
Double_t x[n]
Definition legend1.C:17
R__EXTERN RooBatchComputeInterface * dispatchCUDA
R__EXTERN RooBatchComputeInterface * dispatchCPU
This dispatch pointer points to an implementation of the compute library, provided one has been loade...
void checkRangeOfParameters(const RooAbsReal *callingClass, std::initializer_list< const RooAbsReal * > pars, double min=-std::numeric_limits< double >::max(), double max=std::numeric_limits< double >::max(), bool limitsInAllowedRange=false, std::string const &extraMessage="")
Check if the parameters have a range, and warn if the range extends below / above the set limits.
Double_t Landau(Double_t x, Double_t mpv=0, Double_t sigma=1, Bool_t norm=kFALSE)
The LANDAU function.
Definition TMath.cxx:492
static void output()