58 ClassImp(RooNonCPEigenDecay);
60 #define Debug_RooNonCPEigenDecay 1
65 RooNonCPEigenDecay::RooNonCPEigenDecay(
const char *name,
const char *title,
80 const RooResolutionModel& model,
82 : RooAbsAnaConvPdf( name, title, model, t ),
83 _acp (
"acp",
"acp", this, acp ),
84 _avgC (
"C",
"C", this, C ),
85 _delC (
"delC",
"delC", this, delC ),
86 _avgS (
"S",
"S", this, S ),
87 _delS (
"delS",
"delS", this, delS ),
88 _avgW (
"avgW",
"Average mistag rate",this, avgW ),
89 _delW (
"delW",
"Shift mistag rate", this, delW ),
90 _t (
"t",
"time", this, t ),
91 _tau (
"tau",
"decay time", this, tau ),
92 _dm (
"dm",
"mixing frequency", this, dm ),
93 _tag (
"tag",
"CP state", this, tag ),
94 _rhoQ (
"rhoQ",
"Charge of the rho", this, rhoQ ),
95 _correctQ (
"correctQ",
"correction of rhoQ", this, correctQ ),
96 _wQ (
"wQ",
"mischarge", this, wQ ),
104 _basisExp = declareBasis(
"exp(-@0/@1)", RooArgList( tau ) );
105 _basisSin = declareBasis(
"exp(-@0/@1)*sin(@0*@2)", RooArgList( tau, dm ) );
106 _basisCos = declareBasis(
"exp(-@0/@1)*cos(@0*@2)", RooArgList( tau, dm ) );
109 _basisExp = declareBasis(
"exp(@0)/@1)", RooArgList( tau ) );
110 _basisSin = declareBasis(
"exp(@0/@1)*sin(@0*@2)", RooArgList( tau, dm ) );
111 _basisCos = declareBasis(
"exp(@0/@1)*cos(@0*@2)", RooArgList( tau, dm ) );
114 _basisExp = declareBasis(
"exp(-abs(@0)/@1)", RooArgList( tau ) );
115 _basisSin = declareBasis(
"exp(-abs(@0)/@1)*sin(@0*@2)", RooArgList( tau, dm ) );
116 _basisCos = declareBasis(
"exp(-abs(@0)/@1)*cos(@0*@2)", RooArgList( tau, dm ) );
123 RooNonCPEigenDecay::RooNonCPEigenDecay(
const char *name,
const char *title,
130 RooAbsCategory& rhoQ,
131 RooAbsReal& correctQ,
137 const RooResolutionModel& model,
139 : RooAbsAnaConvPdf( name, title, model, t ),
140 _acp (
"acp",
"acp", this, acp ),
141 _avgC (
"C",
"C", this, C ),
142 _delC (
"delC",
"delC", this, delC ),
143 _avgS (
"S",
"S", this, S ),
144 _delS (
"delS",
"delS", this, delS ),
145 _avgW (
"avgW",
"Average mistag rate",this, avgW ),
146 _delW (
"delW",
"Shift mistag rate", this, delW ),
147 _t (
"t",
"time", this, t ),
148 _tau (
"tau",
"decay time", this, tau ),
149 _dm (
"dm",
"mixing frequency", this, dm ),
150 _tag (
"tag",
"CP state", this, tag ),
151 _rhoQ (
"rhoQ",
"Charge of the rho", this, rhoQ ),
152 _correctQ (
"correctQ",
"correction of rhoQ", this, correctQ ),
154 _genRhoPlusFrac( 0 ),
158 _wQ = RooRealProxy(
"wQ",
"mischarge",
this, *(
new RooRealVar(
"wQ",
"wQ", 0 )) );
162 _basisExp = declareBasis(
"exp(-@0/@1)", RooArgList( tau ) );
163 _basisSin = declareBasis(
"exp(-@0/@1)*sin(@0*@2)", RooArgList( tau, dm ) );
164 _basisCos = declareBasis(
"exp(-@0/@1)*cos(@0*@2)", RooArgList( tau, dm ) );
167 _basisExp = declareBasis(
"exp(@0)/@1)", RooArgList( tau ) );
168 _basisSin = declareBasis(
"exp(@0/@1)*sin(@0*@2)", RooArgList( tau, dm ) );
169 _basisCos = declareBasis(
"exp(@0/@1)*cos(@0*@2)", RooArgList( tau, dm ) );
172 _basisExp = declareBasis(
"exp(-abs(@0)/@1)", RooArgList( tau ) );
173 _basisSin = declareBasis(
"exp(-abs(@0)/@1)*sin(@0*@2)", RooArgList( tau, dm ) );
174 _basisCos = declareBasis(
"exp(-abs(@0)/@1)*cos(@0*@2)", RooArgList( tau, dm ) );
182 RooNonCPEigenDecay::RooNonCPEigenDecay(
const RooNonCPEigenDecay& other,
const char* name )
183 : RooAbsAnaConvPdf( other, name ),
184 _acp (
"acp", this, other._acp ),
185 _avgC (
"C", this, other._avgC ),
186 _delC (
"delC", this, other._delC ),
187 _avgS (
"S", this, other._avgS ),
188 _delS (
"delS", this, other._delS ),
189 _avgW (
"avgW", this, other._avgW ),
190 _delW (
"delW", this, other._delW ),
191 _t (
"t", this, other._t ),
192 _tau (
"tau", this, other._tau ),
193 _dm (
"dm", this, other._dm ),
194 _tag (
"tag", this, other._tag ),
195 _rhoQ (
"rhoQ", this, other._rhoQ ),
196 _correctQ (
"correctQ", this, other._correctQ ),
197 _wQ (
"wQ", this, other._wQ ),
198 _genB0Frac ( other._genB0Frac ),
199 _genRhoPlusFrac( other._genRhoPlusFrac ),
200 _type ( other._type ),
201 _basisExp ( other._basisExp ),
202 _basisSin ( other._basisSin ),
203 _basisCos ( other._basisCos )
210 RooNonCPEigenDecay::~RooNonCPEigenDecay(
void )
221 Double_t RooNonCPEigenDecay::coefficient( Int_t basisIndex )
const
223 Int_t rhoQc = _rhoQ * int(_correctQ);
224 assert( rhoQc == 1 || rhoQc == -1 );
226 Double_t a_sin_p = _avgS + _delS;
227 Double_t a_sin_m = _avgS - _delS;
228 Double_t a_cos_p = _avgC + _delC;
229 Double_t a_cos_m = _avgC - _delC;
231 if (basisIndex == _basisExp) {
232 if (rhoQc == -1 || rhoQc == +1)
233 return (1 + rhoQc*_acp*(1 - 2*_wQ))*(1 + 0.5*_tag*(2*_delW));
238 if (basisIndex == _basisSin) {
242 return - ((1 - _acp)*a_sin_m*(1 - _wQ) + (1 + _acp)*a_sin_p*_wQ)*(1 - 2*_avgW)*_tag;
244 else if (rhoQc == +1)
246 return - ((1 + _acp)*a_sin_p*(1 - _wQ) + (1 - _acp)*a_sin_m*_wQ)*(1 - 2*_avgW)*_tag;
249 return - _tag*((a_sin_p + a_sin_m)/2)*(1 - 2*_avgW);
252 if (basisIndex == _basisCos) {
256 return + ((1 - _acp)*a_cos_m*(1 - _wQ) + (1 + _acp)*a_cos_p*_wQ)*(1 - 2*_avgW)*_tag;
258 else if (rhoQc == +1)
260 return + ((1 + _acp)*a_cos_p*(1 - _wQ) + (1 - _acp)*a_cos_m*_wQ)*(1 - 2*_avgW)*_tag;
263 return _tag*((a_cos_p + a_cos_m)/2)*(1 - 2*_avgW);
273 Int_t RooNonCPEigenDecay::getCoefAnalyticalIntegral( Int_t , RooArgSet& allVars,
274 RooArgSet& analVars,
const char* rangeName )
const
276 if (rangeName)
return 0 ;
278 if (matchArgs( allVars, analVars, _tag, _rhoQ ))
return 3;
279 if (matchArgs( allVars, analVars, _rhoQ ))
return 2;
280 if (matchArgs( allVars, analVars, _tag ))
return 1;
288 Double_t RooNonCPEigenDecay::coefAnalyticalIntegral( Int_t basisIndex,
289 Int_t code,
const char* )
const
291 Int_t rhoQc = _rhoQ*int(_correctQ);
293 Double_t a_sin_p = _avgS + _delS;
294 Double_t a_sin_m = _avgS - _delS;
295 Double_t a_cos_p = _avgC + _delC;
296 Double_t a_cos_m = _avgC - _delC;
301 case 0:
return coefficient(basisIndex);
305 if (basisIndex == _basisExp)
return 2*(1 + rhoQc*_acp*(1 - 2*_wQ));
306 if (basisIndex == _basisSin || basisIndex==_basisCos)
return 0;
311 if (basisIndex == _basisExp)
return 2*(1 + 0.5*_tag*(2.*_delW));
313 if (basisIndex == _basisSin)
315 return - ( (1 - _acp)*a_sin_m + (1 + _acp)*a_sin_p )*(1 - 2*_avgW)*_tag;
317 if (basisIndex == _basisCos)
319 return + ( (1 - _acp)*a_cos_m + (1 + _acp)*a_cos_p )*(1 - 2*_avgW)*_tag;
325 if (basisIndex == _basisExp)
return 2*2;
326 if (basisIndex == _basisSin || basisIndex==_basisCos)
return 0;
338 Int_t RooNonCPEigenDecay::getGenerator(
const RooArgSet& directVars,
339 RooArgSet& generateVars, Bool_t staticInitOK )
const
342 if (matchArgs( directVars, generateVars, _t, _tag, _rhoQ ))
return 4;
343 if (matchArgs( directVars, generateVars, _t, _rhoQ ))
return 3;
344 if (matchArgs( directVars, generateVars, _t, _tag ))
return 2;
346 if (matchArgs( directVars, generateVars, _t ))
return 1;
352 void RooNonCPEigenDecay::initGenerator( Int_t code )
354 if (code == 2 || code == 4) {
356 Double_t sumInt1 = RooRealIntegral(
"sumInt1",
"sum integral1", *
this,
357 RooArgSet( _t.arg(), _tag.arg(), _rhoQ.arg() )
360 Double_t b0Int1 = RooRealIntegral(
"mixInt1",
"mix integral1", *
this,
361 RooArgSet( _t.arg(), _rhoQ.arg() )
363 _genB0Frac = b0Int1/sumInt1;
365 if (Debug_RooNonCPEigenDecay == 1)
366 cout <<
" o RooNonCPEigenDecay::initgenerator: genB0Frac : "
368 <<
", tag dilution: " << (1 - 2*_avgW)
372 if (code == 3 || code == 4) {
374 Double_t sumInt2 = RooRealIntegral(
"sumInt2",
"sum integral2", *
this,
375 RooArgSet( _t.arg(), _tag.arg(), _rhoQ.arg() )
378 Double_t b0Int2 = RooRealIntegral(
"mixInt2",
"mix integral2", *
this,
379 RooArgSet( _t.arg(), _tag.arg() )
381 _genRhoPlusFrac = b0Int2/sumInt2;
383 if (Debug_RooNonCPEigenDecay == 1)
384 cout <<
" o RooNonCPEigenDecay::initgenerator: genRhoPlusFrac: "
385 << _genRhoPlusFrac << endl;
391 void RooNonCPEigenDecay::generateEvent( Int_t code )
398 if (code != 3) _tag = (RooRandom::uniform()<=0.5) ? -1 : +1;
399 if (code != 2) _rhoQ = (RooRandom::uniform()<=0.5) ? 1 : -1;
405 Double_t a_sin_p = _avgS + _delS;
406 Double_t a_sin_m = _avgS - _delS;
407 Double_t a_cos_p = _avgC + _delC;
408 Double_t a_cos_m = _avgC - _delC;
411 double a1 = 1 + sqrt(TMath::Power(a_cos_m, 2) + TMath::Power(a_sin_m, 2));
412 double a2 = 1 + sqrt(TMath::Power(a_cos_p, 2) + TMath::Power(a_sin_p, 2));
414 Double_t maxAcceptProb = (1.10 + TMath::Abs(_acp)) * (a1 > a2 ? a1 : a2);
417 Double_t rand = RooRandom::uniform();
423 tval = -_tau*log(rand);
427 tval = +_tau*log(rand);
431 tval = (rand<=0.5) ? -_tau*log(2*rand) : +_tau*log(2*(rand-0.5));
436 Double_t expC = coefficient( _basisExp );
437 Double_t sinC = coefficient( _basisSin );
438 Double_t cosC = coefficient( _basisCos );
441 Double_t acceptProb = expC + sinC*sin(_dm*tval) + cosC*cos(_dm*tval);
444 assert( acceptProb <= maxAcceptProb );
447 Bool_t accept = maxAcceptProb*RooRandom::uniform() < acceptProb ? kTRUE : kFALSE;
449 if (accept && tval<_t.max() && tval>_t.min()) {