/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Generator/BesEvtGen/BesEvtGen-00-03-58/src/EvtGen/EvtGenBase/EvtDecayAmp.cc

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //
00003 // Environment:
00004 //      This software is part of the EvtGen package developed jointly
00005 //      for the BaBar and CLEO collaborations.  If you use all or part
00006 //      of it, please give an appropriate acknowledgement.
00007 //
00008 // Copyright Information: See EvtGen/COPYRIGHT
00009 //      Copyright (C) 1998      Caltech, UCSB
00010 //
00011 // Module: EvtGen/EvtDecayAmp.cc
00012 //
00013 // Description:
00014 //
00015 // Modification history:
00016 //
00017 //    DJL/RYD     August 11, 1998         Module created
00018 //
00019 //------------------------------------------------------------------------
00020 #include "EvtGenBase/EvtPatches.hh"
00021 
00022 #include "EvtGenBase/EvtDecayBase.hh"
00023 #include "EvtGenBase/EvtDecayAmp.hh"
00024 #include "EvtGenBase/EvtParticle.hh"
00025 #include "EvtGenBase/EvtPDL.hh"
00026 #include "EvtGenBase/EvtRandom.hh"
00027 #include "EvtGenBase/EvtRadCorr.hh"
00028 #include "EvtGenBase/EvtAmp.hh"
00029 #include "EvtGenBase/EvtReport.hh"
00030 #include "EvtGenBase/EvtSpinDensity.hh"
00031 #include <vector>
00032 using std::endl;
00033 
00034 
00035 void EvtDecayAmp::makeDecay(EvtParticle* p){
00036 
00037   int ntimes=10000;
00038 
00039   int i,more;
00040 
00041   EvtSpinDensity rho;
00042   double prob,prob_max;
00043 
00044   _amp2.init(p->getId(),getNDaug(),getDaugs());
00045 //  report(INFO,"EvtGen") << "Decaying " << EvtPDL::name(p->getId()) << endl;
00046   do{
00047 
00048     _daugsDecayedByParentModel=false;
00049     _weight = 1.0;
00050     decay(p);
00051 
00052     rho=_amp2.getSpinDensity();
00053     prob=p->getSpinDensityForward().NormalizedProb(rho);
00054     if (prob<0.0) {
00055 
00056       report(ERROR,"EvtGen")<<"Negative prob:"<<p->getId().getId()
00057                             <<" "<<p->getChannel()<<endl;
00058 
00059       report(ERROR,"EvtGen") << "rho_forward:"<<endl;
00060       report(ERROR,"EvtGen") << p->getSpinDensityForward();
00061       report(ERROR,"EvtGen") << "rho decay:"<<endl;
00062       report(ERROR,"EvtGen") << rho <<endl;
00063     }
00064 
00065     if (prob!=prob) {
00066 
00067       report(DEBUG,"EvtGen") << "Forward density matrix:"<<endl;
00068       report(ERROR,"EvtGen") << p->getSpinDensityForward();
00069 
00070       report(DEBUG,"EvtGen") << "Decay density matrix:"<<endl;
00071       report(ERROR,"EvtGen") << rho;
00072 
00073       report(DEBUG,"EvtGen") << "prob:"<<prob<<endl;
00074       
00075       report(DEBUG,"EvtGen") << "Particle:"
00076                              <<EvtPDL::name(p->getId()).c_str()<<endl;
00077       report(DEBUG,"EvtGen") << "channel        :"<<p->getChannel()<<endl;
00078       report(DEBUG,"EvtGen") << "Momentum:" << p->getP4() << " " << p->mass() << endl;
00079       if( p->getParent()!=0){
00080         report(DEBUG,"EvtGen") << "parent:"
00081                                <<EvtPDL::name(
00082                                 p->getParent()->getId()).c_str()<<endl;
00083         report(DEBUG,"EvtGen") << "parent channel        :"
00084                                <<p->getParent()->getChannel()<<endl;
00085 
00086         int i;
00087         report(DEBUG,"EvtGen") << "parent daughters  :";
00088         for (i=0;i<p->getParent()->getNDaug();i++){
00089           report(DEBUG,"") << EvtPDL::name(
00090                             p->getParent()->getDaug(i)->getId()).c_str()
00091                                  << " ";
00092         }
00093         report(DEBUG,"") << endl;
00094 
00095         report(DEBUG,"EvtGen") << "daughters  :";
00096         for (i=0;i<p->getNDaug();i++){
00097           report(DEBUG,"") << EvtPDL::name(
00098                             p->getDaug(i)->getId()).c_str()
00099                                  << " ";
00100         }
00101         report(DEBUG,"") << endl;
00102 
00103         report(DEBUG,"EvtGen") << "daughter momenta  :" << endl;;
00104         for (i=0;i<p->getNDaug();i++){
00105           report(DEBUG,"") << p->getDaug(i)->getP4() << " " << p->getDaug(i)->mass();
00106           report(DEBUG,"") << endl;
00107         }
00108 
00109       }
00110     }
00111 
00112 
00113     prob/=_weight;
00114 
00115 
00116     prob_max = getProbMax(prob);
00117     p->setDecayProb(prob/prob_max);
00118 
00119     //report(INFO,"EvtGen") << "Prob,prob_max,weight:"<<prob<<" "<<prob_max<<" "<<_weight<<endl;
00120 
00121     more=prob<EvtRandom::Flat(prob_max);
00122 
00123     ntimes--;
00124 
00125   }while(ntimes&&more);
00126   //report(INFO,"EvtGen") << "Done\n";
00127 
00128   if (ntimes==0){
00129     report(DEBUG,"EvtGen") << "Tried accept/reject:10000"
00130                            <<" times, and rejected all the times!"<<endl;
00131     report(DEBUG,"")<<p->getSpinDensityForward()<<endl;
00132     report(DEBUG,"EvtGen") << "Is therefore accepting the last event!"<<endl;
00133     report(DEBUG,"EvtGen") << "Decay of particle:"<<
00134       EvtPDL::name(p->getId()).c_str()<<"(channel:"<<
00135       p->getChannel()<<") with mass "<<p->mass()<<endl;
00136     
00137     int ii;
00138     for(ii=0;ii<p->getNDaug();ii++){
00139       report(DEBUG,"EvtGen") <<"Daughter "<<ii<<":"<<
00140         EvtPDL::name(p->getDaug(ii)->getId()).c_str()<<" with mass "<<
00141         p->getDaug(ii)->mass()<<endl;
00142     }                              
00143   }
00144 
00145 
00146   EvtSpinDensity rho_list[10];
00147 
00148   rho_list[0]=p->getSpinDensityForward();
00149    
00150 
00151   EvtAmp ampcont;
00152 
00153   if (_amp2._pstates!=1){
00154     ampcont=_amp2.contract(0,p->getSpinDensityForward());   // J2BB2 bugging here
00155 
00156   }
00157   else{
00158     ampcont=_amp2;
00159   }
00160 
00161           
00162 
00163   // it may be that the parent decay model has already
00164   // done the decay - this should be rare and the
00165   // model better know what it is doing..
00166   
00167   if ( !daugsDecayedByParentModel() ){
00168     
00169 
00170  //   report(INFO,"EvtGen") << "Found " << p->getNDaug() << " daughters\n";
00171     for(i=0;i<p->getNDaug();i++){
00172     
00173       rho.SetDim(_amp2.dstates[i]);
00174 
00175       if (_amp2.dstates[i]==1) {
00176         rho.Set(0,0,EvtComplex(1.0,0.0));
00177       }
00178       else{
00179         rho=ampcont.contract(_amp2._dnontrivial[i],_amp2);
00180       }
00181       
00182       if (!rho.Check()) {
00183         
00184         report(ERROR,"EvtGen") << "-------start error-------"<<endl;
00185         report(ERROR,"EvtGen")<<"forward rho failed Check:"<<
00186           EvtPDL::name(p->getId()).c_str()<<" "<<p->getChannel()<<" "<<i<<endl;
00187         
00188         report(ERROR,"EvtGen")<<"Parent:"<<EvtPDL::name(p->getParent()->getId()).c_str()<<endl;
00189         report(ERROR,"EvtGen")<<"GrandParent:"<<EvtPDL::name(p->getParent()->getParent()->getId()).c_str()<<endl;
00190         report(ERROR,"EvtGen")<<"GrandGrandParent:"<<EvtPDL::name(p->getParent()->getParent()->getParent()->getId()).c_str()<<endl;
00191         
00192         report(ERROR,"EvtGen") << rho;
00193         int ii; 
00194         _amp2.dump();
00195         
00196         for(ii=0;ii<i+1;ii++){
00197           report(ERROR,"EvtGen") << rho_list[ii];
00198         }
00199         report(ERROR,"EvtGen") << "-------Done with error-------"<<endl;  
00200       }
00201 
00202 
00203       
00204       p->getDaug(i)->setSpinDensityForward(rho);
00205 
00206       //debugging
00207       // p->printTree();
00208      p->getDaug(i)->decay();
00209 
00210      rho_list[i+1]= p->getDaug(i)->getSpinDensityBackward();
00211 
00212       if (_amp2.dstates[i]!=1){
00213         ampcont=ampcont.contract(_amp2._dnontrivial[i],rho_list[i+1]);
00214       }
00215   
00216       
00217     }
00218 
00219     p->setSpinDensityBackward(_amp2.getBackwardSpinDensity(rho_list));
00220    
00221     
00222     if (!p->getSpinDensityBackward().Check()) {
00223       
00224       report(ERROR,"EvtGen")<<"rho_backward failed Check"<<
00225         p->getId().getId()<<" "<<p->getChannel()<<endl;
00226       
00227       report(ERROR,"EvtGen") << p->getSpinDensityBackward();
00228       
00229     }
00230   }
00231 
00232   if (getPHOTOS() || EvtRadCorr::alwaysRadCorr()) {
00233     EvtRadCorr::doRadCorr(p);
00234 
00235   }
00236 
00237 }
00238 
00239 
00240 
00241 
00242 
00243 
00244 
00245 

Generated on Tue Nov 29 23:12:12 2016 for BOSS_7.0.2 by  doxygen 1.4.7