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