Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooBMixDecay.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 RooBMixDecay
18 \ingroup Roofit
19
20Class RooBMixDecay is a RooAbsAnaConvPdf implementation that describes
21the decay of B mesons with the effects of B0/B0bar mixing.
22This function can be analytically convolved with any RooResolutionModel implementation
23**/
24
25#include "RooRealVar.h"
26#include "RooBMixDecay.h"
27#include "RooRealIntegral.h"
28#include "RooRandom.h"
29#include "RooBatchCompute.h"
30
31
32/// \brief Constructor for RooBMixDecay.
33///
34/// Creates an instance of RooBMixDecay with the specified parameters.
35///
36/// \param[in] name The name of the PDF.
37/// \param[in] title The title of the PDF.
38/// \param[in] t The time variable.
39/// \param[in] mixState The mixing state category.
40/// \param[in] tagFlav The flavour of tagged B0 category.
41/// \param[in] tau The mixing life time parameter.
42/// \param[in] dm The mixing frequency parameter.
43/// \param[in] mistag The mistag rate parameter.
44/// \param[in] delMistag The delta mistag rate parameter.
45/// \param[in] model The resolution model.
46/// \param[in] type The decay type.
47
48RooBMixDecay::RooBMixDecay(const char *name, const char *title,
51 RooAbsReal& tau, RooAbsReal& dm,
53 const RooResolutionModel& model,
55 RooAbsAnaConvPdf(name,title,model,t),
56 _type(type),
57 _mistag("mistag","Mistag rate",this,mistag),
58 _delMistag("delMistag","Delta mistag rate",this,delMistag),
59 _mixState("mixState","Mixing state",this,mixState),
60 _tagFlav("tagFlav","Flavour of tagged B0",this,tagFlav),
61 _tau("tau","Mixing life time",this,tau),
62 _dm("dm","Mixing frequency",this,dm),
63 _t("_t","time",this,t), _genMixFrac(0)
64{
65 switch(type) {
66 case SingleSided:
67 _basisExp = declareBasis("exp(-@0/@1)",RooArgList(tau)) ;
68 _basisCos = declareBasis("exp(-@0/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
69 break ;
70 case Flipped:
71 _basisExp = declareBasis("exp(@0/@1)",RooArgList(tau)) ;
72 _basisCos = declareBasis("exp(@0/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
73 break ;
74 case DoubleSided:
75 _basisExp = declareBasis("exp(-abs(@0)/@1)",RooArgList(tau)) ;
76 _basisCos = declareBasis("exp(-abs(@0)/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
77 break ;
78 }
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Copy constructor
83
86 _type(other._type),
87 _mistag("mistag",this,other._mistag),
88 _delMistag("delMistag",this,other._delMistag),
89 _mixState("mixState",this,other._mixState),
90 _tagFlav("tagFlav",this,other._tagFlav),
91 _tau("tau",this,other._tau),
92 _dm("dm",this,other._dm),
93 _t("t",this,other._t),
94 _basisExp(other._basisExp),
95 _basisCos(other._basisCos),
96 _genMixFrac(other._genMixFrac),
97 _genFlavFrac(other._genFlavFrac),
98 _genFlavFracMix(other._genFlavFracMix),
99 _genFlavFracUnmix(other._genFlavFracUnmix)
100{
101}
102
103////////////////////////////////////////////////////////////////////////////////
104/// Comp with tFit MC: must be (1 - tagFlav*...)
105
107{
108 if (basisIndex==_basisExp) {
109 return (1 - _tagFlav*_delMistag) ;
110 }
111
112 if (basisIndex==_basisCos) {
113 return _mixState*(1-2*_mistag) ;
114 }
115
116 return 0 ;
117}
118
120{
122 {ctx.at(&_convSet[0]), ctx.at(&_convSet[1]), ctx.at(_tagFlav),
123 ctx.at(_delMistag), ctx.at(_mixState), ctx.at(_mistag)});
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// std::cout << "RooBMixDecay::getCoefAI " ; allVars.Print("1") ;
128
130{
131 if (rangeName) {
132 return 0 ;
133 }
134
135 if (matchArgs(allVars,analVars,_mixState,_tagFlav)) return 3 ;
136 if (matchArgs(allVars,analVars,_mixState)) return 2 ;
137 if (matchArgs(allVars,analVars,_tagFlav)) return 1 ;
138 return 0 ;
139}
140
141////////////////////////////////////////////////////////////////////////////////
142
143double RooBMixDecay::coefAnalyticalIntegral(Int_t basisIndex, Int_t code, const char* /*rangeName*/) const
144{
145 switch(code) {
146 // No integration
147 case 0: return coefficient(basisIndex) ;
148
149 // Integration over 'mixState' and 'tagFlav'
150 case 3:
151 if (basisIndex==_basisExp) {
152 return 4.0 ;
153 }
154 if (basisIndex==_basisCos) {
155 return 0.0 ;
156 }
157 break ;
158
159 // Integration over 'mixState'
160 case 2:
161 if (basisIndex==_basisExp) {
162 return 2.0*coefficient(basisIndex) ;
163 }
164 if (basisIndex==_basisCos) {
165 return 0.0 ;
166 }
167 break ;
168
169 // Integration over 'tagFlav'
170 case 1:
171 if (basisIndex==_basisExp) {
172 return 2.0 ;
173 }
174 if (basisIndex==_basisCos) {
175 return 2.0*coefficient(basisIndex) ;
176 }
177 break ;
178
179 default:
180 assert(0) ;
181 }
182
183 return 0 ;
184}
185
186////////////////////////////////////////////////////////////////////////////////
187
189{
190 if (staticInitOK) {
194 }
195
196 if (matchArgs(directVars,generateVars,_t)) return 1 ;
197 return 0 ;
198}
199
200////////////////////////////////////////////////////////////////////////////////
201
203{
204 switch (code) {
205 case 2:
206 {
207 // Calculate the fraction of B0bar events to generate
208 double sumInt = RooRealIntegral("sumInt","sum integral",*this,RooArgSet(_t.arg(),_tagFlav.arg())).getVal() ;
209 _tagFlav = 1 ; // B0
210 double flavInt = RooRealIntegral("flavInt","flav integral",*this,RooArgSet(_t.arg())).getVal() ;
212 break ;
213 }
214 case 3:
215 {
216 // Calculate the fraction of mixed events to generate
217 double sumInt = RooRealIntegral("sumInt","sum integral",*this,RooArgSet(_t.arg(),_mixState.arg())).getVal() ;
218 _mixState = -1 ; // mixed
219 double mixInt = RooRealIntegral("mixInt","mix integral",*this,RooArgSet(_t.arg())).getVal() ;
221 break ;
222 }
223 case 4:
224 {
225 // Calculate the fraction of mixed events to generate
226 double sumInt = RooRealIntegral("sumInt","sum integral",*this,RooArgSet(_t.arg(),_mixState.arg(),_tagFlav.arg())).getVal() ;
227 _mixState = -1 ; // mixed
228 double mixInt = RooRealIntegral("mixInt","mix integral",*this,RooArgSet(_t.arg(),_tagFlav.arg())).getVal() ;
230
231 // Calculate the fraction of B0bar tags for mixed and unmixed
232 RooRealIntegral dtInt("mixInt","mix integral",*this,RooArgSet(_t.arg())) ;
233 _mixState = -1 ; // Mixed
234 _tagFlav = 1 ; // B0
235 _genFlavFracMix = dtInt.getVal() / mixInt ;
236 _mixState = 1 ; // Unmixed
237 _tagFlav = 1 ; // B0
238 _genFlavFracUnmix = dtInt.getVal() / (sumInt - mixInt) ;
239 break ;
240 }
241 }
242}
243
244////////////////////////////////////////////////////////////////////////////////
245/// Generate mix-state dependent
246
248{
249 switch(code) {
250 case 2:
251 {
252 double rand = RooRandom::uniform() ;
253 _tagFlav = (Int_t) ((rand<=_genFlavFrac) ? 1 : -1) ;
254 break ;
255 }
256 case 3:
257 {
258 double rand = RooRandom::uniform() ;
259 _mixState = (Int_t) ((rand<=_genMixFrac) ? -1 : 1) ;
260 break ;
261 }
262 case 4:
263 {
264 double rand = RooRandom::uniform() ;
265 _mixState = (Int_t) ((rand<=_genMixFrac) ? -1 : 1) ;
266
269 _tagFlav = (Int_t) ((rand<=genFlavFrac) ? 1 : -1) ;
270 break ;
271 }
272 }
273
274 // Generate delta-t dependent
275 while(true) {
276 double rand = RooRandom::uniform() ;
277 double tval(0) ;
278
279 switch(_type) {
280 case SingleSided:
281 tval = -_tau*log(rand);
282 break ;
283 case Flipped:
284 tval= +_tau*log(rand);
285 break ;
286 case DoubleSided:
287 tval = (rand<=0.5) ? -_tau*log(2*rand) : +_tau*log(2*(rand-0.5)) ;
288 break ;
289 }
290
291 // Accept event if T is in generated range
292 double dil = 1-2.*_mistag ;
293 double maxAcceptProb = 1 + std::abs(_delMistag) + std::abs(dil) ;
294 double acceptProb = (1-_tagFlav*_delMistag) + _mixState*dil*cos(_dm*tval);
296
297 if (tval<_t.max() && tval>_t.min() && mixAccept) {
298 _t = tval ;
299 break ;
300 }
301 }
302}
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
friend class RooRealIntegral
Definition RooAbsArg.h:543
A space to attach TBranches.
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
Class RooBMixDecay is a RooAbsAnaConvPdf implementation that describes the decay of B mesons with the...
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...
RooRealProxy _tau
double _genMixFrac
! do not persist
double coefAnalyticalIntegral(Int_t coef, Int_t code, const char *rangeName=nullptr) const override
Default implementation of function implementing advertised integrals.
DecayType _type
double _genFlavFracMix
!
RooRealProxy _mistag
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
RooRealProxy _t
void initGenerator(Int_t code) override
Interface for one-time initialization to setup the generator for the specified code.
void generateEvent(Int_t code) override
Generate mix-state dependent.
RooCategoryProxy _mixState
Int_t getCoefAnalyticalIntegral(Int_t coef, RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
std::cout << "RooBMixDecay::getCoefAI " ; allVars.Print("1") ;
double coefficient(Int_t basisIndex) const override
Comp with tFit MC: must be (1 - tagFlav*...)
double _genFlavFracUnmix
!
RooRealProxy _dm
double _genFlavFrac
!
RooCategoryProxy _tagFlav
RooRealProxy _delMistag
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Definition RooRandom.cxx:77
Performs hybrid numerical/analytical integrals of RooAbsReal objects.
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.
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})