LCOV - code coverage report
Current view: top level - TEvtGen/EvtGen/EvtGenBase - EvtIncoherentMixing.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 117 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 27 0.0 %

          Line data    Source code
       1             : // $Id: EvtIncoherentMixing.cpp,v 1.13 2009-11-27 09:09:41 mwhitehe Exp $
       2             : // Include files 
       3             : 
       4             : 
       5             : // local
       6             : #include "EvtGenBase/EvtIncoherentMixing.hh"
       7             : #include <stdlib.h>
       8             : #include "EvtGenBase/EvtPDL.hh"
       9             : #include "EvtGenBase/EvtId.hh"
      10             : #include "EvtGenBase/EvtRandom.hh"
      11             : 
      12             : //-----------------------------------------------------------------------------
      13             : // Implementation file for class : EvtIncoherentMixing
      14             : //
      15             : // 2003-10-09 : Patrick Robbe
      16             : //-----------------------------------------------------------------------------
      17             : 
      18             : 
      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 ;
      27             : 
      28             : //=============================================================================
      29             : // Standard constructor, initializes variables
      30             : //=============================================================================
      31           0 : EvtIncoherentMixing::EvtIncoherentMixing(  ) {
      32           0 :   _doB0Mixing = false ;
      33           0 :   _doBsMixing = false ;
      34           0 :   _dGammad = 0. ;
      35             :   // dGammas corresponds to DeltaGamma / Gamma = 10 %
      36           0 :   _dGammas = 6.852e10 ;
      37           0 :   _deltamd = 0.502e12 ;
      38           0 :   _deltams = 20.e12 ;
      39           0 :   _enableFlip = false ;
      40           0 : }
      41             : //=============================================================================
      42             : EvtIncoherentMixing::~EvtIncoherentMixing( ) 
      43           0 : {
      44           0 : }
      45             : // ============================================================================
      46             : void EvtIncoherentMixing::incoherentB0Mix( const EvtId id, double &t , 
      47             :                                            int &mix )
      48             : {
      49           0 :   static EvtId B0  = EvtPDL::getId( "B0" ) ;
      50           0 :   static EvtId B0B = EvtPDL::getId( "anti-B0" ) ;
      51             :  
      52           0 :   if ( ( B0 != id ) && ( B0B != id ) ) {
      53           0 :     report(Severity::Error,"EvtGen") << "Bad configuration in incoherentB0Mix" 
      54           0 :                            << std::endl ;
      55           0 :     ::abort() ;
      56             :   }
      57             :   
      58           0 :   double x = getdeltamd() * EvtPDL::getctau( B0 ) / EvtConst::c ;
      59             : 
      60           0 :   double y = getdGammad() * ( EvtPDL::getctau( B0 ) / EvtConst::c ) / 2. ;
      61             : 
      62             :   double fac = 1. ; // No CP violation
      63             : 
      64           0 :   double mixprob = ( x*x + y*y ) / ( x*x + y*y + ( 1./fac ) * 
      65           0 :                                      ( 2. + x*x - y*y ) ) ;
      66             : 
      67             :   int mixsign ;
      68             :   
      69             :   // decide if state is mixed
      70           0 :   mixsign = ( mixprob > EvtRandom::Flat( 0. , 1. ) ) ? -1 : 1 ;
      71             : 
      72             :   double prob ;
      73             :   
      74           0 :   do {
      75           0 :     t = -log( EvtRandom::Flat() ) * EvtPDL::getctau( B0 ) / ( 1. - y ) ;
      76           0 :     prob = ( 1. + exp( -2. * y * t / EvtPDL::getctau( B0 ) ) +
      77           0 :       mixsign * 2. * exp( -y * t / EvtPDL::getctau( B0 ) ) * 
      78           0 :       cos( getdeltamd() * t / EvtConst::c ) ) / 2. ;
      79           0 :   } while ( prob < 2. * EvtRandom::Flat() ) ;
      80             :  
      81           0 :   mix = 0 ;
      82           0 :   if ( mixsign == -1 ) mix = 1 ;
      83             :   
      84             :   return ;  
      85           0 : }
      86             : // ============================================================================
      87             : void EvtIncoherentMixing::incoherentBsMix( const EvtId id, double &t , 
      88             :                                            int &mix )
      89             : {
      90           0 :   static EvtId BS  = EvtPDL::getId( "B_s0" ) ;
      91           0 :   static EvtId BSB = EvtPDL::getId( "anti-B_s0" ) ;
      92             :  
      93           0 :   if ( ( BS != id ) && ( BSB != id ) ) {
      94           0 :     report(Severity::Error,"EvtGen") << "Bad configuration in incoherentBsMix" 
      95           0 :                            << std::endl ;
      96           0 :     ::abort() ;
      97             :   }
      98             :   
      99           0 :   double x = getdeltams() * EvtPDL::getctau( BS ) / EvtConst::c ;
     100             : 
     101           0 :   double y = getdGammas() * ( EvtPDL::getctau( BS ) / EvtConst::c ) / 2. ;
     102             : 
     103             :   double fac = 1. ; // No CP violation
     104             : 
     105           0 :   double mixprob = ( x*x + y*y ) / ( x*x + y*y + ( 1./fac ) * 
     106           0 :                                      ( 2. + x*x - y*y ) ) ;
     107             : 
     108             :   int mixsign ;
     109             :   
     110             :   // decide if state is mixed
     111           0 :   mixsign = ( mixprob > EvtRandom::Flat( 0. , 1. ) ) ? -1 : 1 ;
     112             : 
     113             :   double prob ;
     114             :   
     115           0 :   do {
     116           0 :     t = -log( EvtRandom::Flat() ) * EvtPDL::getctau( BS ) / ( 1. - y ) ;
     117           0 :     prob = ( 1. + exp( -2. * y * t / EvtPDL::getctau( BS ) ) +
     118           0 :       mixsign * 2. * exp( -y * t / EvtPDL::getctau( BS ) ) * 
     119           0 :       cos( getdeltams() * t / EvtConst::c ) ) / 2. ;
     120           0 :   } while ( prob < 2. * EvtRandom::Flat() ) ;
     121             :  
     122           0 :   mix = 0 ;
     123           0 :   if ( mixsign == -1 ) mix = 1 ;
     124             :   
     125             :   return ;  
     126           0 : }
     127             : 
     128             : // ========================================================================
     129             : bool EvtIncoherentMixing::isBsMixed ( EvtParticle * p ) 
     130             : { 
     131           0 :   if ( ! ( p->getParent() ) ) return false ;
     132             :   
     133           0 :   static EvtId BS0=EvtPDL::getId("B_s0");
     134           0 :   static EvtId BSB=EvtPDL::getId("anti-B_s0");
     135             :   
     136           0 :   if ( ( p->getId() != BS0 ) && ( p->getId() != BSB ) ) return false ;
     137             :   
     138           0 :   if ( ( p->getParent()->getId() == BS0 ) ||
     139           0 :        ( p->getParent()->getId() == BSB ) ) return true ;
     140             :   
     141           0 :   return false ;
     142           0 : }
     143             : 
     144             : // ========================================================================
     145             : bool EvtIncoherentMixing::isB0Mixed ( EvtParticle * p ) 
     146             : { 
     147           0 :   if ( ! ( p->getParent() ) ) return false ;
     148             :   
     149           0 :   static EvtId B0 =EvtPDL::getId("B0");
     150           0 :   static EvtId B0B=EvtPDL::getId("anti-B0");
     151             :   
     152           0 :   if ( ( p->getId() != B0 ) && ( p->getId() != B0B ) ) return false ;
     153             :   
     154           0 :   if ( ( p->getParent()->getId() == B0 ) ||
     155           0 :        ( p->getParent()->getId() == B0B ) ) return true ;
     156             :   
     157           0 :   return false ;
     158           0 : }
     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 ,
     164             :                                   double & t ,
     165             :                                   EvtId & otherb ,
     166             :                                   double probB ) 
     167             : {
     168             :   //if(p->getId() == B0 || p->getId() == B0B) 
     169             :   //added by liming Zhang
     170           0 :   enableFlip();
     171           0 :   if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
     172           0 :     p->getParent()->setLifetime() ;
     173           0 :     t = p->getParent()->getLifetime() ;
     174           0 :   }
     175             :   else {
     176           0 :     p->setLifetime() ;
     177           0 :     t = p->getLifetime() ;
     178             :   }
     179             : 
     180           0 :   if ( flipIsEnabled() ) {
     181             :     //std::cout << " liming << flipIsEnabled " << std::endl;
     182             :     // Flip the flavour of the particle with probability probB
     183           0 :     bool isFlipped = ( EvtRandom::Flat( 0. , 1. ) < probB ) ;
     184             :     
     185           0 :     if ( isFlipped ) {
     186           0 :       if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
     187           0 :         p->getParent()
     188           0 :           ->setId( EvtPDL::chargeConj( p->getParent()->getId() ) ) ;
     189           0 :         p->setId( EvtPDL::chargeConj( p->getId() ) ) ;
     190           0 :       }
     191             :       else {
     192           0 :         p->setId( EvtPDL::chargeConj( p->getId() ) ) ;
     193             :       }
     194             :     }
     195           0 :   }
     196             :   
     197           0 :   if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
     198             :     // if B has mixed, tag flavour is charge conjugate of parent of B-meson
     199           0 :     otherb = EvtPDL::chargeConj( p->getParent()->getId() ) ;
     200           0 :   }
     201             :   else {
     202             :     // else it is opposite flavour than this B hadron
     203           0 :     otherb = EvtPDL::chargeConj( p->getId() ) ;
     204             :   }
     205             : 
     206           0 :   return ;
     207             : }
     208             : //============================================================================
     209             : // Return the tag of the event (ie the anti-flavour of the produced 
     210             : // B meson). No flip
     211             : //============================================================================
     212             : void EvtIncoherentMixing::OtherB( EvtParticle * p ,
     213             :                                   double & t ,
     214             :                                   EvtId & otherb ) 
     215             : {
     216           0 :   if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
     217           0 :     p->getParent()->setLifetime() ;
     218           0 :     t = p->getParent()->getLifetime() ;
     219           0 :   }
     220             :   else {
     221           0 :     p->setLifetime() ;
     222           0 :     t = p->getLifetime() ;
     223             :   }
     224             :   
     225           0 :   if ( ( isB0Mixed( p ) ) || ( isBsMixed( p ) ) ) {
     226             :     // if B has mixed, tag flavour is charge conjugate of parent of B-meson
     227           0 :     otherb = EvtPDL::chargeConj( p->getParent()->getId() ) ;
     228           0 :   }
     229             :   else {
     230             :     // else it is opposite flavour than this B hadron
     231           0 :     otherb = EvtPDL::chargeConj( p->getId() ) ;
     232             :   }
     233             : 
     234           0 :   return ;
     235             : }
     236             : 
     237             : 
     238             : // activate or desactivate the Bs mixing
     239           0 : void EvtIncoherentMixing::setB0Mixing()   { _doB0Mixing = true ; }
     240           0 : void EvtIncoherentMixing::unsetB0Mixing() { _doB0Mixing = false ; } 
     241             : 
     242             : // activate or desactivate the B0 mixing
     243           0 : void EvtIncoherentMixing::setBsMixing()   { _doBsMixing = true ; } 
     244           0 : void EvtIncoherentMixing::unsetBsMixing() { _doBsMixing = false ; } 
     245             : 
     246             : // is mixing activated ? 
     247           0 : bool EvtIncoherentMixing::doB0Mixing()  { return _doB0Mixing ; }
     248           0 : bool EvtIncoherentMixing::doBsMixing()  { return _doBsMixing ; }
     249             : 
     250             : // set values for the mixing
     251           0 : void EvtIncoherentMixing::setdGammad( double value )  { _dGammad = value ; } 
     252           0 : void EvtIncoherentMixing::setdeltamd( double value )  { _deltamd = value ; } 
     253           0 : void EvtIncoherentMixing::setdGammas( double value )  { _dGammas = value ; } 
     254           0 : void EvtIncoherentMixing::setdeltams( double value )  { _deltams = value ; } 
     255             : 
     256             : // get parameters for mixing
     257           0 : double EvtIncoherentMixing::getdGammad() { return _dGammad ; } 
     258           0 : double EvtIncoherentMixing::getdeltamd() { return _deltamd ; }
     259           0 : double EvtIncoherentMixing::getdGammas() { return _dGammas ; } 
     260           0 : double EvtIncoherentMixing::getdeltams() { return _deltams ; }
     261             : 
     262           0 : bool EvtIncoherentMixing::flipIsEnabled() { return _enableFlip ; } 
     263           0 : void EvtIncoherentMixing::enableFlip() { _enableFlip = true ; } 
     264           0 : void EvtIncoherentMixing::disableFlip() { _enableFlip = false ; } 

Generated by: LCOV version 1.11