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

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //
00003 // Environment:
00004 //      This software is part of models developed at BES collaboration
00005 //      based on the EvtGen framework.  If you use all or part
00006 //      of it, please give an appropriate acknowledgement.
00007 //
00008 // Copyright Information: See CVS repository
00009 //      Copyright (A) 2011      Ping Rong-Gang
00010 //
00011 // Module: EvtOpenCharm.cc
00012 //
00013 // Description: Routine to decay charmonium-> DD, DDpi according the
00014 // cross section measurement by CLEO  PRD 80, 072001.
00015 //
00016 // Modification history:
00017 //
00018 //    Ping R.-G.    December, 2011       Module created
00019 //
00020 //------------------------------------------------------------------------
00021 //
00022 
00023 #include "EvtGenBase/EvtPatches.hh"
00024 #include "EvtGenBase/EvtPatches.hh"
00025 #include "EvtGenBase/EvtParticle.hh"
00026 #include "EvtGenBase/EvtStringParticle.hh"
00027 #include "EvtGenBase/EvtDecayTable.hh"
00028 #include "EvtGenBase/EvtPDL.hh"
00029 #include "EvtGenModels/EvtOpenCharm.hh"
00030 #include "EvtGenModels/EvtPsi3Sdecay.hh"
00031 #include "EvtGenBase/EvtReport.hh"
00032 #include <string>
00033 #include "EvtGenBase/EvtId.hh"
00034 #include <iostream>
00035 #include <iomanip>
00036 #include <fstream>
00037 #include <string.h>
00038 #include <stdlib.h>
00039 #include <unistd.h>
00040 #include <stdio.h>
00041 using std::endl;
00042 using std::fstream;
00043 using std::ios;
00044 using std::ofstream;
00045 using std::resetiosflags;
00046 using std::setiosflags;
00047 using std::setw;
00048 
00049 
00050 int EvtOpenCharm::nOpencharmdecays=0;
00051 EvtDecayBasePtr* EvtOpenCharm::Opencharmdecays=0; 
00052 int EvtOpenCharm::ntable=0;
00053 
00054 int EvtOpenCharm::ncommand=0;
00055 int EvtOpenCharm::lcommand=0;
00056 std::string* EvtOpenCharm::commands=0;
00057 int EvtOpenCharm::nevt=0;
00058 
00059 int EvtOpenCharm::myiter = 1;
00060 std::vector<EvtId> EvtOpenCharm::mypar;
00061 std::vector<int> EvtOpenCharm::vmode;
00062 std::vector<double> EvtOpenCharm::Vcms;
00063 
00064 
00065 EvtOpenCharm::EvtOpenCharm(){}
00066 
00067 EvtOpenCharm::~EvtOpenCharm(){
00068 
00069 
00070   int i;
00071 
00072 
00073   //the deletion of commands is really uggly!
00074 
00075   if (nOpencharmdecays==0) {
00076     delete [] commands;
00077     commands=0;
00078     return;
00079   }
00080 
00081   for(i=0;i<nOpencharmdecays;i++){
00082     if (Opencharmdecays[i]==this){
00083       Opencharmdecays[i]=Opencharmdecays[nOpencharmdecays-1];
00084       nOpencharmdecays--;
00085       if (nOpencharmdecays==0) {
00086         delete [] commands;
00087         commands=0;
00088       }
00089       return;
00090     }
00091   }
00092 
00093   report(ERROR,"EvtGen") << "Error in destroying OpenCharm model!"<<endl;
00094  
00095 }
00096 
00097 
00098 void EvtOpenCharm::getName(std::string& model_name){
00099 
00100   model_name="OPENCHARM";     
00101 
00102 }
00103 
00104 EvtDecayBase* EvtOpenCharm::clone(){
00105 
00106   return new EvtOpenCharm;
00107 
00108 }
00109 
00110 
00111 void EvtOpenCharm::initProbMax(){
00112 
00113   noProbMax();
00114 
00115 }
00116 
00117 
00118 void EvtOpenCharm::init(){
00119 
00120 //  checkNArg(1);
00121 
00122 
00123   if (getParentId().isAlias()){
00124 
00125     report(ERROR,"EvtGen") << "EvtOpenCharm finds that you are decaying the"<<endl
00126                            << " aliased particle "
00127                            << EvtPDL::name(getParentId()).c_str()
00128                            << " with the OpenCharm model"<<endl
00129                            << " this does not work, please modify decay table."
00130                            << endl;
00131     report(ERROR,"EvtGen") << "Will terminate execution!"<<endl;
00132     ::abort();
00133 
00134   }
00135 
00136   store(this);
00137 
00138 }
00139 
00140 
00141 std::string EvtOpenCharm::commandName(){
00142      
00143   return std::string("OpenCharmPar");
00144   
00145 }
00146 
00147 void EvtOpenCharm::command(std::string cmd){
00148 
00149   if (ncommand==lcommand){
00150 
00151     lcommand=10+2*lcommand;
00152 
00153     std::string* newcommands=new std::string[lcommand];
00154     
00155     int i;
00156 
00157     for(i=0;i<ncommand;i++){
00158       newcommands[i]=commands[i];
00159     }
00160     
00161     delete [] commands;
00162 
00163     commands=newcommands;
00164 
00165   }
00166 
00167   commands[ncommand]=cmd;
00168 
00169   ncommand++;
00170 
00171 
00172 }
00173 
00174 
00175 
00176 void EvtOpenCharm::decay( EvtParticle *p){
00177 
00178   int istdheppar=EvtPDL::getStdHep(p->getId());
00179 
00180   if(istdheppar != 9000443 && istdheppar != 9010443 && istdheppar != 9030443 &&istdheppar != 9020443 ){
00181     std::cout<<"EvtGen: EvtOpenCharm cann't not decay the particle pid= "<<istdheppar<<endl;
00182     ::abort();
00183   }
00184   
00185   double mp=p->mass();
00186   float xmp=mp;
00187   double totEn=0;
00188 
00189   //debugging
00190   //  std::cout<<"parent "<<EvtPDL::name(p->getId())<<"float xmp="<<xmp<<" "<<p->getP4Lab()<<std::endl;
00191 
00192   EvtVector4R p4[20];
00193   
00194   int i,more;
00195   int ip=EvtPDL::getStdHep(p->getId());
00196   int ndaugjs;
00197 
00198   static int myflag;
00199   EvtPsi3Sdecay theIni; 
00200   EvtId pid = p->getId();
00201 
00202   static int themode;
00203   if(getNArg()==1){ themode = getArg(0); theIni.setMode(themode);}
00204 
00205   int count=0;
00206   do{
00207 
00208     theIni.PHSPDecay(p);
00209     std::vector<EvtVector4R> v_p4=theIni.getDaugP4();
00210     std::vector<EvtId> Vid=theIni.getDaugId();
00211     ndaugjs = Vid.size();
00212 
00213     EvtId  myId[3];
00214 
00215     for(int i=0;i<ndaugjs;i++){myId[i]=Vid[i];}
00216   
00217 
00218     if(p->getNDaug()!=0) p->resetNDaug();
00219     p->makeDaughters(ndaugjs,myId);
00220 
00221     for(int i=0;i<ndaugjs;i++){
00222       // std::cout<<"Vid "<<EvtPDL::name(Vid[i])<<" p4: "<<v_p4[i]<<std::endl;
00223       p->getDaug(i)->init(Vid[i],v_p4[i]);
00224     }
00225     
00226 
00227     theMode = theIni.getMode();
00228     p->setGeneratorFlag(theMode);
00229 
00230 
00231     totEn=0;    
00232     for(i=0;i<ndaugjs;i++){
00233        totEn +=p->getDaug(i)->getP4().get(0);
00234       if ( p->getDaug(i)->getId() ==EvtId(-1,-1)) {
00235         report(ERROR,"EvtGen") << "OpenCharm returned particle:"<<EvtPDL::name( p->getDaug(i)->getId() )<<endl;
00236         report(ERROR,"EvtGen") << "This can not be translated to evt number"<<endl;
00237         report(ERROR,"EvtGen") << "and the decay will be rejected!"<<endl;
00238         report(ERROR,"EvtGen") << "The decay was of particle:"<<ip<<endl;
00239 
00240       }
00241 
00242     }
00243    int channel=EvtDecayTable::inChannelList(p->getId(),ndaugjs,myId);
00244      
00245     // std::cout<<"channel= "<<channel<<std::endl;
00246    more=(channel!=-1);
00247    //if(more){std::cout<<"count= "<<count<<" inchannel= "<<channel<<std::endl;}
00248 
00249   count++;
00250 
00251   }while( more && (count<10000) );
00252 
00253   if(fabs(xmp-totEn)>0.01){ 
00254     std::cout<<"Warning:OPENCHARM generate incomplet final state, "<<mp<<" "<<totEn<<endl;
00255     ::abort();
00256   }
00257 
00258   if (count>9999) {
00259     report(INFO,"EvtGen") << "Too many loops in EvtOpenCharm!!!"<<endl;
00260     report(INFO,"EvtGen") << "Parent:"<<EvtPDL::name(getParentId()).c_str()<<endl;
00261    }
00262 
00263     fixPolarizations(p);
00264 
00265     return ;
00266   
00267 
00268 }
00269 
00270 void EvtOpenCharm::fixPolarizations(EvtParticle *p){
00271 
00272   //special case for now to handle the J/psi polarization
00273 
00274   int ndaug=p->getNDaug();
00275   
00276   int i;
00277 
00278   static EvtId Jpsi  =EvtPDL::getId("J/psi");
00279   static EvtId psip  =EvtPDL::getId("psi(2S)");
00280   static EvtId psipp =EvtPDL::getId("psi(3770)");
00281   static EvtId psi_a =EvtPDL::getId("psi(4040)");
00282   static EvtId psi_b =EvtPDL::getId("psi(4160)");
00283   static EvtId psi_c =EvtPDL::getId("psi(4260)");
00284 
00285   for(i=0;i<ndaug;i++){
00286     EvtId idp = p->getDaug(i)->getId();
00287     bool bflag=(idp==Jpsi || idp==psip || idp==psipp || idp==psi_a || idp==psi_b || idp ==psi_c); 
00288     if(bflag){
00289   
00290       EvtSpinDensity rho;
00291       
00292       rho.SetDim(3);
00293       rho.Set(0,0,0.5);
00294       rho.Set(0,1,0.0);
00295       rho.Set(0,2,0.0);
00296 
00297       rho.Set(1,0,0.0);
00298       rho.Set(1,1,1.0);
00299       rho.Set(1,2,0.0);
00300 
00301       rho.Set(2,0,0.0);
00302       rho.Set(2,1,0.0);
00303       rho.Set(2,2,0.5);
00304 
00305       EvtVector4R p4Psi=p->getDaug(i)->getP4();
00306 
00307       double alpha=atan2(p4Psi.get(2),p4Psi.get(1));
00308       double beta=acos(p4Psi.get(3)/p4Psi.d3mag());
00309 
00310 
00311       p->getDaug(i)->setSpinDensityForwardHelicityBasis(rho,alpha,beta,0.0);
00312       setDaughterSpinDensity(i);
00313 
00314     }
00315   }
00316 
00317 }
00318 
00319 void EvtOpenCharm::store(EvtDecayBase* jsdecay){
00320 
00321   if (nOpencharmdecays==ntable){
00322 
00323     EvtDecayBasePtr* newOpencharmdecays=new EvtDecayBasePtr[2*ntable+10];
00324     int i;
00325     for(i=0;i<ntable;i++){
00326       newOpencharmdecays[i]=Opencharmdecays[i];
00327     }
00328     ntable=2*ntable+10;
00329     delete [] Opencharmdecays;
00330     Opencharmdecays=newOpencharmdecays;
00331   }
00332 
00333   Opencharmdecays[nOpencharmdecays++]=jsdecay;
00334 
00335 
00336 
00337 }
00338 
00339 void EvtOpenCharm::OpencrmInit(int dummy){
00340 }
00341 
00342 
00343 bool EvtOpenCharm::isbelong(EvtId myid){
00344   for (int i=0;i<mypar.size();i++){
00345     if(myid == mypar[i]) {_index = i; return true;}
00346   }
00347   return false;
00348 }
00349     
00350 int EvtOpenCharm::which_mode(EvtId myid){
00351   for (int i=0;i<mypar.size();i++){
00352     if(myid == mypar[i]){
00353       _index = i;
00354       return i;
00355     }
00356   }
00357   std::cout<<"EvtOpenCharm::which_mode() fails to find element"<<std::endl; abort();
00358 }
00359   
00360 

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