Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooBDecay.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$Id$
5 * Authors: *
6 * PL, Parker C Lund, UC Irvine *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
9 * *
10 * Copyright (c) 2000-2005, 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
19/** \class RooBDecay
20 \ingroup Roofit
21
22Most general description of B decay time distribution with effects
23of CP violation, mixing and life time differences. This function can
24be analytically convolved with any RooResolutionModel implementation.
25**/
26
27#include "Riostream.h"
28#include "TMath.h"
29#include "RooBDecay.h"
30#include "RooRealVar.h"
31#include "RooRandom.h"
32
33#include "TError.h"
34
35using namespace std;
36
38
39/// \brief Constructor for RooBDecay.
40///
41/// Creates an instance of RooBDecay with the specified parameters.
42///
43/// \param[in] name The name of the PDF.
44/// \param[in] title The title of the PDF.
45/// \param[in] t The time variable.
46/// \param[in] tau The average decay time parameter.
47/// \param[in] dgamma The Delta Gamma parameter.
48/// \param[in] f0 The Cosh Coefficient.
49/// \param[in] f1 The Sinh Coefficient.
50/// \param[in] f2 The Cos Coefficient.
51/// \param[in] f3 The Sin Coefficient.
52/// \param[in] dm The Delta Mass parameter.
53/// \param[in] model The resolution model.
54/// \param[in] type The decay type.
55
56RooBDecay::RooBDecay(const char *name, const char* title,
57 RooRealVar& t, RooAbsReal& tau, RooAbsReal& dgamma,
59 RooAbsReal& dm, const RooResolutionModel& model, DecayType type) :
60 RooAbsAnaConvPdf(name, title, model, t),
61 _t("t", "time", this, t),
62 _tau("tau", "Average Decay Time", this, tau),
63 _dgamma("dgamma", "Delta Gamma", this, dgamma),
64 _f0("f0", "Cosh Coefficient", this, f0),
65 _f1("f1", "Sinh Coefficient", this, f1),
66 _f2("f2", "Cos Coefficient", this, f2),
67 _f3("f3", "Sin Coefficient", this, f3),
68 _dm("dm", "Delta Mass", this, dm),
69 _type(type)
70
71{
72 //Constructor
73 switch(type)
74 {
75 case SingleSided:
76 _basisCosh = declareBasis("exp(-@0/@1)*cosh(@0*@2/2)", RooArgList(tau,dgamma));
77 _basisSinh = declareBasis("exp(-@0/@1)*sinh(@0*@2/2)", RooArgList(tau,dgamma));
78 _basisCos = declareBasis("exp(-@0/@1)*cos(@0*@2)",RooArgList(tau, dm));
79 _basisSin = declareBasis("exp(-@0/@1)*sin(@0*@2)",RooArgList(tau, dm));
80 break;
81 case Flipped:
82 _basisCosh = declareBasis("exp(@0/@1)*cosh(@0*@2/2)", RooArgList(tau,dgamma));
83 _basisSinh = declareBasis("exp(@0/@1)*sinh(@0*@2/2)", RooArgList(tau,dgamma));
84 _basisCos = declareBasis("exp(@0/@1)*cos(@0*@2)",RooArgList(tau, dm));
85 _basisSin = declareBasis("exp(@0/@1)*sin(@0*@2)",RooArgList(tau, dm));
86 break;
87 case DoubleSided:
88 _basisCosh = declareBasis("exp(-abs(@0)/@1)*cosh(@0*@2/2)", RooArgList(tau,dgamma));
89 _basisSinh = declareBasis("exp(-abs(@0)/@1)*sinh(@0*@2/2)", RooArgList(tau,dgamma));
90 _basisCos = declareBasis("exp(-abs(@0)/@1)*cos(@0*@2)",RooArgList(tau, dm));
91 _basisSin = declareBasis("exp(-abs(@0)/@1)*sin(@0*@2)",RooArgList(tau, dm));
92 break;
93 }
94}
95
96////////////////////////////////////////////////////////////////////////////////
97///Copy constructor
98
99RooBDecay::RooBDecay(const RooBDecay& other, const char* name) :
100 RooAbsAnaConvPdf(other, name),
101 _t("t", this, other._t),
102 _tau("tau", this, other._tau),
103 _dgamma("dgamma", this, other._dgamma),
104 _f0("f0", this, other._f0),
105 _f1("f1", this, other._f1),
106 _f2("f2", this, other._f2),
107 _f3("f3", this, other._f3),
108 _dm("dm", this, other._dm),
109 _basisCosh(other._basisCosh),
110 _basisSinh(other._basisSinh),
111 _basisCos(other._basisCos),
112 _basisSin(other._basisSin),
113 _type(other._type)
114{
115}
116
117////////////////////////////////////////////////////////////////////////////////
118
119double RooBDecay::coefficient(Int_t basisIndex) const
120{
121 if(basisIndex == _basisCosh)
122 {
123 return _f0;
124 }
125 if(basisIndex == _basisSinh)
126 {
127 return _f1;
128 }
129 if(basisIndex == _basisCos)
130 {
131 return _f2;
132 }
133 if(basisIndex == _basisSin)
134 {
135 return _f3;
136 }
137
138 return 0 ;
139}
140
141////////////////////////////////////////////////////////////////////////////////
142
144{
145 if(basisIndex == _basisCosh)
146 {
147 return _f0.arg().getVariables();
148 }
149 if(basisIndex == _basisSinh)
150 {
151 return _f1.arg().getVariables();
152 }
153 if(basisIndex == _basisCos)
154 {
155 return _f2.arg().getVariables();
156 }
157 if(basisIndex == _basisSin)
158 {
159 return _f3.arg().getVariables();
160 }
161
162 return nullptr;
163}
164
165////////////////////////////////////////////////////////////////////////////////
166
167Int_t RooBDecay::getCoefAnalyticalIntegral(Int_t coef, RooArgSet& allVars, RooArgSet& analVars, const char* rangeName) const
168{
169 if(coef == _basisCosh)
170 {
171 return _f0.arg().getAnalyticalIntegral(allVars,analVars,rangeName) ;
172 }
173 if(coef == _basisSinh)
174 {
175 return _f1.arg().getAnalyticalIntegral(allVars,analVars,rangeName) ;
176 }
177 if(coef == _basisCos)
178 {
179 return _f2.arg().getAnalyticalIntegral(allVars,analVars,rangeName) ;
180 }
181 if(coef == _basisSin)
182 {
183 return _f3.arg().getAnalyticalIntegral(allVars,analVars,rangeName) ;
184 }
185
186 return 0 ;
187}
188
189////////////////////////////////////////////////////////////////////////////////
190
191double RooBDecay::coefAnalyticalIntegral(Int_t coef, Int_t code, const char* rangeName) const
192{
193 if(coef == _basisCosh)
194 {
195 return _f0.arg().analyticalIntegral(code,rangeName) ;
196 }
197 if(coef == _basisSinh)
198 {
199 return _f1.arg().analyticalIntegral(code,rangeName) ;
200 }
201 if(coef == _basisCos)
202 {
203 return _f2.arg().analyticalIntegral(code,rangeName) ;
204 }
205 if(coef == _basisSin)
206 {
207 return _f3.arg().analyticalIntegral(code,rangeName) ;
208 }
209
210 return 0 ;
211}
212
213////////////////////////////////////////////////////////////////////////////////
214
215Int_t RooBDecay::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool /*staticInitOK*/) const
216{
217 if (matchArgs(directVars, generateVars, _t)) return 1;
218 return 0;
219}
220
221////////////////////////////////////////////////////////////////////////////////
222
224{
225 R__ASSERT(code==1);
226 double gammamin = 1/_tau-TMath::Abs(_dgamma)/2;
227 while(true) {
228 double t = -log(RooRandom::uniform())/gammamin;
229 if (_type == Flipped || (_type == DoubleSided && RooRandom::uniform() <0.5) ) t *= -1;
230 if ( t<_t.min() || t>_t.max() ) continue;
231
232 double dgt = _dgamma*t/2;
233 double dmt = _dm*t;
234 double ft = std::abs(t);
235 double f = exp(-ft/_tau)*(_f0*cosh(dgt)+_f1*sinh(dgt)+_f2*cos(dmt)+_f3*sin(dmt));
236 if(f < 0) {
237 cout << "RooBDecay::generateEvent(" << GetName() << ") ERROR: PDF value less than zero" << endl;
238 ::abort();
239 }
240 double w = 1.001*exp(-ft*gammamin)*(TMath::Abs(_f0)+TMath::Abs(_f1)+sqrt(_f2*_f2+_f3*_f3));
241 if(w < f) {
242 cout << "RooBDecay::generateEvent(" << GetName() << ") ERROR: Envelope function less than p.d.f. " << endl;
243 cout << _f0 << endl;
244 cout << _f1 << endl;
245 cout << _f2 << endl;
246 cout << _f3 << endl;
247 ::abort();
248 }
249 if(w*RooRandom::uniform() > f) continue;
250 _t = t;
251 break;
252 }
253}
#define f(i)
Definition RSha256.hxx:104
#define ClassImp(name)
Definition Rtypes.h:377
#define R__ASSERT(e)
Definition TError.h:118
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
Base class for PDFs that represent a physics model that can be analytically convolved with a resoluti...
Int_t declareBasis(const char *expression, const RooArgList &params)
Declare a basis function for use in this physics model.
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expression tree)
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().
virtual double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
virtual Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Most general description of B decay time distribution with effects of CP violation,...
Definition RooBDecay.h:25
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...
double coefAnalyticalIntegral(Int_t coef, Int_t code, const char *rangeName=nullptr) const override
Default implementation of function implementing advertised integrals.
RooRealProxy _t
Definition RooBDecay.h:57
RooRealProxy _f2
Definition RooBDecay.h:62
Int_t _basisCosh
Definition RooBDecay.h:65
DecayType _type
Definition RooBDecay.h:70
Int_t _basisSin
Definition RooBDecay.h:68
RooRealProxy _tau
Definition RooBDecay.h:58
void generateEvent(Int_t code) override
Interface for generation of an event using the algorithm corresponding to the specified code.
RooRealProxy _f0
Definition RooBDecay.h:60
@ DoubleSided
Definition RooBDecay.h:29
@ SingleSided
Definition RooBDecay.h:29
double coefficient(Int_t basisIndex) const override
RooRealProxy _dgamma
Definition RooBDecay.h:59
RooRealProxy _f3
Definition RooBDecay.h:63
Int_t getCoefAnalyticalIntegral(Int_t coef, RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Default implementation of function advertising integration capabilities.
RooFit::OwningPtr< RooArgSet > coefVars(Int_t coefIdx) const override
Return set of parameters with are used exclusively by the coefficient functions.
Int_t _basisSinh
Definition RooBDecay.h:66
RooRealProxy _dm
Definition RooBDecay.h:64
Int_t _basisCos
Definition RooBDecay.h:67
RooRealProxy _f1
Definition RooBDecay.h:61
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Definition RooRandom.cxx:81
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:37
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
double max(const char *rname=nullptr) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
const T & arg() const
Return reference to object held in proxy.
double min(const char *rname=nullptr) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
TF1 * f1
Definition legend1.C:11
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Definition Config.h:43
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123