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 "RooBDecay.h"
28#include "RooRealVar.h"
29#include "RooRandom.h"
30
31#include "TError.h"
32
33
34/// \brief Constructor for RooBDecay.
35///
36/// Creates an instance of RooBDecay with the specified parameters.
37///
38/// \param[in] name The name of the PDF.
39/// \param[in] title The title of the PDF.
40/// \param[in] t The time variable.
41/// \param[in] tau The average decay time parameter.
42/// \param[in] dgamma The Delta Gamma parameter.
43/// \param[in] f0 The Cosh Coefficient.
44/// \param[in] f1 The Sinh Coefficient.
45/// \param[in] f2 The Cos Coefficient.
46/// \param[in] f3 The Sin Coefficient.
47/// \param[in] dm The Delta Mass parameter.
48/// \param[in] model The resolution model.
49/// \param[in] type The decay type.
50
51RooBDecay::RooBDecay(const char *name, const char* title,
54 RooAbsReal& dm, const RooResolutionModel& model, DecayType type) :
55 RooAbsAnaConvPdf(name, title, model, t),
56 _t("t", "time", this, t),
57 _tau("tau", "Average Decay Time", this, tau),
58 _dgamma("dgamma", "Delta Gamma", this, dgamma),
59 _f0("f0", "Cosh Coefficient", this, f0),
60 _f1("f1", "Sinh Coefficient", this, f1),
61 _f2("f2", "Cos Coefficient", this, f2),
62 _f3("f3", "Sin Coefficient", this, f3),
63 _dm("dm", "Delta Mass", this, dm),
64 _type(type)
65
66{
67 //Constructor
68 switch(type)
69 {
70 case SingleSided:
71 _basisCosh = declareBasis("exp(-@0/@1)*cosh(@0*@2/2)", RooArgList(tau,dgamma));
72 _basisSinh = declareBasis("exp(-@0/@1)*sinh(@0*@2/2)", RooArgList(tau,dgamma));
73 _basisCos = declareBasis("exp(-@0/@1)*cos(@0*@2)",RooArgList(tau, dm));
74 _basisSin = declareBasis("exp(-@0/@1)*sin(@0*@2)",RooArgList(tau, dm));
75 break;
76 case Flipped:
77 _basisCosh = declareBasis("exp(@0/@1)*cosh(@0*@2/2)", RooArgList(tau,dgamma));
78 _basisSinh = declareBasis("exp(@0/@1)*sinh(@0*@2/2)", RooArgList(tau,dgamma));
79 _basisCos = declareBasis("exp(@0/@1)*cos(@0*@2)",RooArgList(tau, dm));
80 _basisSin = declareBasis("exp(@0/@1)*sin(@0*@2)",RooArgList(tau, dm));
81 break;
82 case DoubleSided:
83 _basisCosh = declareBasis("exp(-abs(@0)/@1)*cosh(@0*@2/2)", RooArgList(tau,dgamma));
84 _basisSinh = declareBasis("exp(-abs(@0)/@1)*sinh(@0*@2/2)", RooArgList(tau,dgamma));
85 _basisCos = declareBasis("exp(-abs(@0)/@1)*cos(@0*@2)",RooArgList(tau, dm));
86 _basisSin = declareBasis("exp(-abs(@0)/@1)*sin(@0*@2)",RooArgList(tau, dm));
87 break;
88 }
89}
90
91////////////////////////////////////////////////////////////////////////////////
92///Copy constructor
93
96 _t("t", this, other._t),
97 _tau("tau", this, other._tau),
98 _dgamma("dgamma", this, other._dgamma),
99 _f0("f0", this, other._f0),
100 _f1("f1", this, other._f1),
101 _f2("f2", this, other._f2),
102 _f3("f3", this, other._f3),
103 _dm("dm", this, other._dm),
104 _basisCosh(other._basisCosh),
105 _basisSinh(other._basisSinh),
106 _basisCos(other._basisCos),
107 _basisSin(other._basisSin),
108 _type(other._type)
109{
110}
111
112////////////////////////////////////////////////////////////////////////////////
113
115{
117 {
118 return _f0;
119 }
121 {
122 return _f1;
123 }
124 if(basisIndex == _basisCos)
125 {
126 return _f2;
127 }
128 if(basisIndex == _basisSin)
129 {
130 return _f3;
131 }
132
133 return 0 ;
134}
135
136////////////////////////////////////////////////////////////////////////////////
137
139{
141 {
142 return _f0.arg().getVariables();
143 }
145 {
146 return _f1.arg().getVariables();
147 }
148 if(basisIndex == _basisCos)
149 {
150 return _f2.arg().getVariables();
151 }
152 if(basisIndex == _basisSin)
153 {
154 return _f3.arg().getVariables();
155 }
156
157 return nullptr;
158}
159
160////////////////////////////////////////////////////////////////////////////////
161
163{
164 if(coef == _basisCosh)
165 {
166 return _f0.arg().getAnalyticalIntegral(allVars,analVars,rangeName) ;
167 }
168 if(coef == _basisSinh)
169 {
170 return _f1.arg().getAnalyticalIntegral(allVars,analVars,rangeName) ;
171 }
172 if(coef == _basisCos)
173 {
174 return _f2.arg().getAnalyticalIntegral(allVars,analVars,rangeName) ;
175 }
176 if(coef == _basisSin)
177 {
178 return _f3.arg().getAnalyticalIntegral(allVars,analVars,rangeName) ;
179 }
180
181 return 0 ;
182}
183
184////////////////////////////////////////////////////////////////////////////////
185
186double RooBDecay::coefAnalyticalIntegral(Int_t coef, Int_t code, const char* rangeName) const
187{
188 if(coef == _basisCosh)
189 {
190 return _f0.arg().analyticalIntegral(code,rangeName) ;
191 }
192 if(coef == _basisSinh)
193 {
194 return _f1.arg().analyticalIntegral(code,rangeName) ;
195 }
196 if(coef == _basisCos)
197 {
198 return _f2.arg().analyticalIntegral(code,rangeName) ;
199 }
200 if(coef == _basisSin)
201 {
202 return _f3.arg().analyticalIntegral(code,rangeName) ;
203 }
204
205 return 0 ;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209
211{
212 if (matchArgs(directVars, generateVars, _t)) return 1;
213 return 0;
214}
215
216////////////////////////////////////////////////////////////////////////////////
217
219{
220 R__ASSERT(code==1);
221 double gammamin = 1/_tau-std::abs(_dgamma)/2;
222 while(true) {
223 double t = -log(RooRandom::uniform())/gammamin;
224 if (_type == Flipped || (_type == DoubleSided && RooRandom::uniform() <0.5) ) t *= -1;
225 if ( t<_t.min() || t>_t.max() ) continue;
226
227 double dgt = _dgamma*t/2;
228 double dmt = _dm*t;
229 double ft = std::abs(t);
230 double f = exp(-ft/_tau)*(_f0*cosh(dgt)+_f1*sinh(dgt)+_f2*cos(dmt)+_f3*sin(dmt));
231 if(f < 0) {
232 std::cout << "RooBDecay::generateEvent(" << GetName() << ") ERROR: PDF value less than zero" << std::endl;
233 ::abort();
234 }
235 double w = 1.001*exp(-ft*gammamin)*(std::abs(_f0)+std::abs(_f1)+sqrt(_f2*_f2+_f3*_f3));
236 if(w < f) {
237 std::cout << "RooBDecay::generateEvent(" << GetName() << ") ERROR: Envelope function less than p.d.f. " << std::endl;
238 std::cout << _f0 << std::endl;
239 std::cout << _f1 << std::endl;
240 std::cout << _f2 << std::endl;
241 std::cout << _f3 << std::endl;
242 ::abort();
243 }
244 if(w*RooRandom::uniform() > f) continue;
245 _t = t;
246 break;
247 }
248}
#define f(i)
Definition RSha256.hxx:104
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:130
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:142
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.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
bool matchArgs(const RooArgSet &allDeps, RooArgSet &analDeps, const RooArgProxy &a, const Proxies &... proxies) const
Definition RooAbsReal.h:425
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:24
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:77
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:49
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:35