34 ClassImp(RooBCPGenDecay);
39 RooBCPGenDecay::RooBCPGenDecay(
const char *name,
const char *title,
40 RooRealVar& t, RooAbsCategory& tag,
41 RooAbsReal& tau, RooAbsReal& dm,
42 RooAbsReal& avgMistag,
43 RooAbsReal& a, RooAbsReal& b,
44 RooAbsReal& delMistag,
46 const RooResolutionModel& model, DecayType type) :
47 RooAbsAnaConvPdf(name,title,model,t),
48 _avgC(
"C",
"Coefficient of cos term",this,a),
49 _avgS(
"S",
"Coefficient of sin term",this,b),
50 _avgMistag(
"avgMistag",
"Average mistag rate",this,avgMistag),
51 _delMistag(
"delMistag",
"Delta mistag rate",this,delMistag),
52 _mu(
"mu",
"Tagg efficiency difference",this,mu),
53 _t(
"t",
"time",this,t),
54 _tau(
"tau",
"decay time",this,tau),
55 _dm(
"dm",
"mixing frequency",this,dm),
56 _tag(
"tag",
"CP state",this,tag),
62 _basisExp = declareBasis(
"exp(-@0/@1)",RooArgList(tau,dm)) ;
63 _basisSin = declareBasis(
"exp(-@0/@1)*sin(@0*@2)",RooArgList(tau,dm)) ;
64 _basisCos = declareBasis(
"exp(-@0/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
67 _basisExp = declareBasis(
"exp(@0)/@1)",RooArgList(tau,dm)) ;
68 _basisSin = declareBasis(
"exp(@0/@1)*sin(@0*@2)",RooArgList(tau,dm)) ;
69 _basisCos = declareBasis(
"exp(@0/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
72 _basisExp = declareBasis(
"exp(-abs(@0)/@1)",RooArgList(tau,dm)) ;
73 _basisSin = declareBasis(
"exp(-abs(@0)/@1)*sin(@0*@2)",RooArgList(tau,dm)) ;
74 _basisCos = declareBasis(
"exp(-abs(@0)/@1)*cos(@0*@2)",RooArgList(tau,dm)) ;
82 RooBCPGenDecay::RooBCPGenDecay(
const RooBCPGenDecay& other,
const char* name) :
83 RooAbsAnaConvPdf(other,name),
84 _avgC(
"C",this,other._avgC),
85 _avgS(
"S",this,other._avgS),
86 _avgMistag(
"avgMistag",this,other._avgMistag),
87 _delMistag(
"delMistag",this,other._delMistag),
88 _mu(
"mu",this,other._mu),
89 _t(
"t",this,other._t),
90 _tau(
"tau",this,other._tau),
91 _dm(
"dm",this,other._dm),
92 _tag(
"tag",this,other._tag),
93 _genB0Frac(other._genB0Frac),
95 _basisExp(other._basisExp),
96 _basisSin(other._basisSin),
97 _basisCos(other._basisCos)
104 RooBCPGenDecay::~RooBCPGenDecay()
112 Double_t RooBCPGenDecay::coefficient(Int_t basisIndex)
const
114 if (basisIndex==_basisExp) {
116 return (1 - _tag*_delMistag + _mu*_tag*(1. - 2.*_avgMistag)) ;
120 if (basisIndex==_basisSin) {
122 return (_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgS ;
126 if (basisIndex==_basisCos) {
128 return -1.*(_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgC ;
137 Int_t RooBCPGenDecay::getCoefAnalyticalIntegral(Int_t , RooArgSet& allVars, RooArgSet& analVars,
const char* rangeName)
const
139 if (rangeName)
return 0 ;
140 if (matchArgs(allVars,analVars,_tag))
return 1 ;
146 Double_t RooBCPGenDecay::coefAnalyticalIntegral(Int_t basisIndex, Int_t code,
const char* )
const
150 case 0:
return coefficient(basisIndex) ;
154 if (basisIndex==_basisExp) {
158 if (basisIndex==_basisSin) {
161 if (basisIndex==_basisCos) {
162 return -2*_mu*_avgC ;
175 Int_t RooBCPGenDecay::getGenerator(
const RooArgSet& directVars, RooArgSet &generateVars, Bool_t staticInitOK)
const
178 if (matchArgs(directVars,generateVars,_t,_tag))
return 2 ;
180 if (matchArgs(directVars,generateVars,_t))
return 1 ;
186 void RooBCPGenDecay::initGenerator(Int_t code)
190 Double_t sumInt = RooRealIntegral(
"sumInt",
"sum integral",*
this,RooArgSet(_t.arg(),_tag.arg())).getVal() ;
192 Double_t b0Int = RooRealIntegral(
"mixInt",
"mix integral",*
this,RooArgSet(_t.arg())).getVal() ;
193 _genB0Frac = b0Int/sumInt ;
200 void RooBCPGenDecay::generateEvent(Int_t code)
203 Double_t rand = RooRandom::uniform() ;
204 _tag = (rand<=_genB0Frac) ? 1 : -1 ;
209 Double_t rand = RooRandom::uniform() ;
214 tval = -_tau*log(rand);
217 tval= +_tau*log(rand);
220 tval = (rand<=0.5) ? -_tau*log(2*rand) : +_tau*log(2*(rand-0.5)) ;
225 Double_t maxDil = 1.0 ;
227 Double_t maxAcceptProb = 2 + fabs(maxDil*_avgS) + fabs(maxDil*_avgC);
228 Double_t acceptProb = (1-_tag*_delMistag + _mu*_tag*(1. - 2.*_avgMistag))
229 + (_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgS*sin(_dm*tval)
230 - (_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgC*cos(_dm*tval);
232 Bool_t accept = maxAcceptProb*RooRandom::uniform() < acceptProb ? kTRUE : kFALSE ;
234 if (tval<_t.max() && tval>_t.min() && accept) {