Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooBCPGenDecay.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$Id$
5 * Authors: *
6 * JGS, Jim Smith , University of Colorado, jgsmith@pizero.colorado.edu *
7 * History:
8 * 15-Aug-2002 JGS Created initial version
9 * 11-Sep-2002 JGS Mods to introduce mu (Mirna van Hoek, JGS, Nick Danielson)
10 * *
11 * Copyright (c) 2000-2005, Regents of the University of California, *
12 * University of Colorado *
13 * and Stanford University. All rights reserved. *
14 * *
15 * Redistribution and use in source and binary forms, *
16 * with or without modification, are permitted according to the terms *
17 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
18 *****************************************************************************/
19
20/** \class RooBCPGenDecay
21 \ingroup Roofit
22
23Implement standard CP physics model with S and C (no mention of lambda)
24Suitably stolen and modified from RooBCPEffDecay
25**/
26
27#include "RooRealVar.h"
28#include "RooRandom.h"
29#include "RooBCPGenDecay.h"
30#include "RooRealIntegral.h"
31
32using namespace std;
33
35
36/// \brief Constructor for RooBCPGenDecay.
37///
38/// Creates an instance of RooBCPGenDecay with the specified parameters.
39///
40/// \param[in] name The name of the PDF.
41/// \param[in] title The title of the PDF.
42/// \param[in] t The time variable.
43/// \param[in] tag The CP state category.
44/// \param[in] tau The decay time parameter.
45/// \param[in] dm The mixing frequency parameter.
46/// \param[in] avgMistag The average mistag rate parameter.
47/// \param[in] avgC Coefficient of cos term.
48/// \param[in] avgS Coefficient of sin term.
49/// \param[in] delMistag Delta mistag rate parameter.
50/// \param[in] mu Tag efficiency difference parameter.
51/// \param[in] model The resolution model.
52/// \param[in] type The decay type.
53
54RooBCPGenDecay::RooBCPGenDecay(const char *name, const char *title,
56 RooAbsReal& tau, RooAbsReal& dm,
57 RooAbsReal& avgMistag,
58 RooAbsReal& avgC, RooAbsReal& avgS,
59 RooAbsReal& delMistag,
60 RooAbsReal& mu,
61 const RooResolutionModel& model, DecayType type) :
62 RooAbsAnaConvPdf(name,title,model,t),
63 _avgC("C","Coefficient of cos term",this,avgC),
64 _avgS("S","Coefficient of sin term",this,avgS),
65 _avgMistag("avgMistag","Average mistag rate",this,avgMistag),
66 _delMistag("delMistag","Delta mistag rate",this,delMistag),
67 _mu("mu","Tag efficiency difference",this,mu),
68 _t("t","time",this,t),
69 _tau("tau","decay time",this,tau),
70 _dm("dm","mixing frequency",this,dm),
71 _tag("tag","CP state",this,tag),
72 _genB0Frac(0),
73 _type(type)
74{
75 switch(type) {
76 case SingleSided:
77 _basisExp = declareBasis("exp(-@0/@1)",RooArgList(tau,dm)) ;
78 _basisSin = declareBasis("exp(-@0/@1)*sin(@0*@2)",RooArgList(tau,dm)) ;
79 _basisCos = declareBasis("exp(-@0/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
80 break ;
81 case Flipped:
82 _basisExp = declareBasis("exp(@0)/@1)",RooArgList(tau,dm)) ;
83 _basisSin = declareBasis("exp(@0/@1)*sin(@0*@2)",RooArgList(tau,dm)) ;
84 _basisCos = declareBasis("exp(@0/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
85 break ;
86 case DoubleSided:
87 _basisExp = declareBasis("exp(-abs(@0)/@1)",RooArgList(tau,dm)) ;
88 _basisSin = declareBasis("exp(-abs(@0)/@1)*sin(@0*@2)",RooArgList(tau,dm)) ;
89 _basisCos = declareBasis("exp(-abs(@0)/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
90 break ;
91 }
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Copy constructor
96
99 _avgC("C",this,other._avgC),
100 _avgS("S",this,other._avgS),
101 _avgMistag("avgMistag",this,other._avgMistag),
102 _delMistag("delMistag",this,other._delMistag),
103 _mu("mu",this,other._mu),
104 _t("t",this,other._t),
105 _tau("tau",this,other._tau),
106 _dm("dm",this,other._dm),
107 _tag("tag",this,other._tag),
108 _genB0Frac(other._genB0Frac),
109 _type(other._type),
110 _basisExp(other._basisExp),
111 _basisSin(other._basisSin),
112 _basisCos(other._basisCos)
113{
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// B0 : _tag = +1
118/// B0bar : _tag = -1
119
120double RooBCPGenDecay::coefficient(Int_t basisIndex) const
121{
122 if (basisIndex==_basisExp) {
123 //exp term: (1 -/+ dw + mu*_tag*w)
124 return (1 - _tag*_delMistag + _mu*_tag*(1. - 2.*_avgMistag)) ;
125 // = 1 + _tag*deltaDil/2 + _mu*avgDil
126 }
127
128 if (basisIndex==_basisSin) {
129 //sin term: (+/- (1-2w) + _mu*(1 -/+ delw))*S
130 return (_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgS ;
131 // = (_tag*avgDil + _mu*(1 + tag*deltaDil/2)) * S
132 }
133
134 if (basisIndex==_basisCos) {
135 //cos term: -(+/- (1-2w) + _mu*(1 -/+ delw))*C
136 return -1.*(_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgC ;
137 // = -(_tag*avgDil + _mu*(1 + _tag*deltaDil/2) )* C
138 }
139
140 return 0 ;
141}
142
143////////////////////////////////////////////////////////////////////////////////
144
145Int_t RooBCPGenDecay::getCoefAnalyticalIntegral(Int_t /*code*/, RooArgSet& allVars, RooArgSet& analVars, const char* rangeName) const
146{
147 if (rangeName) return 0 ;
148 if (matchArgs(allVars,analVars,_tag)) return 1 ;
149 return 0 ;
150}
151
152////////////////////////////////////////////////////////////////////////////////
153
154double RooBCPGenDecay::coefAnalyticalIntegral(Int_t basisIndex, Int_t code, const char* /*rangeName*/) const
155{
156 switch(code) {
157 // No integration
158 case 0: return coefficient(basisIndex) ;
159
160 // Integration over 'tag'
161 case 1:
162 if (basisIndex==_basisExp) {
163 return 2 ;
164 }
165
166 if (basisIndex==_basisSin) {
167 return 2*_mu*_avgS ;
168 }
169 if (basisIndex==_basisCos) {
170 return -2*_mu*_avgC ;
171 }
172 break ;
173
174 default:
175 assert(0) ;
176 }
177
178 return 0 ;
179}
180
181////////////////////////////////////////////////////////////////////////////////
182
183Int_t RooBCPGenDecay::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool staticInitOK) const
184{
185 if (staticInitOK) {
186 if (matchArgs(directVars,generateVars,_t,_tag)) return 2 ;
187 }
188 if (matchArgs(directVars,generateVars,_t)) return 1 ;
189 return 0 ;
190}
191
192////////////////////////////////////////////////////////////////////////////////
193
195{
196 if (code==2) {
197 // Calculate the fraction of mixed events to generate
198 double sumInt = RooRealIntegral("sumInt","sum integral",*this,RooArgSet(_t.arg(),_tag.arg())).getVal() ;
199 _tag = 1 ;
200 double b0Int = RooRealIntegral("mixInt","mix integral",*this,RooArgSet(_t.arg())).getVal() ;
201 _genB0Frac = b0Int/sumInt ;
202 }
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Generate mix-state dependent
207
209{
210 if (code==2) {
211 double rand = RooRandom::uniform() ;
212 _tag = (rand<=_genB0Frac) ? 1 : -1 ;
213 }
214
215 // Generate delta-t dependent
216 while(true) {
217 double rand = RooRandom::uniform() ;
218 double tval(0) ;
219
220 switch(_type) {
221 case SingleSided:
222 tval = -_tau*log(rand);
223 break ;
224 case Flipped:
225 tval= +_tau*log(rand);
226 break ;
227 case DoubleSided:
228 tval = (rand<=0.5) ? -_tau*log(2*rand) : +_tau*log(2*(rand-0.5)) ;
229 break ;
230 }
231
232 // Accept event if T is in generated range
233 double maxDil = 1.0 ;
234// 2 in next line is conservative and inefficient - allows for delMistag=1!
235 double maxAcceptProb = 2 + std::abs(maxDil*_avgS) + std::abs(maxDil*_avgC);
236 double acceptProb = (1-_tag*_delMistag + _mu*_tag*(1. - 2.*_avgMistag))
237 + (_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgS*sin(_dm*tval)
238 - (_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgC*cos(_dm*tval);
239
240 bool accept = maxAcceptProb*RooRandom::uniform() < acceptProb ? true : false ;
241
242 if (tval<_t.max() && tval>_t.min() && accept) {
243 _t = tval ;
244 break ;
245 }
246 }
247
248}
#define ClassImp(name)
Definition Rtypes.h:377
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.
A space to attach TBranches.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
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:55
Implement standard CP physics model with S and C (no mention of lambda) Suitably stolen and modified ...
RooRealProxy _mu
RooRealProxy _avgC
RooRealProxy _avgS
void initGenerator(Int_t code) override
Interface for one-time initialization to setup the generator for the specified code.
RooRealProxy _dm
RooRealProxy _tau
void generateEvent(Int_t code) override
Generate mix-state dependent.
RooCategoryProxy _tag
RooRealProxy _t
double coefficient(Int_t basisIndex) const override
B0 : _tag = +1 B0bar : _tag = -1.
Int_t getCoefAnalyticalIntegral(Int_t coef, RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Default implementation of function advertising integration capabilities.
RooRealProxy _avgMistag
RooRealProxy _delMistag
double coefAnalyticalIntegral(Int_t coef, Int_t code, const char *rangeName=nullptr) const override
Default implementation of function implementing advertised integrals.
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...
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Definition RooRandom.cxx:81
Performs hybrid numerical/analytical integrals of RooAbsReal objects.
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.