1 // $Id: EvtIncoherentMixing.cpp,v 1.13 2009-11-27 09:09:41 mwhitehe Exp $
6 #include "EvtGenBase/EvtIncoherentMixing.hh"
8 #include "EvtGenBase/EvtPDL.hh"
9 #include "EvtGenBase/EvtId.hh"
10 #include "EvtGenBase/EvtRandom.hh"
12 //-----------------------------------------------------------------------------
13 // Implementation file for class : EvtIncoherentMixing
15 // 2003-10-09 : Patrick Robbe
16 //-----------------------------------------------------------------------------
19 bool EvtIncoherentMixing::_doB0Mixing = false ;
20 bool EvtIncoherentMixing::_doBsMixing = false ;
21 bool EvtIncoherentMixing::_enableFlip = false ;
22 double EvtIncoherentMixing::_dGammad = 0. ;
23 double EvtIncoherentMixing::_deltamd = 0.502e12 ;
24 // dGamma_s corresponds to DeltaGamma / Gamma = 10 %
25 double EvtIncoherentMixing::_dGammas = 6.852e10 ;
26 double EvtIncoherentMixing::_deltams = 20.e12 ;
28 //=============================================================================
29 // Standard constructor, initializes variables
30 //=============================================================================
31 EvtIncoherentMixing::EvtIncoherentMixing( ) {
35 // dGammas corresponds to DeltaGamma / Gamma = 10 %
41 //=============================================================================
42 EvtIncoherentMixing::~EvtIncoherentMixing( )
45 // ============================================================================
46 void EvtIncoherentMixing::incoherentB0Mix( const EvtId id, double &t ,
49 static EvtId B0 = EvtPDL::getId( "B0" ) ;
50 static EvtId B0B = EvtPDL::getId( "anti-B0" ) ;
52 if ( ( B0 != id ) && ( B0B != id ) ) {
53 report(ERROR,"EvtGen") << "Bad configuration in incoherentB0Mix"
58 double x = getdeltamd() * EvtPDL::getctau( B0 ) / EvtConst::c ;
60 double y = getdGammad() * ( EvtPDL::getctau( B0 ) / EvtConst::c ) / 2. ;
62 double fac = 1. ; // No CP violation
64 double mixprob = ( x*x + y*y ) / ( x*x + y*y + ( 1./fac ) *
65 ( 2. + x*x - y*y ) ) ;
69 // decide if state is mixed
70 mixsign = ( mixprob > EvtRandom::Flat( 0. , 1. ) ) ? -1 : 1 ;
75 t = -log( EvtRandom::Flat() ) * EvtPDL::getctau( B0 ) / ( 1. - y ) ;
76 prob = ( 1. + exp( -2. * y * t / EvtPDL::getctau( B0 ) ) +
77 mixsign * 2. * exp( -y * t / EvtPDL::getctau( B0 ) ) *
78 cos( getdeltamd() * t / EvtConst::c ) ) / 2. ;
79 } while ( prob < 2. * EvtRandom::Flat() ) ;
82 if ( mixsign == -1 ) mix = 1 ;
86 // ============================================================================
87 void EvtIncoherentMixing::incoherentBsMix( const EvtId id, double &t ,
90 static EvtId BS = EvtPDL::getId( "B_s0" ) ;
91 static EvtId BSB = EvtPDL::getId( "anti-B_s0" ) ;
93 if ( ( BS != id ) && ( BSB != id ) ) {
94 report(ERROR,"EvtGen") << "Bad configuration in incoherentBsMix"
99 double x = getdeltams() * EvtPDL::getctau( BS ) / EvtConst::c ;
101 double y = getdGammas() * ( EvtPDL::getctau( BS ) / EvtConst::c ) / 2. ;
103 double fac = 1. ; // No CP violation
105 double mixprob = ( x*x + y*y ) / ( x*x + y*y + ( 1./fac ) *
106 ( 2. + x*x - y*y ) ) ;
110 // decide if state is mixed
111 mixsign = ( mixprob > EvtRandom::Flat( 0. , 1. ) ) ? -1 : 1 ;
116 t = -log( EvtRandom::Flat() ) * EvtPDL::getctau( BS ) / ( 1. - y ) ;
117 prob = ( 1. + exp( -2. * y * t / EvtPDL::getctau( BS ) ) +
118 mixsign * 2. * exp( -y * t / EvtPDL::getctau( BS ) ) *
119 cos( getdeltams() * t / EvtConst::c ) ) / 2. ;
120 } while ( prob < 2. * EvtRandom::Flat() ) ;
123 if ( mixsign == -1 ) mix = 1 ;
128 // ========================================================================
129 bool EvtIncoherentMixing::isBsMixed ( EvtParticle * p )
131 if ( ! ( p->getParent() ) ) return false ;
133 static EvtId BS0=EvtPDL::getId("B_s0");
134 static EvtId BSB=EvtPDL::getId("anti-B_s0");
136 if ( ( p->getId() != BS0 ) && ( p->getId() != BSB ) ) return false ;
138 if ( ( p->getParent()->getId() == BS0 ) ||
139 ( p->getParent()->getId() == BSB ) ) return true ;
144 // ========================================================================
145 bool EvtIncoherentMixing::isB0Mixed ( EvtParticle * p )
147 if ( ! ( p->getParent() ) ) return false ;
149 static EvtId B0 =EvtPDL::getId("B0");
150 static EvtId B0B=EvtPDL::getId("anti-B0");
152 if ( ( p->getId() != B0 ) && ( p->getId() != B0B ) ) return false ;
154 if ( ( p->getParent()->getId() == B0 ) ||
155 ( p->getParent()->getId() == B0B ) ) return true ;
159 //============================================================================
160 // Return the tag of the event (ie the anti-flavour of the produced
161 // B meson). Flip the flavour of the event with probB probability
162 //============================================================================
163 void EvtIncoherentMixing::OtherB( EvtParticle * p ,
168 //if(p->getId() == B0 || p->getId() == B0B)
169 //added by liming Zhang
171 if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
172 p->getParent()->setLifetime() ;
173 t = p->getParent()->getLifetime() ;
177 t = p->getLifetime() ;
180 if ( flipIsEnabled() ) {
181 //std::cout << " liming << flipIsEnabled " << std::endl;
182 // Flip the flavour of the particle with probability probB
183 bool isFlipped = ( EvtRandom::Flat( 0. , 1. ) < probB ) ;
186 if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
188 ->setId( EvtPDL::chargeConj( p->getParent()->getId() ) ) ;
189 p->setId( EvtPDL::chargeConj( p->getId() ) ) ;
192 p->setId( EvtPDL::chargeConj( p->getId() ) ) ;
197 if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
198 // if B has mixed, tag flavour is charge conjugate of parent of B-meson
199 otherb = EvtPDL::chargeConj( p->getParent()->getId() ) ;
202 // else it is opposite flavour than this B hadron
203 otherb = EvtPDL::chargeConj( p->getId() ) ;
208 //============================================================================
209 // Return the tag of the event (ie the anti-flavour of the produced
211 //============================================================================
212 void EvtIncoherentMixing::OtherB( EvtParticle * p ,
216 if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
217 p->getParent()->setLifetime() ;
218 t = p->getParent()->getLifetime() ;
222 t = p->getLifetime() ;
225 if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
226 // if B has mixed, tag flavour is charge conjugate of parent of B-meson
227 otherb = EvtPDL::chargeConj( p->getParent()->getId() ) ;
230 // else it is opposite flavour than this B hadron
231 otherb = EvtPDL::chargeConj( p->getId() ) ;
238 // activate or desactivate the Bs mixing
239 void EvtIncoherentMixing::setB0Mixing() { _doB0Mixing = true ; }
240 void EvtIncoherentMixing::unsetB0Mixing() { _doB0Mixing = false ; }
242 // activate or desactivate the B0 mixing
243 void EvtIncoherentMixing::setBsMixing() { _doBsMixing = true ; }
244 void EvtIncoherentMixing::unsetBsMixing() { _doBsMixing = false ; }
246 // is mixing activated ?
247 bool EvtIncoherentMixing::doB0Mixing() { return _doB0Mixing ; }
248 bool EvtIncoherentMixing::doBsMixing() { return _doBsMixing ; }
250 // set values for the mixing
251 void EvtIncoherentMixing::setdGammad( double value ) { _dGammad = value ; }
252 void EvtIncoherentMixing::setdeltamd( double value ) { _deltamd = value ; }
253 void EvtIncoherentMixing::setdGammas( double value ) { _dGammas = value ; }
254 void EvtIncoherentMixing::setdeltams( double value ) { _deltams = value ; }
256 // get parameters for mixing
257 double EvtIncoherentMixing::getdGammad() { return _dGammad ; }
258 double EvtIncoherentMixing::getdeltamd() { return _deltamd ; }
259 double EvtIncoherentMixing::getdGammas() { return _dGammas ; }
260 double EvtIncoherentMixing::getdeltams() { return _deltams ; }
262 bool EvtIncoherentMixing::flipIsEnabled() { return _enableFlip ; }
263 void EvtIncoherentMixing::enableFlip() { _enableFlip = true ; }
264 void EvtIncoherentMixing::disableFlip() { _enableFlip = false ; }