/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Generator/BesEvtGen/BesEvtGen-00-03-58/src/EvtGen/EvtGenModels/EvtConExc.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 EvtGen/BesCopyright
00009 //      Copyright (A) 2006      Ping Rong-Gang @IHEP
00010 //
00011 // Module: VVS.hh
00012 //
00013 // Description: To define cross section for the continuum exclusive process
00014 // Experimental cross section taken from PRD73,012005, PRD76,092006, also 
00015 // see a review: Rev. Mod. Phys. 83,1545
00016 //************
00017 // For Rscan generation, use the index 74110. The pdg table need to add 
00018 // particles gamma* and vgam, gamma* is decayed with model PYCON in the DECAY.dec
00019 //
00020   /*******************--- mode definition:also see EvtXsection.cc
00021   0: ppbar
00022   1: nnbar
00023   2: Lambda0 anti-Lambda0
00024   3: Sigma0 anti-Sigma0
00025   4: Lambda0 anti-Sigma0
00026   5: Sigma0 anti-Lambda0
00027   6: pi+ pi-
00028   7: pi+ pi- pi0
00029   8: K+K- pi0
00030   9: KsK+pi- 
00031   10: KsK-pi+
00032   11: K+K-eta
00033   12: 2(pi+pi-) 
00034   13: pi+pi-2pi0
00035   14: K+K-pi+pi-
00036   15: K+K-2pi0
00037   16: 2(K+K-)
00038   17: 2(pi+pi-)pi0
00039   18: 2(pi+pi-)eta
00040   19: K+K-pi+pi-pi0             
00041   20: K+K-pi+pi-eta
00042   21: 3(pi+pi-)
00043   22: 2(pi+pi-pi0)
00044   23: phi eta
00045   24: phi pi0
00046   25: K+K*-
00047   26: K-K*+
00048   27: K_SK*0-bar
00049   28: K*0(892)K+pi-
00050   29: K*0(892)K-pi+
00051   30: K*+K-pi0
00052   31: K*-K+pi0
00053   32: K_2*(1430)0 K+pi-
00054   33: K_2*(1430)0 K-pi+
00055   34: K+K-rho
00056   35: phi pi+pi-
00057   36: phi f0(980)
00058   37: eta pi+pi-
00059   38: omega pi+ pi-
00060   39: omega f0(980)
00061   40: eta' pi+ pi-
00062   41: f_1(1285)pi+pi-
00063   42: omega K+K-
00064   43: omega pi+pi-pi0
00065   44: Sigma+ Sigma- (Sigma0 Sigma0-bar SU(3) extention )
00066   45: K+K-
00067   46: K_S K_L
00068   47: omega eta
00069   48: phi eta'
00070   49: phi K+ K-
00071 
00072 
00073   70: D0D0-bar
00074   71: D+D-
00075   72: D+D*-
00076   73: D-D*+
00077   74: D*+D*-
00078   75: D0D-pi+
00079   76: D0D+pi-
00080   77: D0D*-pi+
00081   78: D0D*+pi-
00082   79: pi0 pi0 psi(2S)
00083   
00084 
00085   90: J/psi pi+ pi-
00086   91: psi(2S)pi+pi-
00087   92: J/psi K+K-
00088   93: D_s+ D_s-
00089   94: D_s^{*+}D_s^-
00090   95: D_s^{*-}D_s^+
00091   96: Lambda_c+ Lambda_c-
00092   *************************************/
00093 // Modification history:
00094 //
00095 //    Ping R.-G.       Nov., 2012       Module created
00096 //
00097 //------------------------------------------------------------------------
00098 //
00099 #include <math.h>
00100 #include "EvtGenBase/EvtPatches.hh"
00101 #include <stdlib.h>
00102 #include "EvtGenBase/EvtParticle.hh"
00103 #include "EvtGenBase/EvtGenKine.hh"
00104 #include "EvtGenBase/EvtPDL.hh"
00105 #include "EvtGenBase/EvtReport.hh"
00106 #include "EvtGenModels/EvtPhsp.hh"
00107 #include "EvtGenModels/EvtConExc.hh"
00108 #include "EvtGenBase/EvtVector4R.hh"
00109 #include "EvtGenBase/EvtParticleFactory.hh"
00110 #include "EvtGenBase/EvtRandom.hh"
00111 #include "EvtGenBase/EvtHelSys.hh"
00112 #include "EvtGenBase/EvtDecayTable.hh"
00113 #include "EvtGenBase/EvtDecayBase.hh"
00114 #include "EvtGenBase/EvtPDL.hh"
00115 #include "EvtGenModels/EvtGlobalSet.hh"
00116 #include <string> 
00117 #include <iostream>
00118 #include <fstream>
00119 #include <istream>
00120 #include <strstream>
00121 #include <stdio.h>
00122 #include <fstream>
00123 #include <strstream>
00124 #include "TGraphErrors.h"
00125 #include "TCanvas.h"
00126 #include "TPostScript.h" 
00127 #include "TStyle.h"
00128 #include "TMultiGraph.h"
00129 using namespace std;
00130 
00131 extern "C" {
00132   extern double dgauss_( double (*fun)(double*), double *,double *, double *);
00133 }
00134 
00135 extern "C" {
00136   extern double divdif_( float*, float *,int *, float *,int*);
00137 }
00138 
00139 extern "C" {
00140   extern void polint_( float*, float *,int *, float *,float*);
00141 }
00142 
00143 extern "C" {
00144   extern void hadr5n12_( float*, float *,float *, float *,float *, float *);
00145 }
00146 
00147 
00148 double Rad2difXs(double *m);
00149 double Rad2difXs_er(double *m);
00150 
00151 EvtXsection *EvtConExc::myxsection;
00152 double EvtConExc::_cms;
00153 double EvtConExc::XS_max;
00154 
00155 double EvtConExc::_xs0=0;
00156 double EvtConExc::_xs1=0;
00157 double EvtConExc::_er0=0;
00158 double EvtConExc::_er1=0;
00159 int EvtConExc::_nevt=0;
00160 
00161 std::ofstream oa;
00162 int EvtConExc::getMode;
00163 int EvtConExc::conexcmode=-1;
00164 std::vector<std::vector <double> > EvtConExc::VXS;
00165 
00166 EvtConExc::~EvtConExc() {
00167   if(_mode==74110)checkEvtRatio();
00168   if(mydbg){
00169     // xs->Write();
00170     myfile->Write();
00171   }
00172   delete myxsection;
00173   gamH->deleteTree();
00174 }
00175 
00176 void EvtConExc::getName(std::string& model_name){
00177 
00178   model_name="ConExc";     
00179 
00180 }
00181 
00182 EvtDecayBase* EvtConExc::clone(){
00183 
00184   return new EvtConExc;
00185 
00186 }
00187 
00188 
00189 void EvtConExc::init(){
00190   ReadVP();
00191   VXS.resize(120);
00192   for(int i=0;i<120;i++){
00193     VXS[i].resize(600);
00194   }
00195   _mode   = getArg(0);
00196   for(int i=0;i<97;i++){
00197     if(47<=i && i<=49) continue;
00198     if(52<=i && i<=67) continue;
00199     if(85<=i && i<=89) continue;
00200     if(_mode==74110) vmode.push_back(i);
00201   }
00202   if(_mode==74110){
00203     vmode.push_back(74100);
00204     vmode.push_back(74101);
00205     vmode.push_back(74102);
00206     vmode.push_back(74103);
00207     vmode.push_back(74104);
00208     vmode.push_back(74105);
00209     vmode.push_back(74110);
00210   }
00211   //----------------
00212   // check that there are 0 arguments
00213   // checkNArg(1);
00214   //Vector ISR process
00215   VISR=0;
00216   if(getNDaug()==2){
00217     if(getDaugs()[0]==EvtPDL::getId("gamma") &&getDaugs()[1]==EvtPDL::getId("gamma*") || getDaugs()[0]==EvtPDL::getId("gamma*") &&getDaugs()[1]==EvtPDL::getId("gamma") ) VISR=1;
00218   }else if(getNDaug()>2){std::cout<<"Bad daughter specified"<<std::endl;abort();}
00219 
00220   cmsspread=0.0015; //CMC energy spread
00221   testflag=0;
00222   getResMass(); 
00223   if(getArg(0) == -1){ 
00224     radflag=0;mydbg=false;
00225     _mode   = getArg(0);
00226     pdgcode = getArg(1);
00227     pid = EvtPDL::evtIdFromStdHep(pdgcode );
00228     nson = getNArg()-2;
00229     std::cout<<"The decay daughters are "<<std::endl;
00230     for(int i=2;i<getNArg();i++ ){son[i-2]=EvtPDL::evtIdFromStdHep(getArg(i));std::cout<<EvtPDL::name(son[i-2])<<" ";}
00231     std::cout<<std::endl;
00232   }else if(getArg(0)==-2){
00233     radflag=0;mydbg=false;
00234     _mode   = getArg(0);
00235     nson = getNArg()-1;
00236     for(int i=1;i<getNArg();i++ ){son[i-1]=EvtPDL::evtIdFromStdHep(getArg(i));}
00237   }
00238   else if(getNArg()==1){ _mode = getArg(0);radflag=0;mydbg=false;} 
00239   else if(getNArg()==2){ _mode = getArg(0); radflag=getArg(1);mydbg=false;}
00240   else if(getNArg()==3){ _mode = getArg(0); radflag=getArg(1);mydbg=getArg(2);}
00241   else{std::cout<<"ConExc:umber of parameter should be 1,2 or 3, but you set "<<getNArg()<<std::endl;::abort(); }
00242   //--- debugging
00243   //std::cout<<_mode<<" "<<pdgcode<<" "<<nson<<" "<<EvtPDL::name(son[0])<<" "<<EvtPDL::name(son[1])<<std::endl;
00244   
00245   gamId = EvtPDL::getId(std::string("gamma"));
00246   init_mode(_mode);
00247   XS_max=-1;
00248   //-----debugging to make root file
00249     if(mydbg){
00250       myfile = new TFile("mydbg.root","RECREATE");
00251       xs=new TTree ("xs","momentum of rad. gamma and hadrons");
00252       xs->Branch("imode",&imode,"imode/I");
00253       xs->Branch("pgam",pgam,"pgam[4]/D");
00254       xs->Branch("phds",phds,"phds[4]/D");
00255       xs->Branch("ph1",ph1,"ph1[4]/D");
00256       xs->Branch("ph2",ph2,"ph2[4]/D");
00257       xs->Branch("mhds",&mhds,"mhds/D");
00258       xs->Branch("mass1",&mass1,"mass1/D");
00259       xs->Branch("mass2",&mass2,"mass2/D");
00260       xs->Branch("costheta",&costheta,"costheta/D");
00261       xs->Branch("cosp",&cosp,"cosp/D");
00262       xs->Branch("cosk",&cosk,"cosk/D");
00263       xs->Branch("sumxs",&sumxs,"sumxs/D");
00264       xs->Branch("selectmode",&selectmode,"selectmode/D");
00265     }
00266     //--- prepare the output information
00267     EvtId parentId =EvtPDL::getId(std::string("vpho"));
00268     EvtPDL::reSetWidth(parentId,0.0);
00269     double parentMass = EvtPDL::getMass(parentId);
00270     std::cout<<"parent mass = "<<parentMass<<std::endl;
00271 
00272     
00273     EvtVector4R p_init(parentMass,0.0,0.0,0.0);
00274     EvtParticle *p=EvtParticleFactory::particleFactory(parentId,p_init);
00275     theparent = p;
00276     myxsection =new EvtXsection (_mode);
00277     double mth=0;
00278     double mx = EvtPDL::getMeanMass(parentId); //p->getP4().mass();
00279     if(_mode ==-1){
00280       myxsection->setBW(pdgcode);
00281       for(int i=0;i<nson;i++){mth +=EvtPDL::getMeanMass(son[i]);}
00282       if(mx<mth){std::cout<<"The CMS energy is lower than the threshold of the final states"<<std::endl;abort();}
00283     }else if(_mode == -2){
00284       mth=myxsection->getXlw();
00285     }else{ mth=myxsection->getXlw();}
00286     _cms = mx;
00287     _unit = myxsection->getUnit();
00288 
00289     std::cout<<"The specified mode is "<<_mode<<std::endl;
00290     EvtConExc::getMode = _mode;
00291     //std::cout<<"getXlw= "<<mth<<std::endl;
00292 
00293     Egamcut = 0.001; //set photon energy cut according to the BESIII detector
00294     double Esig = 0.0001;  //sigularity engy 
00295     double x = 2*Egamcut/_cms;
00296     double s = _cms*_cms;
00297     double mhscut = sqrt(s*(1-x));
00298 
00299     //for vaccum polarization
00300     float fe,fst2,fder,ferrder,fdeg,ferrdeg;
00301     fe=_cms; 
00302     //using the vacuum pol. value as given by  http://www-com.physik.hu-berlin.de/~fjeger/software.html
00303     vph=getVP(_cms);
00304     if(3.0943<_cms && _cms<3.102) vph=1;// For J/psi, the vacuum factor is included in the resonance
00305     std::cout<<"sum of leptonic, hadronic contributions(u,d,s,c,b) to vacuum polarization: "<<vph<<" @"<<fe<<"GeV"<<std::endl;
00306 
00307     //caculate the xs for ISR to psiprime, J/psi and phi narrow resonance.
00308     double totxsIRS=0;
00309     init_Br_ee();
00310     double mthrld = EvtPDL::getMeanMass(daugs[0]); //threshold mass of hadrons
00311     for(int jj=1;jj<_ndaugs;jj++){
00312       mthrld += EvtPDL::getMeanMass(daugs[jj]);
00313     }
00314 
00315 
00316     ISRXS.clear();ISRM.clear();ISRFLAG.clear();
00317     for(int ii=0;ii<3;ii++){
00318       double mR = EvtPDL::getMeanMass(ResId[ii]);
00319       if(mx<mR || _mode !=74110) continue;
00320       double narRxs=Ros_xs(mx,BR_ee[ii],ResId[ii]);
00321       std::cout<<"The corss section for gamma "<<EvtPDL::name(ResId[ii]).c_str()<<" is: "<< narRxs<<"*Br (nb)."<<std::endl;
00322       ISRXS.push_back(narRxs); 
00323       ISRM.push_back(mR);
00324       ISRFLAG.push_back(1.);
00325       ISRID.push_back(ResId[ii]);
00326       totxsIRS += narRxs;
00327     }
00328     std::cout<<"==========================================================================="<<std::endl;
00329 
00330     //-- calculated with MC integration method
00331      double mhdL=myxsection->getXlw();
00332      if(mhdL<SetMthr) mhdL=SetMthr;
00333      EgamH = (s-mhdL*mhdL)/2/sqrt(s);
00334      int nmc=1000000; 
00335      _xs0 = gamHXSection(s,Esig,Egamcut,nmc); 
00336      _er0 = _er1; // stored when calculate _xs0
00337      std::cout<<"_er0= "<<_er0<<std::endl;
00338      _xs1 = gamHXSection(s,Egamcut,EgamH,nmc);
00339      double xs1_err = _er1;
00340  
00341     
00342    //--- sigularity point x from 0 to 0.0001GeV
00343     double xb= 2*Esig/_cms;
00344     double sig_xs = SoftPhoton_xs(s,xb)*(myxsection->getXsection(mx));
00345     _xs0 += sig_xs;
00346 
00347     //prepare the observed cross section with interpotation function divdif in CERNLIB
00348     testflag=1;
00349     int Nstp=598;
00350     double stp=(EgamH - Egamcut)/Nstp;
00351     for(int i=0;i<Nstp;i++){//points within Egam(max) ~ Egamcut=25MeV
00352       double Eg0=EgamH - i*stp;
00353       double Eg1=EgamH - (i+1)*stp;
00354       int nmc=20000;
00355       double xsi= gamHXSection(s,Eg1,Eg0,nmc); 
00356       AA[i]=(Eg1+Eg0)/2;
00357       double mhi=sqrt(_cms*_cms-2*_cms*AA[i]);
00358       double mh2=sqrt(_cms*_cms-2*_cms*Eg1);
00359       double binwidth = mh2-mhi;
00360       //if(_mode==74110) xsi += addNarrowRXS(mhi,binwidth);
00361       if(i==0) AF[0]=xsi; 
00362       if(i>=1) AF[i]=AF[i-1]+xsi;
00363       RadXS[i]=xsi/stp;
00364     } 
00365     //add the interval 0~Esig
00366     AA[598]=Egamcut;   AA[599]=0; //AA[i]: E_gamma
00367     AF[598]=AF[597];
00368     AF[599]=AF[598]+ _xs0;
00369     RadXS[599]=_xs0;
00370 
00371     
00372     //prepare observed cross section for each mode
00373     for(int i=0;i<vmode.size();i++){
00374       //std::cout<<"vmode index = "<<i<<std::endl;
00375       if(_mode==74110) mk_VXS(Esig,Egamcut,EgamH,i);
00376     }
00377     if(_mode==74110) writeDecayTabel();
00378     //after mk_VXS, restore the myxsection to _mode
00379     delete myxsection;
00380     myxsection =new EvtXsection (_mode);
00381     //debugging VXS
00382     /*
00383     double xtmp=0;
00384     for(int i=0;i<vmode.size();i++){
00385       xtmp+=VXS[i][599];
00386       for(int j=0;j<600;j++){
00387         std::cout<<VXS[i][j]<<" ";
00388         }
00389       std::cout<<std::endl;
00390     }
00391     */
00392 
00393     for(int i=0;i<600;i++){
00394       MH[i]=sqrt(_cms*_cms-2*_cms*AA[i]);
00395       //std::cout<<i<<" Egamma "<<AA[i]<<" Mhadons "<<MH[i]<<std::endl;
00396     }
00397     //for debugging
00398     //for(int i=0;i<600;i++){double s=_cms*_cms; double mhds=sqrt(s-2*_cms*AA[i]);std::cout<<"Mhds="<<mhds<<" Egam="<<AA[i]<<" "<<AF[i]<<std::endl;}
00399     std::cout<<"VXS[79][599]: "<<VXS[79][599]<<" VXS[79][598]= "<<VXS[79][598]<<std::endl;
00400     std::cout<<"EgamH="<<EgamH<<" "<<_xs0+_xs1<<" AF[599]="<<AF[599]<<" AF[598] "<<AF[598]<<std::endl;
00401     //double Etst=0.0241838;
00402     //std::cout<<"Etst="<<Etst<<" "<<gamHXSection(s,Etst,EgamH,nmc)<<" "<< lgr(AA,AF,600,Etst)<<std::endl; abort(); 
00403 
00404     //for information output
00405     double bornXS   = myxsection->getXsection(mx);  // std::cout<<"BornXS= "<<bornXS<<std::endl;
00406     double bornXS_er=myxsection->getErr(mx);
00407     double obsvXS   = _xs0 + _xs1; //gamHXSection(mth ,mx);
00408     double obsvXS_er= _er0 + xs1_err;
00409     double corr = obsvXS/bornXS; 
00410     double corr_er =corr*sqrt(bornXS_er*bornXS_er/bornXS/bornXS + obsvXS_er*obsvXS_er/obsvXS/obsvXS);
00411 
00412  
00413     if(bornXS==0){std::cout<<"EvtConExc::init : The Born cross section at this point is zero!"<<std::endl;abort();}
00414     if(obsvXS==0){std::cout<<"EvtConExc::init : The observed cross section at this point is zero!"<<std::endl;abort();}
00415 
00416     //_xs0 += bornXS;//  events with very soft photon (Egam<0.025) are taken as the born process 
00417     //_er0  = sqrt(_er0*_er0 + bornXS_er*bornXS_er);
00418 
00419     std::cout<<""<<std::endl;
00420     std::cout<<"========= Generation using cross section (Egamcut="<<Egamcut<<" GeV) =============="<<std::endl;
00421     std::cout<<" sqrt(s)= "<<mx<< " GeV "<<std::endl;
00422     if(_mode>=0 || _mode ==-2 ){
00423     std::cout<<"The generated born cross section (sigma_b): "<<_xs0<<"+/-"<<_er0<<" in Unit "<<_unit.c_str()<<std::endl;
00424     std::cout<<"The generated radiative correction cross section (sigma_isr): "<<_xs1<<"+/-"<<xs1_err<<" in Unit "<<_unit.c_str()<<std::endl;
00425     std::cout<<"The Born process is sampled according to the ratio sigma_b/(sigma_b+sigma_isr)"<<std::endl;
00426     std::cout<<"The radiative correction factor f_ISR*f_vacuum= sigma_obs/sigma_born(s)  = "<<corr<<"+/-"<< fabs(corr_er)<<","<<std::endl;
00427     std::cout<<"which is calcualted with these quantities:"<<std::endl;
00428     std::cout<<"the observed cross section is "<<obsvXS<<"+/-"<< obsvXS_er<<_unit.c_str()<<std::endl;
00429     std::cout<<"and the Born cross section (s) is  "<<bornXS<<"+/-"<<bornXS_er<<_unit.c_str()<<std::endl;
00430     std::cout<<"and the vaccum polarziation factor (lep. + hadr.) 1/|1-Pi|^2= "<<vph<<std::endl;
00431     std::cout<<"Within the range "<<myxsection->getXlw()<<" ~"<<myxsection->getXup()<<" GeV, "<<myxsection->getMsg().c_str()<<std::endl;
00432     std::cout<<"==========================================================================="<<std::endl;
00433     }else if(_mode==-1){
00434     std::cout<<"The generated born cross section (sigma_b): "<<_xs0<<" *Br_ee"<<" in Unit "<<_unit.c_str()<<std::endl;
00435     std::cout<<"The generated radiative correction cross section (sigma_isr): "<<_xs1<<"*Br_ee in Unit "<<_unit.c_str()<<std::endl;
00436     std::cout<<"The Born process is sampled according to the ratio sigma_b/(sigma_b+sigma_isr)"<<std::endl;
00437     std::cout<<"The radiative correction factor sigma_obs/sigma_born(s) = (1+delta) = "<<corr<<"+/-"<< fabs(corr_er)<<std::endl;
00438     std::cout<<"==========================================================================="<<std::endl;
00439     }
00440     std::cout<<std::endl;
00441     std::cout<<std::endl;
00442 
00443     findMaxXS(p);
00444     _mhdL=myxsection->getXlw();
00445     //--debugging
00446     //std::cout<<"maxXS= "<<maxXS<<std::endl;
00447     
00448     if(_xs0 == 0 && _xs1==0){std::cout<<"EvtConExc::ini() has zero cross section"<<std::endl;abort();}
00449 
00450     std::cout<<std::endl;
00451     std::cout<<std::endl;
00452 
00453     //--- for debugging
00454   if(mydbg  && _mode!=74110){
00455     int nd = myxsection->getYY().size();
00456     double  xx[10000],yy[10000],xer[10000],yer[10000];
00457     for(int i=0;i<nd;i++){
00458       xx[i]=myxsection->getXX()[i];
00459       yy[i]=myxsection->getYY()[i];
00460       yer[i]=myxsection->getEr()[i];
00461       xer[i]=0.;
00462       //std::cout<<"yy "<<yy[i]<<std::endl;
00463     }
00464     myth=new TH1F("myth","Exp.data",200,xx[0],xx[nd]);
00465     for(int i=0;i<nd;i++){
00466       myth->Fill(xx[i],yy[i]);
00467     }
00468     myth->SetError(yer);
00469     myth->Write();
00470     
00471     //std::cout<<"mass1= "<<mass1<<" mass2= "<<mass2<<std::endl;
00472   }else
00473 
00474     if(mydbg && _mode==74110 ){
00475       int nd = myxsection->getYY().size();
00476       double  xx[10000],yy[10000],xer[10000],yer[10000],ysum[10000],yysum[10000];
00477       for(int i=0;i<nd;i++){
00478         xx[i]=myxsection->getXX()[i];
00479         yy[i]=myxsection->getYY()[i];
00480         yer[i]=myxsection->getEr()[i];
00481         xer[i]=0.;
00482         //std::cout<<"yy "<<yy[i]<<std::endl;
00483       }
00484 #include "sty.C"
00485       double xhigh=5.0;
00486       double xlow = myxsection->getXlw();
00487       TGraphErrors *Gdt = new TGraphErrors(nd,xx,yy,xer,yer);
00488 
00489       myth=new TH1F("myth","Exp.data",600,xlow,xhigh);
00490       Xsum=new TH1F("sumxs","sum of exclusive xs",600,xlow,xhigh);
00491       double mstp=(xhigh-xlow)/600;
00492       for(int i=0;i<600;i++){
00493         double mx=i*mstp+xlow;
00494         double xsi = myxsection->getXsection(mx);
00495         if(xsi==0) continue;
00496         myth->Fill(mx,xsi);
00497         //std::cout<<mx<<" "<<xsi<<std::endl;
00498       }
00499 
00500       for(int i=0;i<600;i++){
00501         double mx=i*mstp+xlow;
00502         ysum[i]=sumExc(mx);
00503         if(ysum[i]==0) continue;
00504         Xsum->Fill(mx,ysum[i]);
00505         //std::cout<<mx<<" "<<ysum[i]<<std::endl;
00506       }
00507 
00508       for(int i=0;i<nd;i++){
00509         yysum[i]=sumExc(xx[i]);
00510       }
00511 
00512       myth->SetError(yer);
00513       myth->Write();
00514       Xsum->Write();
00515 
00516       TGraphErrors *Gsum = new TGraphErrors(nd,xx,yysum,xer,yer);
00517       //draw graph
00518       double ex[600]={600*0};
00519       double ey[600],ta[600];
00520       double exz[600]={600*0};
00521       double eyz[600]={600*0};
00522       for(int i=0;i<600;i++){
00523         ey[i]=AF[i]*0.001;
00524       }
00525       TGraphErrors *gr0 = new TGraphErrors(600,MH,AF,ex,ey);
00526       TGraphErrors *gr1 = new TGraphErrors(600,MH,RadXS,exz,eyz);
00527       TPostScript *ps = new TPostScript("xsobs.ps",111); 
00528       TCanvas *c1 = new TCanvas("c1","TGraphs for data",200,10,600,400);
00529       gPad-> SetLogy(1);
00530       //      c1->SetLogy(1); 
00531       gStyle->SetCanvasColor(0);
00532       gStyle->SetStatBorderSize(1);
00533       c1->Divide(1,1);
00534 
00535       c1->Update(); 
00536       ps->NewPage();
00537       c1->Draw();
00538       c1->cd(1);
00539       c1->SetLogy(1); 
00540       gr0->SetMarkerStyle(10);
00541       gr0->Draw("AP");
00542       gr0->GetXaxis()->SetTitle("M_{hadrons} (GeV)");
00543       gr0->GetYaxis()->SetTitle("observed cross section (nb)");
00544       gr0->Write();
00545 
00546       c1->Update(); 
00547       ps->NewPage();
00548       c1->Draw();
00549       c1->cd(1);
00550       c1->SetLogy(1); 
00551       gr1->SetMarkerStyle(10);
00552       gr1->Draw("AP");
00553       gr1->GetXaxis()->SetTitle("M_{hadrons} (GeV)");
00554       gr1->GetYaxis()->SetTitle("Rad*BornXS");
00555       gr1->Write();
00556 
00557       //--------- imposing graphs to a pad
00558       TMultiGraph *mg = new TMultiGraph();
00559       mg->SetTitle("Exclusion graphs");
00560       Gdt->SetMarkerStyle(2);
00561       Gdt->SetMarkerSize(1);
00562       Gsum->SetLineColor(2);
00563       Gsum->SetLineWidth(1);
00564       mg->Add(Gdt);
00565       mg->Add(Gsum);
00566 
00567       c1->Update(); 
00568       ps->NewPage();
00569       c1->Draw();
00570       c1->cd(1);
00571       gPad-> SetLogy(1);
00572       mg->Draw("APL");
00573       mg->GetXaxis()->SetTitle("M_{hadrons} (GeV)");
00574       mg->GetYaxis()->SetTitle("observed cross section (nb)");
00575       mg->Write();
00576       //-------
00577 
00578       c1->Update(); 
00579       ps->NewPage();
00580       c1->Draw();
00581       c1->cd(1);
00582       Gdt->SetMarkerStyle(2);
00583       Gdt->Draw("AP");
00584       Gdt->GetXaxis()->SetTitle("M_{hadrons} (GeV)");
00585       Gdt->GetYaxis()->SetTitle("observed cross section (nb)");
00586       Gdt->Write();
00587 
00588       c1->Update(); 
00589       ps->NewPage();
00590       c1->Draw();
00591       c1->cd(1);
00592       Gsum->SetMarkerStyle(2);
00593       Gsum->SetMarkerSize(1);
00594       Gsum->Draw("AP");
00595       Gsum->SetLineWidth(0);
00596       Gsum->GetXaxis()->SetTitle("M_{hadrons} (GeV)");
00597       Gsum->GetYaxis()->SetTitle("observed cross section (nb)");
00598       Gsum->Write();
00599 
00600       c1->Update(); 
00601       ps->NewPage();
00602       c1->Draw();
00603       c1->cd(1);
00604       // gPad-> SetLogx(1);
00605       Gdt->SetMarkerStyle(2);
00606       Gdt->SetMarkerSize(1);
00607       Gdt->SetMaximum(8000.0);
00608       Gsum->SetLineColor(2);
00609       Gsum->SetLineWidth(1.5);
00610       Gsum->Draw("AL"); //A: draw axis
00611       Gdt->Draw("P");   // superpose to the Gsum, without A-option
00612       Gsum->GetXaxis()->SetTitle("M_{hadrons} (GeV)");
00613       Gsum->GetYaxis()->SetTitle("cross section (nb)");
00614       Gsum->Write();
00615 
00616       ps->Close(); 
00617      } //if(mydbg)_block
00618     //-------------------------
00619 
00620 }
00621 
00622 
00623 //--
00624 void EvtConExc::init_mode(int mode){
00625   if(mode ==0 ){
00626     _ndaugs =2;
00627     daugs[0]=EvtPDL::getId(std::string("p+"));
00628     daugs[1]=EvtPDL::getId(std::string("anti-p-"));
00629   }else  if(mode ==1 ){
00630     _ndaugs =2;
00631     daugs[0]=EvtPDL::getId(std::string("n0"));
00632     daugs[1]=EvtPDL::getId(std::string("anti-n0"));
00633   }else  if(mode ==2 ){
00634     _ndaugs =2;
00635     daugs[0]=EvtPDL::getId(std::string("Lambda0"));
00636     daugs[1]=EvtPDL::getId(std::string("anti-Lambda0"));
00637   }else  if(mode ==3 ){
00638     _ndaugs =2;
00639     daugs[0]=EvtPDL::getId(std::string("Sigma0"));
00640     daugs[1]=EvtPDL::getId(std::string("anti-Sigma0"));
00641   }else  if(mode ==4 ){
00642     _ndaugs =2;
00643     daugs[0]=EvtPDL::getId(std::string("Lambda0"));
00644     daugs[1]=EvtPDL::getId(std::string("anti-Sigma0"));
00645   }else  if(mode ==5 ){
00646     _ndaugs =2;
00647     daugs[0]=EvtPDL::getId(std::string("Sigma0"));
00648     daugs[1]=EvtPDL::getId(std::string("anti-Lambda0"));
00649   }  else  if(mode ==6 ){
00650     _ndaugs =2;
00651     daugs[0]=EvtPDL::getId(std::string("pi+"));
00652     daugs[1]=EvtPDL::getId(std::string("pi-"));
00653   }else  if(mode ==7 ){
00654     _ndaugs =3;
00655     daugs[0]=EvtPDL::getId(std::string("pi+"));
00656     daugs[1]=EvtPDL::getId(std::string("pi-"));
00657     daugs[2]=EvtPDL::getId(std::string("pi0"));
00658   }else  if(mode ==8 ){
00659     _ndaugs =3;
00660     daugs[0]=EvtPDL::getId(std::string("K+"));
00661     daugs[1]=EvtPDL::getId(std::string("K-"));
00662     daugs[2]=EvtPDL::getId(std::string("pi0"));
00663   }else  if(mode ==9 ){
00664     _ndaugs =3;
00665     daugs[0]=EvtPDL::getId(std::string("K_S0"));
00666     daugs[1]=EvtPDL::getId(std::string("K+"));
00667     daugs[2]=EvtPDL::getId(std::string("pi-"));
00668   }else  if(mode ==10 ){
00669     _ndaugs =3;
00670     daugs[0]=EvtPDL::getId(std::string("K_S0"));
00671     daugs[1]=EvtPDL::getId(std::string("K-"));
00672     daugs[2]=EvtPDL::getId(std::string("pi+"));
00673   }else  if(mode ==11 ){
00674     _ndaugs =3;
00675     daugs[0]=EvtPDL::getId(std::string("K+"));
00676     daugs[1]=EvtPDL::getId(std::string("K+"));
00677     daugs[2]=EvtPDL::getId(std::string("eta"));
00678   }else  if(mode ==12 ){
00679     _ndaugs =4;
00680     daugs[0]=EvtPDL::getId(std::string("pi+"));
00681     daugs[1]=EvtPDL::getId(std::string("pi-"));
00682     daugs[2]=EvtPDL::getId(std::string("pi+"));
00683     daugs[3]=EvtPDL::getId(std::string("pi-"));
00684   }else  if(mode ==13 ){
00685     _ndaugs =4;
00686     daugs[0]=EvtPDL::getId(std::string("pi+"));
00687     daugs[1]=EvtPDL::getId(std::string("pi-"));
00688     daugs[2]=EvtPDL::getId(std::string("pi0"));
00689     daugs[3]=EvtPDL::getId(std::string("pi0"));
00690   }else  if(mode ==14 ){
00691     _ndaugs =4;
00692     daugs[0]=EvtPDL::getId(std::string("K+"));
00693     daugs[1]=EvtPDL::getId(std::string("K-"));
00694     daugs[2]=EvtPDL::getId(std::string("pi+"));
00695     daugs[3]=EvtPDL::getId(std::string("pi-"));
00696   }else  if(mode ==15 ){
00697     _ndaugs =4;
00698     daugs[0]=EvtPDL::getId(std::string("K+"));
00699     daugs[1]=EvtPDL::getId(std::string("K-"));
00700     daugs[2]=EvtPDL::getId(std::string("pi0"));
00701     daugs[3]=EvtPDL::getId(std::string("pi0"));
00702   }else  if(mode ==16 ){
00703     _ndaugs =4;
00704     daugs[0]=EvtPDL::getId(std::string("K+"));
00705     daugs[1]=EvtPDL::getId(std::string("K-"));
00706     daugs[2]=EvtPDL::getId(std::string("K+"));
00707     daugs[3]=EvtPDL::getId(std::string("K-"));
00708   }else  if(mode ==17 ){ 
00709     _ndaugs =5;
00710     daugs[0]=EvtPDL::getId(std::string("pi+"));
00711     daugs[1]=EvtPDL::getId(std::string("pi-"));
00712     daugs[2]=EvtPDL::getId(std::string("pi+"));
00713     daugs[3]=EvtPDL::getId(std::string("pi-"));
00714     daugs[4]=EvtPDL::getId(std::string("pi0"));
00715   }else  if(mode ==18 ){
00716     _ndaugs =5;
00717     daugs[0]=EvtPDL::getId(std::string("pi+"));
00718     daugs[1]=EvtPDL::getId(std::string("pi-"));
00719     daugs[2]=EvtPDL::getId(std::string("pi+"));
00720     daugs[3]=EvtPDL::getId(std::string("pi-"));
00721     daugs[4]=EvtPDL::getId(std::string("eta"));
00722   }else  if(mode ==19 ){
00723     _ndaugs =5;
00724     daugs[0]=EvtPDL::getId(std::string("K+"));
00725     daugs[1]=EvtPDL::getId(std::string("K-"));
00726     daugs[2]=EvtPDL::getId(std::string("pi+"));
00727     daugs[3]=EvtPDL::getId(std::string("pi-"));
00728     daugs[4]=EvtPDL::getId(std::string("pi0"));
00729   }else  if(mode ==20 ){
00730     _ndaugs =5;
00731     daugs[0]=EvtPDL::getId(std::string("K+"));
00732     daugs[1]=EvtPDL::getId(std::string("K-"));
00733     daugs[2]=EvtPDL::getId(std::string("pi+"));
00734     daugs[3]=EvtPDL::getId(std::string("pi-"));
00735     daugs[4]=EvtPDL::getId(std::string("eta"));
00736   }else  if(mode ==21 ){
00737     _ndaugs =6;
00738     daugs[0]=EvtPDL::getId(std::string("pi+"));
00739     daugs[1]=EvtPDL::getId(std::string("pi-"));
00740     daugs[2]=EvtPDL::getId(std::string("pi+"));
00741     daugs[3]=EvtPDL::getId(std::string("pi-"));
00742     daugs[4]=EvtPDL::getId(std::string("pi+"));
00743     daugs[5]=EvtPDL::getId(std::string("pi-"));
00744   }else  if(mode ==22 ){
00745     _ndaugs =6;
00746     daugs[0]=EvtPDL::getId(std::string("pi+"));
00747     daugs[1]=EvtPDL::getId(std::string("pi-"));
00748     daugs[2]=EvtPDL::getId(std::string("pi+"));
00749     daugs[3]=EvtPDL::getId(std::string("pi-"));
00750     daugs[4]=EvtPDL::getId(std::string("pi0"));
00751     daugs[5]=EvtPDL::getId(std::string("pi0"));
00752   }else if(mode == 23){
00753     _ndaugs =2;
00754     daugs[0]=EvtPDL::getId(std::string("eta"));
00755     daugs[1]=EvtPDL::getId(std::string("phi"));
00756   }else if(mode == 24){
00757     _ndaugs =2;
00758     daugs[0]=EvtPDL::getId(std::string("phi"));
00759     daugs[1]=EvtPDL::getId(std::string("pi0"));
00760   }else if(mode == 25){
00761     _ndaugs =2;
00762     daugs[0]=EvtPDL::getId(std::string("K+"));
00763     daugs[1]=EvtPDL::getId(std::string("K*-"));
00764   }else if(mode == 26){
00765     _ndaugs =2;
00766     daugs[0]=EvtPDL::getId(std::string("K-"));
00767     daugs[1]=EvtPDL::getId(std::string("K*+"));
00768   }else if(mode == 27){
00769     _ndaugs =2;
00770     daugs[0]=EvtPDL::getId(std::string("K_S0"));
00771     daugs[1]=EvtPDL::getId(std::string("anti-K*0"));
00772   }else if(mode == 28){
00773     _ndaugs =3;
00774     daugs[0]=EvtPDL::getId(std::string("K*0"));
00775     daugs[1]=EvtPDL::getId(std::string("K+"));
00776     daugs[2]=EvtPDL::getId(std::string("pi-"));
00777   }else if(mode == 29){
00778     _ndaugs =3;
00779     daugs[0]=EvtPDL::getId(std::string("K*0"));
00780     daugs[1]=EvtPDL::getId(std::string("K-"));
00781     daugs[2]=EvtPDL::getId(std::string("pi+"));
00782   }else if(mode == 30){
00783     _ndaugs =3;
00784     daugs[0]=EvtPDL::getId(std::string("K*+"));
00785     daugs[1]=EvtPDL::getId(std::string("K-"));
00786     daugs[2]=EvtPDL::getId(std::string("pi0"));
00787   }else if(mode == 31){
00788     _ndaugs =3;
00789     daugs[0]=EvtPDL::getId(std::string("K*-"));
00790     daugs[1]=EvtPDL::getId(std::string("K+"));
00791     daugs[2]=EvtPDL::getId(std::string("pi0"));
00792   }else if(mode == 32){
00793     _ndaugs =3;
00794     daugs[0]=EvtPDL::getId(std::string("K_2*0"));
00795     daugs[1]=EvtPDL::getId(std::string("K+"));
00796     daugs[2]=EvtPDL::getId(std::string("pi-"));
00797   }else if(mode == 33){
00798     _ndaugs =3;
00799     daugs[0]=EvtPDL::getId(std::string("K_2*0"));
00800     daugs[1]=EvtPDL::getId(std::string("K-"));
00801     daugs[2]=EvtPDL::getId(std::string("pi+"));
00802   }else if(mode == 34){
00803     _ndaugs =3;
00804     daugs[0]=EvtPDL::getId(std::string("K+"));
00805     daugs[1]=EvtPDL::getId(std::string("K-"));
00806     daugs[2]=EvtPDL::getId(std::string("rho0"));
00807   }else if(mode == 35){
00808     _ndaugs =3;
00809     daugs[0]=EvtPDL::getId(std::string("phi"));
00810     daugs[1]=EvtPDL::getId(std::string("pi-"));
00811     daugs[2]=EvtPDL::getId(std::string("pi+"));
00812   }else if(mode == 36){
00813     _ndaugs =2;
00814     daugs[0]=EvtPDL::getId(std::string("phi"));
00815     daugs[1]=EvtPDL::getId(std::string("f_0"));
00816   }else if(mode == 37){
00817     _ndaugs =3;
00818     daugs[0]=EvtPDL::getId(std::string("eta"));
00819     daugs[1]=EvtPDL::getId(std::string("pi+"));
00820     daugs[2]=EvtPDL::getId(std::string("pi-"));
00821   }else if(mode == 38){
00822     _ndaugs =3;
00823     daugs[0]=EvtPDL::getId(std::string("omega"));
00824     daugs[1]=EvtPDL::getId(std::string("pi+"));
00825     daugs[2]=EvtPDL::getId(std::string("pi-"));
00826   }else if(mode == 39){
00827     _ndaugs =2;
00828     daugs[0]=EvtPDL::getId(std::string("omega"));
00829     daugs[1]=EvtPDL::getId(std::string("f_0"));
00830   }else if(mode == 40){
00831     _ndaugs =3;
00832     daugs[0]=EvtPDL::getId(std::string("eta'"));
00833     daugs[1]=EvtPDL::getId(std::string("pi+"));
00834     daugs[2]=EvtPDL::getId(std::string("pi-"));
00835   }else if(mode == 41){
00836     _ndaugs =3;
00837     daugs[0]=EvtPDL::getId(std::string("f_1"));
00838     daugs[1]=EvtPDL::getId(std::string("pi+"));
00839     daugs[2]=EvtPDL::getId(std::string("pi-"));
00840   }else if(mode == 42){
00841     _ndaugs =3;
00842     daugs[0]=EvtPDL::getId(std::string("omega"));
00843     daugs[1]=EvtPDL::getId(std::string("K+"));
00844     daugs[2]=EvtPDL::getId(std::string("K-"));
00845   }else if(mode == 43){
00846     _ndaugs =4;
00847     daugs[0]=EvtPDL::getId(std::string("omega"));
00848     daugs[1]=EvtPDL::getId(std::string("pi+"));
00849     daugs[2]=EvtPDL::getId(std::string("pi-"));
00850     daugs[3]=EvtPDL::getId(std::string("pi0"));
00851   }else if(mode == 44){
00852     _ndaugs =2;
00853     daugs[0]=EvtPDL::getId(std::string("Sigma-"));
00854     daugs[1]=EvtPDL::getId(std::string("anti-Sigma+"));
00855   }else if(mode == 45){
00856     _ndaugs =2;
00857     daugs[0]=EvtPDL::getId(std::string("K+"));
00858     daugs[1]=EvtPDL::getId(std::string("K-"));
00859   }else if(mode == 46){
00860     _ndaugs =2;
00861     daugs[0]=EvtPDL::getId(std::string("K_S0"));
00862     daugs[1]=EvtPDL::getId(std::string("K_L0"));
00863   }else if(mode == 47){
00864     _ndaugs =2;
00865     daugs[0]=EvtPDL::getId(std::string("omega"));
00866     daugs[1]=EvtPDL::getId(std::string("eta"));
00867   }else if(mode == 48){
00868     _ndaugs =2;
00869     daugs[0]=EvtPDL::getId(std::string("phi"));
00870     daugs[1]=EvtPDL::getId(std::string("eta'"));
00871   }else if(mode == 49){
00872     _ndaugs =3;
00873     daugs[0]=EvtPDL::getId(std::string("phi"));
00874     daugs[1]=EvtPDL::getId(std::string("K+"));
00875     daugs[2]=EvtPDL::getId(std::string("K-"));
00876   }else if(mode == 50){
00877     _ndaugs =3;
00878     daugs[0]=EvtPDL::getId(std::string("p+"));
00879     daugs[1]=EvtPDL::getId(std::string("anti-p-"));
00880     daugs[2]=EvtPDL::getId(std::string("pi0"));
00881   }else if(mode == 51){
00882     _ndaugs =3;
00883     daugs[0]=EvtPDL::getId(std::string("p+"));
00884     daugs[1]=EvtPDL::getId(std::string("anti-p-"));
00885     daugs[2]=EvtPDL::getId(std::string("eta"));
00886   }else if(mode == 65){
00887     _ndaugs =3;
00888     daugs[0]=EvtPDL::getId(std::string("D-"));
00889     daugs[1]=EvtPDL::getId(std::string("D*0"));
00890     daugs[2]=EvtPDL::getId(std::string("pi+"));
00891   }else if(mode == 66){
00892     _ndaugs =3;
00893     daugs[0]=EvtPDL::getId(std::string("D+"));
00894     daugs[1]=EvtPDL::getId(std::string("anti-D*0"));
00895     daugs[2]=EvtPDL::getId(std::string("pi-"));
00896   }else if(mode == 67){
00897     _ndaugs =2;
00898     daugs[0]=EvtPDL::getId(std::string("D*0"));
00899     daugs[1]=EvtPDL::getId(std::string("anti-D*0"));
00900   }else if(mode == 68){
00901     _ndaugs =2;
00902     daugs[0]=EvtPDL::getId(std::string("D0"));
00903     daugs[1]=EvtPDL::getId(std::string("anti-D*0"));
00904 
00905   }else if(mode == 69){
00906     _ndaugs =2;
00907     daugs[0]=EvtPDL::getId(std::string("anti-D0"));
00908     daugs[1]=EvtPDL::getId(std::string("D*0"));
00909 
00910   }else if(mode == 70){
00911     _ndaugs =2;
00912     daugs[0]=EvtPDL::getId(std::string("D0"));
00913     daugs[1]=EvtPDL::getId(std::string("anti-D0"));
00914 
00915 }else if(mode == 71){
00916     _ndaugs =2;
00917     daugs[0]=EvtPDL::getId(std::string("D+"));
00918     daugs[1]=EvtPDL::getId(std::string("D-"));
00919   }else if(mode == 72){
00920     _ndaugs =2;
00921     daugs[0]=EvtPDL::getId(std::string("D+"));
00922     daugs[1]=EvtPDL::getId(std::string("D*-"));
00923 
00924   }else if(mode == 73){
00925     _ndaugs =2;
00926     daugs[0]=EvtPDL::getId(std::string("D-"));
00927     daugs[1]=EvtPDL::getId(std::string("D*+"));
00928 
00929   }else if(mode == 74){
00930     _ndaugs =2;
00931     daugs[0]=EvtPDL::getId(std::string("D*+"));
00932     daugs[1]=EvtPDL::getId(std::string("D*-"));
00933 
00934   }else if(mode == 75){
00935     _ndaugs =3;
00936     daugs[0]=EvtPDL::getId(std::string("D0"));
00937     daugs[1]=EvtPDL::getId(std::string("D-"));
00938     daugs[2]=EvtPDL::getId(std::string("pi+"));
00939   }else if(mode == 76){
00940     _ndaugs =3;
00941     daugs[0]=EvtPDL::getId(std::string("anti-D0"));
00942     daugs[1]=EvtPDL::getId(std::string("D+"));
00943     daugs[2]=EvtPDL::getId(std::string("pi-"));
00944   }else if(mode == 77){
00945     _ndaugs =3;
00946     daugs[0]=EvtPDL::getId(std::string("D0"));
00947     daugs[1]=EvtPDL::getId(std::string("D*-"));
00948     daugs[2]=EvtPDL::getId(std::string("pi+"));
00949   }else if(mode == 78){
00950     _ndaugs =3;
00951     daugs[0]=EvtPDL::getId(std::string("anti-D0"));
00952     daugs[1]=EvtPDL::getId(std::string("D*+"));
00953     daugs[2]=EvtPDL::getId(std::string("pi-"));
00954   }else if(mode == 79){
00955     _ndaugs =3;
00956     daugs[0]=EvtPDL::getId(std::string("psi(2S)"));
00957     daugs[1]=EvtPDL::getId(std::string("pi0"));
00958     daugs[2]=EvtPDL::getId(std::string("pi0"));
00959   }else if(mode == 80){
00960     _ndaugs =2;
00961     daugs[0]=EvtPDL::getId(std::string("eta"));
00962     daugs[1]=EvtPDL::getId(std::string("J/psi"));
00963   }else if(mode == 81){
00964     _ndaugs =3;
00965     daugs[0]=EvtPDL::getId(std::string("h_c"));
00966     daugs[1]=EvtPDL::getId(std::string("pi+"));
00967     daugs[2]=EvtPDL::getId(std::string("pi-"));
00968   }else if(mode == 82){
00969     _ndaugs =3;
00970     daugs[0]=EvtPDL::getId(std::string("h_c"));
00971     daugs[1]=EvtPDL::getId(std::string("pi0"));
00972     daugs[2]=EvtPDL::getId(std::string("pi0"));
00973   }else if(mode == 83){
00974     _ndaugs =3;
00975     daugs[0]=EvtPDL::getId(std::string("J/psi"));
00976     daugs[1]=EvtPDL::getId(std::string("K+"));
00977     daugs[2]=EvtPDL::getId(std::string("K-"));
00978   }else if(mode == 84){
00979     _ndaugs =3;
00980     daugs[0]=EvtPDL::getId(std::string("J/psi"));
00981     daugs[1]=EvtPDL::getId(std::string("K_S0"));
00982     daugs[2]=EvtPDL::getId(std::string("K_S0"));
00983   }else if(mode == 90){
00984     _ndaugs =3;
00985     daugs[0]=EvtPDL::getId(std::string("J/psi"));
00986     daugs[1]=EvtPDL::getId(std::string("pi+"));
00987     daugs[2]=EvtPDL::getId(std::string("pi-"));
00988   }else if(mode == 91){
00989     _ndaugs =3;
00990     daugs[0]=EvtPDL::getId(std::string("psi(2S)"));
00991     daugs[1]=EvtPDL::getId(std::string("pi+"));
00992     daugs[2]=EvtPDL::getId(std::string("pi-"));
00993   }else if(mode == 92){
00994     _ndaugs =3;
00995     daugs[0]=EvtPDL::getId(std::string("J/psi"));
00996     daugs[1]=EvtPDL::getId(std::string("K+"));
00997     daugs[2]=EvtPDL::getId(std::string("K-"));
00998   }else if(mode == 93){
00999     _ndaugs =2;
01000     daugs[0]=EvtPDL::getId(std::string("D_s+"));
01001     daugs[1]=EvtPDL::getId(std::string("D_s-"));
01002   }else if(mode == 94){
01003     _ndaugs =2;
01004     daugs[0]=EvtPDL::getId(std::string("D_s*+"));
01005     daugs[1]=EvtPDL::getId(std::string("D_s-"));
01006   }else if(mode == 95){
01007     _ndaugs =2;
01008     daugs[0]=EvtPDL::getId(std::string("D_s*-"));
01009     daugs[1]=EvtPDL::getId(std::string("D_s+"));
01010   }else if(mode == 96){
01011     _ndaugs =2;
01012     daugs[0]=EvtPDL::getId(std::string("Lambda_c+"));
01013     daugs[1]=EvtPDL::getId(std::string("anti-Lambda_c-"));
01014   }else if(mode == 74100){
01015     _ndaugs =1;
01016     daugs[0]=EvtPDL::getId(std::string("J/psi"));     
01017   }else if(mode == 74101){
01018     _ndaugs =1;
01019     daugs[0]=EvtPDL::getId(std::string("psi(2S)"));
01020   }else if(mode == 74102){
01021     _ndaugs =1;
01022     daugs[0]=EvtPDL::getId(std::string("psi(3770)"));  
01023   }else if(mode == 74103){
01024     _ndaugs =1;
01025     daugs[0]=EvtPDL::getId(std::string("phi"));
01026   }else if(mode == 74104){
01027     _ndaugs =1;
01028     daugs[0]=EvtPDL::getId(std::string("omega"));
01029   }else if(mode == 74105){
01030     _ndaugs =1;
01031     daugs[0]=EvtPDL::getId(std::string("rho0"));
01032   }else if(mode == 74106){
01033     _ndaugs =1;
01034     daugs[0]=EvtPDL::getId(std::string("rho(3S)0")); 
01035   }else if(mode == 74107){
01036     _ndaugs =1;
01037     daugs[0]=EvtPDL::getId(std::string("omega(2S)"));          
01038   }else if(mode == 74110){
01039     _ndaugs =1;
01040     daugs[0]=EvtPDL::getId(std::string("gamma*")); 
01041     EvtId  myvpho = EvtPDL::getId(std::string("gamma*"));
01042     EvtPDL::reSetMass(myvpho,mhds*0.9); //for calculating maxXS, it will be resent when this mode is selected   
01043     _modeFlag.clear();
01044     _modeFlag.push_back(74110); //R-value generator tag
01045     _modeFlag.push_back(0);     //to contain the mode selected
01046   }else if(mode == -1){
01047     _ndaugs = nson;
01048     for(int i=0;i<nson;i++){ daugs[i]=son[i];  }
01049     std::cout<<"The paraent particle: "<<EvtPDL::name(pid)<<std::endl;
01050   }else if(mode == -2){
01051     _ndaugs = nson;
01052     for(int i=0;i<nson;i++){  daugs[i]=son[i];  }
01053   }else if(mode == 10000){//use for check ISR
01054     _ndaugs =2;
01055     daugs[0]=EvtPDL::getId(std::string("pi+"));
01056     daugs[1]=EvtPDL::getId(std::string("pi-"));
01057   }else {
01058     std::cout<<"Bad mode_index number " <<mode<<", please refer to the manual."<<std::endl;
01059     ::abort();
01060   }
01061   // std::cout<<_ndaugs<<", "<<daugs[0]<<daugs[1]<<std::endl;
01062 
01063   if(VISR){
01064     _ndaugs=2;
01065     daugs[0]=getDaugs()[0];//EvtPDL::getId(std::string("gamma"));
01066     daugs[1]=getDaugs()[1];//EvtPDL::getId(std::string("gamma*"));
01067   }
01068 
01069   double fmth=0;
01070   for(int i=0;i<_ndaugs;i++){
01071     double xmi=EvtPDL::getMinMass(daugs[i]);
01072     fmth +=xmi;
01073   }
01074   myxsection = new EvtXsection (mode);
01075   Mthr=myxsection->getXlw();   
01076   if(_mode!=74110 && Mthr<fmth) {std::cout<<"Low end of cross section: ("<<Mthr<<" < (mass of final state)"<<fmth<<") GeV."<< std::endl; abort();}
01077 }
01078 
01079 //--
01080 std::vector<EvtId> EvtConExc::get_mode(int mode){
01081   int _ndaugs;
01082   EvtId daugs[100];
01083   if(mode ==0 ){
01084     _ndaugs =2;
01085     daugs[0]=EvtPDL::getId(std::string("p+"));
01086     daugs[1]=EvtPDL::getId(std::string("anti-p-"));
01087   }else  if(mode ==1 ){
01088     _ndaugs =2;
01089     daugs[0]=EvtPDL::getId(std::string("n0"));
01090     daugs[1]=EvtPDL::getId(std::string("anti-n0"));
01091   }else  if(mode ==2 ){
01092     _ndaugs =2;
01093     daugs[0]=EvtPDL::getId(std::string("Lambda0"));
01094     daugs[1]=EvtPDL::getId(std::string("anti-Lambda0"));
01095   }else  if(mode ==3 ){
01096     _ndaugs =2;
01097     daugs[0]=EvtPDL::getId(std::string("Sigma0"));
01098     daugs[1]=EvtPDL::getId(std::string("anti-Sigma0"));
01099   }else  if(mode ==4 ){
01100     _ndaugs =2;
01101     daugs[0]=EvtPDL::getId(std::string("Lambda0"));
01102     daugs[1]=EvtPDL::getId(std::string("anti-Sigma0"));
01103   }else  if(mode ==5 ){
01104     _ndaugs =2;
01105     daugs[0]=EvtPDL::getId(std::string("Sigma0"));
01106     daugs[1]=EvtPDL::getId(std::string("anti-Lambda0"));
01107   }  else  if(mode ==6 ){
01108     _ndaugs =2;
01109     daugs[0]=EvtPDL::getId(std::string("pi+"));
01110     daugs[1]=EvtPDL::getId(std::string("pi-"));
01111   }else  if(mode ==7 ){
01112     _ndaugs =3;
01113     daugs[0]=EvtPDL::getId(std::string("pi+"));
01114     daugs[1]=EvtPDL::getId(std::string("pi-"));
01115     daugs[2]=EvtPDL::getId(std::string("pi0"));
01116   }else  if(mode ==8 ){
01117     _ndaugs =3;
01118     daugs[0]=EvtPDL::getId(std::string("K+"));
01119     daugs[1]=EvtPDL::getId(std::string("K-"));
01120     daugs[2]=EvtPDL::getId(std::string("pi0"));
01121   }else  if(mode ==9 ){
01122     _ndaugs =3;
01123     daugs[0]=EvtPDL::getId(std::string("K_S0"));
01124     daugs[1]=EvtPDL::getId(std::string("K+"));
01125     daugs[2]=EvtPDL::getId(std::string("pi-"));
01126   }else  if(mode ==10 ){
01127     _ndaugs =3;
01128     daugs[0]=EvtPDL::getId(std::string("K_S0"));
01129     daugs[1]=EvtPDL::getId(std::string("K-"));
01130     daugs[2]=EvtPDL::getId(std::string("pi+"));
01131   }else  if(mode ==11 ){
01132     _ndaugs =3;
01133     daugs[0]=EvtPDL::getId(std::string("K+"));
01134     daugs[1]=EvtPDL::getId(std::string("K-"));
01135     daugs[2]=EvtPDL::getId(std::string("eta"));
01136   }else  if(mode ==12 ){
01137     _ndaugs =4;
01138     daugs[0]=EvtPDL::getId(std::string("pi+"));
01139     daugs[1]=EvtPDL::getId(std::string("pi-"));
01140     daugs[2]=EvtPDL::getId(std::string("pi+"));
01141     daugs[3]=EvtPDL::getId(std::string("pi-"));
01142   }else  if(mode ==13 ){
01143     _ndaugs =4;
01144     daugs[0]=EvtPDL::getId(std::string("pi+"));
01145     daugs[1]=EvtPDL::getId(std::string("pi-"));
01146     daugs[2]=EvtPDL::getId(std::string("pi0"));
01147     daugs[3]=EvtPDL::getId(std::string("pi0"));
01148   }else  if(mode ==14 ){
01149     _ndaugs =4;
01150     daugs[0]=EvtPDL::getId(std::string("K+"));
01151     daugs[1]=EvtPDL::getId(std::string("K-"));
01152     daugs[2]=EvtPDL::getId(std::string("pi+"));
01153     daugs[3]=EvtPDL::getId(std::string("pi-"));
01154   }else  if(mode ==15 ){
01155     _ndaugs =4;
01156     daugs[0]=EvtPDL::getId(std::string("K+"));
01157     daugs[1]=EvtPDL::getId(std::string("K-"));
01158     daugs[2]=EvtPDL::getId(std::string("pi0"));
01159     daugs[3]=EvtPDL::getId(std::string("pi0"));
01160   }else  if(mode ==16 ){
01161     _ndaugs =4;
01162     daugs[0]=EvtPDL::getId(std::string("K+"));
01163     daugs[1]=EvtPDL::getId(std::string("K-"));
01164     daugs[2]=EvtPDL::getId(std::string("K+"));
01165     daugs[3]=EvtPDL::getId(std::string("K-"));
01166   }else  if(mode ==17 ){ 
01167     _ndaugs =5;
01168     daugs[0]=EvtPDL::getId(std::string("pi+"));
01169     daugs[1]=EvtPDL::getId(std::string("pi-"));
01170     daugs[2]=EvtPDL::getId(std::string("pi+"));
01171     daugs[3]=EvtPDL::getId(std::string("pi-"));
01172     daugs[4]=EvtPDL::getId(std::string("pi0"));
01173   }else  if(mode ==18 ){
01174     _ndaugs =5;
01175     daugs[0]=EvtPDL::getId(std::string("pi+"));
01176     daugs[1]=EvtPDL::getId(std::string("pi-"));
01177     daugs[2]=EvtPDL::getId(std::string("pi+"));
01178     daugs[3]=EvtPDL::getId(std::string("pi-"));
01179     daugs[4]=EvtPDL::getId(std::string("eta"));
01180   }else  if(mode ==19 ){
01181     _ndaugs =5;
01182     daugs[0]=EvtPDL::getId(std::string("K+"));
01183     daugs[1]=EvtPDL::getId(std::string("K-"));
01184     daugs[2]=EvtPDL::getId(std::string("pi+"));
01185     daugs[3]=EvtPDL::getId(std::string("pi-"));
01186     daugs[4]=EvtPDL::getId(std::string("pi0"));
01187   }else  if(mode ==20 ){
01188     _ndaugs =5;
01189     daugs[0]=EvtPDL::getId(std::string("K+"));
01190     daugs[1]=EvtPDL::getId(std::string("K-"));
01191     daugs[2]=EvtPDL::getId(std::string("pi+"));
01192     daugs[3]=EvtPDL::getId(std::string("pi-"));
01193     daugs[4]=EvtPDL::getId(std::string("eta"));
01194   }else  if(mode ==21 ){
01195     _ndaugs =6;
01196     daugs[0]=EvtPDL::getId(std::string("pi+"));
01197     daugs[1]=EvtPDL::getId(std::string("pi-"));
01198     daugs[2]=EvtPDL::getId(std::string("pi+"));
01199     daugs[3]=EvtPDL::getId(std::string("pi-"));
01200     daugs[4]=EvtPDL::getId(std::string("pi+"));
01201     daugs[5]=EvtPDL::getId(std::string("pi-"));
01202   }else  if(mode ==22 ){
01203     _ndaugs =6;
01204     daugs[0]=EvtPDL::getId(std::string("pi+"));
01205     daugs[1]=EvtPDL::getId(std::string("pi-"));
01206     daugs[2]=EvtPDL::getId(std::string("pi+"));
01207     daugs[3]=EvtPDL::getId(std::string("pi-"));
01208     daugs[4]=EvtPDL::getId(std::string("pi0"));
01209     daugs[5]=EvtPDL::getId(std::string("pi0"));
01210   }else if(mode == 23){
01211     _ndaugs =2;
01212     daugs[0]=EvtPDL::getId(std::string("eta"));
01213     daugs[1]=EvtPDL::getId(std::string("phi"));
01214   }else if(mode == 24){
01215     _ndaugs =2;
01216     daugs[0]=EvtPDL::getId(std::string("phi"));
01217     daugs[1]=EvtPDL::getId(std::string("pi0"));
01218   }else if(mode == 25){
01219     _ndaugs =2;
01220     daugs[0]=EvtPDL::getId(std::string("K+"));
01221     daugs[1]=EvtPDL::getId(std::string("K*-"));
01222   }else if(mode == 26){
01223     _ndaugs =2;
01224     daugs[0]=EvtPDL::getId(std::string("K-"));
01225     daugs[1]=EvtPDL::getId(std::string("K*+"));
01226   }else if(mode == 27){
01227     _ndaugs =2;
01228     daugs[0]=EvtPDL::getId(std::string("K_S0"));
01229     daugs[1]=EvtPDL::getId(std::string("anti-K*0"));
01230   }else if(mode == 28){
01231     _ndaugs =3;
01232     daugs[0]=EvtPDL::getId(std::string("K*0"));
01233     daugs[1]=EvtPDL::getId(std::string("K+"));
01234     daugs[2]=EvtPDL::getId(std::string("pi-"));
01235   }else if(mode == 29){
01236     _ndaugs =3;
01237     daugs[0]=EvtPDL::getId(std::string("K*0"));
01238     daugs[1]=EvtPDL::getId(std::string("K-"));
01239     daugs[2]=EvtPDL::getId(std::string("pi+"));
01240   }else if(mode == 30){
01241     _ndaugs =3;
01242     daugs[0]=EvtPDL::getId(std::string("K*+"));
01243     daugs[1]=EvtPDL::getId(std::string("K-"));
01244     daugs[2]=EvtPDL::getId(std::string("pi0"));
01245   }else if(mode == 31){
01246     _ndaugs =3;
01247     daugs[0]=EvtPDL::getId(std::string("K*-"));
01248     daugs[1]=EvtPDL::getId(std::string("K+"));
01249     daugs[2]=EvtPDL::getId(std::string("pi0"));
01250   }else if(mode == 32){
01251     _ndaugs =3;
01252     daugs[0]=EvtPDL::getId(std::string("K_2*0"));
01253     daugs[1]=EvtPDL::getId(std::string("K+"));
01254     daugs[2]=EvtPDL::getId(std::string("pi-"));
01255   }else if(mode == 33){
01256     _ndaugs =3;
01257     daugs[0]=EvtPDL::getId(std::string("K_2*0"));
01258     daugs[1]=EvtPDL::getId(std::string("K-"));
01259     daugs[2]=EvtPDL::getId(std::string("pi+"));
01260   }else if(mode == 34){
01261     _ndaugs =3;
01262     daugs[0]=EvtPDL::getId(std::string("K+"));
01263     daugs[1]=EvtPDL::getId(std::string("K-"));
01264     daugs[2]=EvtPDL::getId(std::string("rho0"));
01265   }else if(mode == 35){
01266     _ndaugs =3;
01267     daugs[0]=EvtPDL::getId(std::string("phi"));
01268     daugs[1]=EvtPDL::getId(std::string("pi-"));
01269     daugs[2]=EvtPDL::getId(std::string("pi+"));
01270   }else if(mode == 36){
01271     _ndaugs =2;
01272     daugs[0]=EvtPDL::getId(std::string("phi"));
01273     daugs[1]=EvtPDL::getId(std::string("f_0"));
01274   }else if(mode == 37){
01275     _ndaugs =3;
01276     daugs[0]=EvtPDL::getId(std::string("eta"));
01277     daugs[1]=EvtPDL::getId(std::string("pi+"));
01278     daugs[2]=EvtPDL::getId(std::string("pi-"));
01279   }else if(mode == 38){
01280     _ndaugs =3;
01281     daugs[0]=EvtPDL::getId(std::string("omega"));
01282     daugs[1]=EvtPDL::getId(std::string("pi+"));
01283     daugs[2]=EvtPDL::getId(std::string("pi-"));
01284   }else if(mode == 39){
01285     _ndaugs =2;
01286     daugs[0]=EvtPDL::getId(std::string("omega"));
01287     daugs[1]=EvtPDL::getId(std::string("f_0"));
01288   }else if(mode == 40){
01289     _ndaugs =3;
01290     daugs[0]=EvtPDL::getId(std::string("eta'"));
01291     daugs[1]=EvtPDL::getId(std::string("pi+"));
01292     daugs[2]=EvtPDL::getId(std::string("pi-"));
01293   }else if(mode == 41){
01294     _ndaugs =3;
01295     daugs[0]=EvtPDL::getId(std::string("f_1"));
01296     daugs[1]=EvtPDL::getId(std::string("pi+"));
01297     daugs[2]=EvtPDL::getId(std::string("pi-"));
01298   }else if(mode == 42){
01299     _ndaugs =3;
01300     daugs[0]=EvtPDL::getId(std::string("omega"));
01301     daugs[1]=EvtPDL::getId(std::string("K+"));
01302     daugs[2]=EvtPDL::getId(std::string("K-"));
01303   }else if(mode == 43){
01304     _ndaugs =4;
01305     daugs[0]=EvtPDL::getId(std::string("omega"));
01306     daugs[1]=EvtPDL::getId(std::string("pi+"));
01307     daugs[2]=EvtPDL::getId(std::string("pi-"));
01308     daugs[3]=EvtPDL::getId(std::string("pi0"));
01309   }else if(mode == 44){
01310     _ndaugs =2;
01311     daugs[0]=EvtPDL::getId(std::string("Sigma-"));
01312     daugs[1]=EvtPDL::getId(std::string("anti-Sigma+"));
01313   }else if(mode == 45){
01314     _ndaugs =2;
01315     daugs[0]=EvtPDL::getId(std::string("K+"));
01316     daugs[1]=EvtPDL::getId(std::string("K-"));
01317   }else if(mode == 46){
01318     _ndaugs =2;
01319     daugs[0]=EvtPDL::getId(std::string("K_S0"));
01320     daugs[1]=EvtPDL::getId(std::string("K_L0"));
01321   }else if(mode == 47){
01322     _ndaugs =2;
01323     daugs[0]=EvtPDL::getId(std::string("omega"));
01324     daugs[1]=EvtPDL::getId(std::string("eta"));
01325   }else if(mode == 48){
01326     _ndaugs =2;
01327     daugs[0]=EvtPDL::getId(std::string("phi"));
01328     daugs[1]=EvtPDL::getId(std::string("eta'"));
01329   }else if(mode == 49){
01330     _ndaugs =3;
01331     daugs[0]=EvtPDL::getId(std::string("phi"));
01332     daugs[1]=EvtPDL::getId(std::string("K+"));
01333     daugs[2]=EvtPDL::getId(std::string("K-"));
01334   }else if(mode == 50){
01335     _ndaugs =3;
01336     daugs[0]=EvtPDL::getId(std::string("p+"));
01337     daugs[1]=EvtPDL::getId(std::string("anti-p-"));
01338     daugs[2]=EvtPDL::getId(std::string("pi0"));
01339   }else if(mode == 51){
01340     _ndaugs =3;
01341     daugs[0]=EvtPDL::getId(std::string("p+"));
01342     daugs[1]=EvtPDL::getId(std::string("anti-p-"));
01343     daugs[2]=EvtPDL::getId(std::string("eta"));
01344   }else if(mode == 65){
01345     _ndaugs =3;
01346     daugs[0]=EvtPDL::getId(std::string("D-"));
01347     daugs[1]=EvtPDL::getId(std::string("D*0"));
01348     daugs[2]=EvtPDL::getId(std::string("pi+"));
01349   }else if(mode == 66){
01350     _ndaugs =3;
01351     daugs[0]=EvtPDL::getId(std::string("D+"));
01352     daugs[1]=EvtPDL::getId(std::string("anti-D*0"));
01353     daugs[2]=EvtPDL::getId(std::string("pi-"));
01354   }else if(mode == 67){
01355     _ndaugs =2;
01356     daugs[0]=EvtPDL::getId(std::string("D*0"));
01357     daugs[1]=EvtPDL::getId(std::string("anti-D*0"));
01358   }else if(mode == 68){
01359     _ndaugs =2;
01360     daugs[0]=EvtPDL::getId(std::string("D0"));
01361     daugs[1]=EvtPDL::getId(std::string("anti-D*0"));
01362 
01363   }else if(mode == 69){
01364     _ndaugs =2;
01365     daugs[0]=EvtPDL::getId(std::string("anti-D0"));
01366     daugs[1]=EvtPDL::getId(std::string("D*0"));
01367 
01368   }else if(mode == 70){
01369     _ndaugs =2;
01370     daugs[0]=EvtPDL::getId(std::string("D0"));
01371     daugs[1]=EvtPDL::getId(std::string("anti-D0"));
01372 
01373 }else if(mode == 71){
01374     _ndaugs =2;
01375     daugs[0]=EvtPDL::getId(std::string("D+"));
01376     daugs[1]=EvtPDL::getId(std::string("D-"));
01377   }else if(mode == 72){
01378     _ndaugs =2;
01379     daugs[0]=EvtPDL::getId(std::string("D+"));
01380     daugs[1]=EvtPDL::getId(std::string("D*-"));
01381 
01382   }else if(mode == 73){
01383     _ndaugs =2;
01384     daugs[0]=EvtPDL::getId(std::string("D-"));
01385     daugs[1]=EvtPDL::getId(std::string("D*+"));
01386 
01387   }else if(mode == 74){
01388     _ndaugs =2;
01389     daugs[0]=EvtPDL::getId(std::string("D*+"));
01390     daugs[1]=EvtPDL::getId(std::string("D*-"));
01391 
01392   }else if(mode == 75){
01393     _ndaugs =3;
01394     daugs[0]=EvtPDL::getId(std::string("D0"));
01395     daugs[1]=EvtPDL::getId(std::string("D-"));
01396     daugs[2]=EvtPDL::getId(std::string("pi+"));
01397   }else if(mode == 76){
01398     _ndaugs =3;
01399     daugs[0]=EvtPDL::getId(std::string("anti-D0"));
01400     daugs[1]=EvtPDL::getId(std::string("D+"));
01401     daugs[2]=EvtPDL::getId(std::string("pi-"));
01402   }else if(mode == 77){
01403     _ndaugs =3;
01404     daugs[0]=EvtPDL::getId(std::string("D0"));
01405     daugs[1]=EvtPDL::getId(std::string("D*-"));
01406     daugs[2]=EvtPDL::getId(std::string("pi+"));
01407   }else if(mode == 78){
01408     _ndaugs =3;
01409     daugs[0]=EvtPDL::getId(std::string("anti-D0"));
01410     daugs[1]=EvtPDL::getId(std::string("D*+"));
01411     daugs[2]=EvtPDL::getId(std::string("pi-"));
01412   }else if(mode == 79){
01413     _ndaugs =3;
01414     daugs[0]=EvtPDL::getId(std::string("psi(2S)"));
01415     daugs[1]=EvtPDL::getId(std::string("pi0"));
01416     daugs[2]=EvtPDL::getId(std::string("pi0"));
01417   }else if(mode == 80){
01418     _ndaugs =2;
01419     daugs[0]=EvtPDL::getId(std::string("eta"));
01420     daugs[1]=EvtPDL::getId(std::string("J/psi"));
01421   }else if(mode == 81){
01422     _ndaugs =3;
01423     daugs[0]=EvtPDL::getId(std::string("h_c"));
01424     daugs[1]=EvtPDL::getId(std::string("pi+"));
01425     daugs[2]=EvtPDL::getId(std::string("pi-"));
01426   }else if(mode == 82){
01427     _ndaugs =3;
01428     daugs[0]=EvtPDL::getId(std::string("h_c"));
01429     daugs[1]=EvtPDL::getId(std::string("pi0"));
01430     daugs[2]=EvtPDL::getId(std::string("pi0"));
01431   }else if(mode == 83){
01432     _ndaugs =3;
01433     daugs[0]=EvtPDL::getId(std::string("J/psi"));
01434     daugs[1]=EvtPDL::getId(std::string("K+"));
01435     daugs[2]=EvtPDL::getId(std::string("K-"));
01436   }else if(mode == 84){
01437     _ndaugs =3;
01438     daugs[0]=EvtPDL::getId(std::string("J/psi"));
01439     daugs[1]=EvtPDL::getId(std::string("K_S0"));
01440     daugs[2]=EvtPDL::getId(std::string("K_S0"));
01441   }else if(mode == 90){
01442     _ndaugs =3;
01443     daugs[0]=EvtPDL::getId(std::string("J/psi"));
01444     daugs[1]=EvtPDL::getId(std::string("pi+"));
01445     daugs[2]=EvtPDL::getId(std::string("pi-"));
01446   }else if(mode == 91){
01447     _ndaugs =3;
01448     daugs[0]=EvtPDL::getId(std::string("psi(2S)"));
01449     daugs[1]=EvtPDL::getId(std::string("pi+"));
01450     daugs[2]=EvtPDL::getId(std::string("pi-"));
01451   }else if(mode == 92){
01452     _ndaugs =3;
01453     daugs[0]=EvtPDL::getId(std::string("J/psi"));
01454     daugs[1]=EvtPDL::getId(std::string("K+"));
01455     daugs[2]=EvtPDL::getId(std::string("K-"));
01456   }else if(mode == 93){
01457     _ndaugs =2;
01458     daugs[0]=EvtPDL::getId(std::string("D_s+"));
01459     daugs[1]=EvtPDL::getId(std::string("D_s-"));
01460   }else if(mode == 94){
01461     _ndaugs =2;
01462     daugs[0]=EvtPDL::getId(std::string("D_s*+"));
01463     daugs[1]=EvtPDL::getId(std::string("D_s-"));
01464   }else if(mode == 95){
01465     _ndaugs =2;
01466     daugs[0]=EvtPDL::getId(std::string("D_s*-"));
01467     daugs[1]=EvtPDL::getId(std::string("D_s+"));
01468   }else if(mode == 96){
01469     _ndaugs =2;
01470     daugs[0]=EvtPDL::getId(std::string("Lambda_c+"));
01471     daugs[1]=EvtPDL::getId(std::string("anti-Lambda_c-"));
01472   }else if(mode == 74100){
01473     _ndaugs =2;
01474     daugs[0]=EvtPDL::getId(std::string("J/psi"));   
01475     daugs[1]=EvtPDL::getId(std::string("gamma"));  
01476   }else if(mode == 74101){
01477     _ndaugs =2;
01478     daugs[0]=EvtPDL::getId(std::string("psi(2S)"));
01479     daugs[1]=EvtPDL::getId(std::string("gamma"));
01480   }else if(mode == 74102){
01481     _ndaugs =2;
01482     daugs[0]=EvtPDL::getId(std::string("psi(3770)"));
01483     daugs[1]=EvtPDL::getId(std::string("gamma"));  
01484   }else if(mode == 74103){
01485     _ndaugs =2;
01486     daugs[0]=EvtPDL::getId(std::string("phi"));
01487     daugs[1]=EvtPDL::getId(std::string("gamma"));
01488   }else if(mode == 74104){
01489     _ndaugs =2;
01490     daugs[0]=EvtPDL::getId(std::string("omega"));
01491     daugs[1]=EvtPDL::getId(std::string("gamma"));
01492   }else if(mode == 74105){
01493     _ndaugs =2;
01494     daugs[0]=EvtPDL::getId(std::string("rho0"));
01495     daugs[1]=EvtPDL::getId(std::string("gamma"));
01496   }else if(mode == 74106){
01497     _ndaugs =2;
01498     daugs[0]=EvtPDL::getId(std::string("rho(3S)0"));
01499     daugs[1]=EvtPDL::getId(std::string("gamma")); 
01500   }else if(mode == 74107){
01501     _ndaugs =2;
01502     daugs[0]=EvtPDL::getId(std::string("omega(2S)"));
01503     daugs[1]=EvtPDL::getId(std::string("gamma"));          
01504   }else if(mode == 74110){
01505     _ndaugs =2;
01506     daugs[0]=EvtPDL::getId(std::string("gamma*")); 
01507     daugs[1]=EvtPDL::getId(std::string("gamma"));
01508     EvtId  myvpho = EvtPDL::getId(std::string("gamma*"));
01509     EvtPDL::reSetMass(myvpho,mhds*0.9); //for calculating maxXS, it will be resent when this mode is selected   
01510     _modeFlag.clear();
01511     _modeFlag.push_back(74110); //R-value generator tag
01512     _modeFlag.push_back(0);     //to contain the mode selected
01513   }else if(mode == -1){
01514     _ndaugs = nson;
01515     for(int i=0;i<nson;i++){ daugs[i]=son[i];  }
01516     std::cout<<"The paraent particle: "<<EvtPDL::name(pid)<<std::endl;
01517   }else if(mode == -2){
01518     _ndaugs = nson;
01519     for(int i=0;i<nson;i++){  daugs[i]=son[i];  }
01520   }else if(mode == 10000){//use for check ISR
01521     _ndaugs =2;
01522     daugs[0]=EvtPDL::getId(std::string("pi+"));
01523     daugs[1]=EvtPDL::getId(std::string("pi-"));
01524   }else {
01525     std::cout<<"Bad mode_index number " <<mode<<", please refer to the manual."<<std::endl;
01526     ::abort();
01527   }
01528   // std::cout<<_ndaugs<<", "<<daugs[0]<<daugs[1]<<std::endl;
01529 
01530   if(VISR){
01531     _ndaugs=2;
01532     daugs[0]=getDaugs()[0];//EvtPDL::getId(std::string("gamma"));
01533     daugs[1]=getDaugs()[1];//EvtPDL::getId(std::string("gamma*"));
01534   }
01535 
01536  std::vector<EvtId> theDaugs; 
01537  for(int i=0;i<_ndaugs;i++){
01538     theDaugs.push_back(daugs[i]);
01539   }
01540  if(theDaugs.size()) {return theDaugs;} else {std::cout<<"EvtConExc::get_mode: zero size"<<std::endl;abort();}
01541 }
01542 
01543  
01544 void EvtConExc::initProbMax(){
01545 
01546   noProbMax();
01547 
01548 }
01549 
01550 void EvtConExc::decay( EvtParticle *p ){
01551   //std::cout<<"_cms= "<<_cms<<" mode= "<<_mode<<std::endl;
01552   EvtId  myvpho = EvtPDL::getId(std::string("vpho"));
01553   if(myvpho != p->getId()){
01554     std::cout<<"Parent needs to be vpho, but found "<<EvtPDL::name(p->getId())<<std::endl;
01555     abort();
01556   }
01557   //for fill root tree
01558   EvtVector4R vgam,hd1,hd2,vhds;
01559 
01560   //first for Rscan generator with _mode=74110
01561   if(_mode==74110){
01562     //preparation of mode sampling
01563     std::vector<int> vmod; vmod.clear();
01564     int mn[78]={0,1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,45,46, // 12 and 43 is removed
01565                 50,51,
01566                 68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,
01567                 90,91,92,93,94,95,96,
01568                 74100,74101,74102,74103,74104,74105,74110};
01569     int mn2[79]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,45,46,//mode 43 are removed
01570                  50,51,
01571                  68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,
01572                  90,91,92,93,94,95,96,
01573                  74100,74101,74102,74103,74104,74105,74110};
01574     int mn3[76]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,45,46,
01575                  50,51,
01576                  68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,
01577                  90,91,92,93,94,95,96,
01578                  74100,74101,74102,74110}; //remove 43, 74103,74104,74105, this is included in PHOKHARA
01579     double mx = p->getP4().mass();
01580   
01581     if(_cms>2.5){
01582       for(int i=0;i<78;i++){vmod.push_back(mn[i]);}
01583     }else{
01584       for(int i=0;i<79;i++){vmod.push_back(mn2[i]);}  
01585     }
01586     
01587     //for(int i=0;i<76;i++){vmod.push_back(mn3[i]);}
01588 
01589     int mymode;
01590     double pm= EvtRandom::Flat(0.,1);
01591 
01592     //std::cout<<"AF[598], AF[598] "<<AF[598]<<" "<<AF[599]<<std::endl;
01593     //--
01594     //-- where AF[599]: cross section with full region (0-Egamma^max GeV), AF[598]: cross section within Egam=(0.025-Egamma^max GeV)
01595     if(pm <_xs0/(_xs0 + _xs1) ){//without ISR photon for mode=74110
01596 
01597       mhds=_cms;
01598       mymode=selectMode(vmod,mhds);
01599       _selectedMode = mymode;
01600       std::cout<<"A selected mode is "<<mymode<<" with Mhds= "<<mhds<<std::endl; //debugging
01601       delete myxsection;                        
01602       myxsection =new EvtXsection (mymode);     
01603       init_mode(mymode);                        
01604       resetResMass();                           
01605                                                 
01606       if(_ndaugs>1){//for e+e- -> exclusive decays
01607       checkA:
01608         p->makeDaughters(_ndaugs,daugs); 
01609         double totMass=0;
01610         for(int i=0;i< _ndaugs;i++){            
01611           EvtParticle* di=p->getDaug(i);
01612           double xmi=EvtPDL::getMass(di->getId()); 
01613           di->setMass(xmi);
01614           totMass+=xmi;
01615         } 
01616         if(totMass>p->mass()) goto checkA;
01617         p->initializePhaseSpace( _ndaugs , daugs);   
01618         if(!checkdecay(p)) goto checkA;
01619         vhds = p->getP4();
01620         if(_cms>2.5 && !angularSampling(p)) goto checkA;
01621         if(_cms<2.5 && !photonSampling(p)) goto checkA;
01622       }else{// for e+e- -> vector resonace, add a very soft photon
01623         EvtId mydaugs[2];
01624         mydaugs[0]=daugs[0];
01625         EvtPDL::reSetMass(mydaugs[0],mhds-0.001);
01626         //EvtPDL::reSetWidth(mydaugs[0],0);
01627         mydaugs[1]=gamId;    //ISR photon
01628         p->makeDaughters(2,mydaugs); 
01629       checkB:
01630         double totMass=0;
01631         for(int i=0;i< 2;i++){
01632           EvtParticle* di=p->getDaug(i);
01633           double xmi=EvtPDL::getMass(di->getId());
01634           di->setMass(xmi);
01635           totMass+=xmi;
01636         }
01637         //std::cout<<"checkB "<<totMass<<" p->mass() "<<p->mass()<<" "<<checkdecay(p)<<std::endl;
01638         if(totMass>p->mass()) goto checkB;
01639         p->initializePhaseSpace(2,mydaugs);
01640 
01641         if(!checkdecay(p)) goto checkB; 
01642         vhds = p->getDaug(0)->getP4();;
01643         vgam = p->getDaug(1)->getP4();
01644       }
01645  //-----
01646     }else{// with ISR photon for mode=74110
01647 Sampling_mhds:
01648       mhds=Mhad_sampling(MH,AF);
01649       //std::cout<<"SetMthr= "<<SetMthr<<std::endl;
01650       if(mhds<SetMthr) goto Sampling_mhds;
01651       double xeng=1-mhds*mhds/(_cms*_cms); //photon energy ratio
01652       double theta=ISR_ang_sampling(xeng); //ISR photon polar angle in rad unit
01653       
01654       if(mydbg) mass2=mhds;
01655       
01656       //generating events
01657     ModeSelection:
01658       EvtGlobalSet::ConExcPythia=1;
01659       mymode=selectMode(vmod,mhds);
01660       if(mymode==-10) goto Sampling_mhds;
01661       conexcmode = mymode; //save for model REXC ( see EvtRexc.cc) decay 
01662       if(mhds<2.3 && mymode==74110) {goto ModeSelection;}  // E<2.3 GeV, fully exclusive production 
01663       std::cout<<"A selected mode is "<<mymode<<" with Mhds= "<<mhds<<std::endl; //debugging
01664       _selectedMode = mymode;
01665       delete myxsection;
01666       myxsection =new EvtXsection (mymode);
01667       init_mode(mymode);
01668       EvtId  myvpho = EvtPDL::getId(std::string("vgam"));
01669       EvtPDL::reSetMass(myvpho,mhds); //set to continum cms energy
01670       EvtPDL::reSetWidth(myvpho,0);
01671       
01672       //debugging
01673       //for(int i=0;i<_ndaugs+1;i++){std::cout<<_ndaugs<<" "<<EvtPDL::name(daugs[i])<<std::endl;}
01674       
01675       //decay e+e- ->gamma_ISR gamma*
01676       EvtId mydaugs[2];
01677       if(_ndaugs>1) { //gamma* -> exclusive decays 
01678         resetResMass(); 
01679         mydaugs[0]=myvpho;
01680       }else{// vector resonance decays
01681         resetResMass(); 
01682         mydaugs[0]=daugs[0];
01683         EvtPDL::reSetMass(mydaugs[0],mhds);
01684         //EvtPDL::reSetWidth(mydaugs[0],0);
01685       }
01686       mydaugs[1]=gamId;    //ISR photon
01687       int maxflag=0;
01688       int trycount=0;
01689     ISRphotonAng_sampling:
01690       double totMass=0;
01691       p->makeDaughters(2,mydaugs); 
01692       for(int i=0;i< 2;i++){
01693         EvtParticle* di=p->getDaug(i);
01694         double xmi=EvtPDL::getMass(di->getId());
01695         di->setMass(xmi);
01696         totMass+=xmi;
01697       }
01698       if(totMass>p->mass()) goto ISRphotonAng_sampling;
01699       //std::cout<<"Ndaugs= "<<_ndaugs<<" Mhds= "<<mhds<<std::endl;
01700       double weight1 = p->initializePhaseSpace(2,mydaugs);
01701       if(!checkdecay(p)) goto ISRphotonAng_sampling;
01702       //set the ISR photon angular distribution
01703       SetP4Rvalue(p,mhds,xeng,theta);  //end of decay e+e- -> vpho gamma_ISR
01704 
01705       if(maxflag==0) {findMaxXS(mhds); maxflag=1;}
01706       vhds = p->getDaug(0)->getP4();
01707       vgam=p->getDaug(1)->getP4();
01708       double gx=vgam.get(1);
01709       double gy=vgam.get(2);
01710       double sintheta= sqrt(gx*gx+gy*gy)/vgam.d3mag();
01711       bool gam_ang=gam_sampling(mhds,sintheta);
01712       trycount++;
01713 
01714     } // with and without ISR sampling block       
01715     // finish event generation
01716     // for debugging
01717     if(mydbg){
01718       pgam[0]=vgam.get(0);
01719       pgam[1]=vgam.get(1);
01720       pgam[2]=vgam.get(2);
01721       pgam[3]=vgam.get(3);   
01722        
01723       phds[0]=vhds.get(0);
01724       phds[1]=vhds.get(1);    
01725       phds[2]=vhds.get(2);
01726       phds[3]=vhds.get(3);
01727       costheta = vgam.get(3)/vgam.d3mag();
01728       selectmode = mymode;
01729       xs->Fill();
01730       //std::cout<<"mass1= "<<mass1<<" mass2= "<<mass2<<std::endl;
01731     }
01732     _modeFlag[1]= _selectedMode;
01733     p->setIntFlag(_modeFlag);
01734     return;
01735   }//end block  if(_mode==74110)
01736 
01737   //=======================================================
01738   // e+e- -> gamma_ISR gamma*
01739   //=======================================================
01740   if(VISR){
01741      EvtId gid=EvtPDL::getId("gamma*"); 
01742      double pm= EvtRandom::Flat(0.,1);
01743 
01744      if(pm <_xs0/(_xs0 + _xs1) ){//with a very soft ISR photon
01745        EvtPDL::reSetMass(gid,(_cms-0.0001) );
01746        mhds = _cms-0.0001;
01747      }else{
01748        mhds=Mhad_sampling(MH,AF);
01749        EvtPDL::reSetMass(gid,mhds);
01750      }
01751      //debugging
01752      std::cout<<"generatedMass "<<EvtPDL::getMeanMass(gid)<<std::endl;
01753      double xeng=1-mhds*mhds/(_cms*_cms); //photon energy ratio
01754      double theta=ISR_ang_sampling(xeng); //ISR photon polar angle in rad unit
01755      p->makeDaughters(2,daugs);
01756      for(int i=0;i< 2;i++){
01757        EvtParticle* di=p->getDaug(i);
01758        double xmi=EvtPDL::getMeanMass(di->getId());
01759        di->setMass(xmi);
01760      }
01761      p->initializePhaseSpace(2,daugs);
01762      SetP4(p,mhds,xeng,theta);
01763     return;
01764   }
01765 
01766 
01767   //========================================================
01768   //=== for other mode generation with _mode != 74110
01769   //========================================================
01770 
01771   if((_xs0 + _xs1)==0) {std::cout<<"EvtConExc::zero total xsection"<<std::endl;::abort();}
01772   double pm= EvtRandom::Flat(0.,1);
01773   double xsratio = _xs0/(_xs0 + _xs1);
01774   int iflag=2; //flag = 0 for ee->hadrons, 1 for ee->gamma_ISR hadrons, 2: mix 0 and 1 case
01775   if(getArg(0)!= -2){// exclude DIY case
01776     if(getNArg()==3 && radflag==1){iflag=1;xsratio=0;} // only generating gamma hadrons mode
01777     else if(getNArg()==3 && radflag==0) {iflag=0;xsratio=1;}
01778   }
01779  
01780   // std::cout<<"xsratio= "<<xsratio<<std::endl;
01781  
01782   if(pm<xsratio ){// no ISR photon
01783   masscheck:
01784     double summassx=0;
01785     p->makeDaughters(_ndaugs,daugs);
01786     for(int i=0;i< _ndaugs;i++){
01787       EvtParticle* di=p->getDaug(i);
01788       double xmi=EvtPDL::getMass(di->getId());
01789       di->setMass(xmi);
01790       summassx += xmi;
01791       //std::cout<<"PID and mass "<<di->getId()<<" "<<xmi<<std::endl;
01792     }    
01793     if(summassx>p->mass()) goto masscheck;
01794   angular_hadron:
01795     p->initializePhaseSpace(_ndaugs,daugs);
01796     bool byn_ang;
01797     EvtVector4R pd1 = p->getDaug(0)->getP4();  
01798     EvtVector4R pcm(_cms,0,0,0);
01799     if(_ndaugs==2){//angular distribution for the hadrons only for two-body decays
01800       byn_ang=hadron_angle_sampling(pd1, pcm);
01801       if(!byn_ang) goto angular_hadron;
01802     }
01803     
01804     //for histogram
01805     cosp = pd1.get(3)/pd1.d3mag();
01806     mhds = _cms;
01807     //std::cout<<"cosp, mhds "<<cosp<<" "<<mhds<<std::endl;
01808     //p->printTree();
01809 
01810   }else{// sampling m_hadrons and decay e+e- ->gamma gamma*
01811     double mhdr=Mhad_sampling(MH,AF);
01812     double xeng=1-mhdr*mhdr/(_cms*_cms); //photon energy ratio
01813     double theta=ISR_ang_sampling(xeng); //ISR photon polar angle in rad unit
01814     EvtId gid =EvtPDL::getId("vhdr");
01815     EvtPDL::reSetMass(gid,mhdr);
01816     int ndaugs =2;
01817     EvtId mydaugs[2];
01818     mydaugs[0] =EvtPDL::getId(std::string("gamma"));
01819     mydaugs[1]=EvtPDL::getId(std::string("vhdr"));
01820 
01821     //for histogram
01822     mhds = mhdr;
01823     costheta = cos(theta);
01824     //-- 
01825 
01826     p->makeDaughters(2,mydaugs);
01827     for(int i=0;i< 2;i++){
01828       EvtParticle* di=p->getDaug(i);
01829       double xmi=EvtPDL::getMass(di->getId());
01830       di->setMass(xmi);
01831     }
01832     p->initializePhaseSpace(2,mydaugs);
01833     SetP4(p,mhdr,xeng,theta);  //end of decay e+e- -> gamma_ISR gamma*
01834     //p->printTree();
01835 
01836  //----
01837   }//end of gamma gamma*, gamma*->hadrons generation
01838   // p->printTree();
01839 
01840   //-----------------------------------------
01841   // End of decays for all topology
01842   //----------------------------------------
01843   //================================= event analysis 
01844     if(_nevt ==0 ){
01845       std::cout<<"The decay chain: "<<std::endl;
01846       p->printTree();
01847     }
01848     _nevt++;
01849     //--- for debuggint to make root file
01850   if(mydbg){
01851     xs->Fill();
01852   }
01853   
01854   //----
01855   return ;
01856 }
01857 
01858 bool EvtConExc::hadron_angle_sampling(EvtVector4R ppi, EvtVector4R pcm){
01859   EvtVector4R pbst=-1*pcm;
01860   pbst.set(0,pcm.get(0));
01861   EvtVector4R p4i = boostTo(ppi,pbst);
01862   if(_mode<=5 || _mode ==44|| _mode ==47|| _mode ==48 ||_mode ==72 ||_mode == 73||_mode==94||_mode==95 ||_mode ==96 || _mode>=23 &&_mode<=27 || _mode==36|| _mode ==39 || _mode == 80 ){//ee->two baryon mode, VP, SP
01863     bool byn_ang = baryon_sampling(pcm, p4i);
01864     return byn_ang;
01865   }else if(_mode ==6||_mode==45 || _mode==46 || _mode==70 || _mode==71|| _mode==93){// ee->PP (pi+pi-,..) mode
01866     bool msn_ang = meson_sampling(pcm,p4i);
01867     return msn_ang;
01868   }else if(_mode==23 || _mode==24 || _mode==25 || _mode==26 || _mode==27 || _mode==36||_mode==47||_mode==48||_mode==68||_mode==69||_mode==72||_mode==73||_mode==80||_mode==94||_mode==95){
01869     bool msn_ang = VP_sampling(pcm,p4i);
01870     return msn_ang;
01871   }
01872   return true;
01873 }
01874 
01875 
01876 double EvtConExc::gamHXSection(EvtParticle *p,double El,double Eh,int nmc){//El, Eh : the lower and higher energy of radiative photons
01877   //std::cout<<"nmc= "<<nmc<<std::endl;
01878   gamId = EvtPDL::getId(std::string("gamma"));
01879   EvtId xvp = EvtPDL::getId(std::string("xvpho"));
01880   EvtVector4R p_init( p->getP4().mass(),0.,0.,0.);
01881   double totxs = 0;
01882   maxXS=-1;
01883   _er1=0;
01884   Rad2Xs =0;
01885   for(int ii=0;ii<nmc;ii++){// integarted the gamma hadrons xsection
01886   gamH=EvtParticleFactory::particleFactory(xvp, p_init);
01887   int gamdaugs = _ndaugs+1;
01888 
01889   EvtId theDaugs[10];
01890   for(int i=0;i<_ndaugs;i++){
01891     theDaugs[i] = daugs[i];
01892   }
01893   theDaugs[_ndaugs]=gamId;
01894 
01895   gamH->makeDaughters(gamdaugs,theDaugs); 
01896 
01897   for(int i=0;i<gamdaugs;i++){
01898     EvtParticle* di=gamH->getDaug(i);
01899     double xmi=EvtPDL::getMass(di->getId());
01900     di->setMass(xmi);
01901    }
01902   loop:
01903   double weight = gamH->initializePhaseSpace(  gamdaugs , theDaugs);
01904   //-- slection:theta_gamma > 1 degree
01905   EvtVector4R pgam = gamH -> getDaug(_ndaugs)->getP4();
01906   double pmag = pgam.d3mag();
01907   double pz = pgam.get(3);
01908   double sintheta = sqrt( pmag*pmag - pz*pz)/pmag;
01909   double onedegree = 1./180.*3.1415926;
01910   //if(sintheta < onedegree) {goto loop;}
01911   if(pmag <El || pmag >Eh) {goto loop;}
01912   //--------
01913   // std::cout<<"pmag= "<<pmag<<std::endl;
01914   
01915   double thexs = difgamXs(gamH); //prepare the photon angular distribution
01916   Rad2Xs += Rad2difXs( gamH );
01917   if(thexs>maxXS) {maxXS=thexs;}
01918   double s = p_init.mass2();
01919   double x = 2*pgam.get(0)/sqrt(s);
01920   double rad1xs = Rad1difXs(gamH); //first order xs by Eq(4)hep-ph/9910523
01921   totxs += rad1xs;
01922   _er1 += differ;
01923   gamH->deleteDaughters();
01924   }  //for int_i block
01925   _er1/=nmc;
01926 
01927   Rad2Xs/=nmc; // the leading second order correction 
01928   totxs/=nmc;  // first order correction XS
01929 
01930   // return totxs;  // first order correction XS
01931    return Rad2Xs;  // the leading second order correction 
01932 }
01933 
01934 
01935 double EvtConExc::gamHXSection(double s, double El,double Eh,int nmc){//El, Eh : the lower and higher energy of radiative photons
01936   //--for narrow resonance psi(2S),J/psi, phi, which can not calculated with the MC integration
01937   //double mxL = sqrt( s-2*Eh*sqrt(s) ); //low mass
01938   //double mxH = sqrt( s-2*El*sqrt(s) ); //high mass
01939   //double sigv = narrowRXS(mxL,mxH);
01940   //--
01941 
01942   double totxs = 0; 
01943   maxXS=-1;
01944   _er1=0;
01945   Rad2Xs =0;
01946   double xL=2*El/sqrt(s);
01947   double xH=2*Eh/sqrt(s);
01948   for(int i=0;i<nmc;i++){//It is found that the narrow resonance can not included in this MC integartion
01949     double rdm = EvtRandom::Flat(0.,1.);// set angular cut 1^o
01950     double x= xL+ (xH-xL)*rdm;
01951     Rad2Xs += Rad2difXs(s,x);
01952     _er1 += differ2; //stored when calculate Rad2Xs
01953     //  std::cout<<"i= "<<i<<" Rad2Xs= "<<Rad2Xs<<std::endl;
01954   }
01955   _er1/=nmc;
01956   _er1*=(xH-xL);
01957   //std::cout<<"_er1= "<<_er1<<std::endl;
01958   Rad2Xs/=nmc; // the leading second order correction 
01959   double thexs= Rad2Xs*(xH-xL);  //xH-xL is the Jacobi factor 
01960   //std::cout<<"thexs= "<<thexs<<std::endl;
01961   //if(sigv != -1) thexs += sigv; //add narrow resonance ISR cross section
01962   return thexs;
01963 }
01964  
01965 
01966 
01967 double EvtConExc::gamHXSection(double El,double Eh){// using Gaussian integration subroutine from Cern lib
01968   std::cout<<" "<<std::endl;
01969   extern double Rad2difXs(double *x);
01970   extern double Rad2difXs2(double *x);
01971   double eps = 0.01;
01972   double Rad2Xs;
01973   if(_mode!=-2) {Rad2Xs= dgauss_(&Rad2difXs,&El,&Eh,&eps);}else{Rad2Xs = dgauss_(&Rad2difXs2,&El,&Eh,&eps);}
01974   if(Rad2Xs==0){
01975     for(int iter=0;iter<10;iter++){
01976       eps += 0.01;
01977       if(_mode!=-2) {Rad2Xs= dgauss_(&Rad2difXs,&El,&Eh,&eps);}else{Rad2Xs = dgauss_(&Rad2difXs2,&El,&Eh,&eps);}
01978       if(!Rad2Xs)  return Rad2Xs;
01979     }
01980   }
01981   return Rad2Xs;  // the leading second order correction 
01982 }
01983 
01984 
01985 double EvtConExc::gamHXSection(double El,double Eh, int mode){// using Gaussian integration subroutine from Cern lib
01986   std::cout<<" "<<std::endl;
01987   extern double Rad2difXs(double *x);
01988   extern double Rad2difXs2(double *x);
01989   double eps = 0.01;
01990   double Rad2Xs;
01991   if(mode!=-2) {Rad2Xs= dgauss_(&Rad2difXs,&El,&Eh,&eps);}else{Rad2Xs = dgauss_(&Rad2difXs2,&El,&Eh,&eps);}
01992   if(Rad2Xs==0){
01993     for(int iter=0;iter<10;iter++){
01994       eps += 0.01;
01995       if(mode!=-2) {Rad2Xs= dgauss_(&Rad2difXs,&El,&Eh,&eps);}else{Rad2Xs = dgauss_(&Rad2difXs2,&El,&Eh,&eps);}
01996       if(!Rad2Xs)  return Rad2Xs;
01997     }
01998   }
01999   return Rad2Xs;  // the leading second order correction 
02000 }
02001 
02002 
02003 double EvtConExc::gamHXSection_er(double El,double Eh){// using Gaussian integration subroutine from Cern lib
02004   std::cout<<"  "<<std::endl;
02005   extern double Rad2difXs_er(double *x);
02006   extern double Rad2difXs_er2(double *x);
02007   double eps = 0.01;
02008   double Rad2Xs;
02009   if(_mode !=-2){Rad2Xs = dgauss_(&Rad2difXs_er,&El,&Eh,&eps);}else{ Rad2Xs = dgauss_(&Rad2difXs_er2,&El,&Eh,&eps);}
02010   if(Rad2Xs==0){
02011     for(int iter=0;iter<10;iter++){
02012       eps += 0.01;
02013       if(_mode !=-2){Rad2Xs = dgauss_(&Rad2difXs_er,&El,&Eh,&eps);}else{ Rad2Xs = dgauss_(&Rad2difXs_er2,&El,&Eh,&eps);}
02014       if(!Rad2Xs) return Rad2Xs;;
02015     }
02016   }
02017   return Rad2Xs;  // the leading second order correction 
02018 }
02019 
02020 
02021 void  EvtConExc::findMaxXS(EvtParticle *p){
02022   //std::cout<<"nmc= "<<nmc<<std::endl;
02023   gamId = EvtPDL::getId(std::string("gamma"));
02024   EvtId xvp = EvtPDL::getId(std::string("xvpho"));
02025   EvtVector4R p_init( p->getP4().mass(),0.,0.,0.);
02026   double totxs = 0;
02027   maxXS=-1;
02028   _er1=0;
02029   Rad2Xs =0;
02030   int nmc =  50000;
02031   for(int ii=0;ii<nmc;ii++){// integarted the gamma hadrons xsection
02032     gamH=EvtParticleFactory::particleFactory(xvp, p_init);
02033     int gamdaugs = _ndaugs+1;
02034     
02035     EvtId theDaugs[10];
02036     for(int i=0;i<_ndaugs;i++){
02037       theDaugs[i] = daugs[i];
02038     }
02039     theDaugs[_ndaugs]=gamId;
02040     
02041     gamH->makeDaughters(gamdaugs,theDaugs); 
02042   loop:    
02043     double totm=0;
02044     for(int i=0;i<gamdaugs;i++){
02045       EvtParticle* di=gamH->getDaug(i);
02046       double xmi=EvtPDL::getMass(di->getId());
02047       di->setMass(xmi);
02048       totm += xmi;
02049     }
02050     
02051     //std::cout<<totm<<" "<<p_init.get(0)<<std::endl;
02052     if(totm >= p_init.get(0) ) goto loop;
02053 
02054     double weight = gamH->initializePhaseSpace(  gamdaugs , theDaugs);
02055     double thexs = difgamXs(gamH); //prepare the photon angular distribution
02056     EvtVector4R p4gam = gamH->getDaug(_ndaugs)->getP4();
02057     double costheta = p4gam.get(3)/p4gam.d3mag();
02058     double sintheta = sqrt(1-costheta*costheta);
02059     bool acut=(sintheta>0.04) && (sintheta<0.96); //set photon auglar cut 2^o
02060     if(thexs>maxXS && acut ) {maxXS=thexs;}
02061     //gamH->deleteTree();
02062   }
02063   
02064 }
02065 
02066 double EvtConExc::difgamXs(EvtParticle *p){// dsigma/dm/dcos\theta* (Eq(1)@PRD73,012005)
02067   // where p -> hdarons(0 ~ _ndaugs-1) + gamma
02068   EvtVector4R p0 = p->getDaug(0)->getP4();
02069   for(int i=1;i<_ndaugs;i++){
02070   p0 += p->getDaug(i)->getP4();
02071   }
02072   EvtVector4R pgam = p->getDaug(_ndaugs)->getP4();
02073   double mhs = p0.mass();
02074   double egam = pgam.get(0);
02075   double sin2theta =  pgam.get(3)/pgam.d3mag();
02076   sin2theta = 1-sin2theta*sin2theta;
02077 
02078   double cms = p->getP4().mass();
02079   double alpha = 1./137.;
02080   double pi = 3.1415926;
02081   double x = 2*egam/cms;
02082   double wsx = alpha/pi/x*( (2-2*x+x*x)/sin2theta-x*x/2. );
02083   //  std::cout<<"pgam"<<pgam<<" mhs,egam,sin2theta,cms,x,wsx"<<  mhs<<", "<<egam<<", "<<sin2theta<<", "<<cms<<", "<<x<<", "<<wsx<<std::endl;
02084 
02085   double xs = myxsection->getXsection(mhs);
02086   double difxs = 2*mhs/cms/cms * wsx *xs; 
02087   differ = 2*mhs/cms/cms * wsx *(myxsection->getErr(mhs));
02088   return difxs;
02089   
02090 }
02091 
02092 
02093 bool EvtConExc::gam_sampling(EvtParticle *p){//photon angular distribution sampling
02094   double pm= EvtRandom::Flat(0.,1);
02095   double xs = difgamXs( p );
02096   double xsratio = xs/maxXS;
02097   if(pm<xsratio){return true;}else{return false;}
02098 }
02099 
02100 bool EvtConExc::gam_sampling(double mhds,double sintheta){
02101   double pm= EvtRandom::Flat(0.,1);
02102   double xs = difgamXs( mhds,sintheta );
02103   double xsratio = xs/maxXS;
02104   if(pm<xsratio){return true;}else{return false;}
02105 }
02106 
02107 bool EvtConExc::xs_sampling(double xs){
02108   double pm= EvtRandom::Flat(0.,1);
02109   //std::cout<<"Rdm= "<<pm<<std::endl;
02110   if(pm <xs/XS_max) {return true;} else {return false;}
02111 }
02112 
02113 bool EvtConExc::xs_sampling(double xs,double xs0){
02114   double pm= EvtRandom::Flat(0.,1);
02115   // std::cout<<"Rdm= "<<pm<<std::endl;
02116   if(pm <xs/(xs0*1.1)) {return true;} else {return false;}
02117 }
02118 
02119 bool EvtConExc::baryon_sampling(EvtVector4R pcm, EvtVector4R pi){
02120   EvtHelSys angles(pcm,pi);   //using helicity sys.angles
02121   double theta=angles.getHelAng(1);
02122   double phi  =angles.getHelAng(2);
02123   double costheta=cos(theta);  //using helicity angles in parent system
02124 
02125   // double costh = pcm.dot(pi)/pcm.d3mag()/pi.d3mag();
02126   //std::cout<<"costheta: "<<costheta<<", "<<costh<<std::endl;
02127   double alpha = baryonAng(_cms);
02128   if(_mode ==96){alpha=-0.34;}
02129   double pm= EvtRandom::Flat(0.,1);
02130   double ang = 1 + alpha*costheta*costheta;
02131   double myang;
02132   if(alpha>=0){myang=1+alpha;}else{myang=1;}
02133   if(pm< ang/myang) {return true;}else{return false;}
02134 }
02135 
02136 bool EvtConExc::meson_sampling(EvtVector4R pcm, EvtVector4R pi){
02137   EvtHelSys angles(pcm,pi);   //using helicity sys.angles
02138   double theta=angles.getHelAng(1);
02139   double phi  =angles.getHelAng(2);
02140   double costheta=cos(theta);  //using helicity angles in parent system
02141 
02142   double pm= EvtRandom::Flat(0.,1);
02143   double ang = 1 - costheta*costheta;
02144   if(pm< ang/1.) {return true;}else{return false;}
02145 }
02146 
02147 bool EvtConExc::VP_sampling(EvtVector4R pcm, EvtVector4R pi){
02148   EvtHelSys angles(pcm,pi);   //using helicity sys.angles
02149   double theta=angles.getHelAng(1);
02150   double phi  =angles.getHelAng(2);
02151   double costheta=cos(theta);  //using helicity angles in parent system
02152 
02153   double pm= EvtRandom::Flat(0.,1);
02154   double ang = 1 + costheta*costheta;
02155   if(pm< ang/2.) {return true;}else{return false;}
02156 }
02157 
02158 double EvtConExc::Rad1(double s, double x){ //first order correction
02159   //radiator correction upto second order, see Int. J. of Moder.Phys. A
02160   // Spectroscopy at B-factory using hard emision photon, by M. Benayoun, et al
02161   double alpha = 1./137.;
02162   double pi=3.1415926;
02163   double me = 0.5*0.001; //e mass
02164   double sme = sqrt(s)/me;
02165   double L = 2*log(sme);
02166   double wsx = 2*alpha/pi/x*(L-1)*(1 - x + x*x/2 );
02167   return wsx;
02168 }
02169 
02170 double EvtConExc::Rad2(double s, double x){
02171   //radiator correction upto second order, see Int. J. of Moder.Phys. A, hep-ph/9910523, Eq(8)
02172   // Spectroscopy at B-factory using hard emision photon, by M. Benayoun, et al
02173   double alpha = 1./137.;
02174   double pi=3.1415926;
02175   double me = 0.5*0.001; //e mass
02176   double xi2 = 1.64493407;
02177   double xi3=1.2020569;
02178   double sme = sqrt(s)/me;
02179   double L = 2*log(sme);
02180   double beta = 2*alpha/pi*(L-1);
02181   double delta2 = (9./8.-2*xi2)*L*L - (45./16.-5.5*xi2-3*xi3)*L-6./5.*xi2*xi2-4.5*xi3-6*xi2*log(2.)+3./8.*xi2+57./12.;
02182   double ap = alpha/pi;
02183   double Delta = 1 + ap *(1.5*L + 1./3.*pi*pi-2) + ap*ap *delta2;
02184   double wsx = Delta * beta * pow(x,beta-1)-0.5*beta*(2-x);
02185   double wsx2 = (2-x)*( 3*log(1-x)-4*log(x) ) -4*log(1-x)/x-6+x;
02186   wsx = wsx + beta*beta/8. *wsx2;
02187   double mymx = sqrt(s*(1-x));
02188   //  return wsx*vph; //getVP(mymx);//vph is vaccum polarization factor
02189   return wsx*getVP(mymx);//vph is vaccum polarization factor
02190 }
02191 
02192 
02193 
02194 double EvtConExc::Rad2difXs(EvtParticle *p){// leading second order xsection
02195   // where p -> hdarons(0 ~ _ndaugs-1) + gamma
02196   double summass = p->getDaug(0)->getP4().mass();
02197   EvtVector4R v4p=p->getDaug(0)->getP4();
02198   for(int i=1;i<_ndaugs;i++){
02199     summass += p->getDaug(i)->getP4().mass();
02200     v4p +=  p->getDaug(i)->getP4();
02201   }
02202 
02203   double Egam = p->getDaug(_ndaugs)->getP4().d3mag();
02204   double cms = p->getP4().mass();
02205   double mrg = cms - summass;
02206   double pm= EvtRandom::Flat(0.,1);
02207   double mhs = pm*mrg + summass;
02208 
02209   double s = cms * cms;
02210   double x = 2*Egam/cms;
02211   //double mhs = sqrt( s*(1-x) );
02212   double wsx = Rad2(s,x);
02213 
02214   //  std::cout<<"random : "<<pm<<std::endl;
02215 
02216   double xs = myxsection->getXsection(mhs);
02217   if(xs>XS_max){XS_max = xs;}
02218   double difxs = 2*mhs/cms/cms * wsx *xs;
02219   differ2 = 2*mhs/cms/cms * wsx *(myxsection->getErr(mhs));
02220   differ *= mrg; //Jacobi factor for variable m_hds
02221   difxs *= mrg;
02222   return difxs;
02223 }
02224 
02225 double EvtConExc::Rad2difXs(double s, double x ){// leading second order xsection
02226   double wsx = Rad2(s,x);
02227   double mhs = sqrt(s*(1-x));
02228   double xs = myxsection->getXsection(mhs);
02229   //if(testflag==1) std::cout<<"s= "<<s<<" mhs= "<<mhs<<" x= "<<x<<" xs= "<<xs<<std::endl;
02230   if(xs>XS_max){XS_max = xs;}
02231   double difxs =  wsx *xs;
02232   differ2 =  wsx *(myxsection->getErr(mhs));
02233   return difxs;
02234 }
02235 
02236 
02237 double EvtConExc::Rad1difXs(EvtParticle *p){// // first order xsection
02238   // where p -> hdarons(0 ~ _ndaugs-1) + gamma
02239   double summass  = p->getDaug(0)->getP4().mass();
02240   for(int i=1;i<_ndaugs;i++){
02241     summass += p->getDaug(i)->getP4().mass();
02242   }
02243 
02244   double cms = p->getP4().mass();
02245   double mrg = cms - summass;
02246   double pm= EvtRandom::Flat(0.,1);
02247   double mhs = pm*mrg + summass;
02248 
02249   double s = cms * cms;
02250   double x = 1 - mhs*mhs/s;
02251   double wsx = Rad1(s,x);
02252 
02253   //  std::cout<<"pgam"<<pgam<<" mhs,egam,sin2theta,cms,x,wsx"<<  mhs<<", "<<egam<<", "<<sin2theta<<", "<<cms<<", "<<x<<", "<<wsx<<std::endl;
02254 
02255   double xs = myxsection->getXsection(mhs);
02256   if(xs>XS_max){XS_max = xs;}
02257   double difxs = 2*mhs/cms/cms * wsx *xs;
02258 
02259   differ = 2*mhs/cms/cms * wsx *(myxsection->getErr(mhs));
02260   differ *= mrg; //Jacobi factor for variable m_hds
02261   difxs *= mrg;
02262   return difxs;
02263 }
02264 
02265 void EvtConExc::init_Br_ee(){
02266   //  double psipp_ee=9.6E-06;
02267   double psip_ee =7.73E-03;
02268   double jsi_ee  =5.94*0.01;
02269   double phi_ee  =2.954E-04;
02270   // double omega_ee=7.28E-05;
02271   // double rho_ee = 4.72E-05;
02272   EvtId psppId=EvtPDL::getId(std::string("psi(3770)"));
02273   EvtId pspId=EvtPDL::getId(std::string("psi(2S)"));
02274   EvtId jsiId=EvtPDL::getId(std::string("J/psi"));
02275   EvtId phiId=EvtPDL::getId(std::string("phi"));
02276   EvtId omegaId=EvtPDL::getId(std::string("omega"));
02277   EvtId rhoId=EvtPDL::getId(std::string("rho0"));
02278   BR_ee.clear();
02279   ResId.clear();
02280 
02281   //BR_ee.push_back(rho_ee);  
02282   //BR_ee.push_back(omega_ee);
02283   BR_ee.push_back(phi_ee);
02284   BR_ee.push_back(jsi_ee);
02285   BR_ee.push_back(psip_ee);
02286   //BR_ee.push_back(psipp_ee);
02287 
02288   //ResId.push_back(rhoId);
02289   //ResId.push_back(omegaId);
02290   ResId.push_back(phiId);
02291   ResId.push_back(jsiId);
02292   ResId.push_back(pspId);
02293   //ResId.push_back(psppId);
02294   
02295 }
02296 
02297 double EvtConExc::Ros_xs(double mx,double bree, EvtId pid){// in unit nb
02298   double pi=3.1415926;
02299   double s= mx*mx;
02300   double width = EvtPDL::getWidth(pid);
02301   double mass = EvtPDL::getMeanMass(pid);
02302   double xv = 1-mass*mass/s;
02303   double sigma = 12*pi*pi*bree*width/mass/s;
02304   sigma *= Rad2(s, xv);
02305   double nbar = 3.89379304*100000;  // ! GeV-2 = 3.89379304*10^5 nbar
02306    return sigma*nbar;
02307 }
02308 
02309 
02310 double Rad2difXs(double *mhs){// leading second order xsection, mhs: the mass of final states
02311   double cms = EvtConExc::_cms;
02312   double s = cms * cms;
02313   double x = 1 - (*mhs)*(*mhs)/s;
02314   EvtConExc myconexc; 
02315   double wsx;
02316   double dhs=(*mhs);
02317   double xs = EvtConExc::myxsection->getXsection(dhs); 
02318   wsx=myconexc.Rad2(s,x);
02319   if(xs>EvtConExc::XS_max){EvtConExc::XS_max = xs;}
02320   double difxs = 2*dhs/cms/cms * wsx *xs; 
02321   std::ofstream oa;oa<<x<<std::endl; //without this line, the running will breaking, I don't know why
02322   return difxs;
02323 }
02324 double Rad2difXs_er(double *mhs){// leading second order xsection, mhs: the mass of final states
02325   double cms = EvtConExc::_cms;
02326   double s = cms * cms;
02327   double x = 1 - (*mhs)*(*mhs)/s;
02328   EvtConExc myconexc; 
02329   double wsx;
02330   double xs = EvtConExc::myxsection->getErr(*mhs);
02331   wsx=myconexc.Rad2(s,x);
02332   double differ2 = 2*(*mhs)/cms/cms * wsx *xs; 
02333   std::ofstream oa;oa<<x<<std::endl;
02334   return differ2;
02335 }
02336 
02337 double Rad2difXs2(double *mhs){// leading second order xsection, mhs: the mass of final states
02338   double cms = EvtConExc::_cms;
02339   double s = cms * cms;
02340   double x = 1 - (*mhs)*(*mhs)/s;
02341   EvtConExc myconexc; 
02342   double wsx;
02343   double dhs=(*mhs);
02344   double xs = EvtConExc::myxsection->getXsection(dhs);
02345   wsx=myconexc.Rad2(s,x);
02346   if(xs>EvtConExc::XS_max){EvtConExc::XS_max = xs;}
02347   double difxs = 2*dhs/cms/cms * wsx *xs; 
02348   oa<<x<<std::endl; //without this line, the running will breaking, I don't know why
02349   return difxs;
02350 }
02351 
02352 double Rad2difXs_er2(double *mhs){// leading second order xsection, mhs: the mass of final states
02353   double cms = EvtConExc::_cms;
02354   double s = cms * cms;
02355   double x = 1 - (*mhs)*(*mhs)/s;
02356   EvtConExc myconexc; 
02357   double wsx;
02358   double xs = EvtConExc::myxsection->getErr(*mhs);
02359   wsx=myconexc.Rad2(s,x);
02360   double differ2 = 2*(*mhs)/cms/cms * wsx *xs; 
02361   oa<<x<<std::endl;
02362   return differ2;
02363 }
02364 
02365 
02366 double EvtConExc::SoftPhoton_xs(double s, double b){
02367   double alpha = 1./137.;
02368   double pi=3.1415926;
02369   double me = 0.5*0.001; //e mass
02370   double xi2 = 1.64493407;
02371   double xi3=1.2020569;
02372   double sme = sqrt(s)/me;
02373   double L = 2*log(sme);
02374   double beta = 2*alpha/pi*(L-1);
02375   double delta2 = (9./8.-2*xi2)*L*L - (45./16.-5.5*xi2-3*xi3)*L-6./5.*xi2*xi2-4.5*xi3-6*xi2*log(2.)+3./8.*xi2+57./12.;
02376   double ap = alpha/pi;
02377   double Delta = 1 + ap *(1.5*L + 1./3.*pi*pi-2) + ap*ap *delta2;
02378 
02379   double beta2 = beta*beta;
02380   double b2 = b*b;
02381 
02382   double xs=(-32*b*beta + 8*pow(b,2)*beta - 10*b*pow(beta,2) + pow(b,2)*pow(beta,2)  + 32*pow(b,beta)*Delta - 
02383      6*(3 - 4*b + pow(b,2))*pow(beta,2)*log(1 - b) - 32*b*pow(beta,2)*log(b) + 8*pow(b,2)*pow(beta,2)*log(b) + 
02384              16*pow(beta,2)*Li2(b))/32. ;
02385   double mymx = sqrt(s*(1-b));
02386   //return xs*vph; //getVP(mymx); //vph :the vaccum polarzation factor
02387   return xs*getVP(mymx); //vph :the vaccum polarzation factor
02388 
02389 }
02390 
02391 double EvtConExc::Li2(double x){
02392   double li2= -x +x*x/4. - x*x*x/9;
02393   return li2;
02394 }
02395 
02396 
02397 double EvtConExc::lgr(double *x,double *y,int n,double t)
02398 { int n0=-1;
02399   double z;
02400   for(int i=0;i<n-1;i++){
02401     if(x[i]>=t && t> x[i+1]) {n0=i;break;}
02402   }
02403   if(n0==-1) {return 0.0;}else{
02404     double k=(y[n0]-y[n0+1])/(x[n0]-x[n0+1]);
02405     z= y[n0+1]+k*(t-x[n0+1]);
02406   }
02407   //std::cout<<"t="<<t<<" "<<x[n0+1]<<" "<<x[n0]<<std::endl;
02408   //std::cout<<"t="<<t<<" "<<y[n0+1]<<" "<<y[n0]<<std::endl;
02409   return z;
02410 }
02411 
02412 bool EvtConExc::islgr(double *x,double *y,int n,double t)
02413 { int n0=-1;
02414   double z;
02415   for(int i=0;i<n-1;i++){
02416     if(x[i]>=t && t> x[i+1]) {n0=i;break;}
02417   }
02418   double xstotal=y[599];
02419   if(n0==-1) {return 0;}else{
02420     double p1=y[n0]/xstotal;
02421     double p2=y[n0+1]/xstotal;
02422     double pm= EvtRandom::Flat(0.,1);
02423     if(p1<pm && pm<=p2) {return 1;}else{return 0;}
02424   }
02425 }
02426 
02427 double EvtConExc::LLr(double *x,double *y,int n,double t)
02428 { int n0=-1;
02429   double z;
02430   if( t==x[n-1] ) return y[n-1];
02431   for(int i=0;i<n-1;i++){
02432     if(x[i]<=t && t< x[i+1]) {n0=i;break;}
02433   }
02434   if(n0==-1) {return 0.0;}else{
02435     double k=(y[n0]-y[n0+1])/(x[n0]-x[n0+1]);
02436     z= y[n0+1]+k*(t-x[n0+1]);
02437   }
02438   //std::cout<<"t="<<t<<" "<<x[n0+1]<<" "<<x[n0]<<std::endl;
02439   //std::cout<<"t="<<t<<" "<<y[n0+1]<<" "<<y[n0]<<std::endl;
02440   return z;
02441 }
02442 
02443 double EvtConExc::Mhad_sampling(double *x,double *y){//sample ISR hadrons, return Mhadron
02444   //x=MH: array contains the Mhad
02445   //y=AF: array contains the Mhad*Xsection
02446   //n: specify how many bins in the hadron sampling
02447   int n=598; //AF[599] is the total xs including Ecms point
02448   double pm= EvtRandom::Flat(0.,1);
02449   int mybin=1;
02450   double xst=y[n]; 
02451   for(int i=0;i<n;i++){
02452     if((y[i]/xst)<pm && pm<=(y[i+1]/xst)){mybin=i+1;break;}
02453   }
02454   pm= EvtRandom::Flat(0.,1);
02455   double mhd=x[mybin-1]+(x[mybin]-x[mybin-1])*pm;
02456 
02457   if(mhd>_cms) {std::cout<<"selected mhd larger than Ecms "<<mhd<<" > "<<x[mybin]<<std::endl;abort();}
02458   if(mhd<_mhdL){
02459     std::cout<<"the sample mhassrons is less than the low end of XS"<<mhd<<" <"<<_mhdL<<std::endl;
02460     for(int i=0;i<598;i++){std::cout<<i<<" "<<x[i]<<" "<<y[i]<<std::endl;}
02461     abort();
02462   }
02463   return mhd;
02464 }
02465 
02466 double EvtConExc::ISR_ang_integrate(double x,double theta){
02467   //see Eq(11) in arXif:hep-ph/9910523, return h(theta)/h(pi)
02468   double costheta=cos(theta);
02469   double eb=_cms/2;
02470   double cos2=costheta*costheta;
02471   double sin2=1-cos2;
02472   double me=0.51*0.001;
02473   double L=2*log(_cms/me);
02474   double meE2= me*me/eb/eb;
02475   double hpi=L-1;
02476   double hq1= meE2/2*costheta/(sin2+meE2*cos2);
02477   double hq2= -0.5*log((1+sqrt(1-meE2)*costheta)/(1-sqrt(1-meE2)*costheta));
02478   double hq3=x*x*costheta/2/(x*x-2*x+2)*(1-meE2/(sin2+meE2*cos2));
02479   double hq=(L-1)/2.+hq1+hq2+hq3;
02480   hq /= hpi;   //Eq (11) in  arXif:hep-ph/9910523
02481   return hq;
02482 }
02483 
02484 double EvtConExc::ISR_ang_sampling(double x){
02485   double xx[180],yy[180];
02486   double dgr2rad=1./180.*3.1415926;
02487   xx[0]=0;
02488   xx[1]=5*dgr2rad;  //first bin is 5 degree
02489   int nc=2;
02490   for(int i=6;i<=175;i++){ //last bin is 5 degree
02491     xx[nc]=i*dgr2rad;
02492     nc++;
02493   }
02494   xx[nc]=180*dgr2rad;
02495   for(int j=0;j<=nc;j++){
02496     yy[j]=ISR_ang_integrate(x,xx[j]);
02497   }
02498   double pm= EvtRandom::Flat(0.,1);
02499   int mypt=1;
02500   for(int j=1;j<=nc;j++){
02501     if(yy[j-1]<pm && pm<=yy[j]){mypt=j;break;}
02502   }
02503   pm= EvtRandom::Flat(0.,1);
02504   double mytheta= xx[mypt-1]+ (xx[mypt]-xx[mypt-1])*pm;
02505   return mytheta; //theta in rad unit
02506 }
02507 
02508 void EvtConExc::SetP4(EvtParticle *p, double mhdr, double xeng,double theta){ //set the gamma and gamma* momentum according sampled results
02509   double  pm= EvtRandom::Flat(0.,1);
02510   double phi=2*3.1415926*pm;
02511   double gamE = _cms/2*xeng;
02512   double hdrE = sqrt(mhdr*mhdr+gamE*gamE);
02513   double px = gamE*sin(theta)*cos(phi);
02514   double py = gamE*sin(theta)*sin(phi);
02515   double pz = gamE*cos(theta);
02516   EvtVector4R p4[2];
02517   p4[0].set(gamE,px,py,pz);//ISR photon
02518   p4[1].set(hdrE,-px,-py,-pz); //mhdraons
02519   for(int i=0;i<2;i++){
02520     EvtId myid = p->getDaug(i)->getId();
02521     p->getDaug(i)->init(myid,p4[i]);
02522   }
02523 }
02524 
02525 void EvtConExc::SetP4Rvalue(EvtParticle *p, double mhdr, double xeng,double theta){ //set the gamma and gamma* momentum according sampled results
02526   double  pm= EvtRandom::Flat(0.,1);
02527   double phi=2*3.1415926*pm;
02528   double gamE = _cms/2*xeng;
02529   double hdrE = sqrt(mhdr*mhdr+gamE*gamE);
02530   double px = gamE*sin(theta)*cos(phi);
02531   double py = gamE*sin(theta)*sin(phi);
02532   double pz = gamE*cos(theta);
02533   EvtVector4R p4[2];
02534   p4[0].set(hdrE,px,py,pz);//mhdraons
02535   p4[1].set(gamE,-px,-py,-pz); //ISR photon
02536   for(int i=0;i<2;i++){
02537     EvtId myid = p->getDaug(i)->getId();
02538     p->getDaug(i)->init(myid,p4[i]);
02539   }
02540 }
02541 
02542 
02543 void EvtConExc::findMaxXS(double mhds ){// dsigma/dm/dcos\theta* (Eq(1)@PRD73,012005)
02544   maxXS=-1;
02545   for(int i=0;i<90000;i++){
02546     double x =  1-(mhds/_cms)*(mhds/_cms);
02547     double cos = EvtRandom::Flat(0.0006,0.9994); //set cut on ISR gamma 2^o
02548     double sin2theta =sqrt(1-cos*cos);
02549     double alpha = 1./137.;
02550     double pi = 3.1415926;
02551     double wsx = alpha/pi/x*( (2-2*x+x*x)/sin2theta-x*x/2. );
02552     double xs = myxsection->getXsection(mhds);
02553     double difxs = 2*mhds/_cms/_cms * wsx *xs;
02554     if(difxs>maxXS)maxXS=difxs;
02555   }
02556 }
02557 
02558 double EvtConExc::difgamXs(double mhds,double sintheta ){// dsigma/dm/dcos\theta* (Eq(1)@PRD73,012005)
02559   double x = 1-(mhds/_cms)*(mhds/_cms);
02560   double sin2theta = sintheta*sintheta;
02561   double alpha = 1./137.;
02562   double pi = 3.1415926;
02563   double wsx = alpha/pi/x*( (2-2*x+x*x)/sin2theta-x*x/2. );
02564   double xs = myxsection->getXsection(mhds);
02565   double difxs = 2*mhds/_cms/_cms * wsx *xs;  
02566   return difxs;
02567 }
02568 
02569 int EvtConExc::selectMode(std::vector<int> vmod, double mhds){
02570   //first get xsection for each mode in vmod array
02571   //std::cout<<"vmod.size, mhds "<<vmod.size()<<" "<<mhds<<std::endl;
02572   std::vector<int>excmod;
02573   excmod.push_back(0);
02574   excmod.push_back(1);
02575   excmod.push_back(2);
02576   excmod.push_back(6);
02577   excmod.push_back(7);
02578   excmod.push_back(12);
02579   excmod.push_back(13);
02580   excmod.push_back(45);
02581   excmod.push_back(46);
02582   double uscale = 1;  
02583   std::vector<double> vxs;vxs.clear();
02584   for (int i=0;i<vmod.size();i++){
02585     int imod = vmod[i];
02586     delete myxsection;
02587     myxsection =new EvtXsection (imod);
02588     if(myxsection->getUnit() =="pb") {uscale =0.001;}else{uscale=1;}
02589     //if(uscale!=1) std::cout<<"mode="<<imod<<" uscale= "<<uscale<<std::endl;
02590 
02591      double myxs=uscale*myxsection->getXsection(mhds);
02592 
02593     if(imod==0) {vxs.push_back(myxs);} 
02594     else if(imod==74110){//for continuum process
02595       double xcon = myxs - vxs[i-1];
02596       if(xcon<0) {xcon=vxs[i-1];}else{xcon=myxs;}
02597       if(mhds<2.0) xcon=vxs[i-1]; //continuum cut: _cms energy less than 1.1, sampling phi,rho0 and omega resonance, see parp(2)=1.08 at Pythia.F
02598       vxs.push_back(xcon); 
02599     }else{
02600       vxs.push_back(myxs+vxs[i-1]);
02601     }
02602   }//for_i_block
02603   //degugging
02604   // for(int i=0;i<vxs.size();i++){std::cout<<"Mhds="<<mhds<<" Mode="<<vmod[i]<<" xs_i= "<<vxs[i]<<" totalxs "<< vxs[vxs.size()-1]<<std::endl;} 
02605 
02606   double totxs = vxs[vxs.size()-1];
02607   //if(totxs==0){std::cout<<"totalXs=0, vxs.size()= "<<vxs.size()<<std::endl;}
02608   int icount=0;
02609   int themode;
02610  mode_iter:
02611         double pm= EvtRandom::Flat(0.,1);  //std::cout<<"pm= "<<pm<<" mhds= "<<mhds<<std::endl;
02612          if(pm <= vxs[0]/totxs) {
02613            themode= vmod[0];
02614            std::vector<EvtId> theDaug=get_mode(themode);
02615            EvtId daugs[100];
02616            for(int i=0;i<theDaug.size();i++){daugs[i]=theDaug[i];}
02617            int exmode=EvtDecayTable::inChannelList(theparent->getId(),theDaug.size(),daugs);
02618            if(exmode==-1){ return themode;}else{goto mycount;} 
02619           } 
02620 
02621           for(int j=1;j<vxs.size();j++){
02622             double x0 = vxs[j-1]/totxs;
02623             double x1 = vxs[j]/totxs;   //std::cout<<"j,x0,x1 "<<j<<" "<<x0<<" "<<x1<<std::endl;
02624             if(x0<pm && pm<=x1){
02625               themode=vmod[j];
02626               std::vector<EvtId> theDaug=get_mode(themode);
02627               EvtId daugs[100];
02628               for(int i=0;i<theDaug.size();i++){daugs[i]=theDaug[i];}
02629               int exmode=EvtDecayTable::inChannelList(theparent->getId(),theDaug.size(),daugs);
02630               if(exmode==-1){ return themode;} else{ break;}
02631             }
02632           }
02633  
02634  mycount:
02635           icount++;
02636           if(icount<20000) goto mode_iter;
02637           //debugging
02638           //for(int i=0;i<vxs.size();i++){std::cout<<"Random="<<pm<<" Mode,Mhad "<<vmod[i]<<", "<<mhds<<" xs_i "<<vxs[i]<<" xsi/totalxs "<<vxs[i]/totxs<<std::endl;}
02639           std::cout<<"EvtConExc::selectMode can not find a mode with 20000 iteration for Mhadrons="<<mhds<<std::endl;
02640           return -10;
02641           //abort();
02642 
02643 }
02644 
02645 
02646 void EvtConExc::resetResMass(){
02647   // EvtGen base class resetwidth has bugs, it make the mass of particle changed.
02648   EvtId  myres = EvtPDL::getId(std::string("J/psi"));
02649   EvtPDL::reSetMass(myres,mjsi); 
02650   //EvtPDL::reSetWidth(myres,wjsi); 
02651 
02652   myres = EvtPDL::getId(std::string("psi(2S)"));
02653   EvtPDL::reSetMass(myres,mpsip); 
02654   //EvtPDL::reSetWidth(myres,wpsip); 
02655 
02656   myres = EvtPDL::getId(std::string("psi(3770)"));
02657   EvtPDL::reSetMass(myres,mpsipp); 
02658   //EvtPDL::reSetWidth(myres,wpsipp); 
02659 
02660   myres = EvtPDL::getId(std::string("phi"));
02661   EvtPDL::reSetMass(myres,mphi); 
02662   //EvtPDL::reSetWidth(myres,wphi); 
02663 
02664   myres = EvtPDL::getId(std::string("omega"));
02665   EvtPDL::reSetMass(myres,momega);
02666   //EvtPDL::reSetWidth(myres,womega);
02667 
02668   myres = EvtPDL::getId(std::string("rho0"));
02669   EvtPDL::reSetMass(myres,mrho0);
02670   //EvtPDL::reSetWidth(myres,wrho0);
02671 
02672   myres = EvtPDL::getId(std::string("rho(3S)0"));
02673   EvtPDL::reSetMass(myres,mrho3s); 
02674   //EvtPDL::reSetWidth(myres,wrho3s); 
02675 
02676   myres = EvtPDL::getId(std::string("omega(2S)"));
02677   EvtPDL::reSetMass(myres,momega2s);
02678   //EvtPDL::reSetWidth(myres,womega2s);
02679 }
02680 
02681 void EvtConExc::getResMass(){
02682   EvtId  myres = EvtPDL::getId(std::string("J/psi"));
02683   mjsi = EvtPDL::getMeanMass(myres); 
02684   wjsi = EvtPDL::getWidth(myres); 
02685 
02686   myres = EvtPDL::getId(std::string("psi(2S)"));
02687   mpsip= EvtPDL::getMeanMass(myres); 
02688   wpsip= EvtPDL::getWidth(myres); 
02689 
02690   myres = EvtPDL::getId(std::string("psi(3770)"));
02691   mpsipp= EvtPDL::getMeanMass(myres); 
02692   wpsipp= EvtPDL::getWidth(myres); 
02693 
02694   myres = EvtPDL::getId(std::string("phi"));
02695   mphi = EvtPDL::getMeanMass(myres); 
02696   wphi = EvtPDL::getWidth(myres); 
02697 
02698   myres = EvtPDL::getId(std::string("omega"));
02699   momega= EvtPDL::getMeanMass(myres);
02700   womega= EvtPDL::getWidth(myres);
02701 
02702   myres = EvtPDL::getId(std::string("rho0"));
02703   mrho0 = EvtPDL::getMeanMass(myres);
02704   wrho0 = EvtPDL::getWidth(myres);
02705 
02706   myres = EvtPDL::getId(std::string("rho(3S)0"));
02707   mrho3s= EvtPDL::getMeanMass(myres);
02708   wrho3s= EvtPDL::getWidth(myres);
02709 
02710 
02711   myres = EvtPDL::getId(std::string("omega(2S)"));
02712   momega2s= EvtPDL::getMeanMass(myres);
02713   womega2s= EvtPDL::getWidth(myres);
02714 
02715 }
02716 
02717 void EvtConExc::showResMass(){
02718   std::cout<<"J/psi: "<<mjsi<<" "<<wjsi<<std::endl;
02719   std::cout<<"psipr: "<<mpsip<<" "<<wpsip<<std::endl;
02720   std::cout<<"psipp: "<<mpsipp<<" "<<wpsipp<<std::endl;
02721   std::cout<<"phi  : "<<mphi<<" "<<wphi<<std::endl;
02722   std::cout<<"omega: "<<momega<<" "<<womega<<std::endl;
02723   std::cout<<"rho0 : "<<mrho0<<" "<<wrho0<<std::endl;
02724   std::cout<<"rho(3S)0: "<<mrho3s<<" "<<wrho3s<<std::endl;
02725   std::cout<<"omega(2S): "<<momega2s<<" "<<womega2s<<std::endl;
02726 }
02727 
02728 bool EvtConExc::checkdecay(EvtParticle* p){
02729   int nson=p->getNDaug();
02730   double massflag=1;
02731   for(int i=0;i<nson;i++){
02732     if( EvtPDL::getStdHep(p->getDaug(i)->getId())==22 ) continue;
02733     massflag *= p->getDaug(i)->mass();
02734   }
02735   if(massflag==0){
02736     std::cout<<"Zero mass!"<<std::endl;
02737     return 0;
02738   }else{return 1;}
02739 }
02740 
02741 
02742 double EvtConExc::sumExc(double mx){//summation all cross section of exclusive decays
02743   std::vector<int> vmod; vmod.clear();
02744   int mn[78]={0,1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,45,46,//mode 12 and 43 are removed
02745               50,51,
02746               68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,
02747               90,91,92,93,94,95,96,
02748               74100,74101,74102,74103,74104,74105,74110};
02749   int mn2[79]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,45,46,//mode 12 and 43 are removed
02750                50,51,
02751                68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,
02752                90,91,92,93,94,95,96,
02753                74100,74101,74102,74103,74104,74105,74110};
02754   
02755   if(_cms > 2.5){
02756     for(int i=0;i<78;i++){vmod.push_back(mn[i]);}
02757   }else{
02758     for(int i=0;i<79;i++){vmod.push_back(mn2[i]);}  
02759   }
02760   
02761  // for(int i=0;i<79;i++){vmod.push_back(mn2[i]);}  
02762 
02763   double xsum=0;
02764   double uscale = 1;
02765   for(int i=0;i<vmod.size();i++){
02766     int mymode = vmod[i];
02767     if(mymode ==74110) continue;
02768     delete myxsection;
02769     myxsection =new EvtXsection (mymode);
02770     init_mode(mymode);
02771     if(myxsection->getUnit() =="pb") {uscale =0.001;}else{uscale=1;}
02772     xsum += uscale*myxsection->getXsection(mx);
02773     //if(mx==3.0967) {std::cout<<vmod[i]<<" "<<uscale<<" "<<xsum<<std::endl;}
02774   }
02775   return xsum;
02776 }
02777 
02778 bool EvtConExc::angularSampling(EvtParticle* par){
02779   bool tagp,tagk;
02780   tagk=0;
02781   tagp=0;
02782   int nds = par->getNDaug();
02783   for(int i=0;i<par->getNDaug();i++){
02784     EvtId di=par->getDaug(i)->getId();
02785     EvtVector4R p4i = par->getDaug(i)->getP4Lab();
02786     int pdgcode =EvtPDL::getStdHep( di );
02787     double alpha=1;
02788     /*
02789     if(fabs(pdgcode)==2212){//proton and anti-proton
02790       alpha = baryonAng(p4i.mass());
02791       cosp = cos(p4i.theta());
02792       tagp=1;
02793     }else if(fabs(pdgcode)==321||fabs(pdgcode)==211 ){
02794       alpha=1;
02795       cosk = cos(p4i.theta());
02796       tagk=1;
02797     }else continue;
02798     */
02799     double angmax = 1+alpha;
02800     double costheta = cos(p4i.theta());
02801     double ang=1+alpha*costheta*costheta;
02802     double xratio = ang/angmax;
02803     double xi=EvtRandom::Flat(0.,1);
02804     //std::cout<<"pdgcode "<<pdgcode<<std::endl;
02805     //std::cout<<ang<<" "<<angmax<<" "<<xi<<" "<<xratio<<std::endl;
02806     if(xi>xratio) return false;
02807   }//loop over duaghters
02808   //if(tagp) std::cout<<" cosp "<<cosp<<std::endl;
02809   //if(tagk) std::cout<<" cosk "<<cosk<<std::endl;
02810 
02811   return true;
02812 }
02813 
02814 double EvtConExc::baryonAng(double mx){
02815   double mp=0.938;
02816   double u = 0.938/mx;
02817   u = u*u;
02818   double u2 = (1+u)*(1+u);
02819   double uu = u*(1+6*u);
02820   double alpha = (u2-uu)/(u2+uu);
02821   return alpha;
02822 }
02823 
02824 bool EvtConExc::photonSampling(EvtParticle* par){
02825   bool tagp,tagk;
02826   tagk=0;
02827   tagp=0;
02828   int nds = par->getNDaug();
02829   for(int i=0;i<par->getNDaug();i++){
02830     EvtId di=par->getDaug(i)->getId();
02831     EvtVector4R p4i = par->getDaug(i)->getP4Lab();
02832     int pdgcode =EvtPDL::getStdHep( di );
02833     double alpha=0;
02834 
02835     if(pdgcode==111 ||pdgcode==221 || pdgcode==331 ){//for photon 
02836       alpha = 1;
02837     }else continue;
02838 
02839     double angmax = 1+alpha;
02840     double costheta = cos(p4i.theta());
02841     double ang=1+alpha*costheta*costheta;
02842     double xratio = ang/angmax;
02843     double xi=EvtRandom::Flat(0.,1);
02844     //std::cout<<"pdgcode "<<pdgcode<<std::endl;
02845     //std::cout<<ang<<" "<<angmax<<" "<<xi<<" "<<xratio<<std::endl;
02846     if(xi>xratio) return false;
02847   }//loop over duaghters
02848   //if(tagp) std::cout<<" cosp "<<cosp<<std::endl;
02849   //if(tagk) std::cout<<" cosk "<<cosk<<std::endl;
02850 
02851   return true;
02852 }
02853 
02854 
02855 double EvtConExc::narrowRXS(double mxL,double mxH){
02856   //br for ee 
02857   double psippee,psipee,jsiee,phiee,omegaee,rhoee;
02858   double kev2Gev=0.000001;
02859   psippee=0.262*kev2Gev;
02860   psipee =2.36*kev2Gev;
02861   jsiee  =5.55*kev2Gev;
02862   phiee=4.266*0.001*2.954*0.0001;
02863   omegaee=0.6*kev2Gev;
02864   rhoee=7.04*kev2Gev;
02865   double s=_cms*_cms;
02866   double sigv=0;
02867   double mv=0;
02868   double widee=0;
02869   double xpi=12*3.1415926*3.1415926;
02870   if(mxL<=3.0957 && 3.0957<=mxH || mxL<=3.0983 && 3.0983<=mxH) {
02871     widee = jsiee;
02872     mv = 3.096916;
02873   }else if(mxL<=3.6847 && 3.6847<=mxH || mxL<=3.6873 && 3.6873<=mxH){
02874     widee = psipee;
02875     mv = 3.686109;
02876   }else if(mxL<=1.01906 && 1.01906<=mxH || mxL<= 1.01986 &&  1.01986<=mxH){
02877     widee = phiee;
02878     mv = 1.01946;
02879   }else{return -1.0;}
02880   
02881   if(_cms<=mv) return -1.;
02882   double xv = 1-mv*mv/s;
02883   sigv += xpi*widee/mv/s*Rad2(s,xv);
02884   double unic = 3.89379304*100000;  //in unit nb
02885   return sigv*unic;  //vaccum factor has included in the Rad2
02886 }
02887 
02888 
02889 double EvtConExc::addNarrowRXS(double mhi,double binwidth){
02890   double myxs = 0;
02891   for(int i=0;i<ISRXS.size();i++){ // std::cout<<"ISRM "<<ISRM[i]<<std::endl;
02892     if( (ISRM[i]-mhi)<binwidth && ISRFLAG[i]){ISRFLAG[i]=0; myxs = ISRXS[i];}
02893   }
02894   //std::cout<<mhi<<" "<<binwidth<<" "<<myxs<<std::endl;
02895   return myxs;
02896 }
02897 
02898 double EvtConExc::selectMass(){
02899   double pm,mhdL,mhds;
02900   pm   = EvtRandom::Flat(0.,1);
02901   mhdL =_mhdL; 
02902   mhds = pm*(_cms - mhdL)+mhdL;  //non narrow resonance
02903   std::vector<double> sxs;
02904   for(int i=0;i<ISRID.size();i++){
02905     double ri=ISRXS[i]/AF[598];
02906     sxs.push_back(ri);
02907   }
02908   for(int j=0;j<sxs.size();j++){
02909     if(j>0) sxs[j] += sxs[j-1];
02910   }
02911   pm  = EvtRandom::Flat(0.,1);
02912   if(pm<sxs[0]) {
02913     mhds = EvtPDL::getMass(ISRID[0]); //narrow resonance
02914   }
02915   for(int j=1;j<sxs.size();j++){
02916     double x0 = sxs[j-1];
02917     double x1 = sxs[j];
02918     if(x0<pm && pm<=x1)  mhds = EvtPDL::getMass(ISRID[j]); //narrow resonance
02919   }
02920   return mhds;
02921 }
02922 
02923 double EvtConExc::getVP(double mx){
02924   double xx,r1,i1;
02925   double x1,y1,y2;
02926   xx=0;
02927   int mytag=1;
02928   for(int i=0;i<4001;i++){
02929     x1=vpx[i];
02930     y1=vpr[i];
02931     y2=vpi[i];
02932     if(xx<=mx && mx <x1){xx=x1; r1=y1; i1=y2; mytag=0; break;}
02933     xx=x1; r1=y1; i1=y2;
02934   }
02935   if(mytag==1){std::cout<<"No vacuum polarization value found"<<std::endl;abort();}
02936   EvtComplex cvp(r1,i1);
02937   double thevp=abs(1./(1-cvp));
02938   if(3.0933<mx && mx<3.1035) return 1.; //J/psi peak excluded
02939   if(3.6810<mx && mx<3.6913) return 1.; //psi(2S) peak excluded
02940   return thevp*thevp;
02941 }
02942 
02943 
02944 void EvtConExc::ReadVP(){
02945   vpx.clear();vpr.clear();vpi.clear();
02946   int vpsize=4001;
02947   vpx.resize(vpsize);
02948   vpr.resize(vpsize);
02949   vpi.resize(vpsize);
02950   std::string locvp=getenv("BESEVTGENROOT");
02951   locvp +="/share/vp.dat";
02952   ifstream m_inputFile; 
02953   m_inputFile.open(locvp.c_str());
02954   double xx,r1,i1;
02955   double x1,y1,y2;
02956   xx=0;
02957   int mytag=1;
02958   for(int i=0;i<4001;i++){
02959     m_inputFile>>vpx[i]>>vpr[i]>>vpi[i]; 
02960   }
02961   
02962 }
02963 
02964 
02965 
02966 
02967 void EvtConExc::mk_VXS(double Esig,double Egamcut,double EgamH,int midx){
02968   //the mode index is put into vmode
02969   //initial
02970   //midx: mode index in vmode[midx] and VXS[midx][bin]
02971   int mode=vmode[midx];
02972   double uscale;
02973   delete myxsection;
02974   myxsection =new EvtXsection (mode);
02975   if(myxsection->getUnit() =="pb") {uscale =0.001;}else{uscale=1;} 
02976   double s = _cms*_cms;  
02977   int nmc=800;
02978   double myxs0 =uscale*gamHXSection(s,Esig,Egamcut,nmc);
02979   double xb= 2*Esig/_cms;
02980   double sig_xs = uscale*SoftPhoton_xs(s,xb)*(myxsection->getXsection(_cms));
02981   myxs0 += sig_xs;
02982 
02983   int Nstp=598;
02984   double stp=(EgamH - Egamcut)/Nstp;
02985   for(int i=0;i<Nstp;i++){//points within Egam(max) ~ Egamcut=25MeV
02986     double Eg0=EgamH - i*stp;
02987     double Eg1=EgamH - (i+1)*stp;           
02988     double xsi= uscale*gamHXSection(s,Eg1,Eg0,nmc); 
02989     if(i==0) VXS[midx][0]=xsi; 
02990     if(i>=1) VXS[midx][i]=VXS[midx][i-1]+xsi;
02991   }
02992    VXS[midx][598]=VXS[midx][597];
02993    VXS[midx][599]=VXS[midx][598]+ myxs0;
02994    //std::cout<<"mode "<<mode<<" "<<uscale<<" "<<VXS[midx][599]<<std::endl; 
02995 }
02996 
02997 int EvtConExc::get_mode_index(int mode){
02998   int i=0;
02999   for(int j=0;i<vmode.size();j++){
03000     if(mode==vmode[j]) return j;
03001   }
03002   std::cout<<" EvtConExc::get_mode_index:  no index is found in vmode"<<std::endl;
03003   abort();
03004 }
03005 
03006 double EvtConExc::getObsXsection(double mhds,int mode){
03007   double hwid=(AA[0]-AA[1])/2.;
03008   double s=_cms*_cms;
03009   int idx=get_mode_index(mode);
03010   double Egam=(s-mhds*mhds)/2/_cms;
03011   for(int i=0;i<600;i++){
03012     if( (AA[i]-hwid)<=Egam && Egam<(AA[i]+hwid) ) return VXS[idx][i];
03013   }
03014 
03015  std:cout<<"EvtConExc::getObsXsection : no observed xs is found "<<endl;
03016   abort();
03017 }
03018 
03019 double EvtConExc::Egam2Mhds(double Egam){
03020   double s=_cms*_cms;
03021   double mhds = sqrt( s - 2*Egam*_cms);
03022   return mhds;
03023 }
03024 
03025 void EvtConExc::writeDecayTabel(){
03026   ofstream oa;
03027   oa.open("_pkhr.dec");
03028   //
03029   int im=getModeIndex(74110);
03030 
03031   double xscon=VXS[im][599];
03032   //std::cout<<"tsize "<<tsize<<" "<<xscon<<" "<<VXS[70][599]<<std::endl;
03033   std::vector<int> Vmode;
03034   Vmode.push_back(6);//1:pi+pi-
03035   Vmode.push_back(13);//2:pi+pi-2pi0
03036   Vmode.push_back(12);//3:2(pi+pi-)
03037   Vmode.push_back(0);//4:ppbar
03038   Vmode.push_back(1);//5:nnbar
03039   Vmode.push_back(45);//6:K+K-
03040   Vmode.push_back(46);//7:K0K0bar
03041   Vmode.push_back(7);//8:pi+pi-pi0
03042   Vmode.push_back(2);//9:Lambda anti-Lambda
03043   std::vector<std::string> vmdl;
03044   vmdl.push_back("PHOKHARA_pipi");
03045   vmdl.push_back("PHOKHARA_pi0pi0pipi");
03046   vmdl.push_back("PHOKHARA_4pi");
03047   vmdl.push_back("PHOKHARA_ppbar");
03048   vmdl.push_back("PHOKHARA_nnbar");
03049   vmdl.push_back("PHOKHARA_KK");
03050   vmdl.push_back("PHOKHARA_K0K0");
03051   vmdl.push_back("PHOKHARA_pipipi0");
03052   vmdl.push_back("PHOKHARA_LLB");
03053 
03054   for(int i=0;i<Vmode.size();i++){
03055     //std::cout<<"i: "<<xscon<<" "<<VXS[Vmode[i]][599]<<std::endl;
03056     xscon -= VXS[ getModeIndex(Vmode[i]) ][599];
03057   }
03058   //debugging
03059   for(int i=0;i<Vmode.size();i++){
03060     //  std::cout<<Vmode[i]<<"-th mode: "<<VXS[getModeIndex(Vmode[i])][599]<<" "<<std::endl;
03061   }  
03062 
03063   oa<<"LundaPar PARJ(11)=0.611798"<<std::endl;
03064   oa<<"LundaPar PARJ(12)=7.92527E-12"<<std::endl;
03065   oa<<"LundaPar PARJ(14)=0.244495"<<std::endl;
03066   oa<<"LundaPar PARJ(15)=1.16573E-15"<<std::endl;
03067   oa<<"LundaPar PARJ(16)=0.436516"<<std::endl;
03068   oa<<"LundaPar PARJ(17)=0.530517"<<std::endl;
03069   oa<<"LundaPar PARJ(1)=0.0651577"<<std::endl;
03070   oa<<"LundaPar PARJ(2)=0.260378"<<std::endl;
03071   oa<<"LundaPar PARJ(21)=0.0664835"<<std::endl;
03072   oa<<"LundaPar RALPA(15)=0.576687"<<std::endl;
03073   oa<<"LundaPar RALPA(16)=0.364796"<<std::endl;
03074   oa<<"LundaPar RALPA(17)=3.19486E-06"<<std::endl;
03075   oa<<"noPhotos"<<std::endl;
03076   oa<<"Particle vpho "<<_cms<<" 0"<<std::endl;
03077   oa<<"Decay vpho"<<std::endl;
03078   oa<<"0  pi+ pi-         PHSP ;"<<std::endl;
03079   oa<<"0  pi0 pi0 pi- pi+ PHSP ;"<<std::endl;
03080   oa<<"0  pi+ pi- pi- pi+ PHSP ;"<<std::endl;
03081   oa<<"0  anti-p- p+      PHSP ;"<<std::endl;
03082   oa<<"0  anti-n0 n0      PHSP ;"<<std::endl;
03083   oa<<"0  K+ K-           PHSP ;"<<std::endl;
03084   oa<<"0  K_S0 K_L0       PHSP ;"<<std::endl;
03085   oa<<"0  pi+ pi- pi0     PHSP ;"<<std::endl;
03086   oa<<"0  Lambda0 anti-Lambda0 PHSP ;"<<std::endl;
03087   oa<<"0  gamma phi      PHSP;"<<std::endl;
03088   oa<<"0  gamma rho0     PHSP;"<<std::endl;
03089   oa<<"0  gamma omega    PHSP;"<<std::endl;
03090   oa<<xscon<<" ConExc 74110;"<<std::endl;
03091   for(int i=0;i<Vmode.size();i++){
03092     oa<<VXS[ getModeIndex(Vmode[i]) ][599]<<" "<<vmdl[i]<<" ;"<<std::endl;
03093   }
03094   oa<<"Enddecay"<<std::endl;
03095   oa<<"End"<<std::endl;
03096 }
03097 
03098 
03099 
03100 void EvtConExc::checkEvtRatio(){
03101   ofstream oa;
03102   oa.open("_evtR.dat");
03103   //
03104   int im=getModeIndex(74110);
03105      double xscon=VXS[im][599];
03106      double xscon0=xscon;
03107   oa<<"Ecms= "<<_cms<<" GeV"<<std::endl;
03108   oa<<"The total observed xs: "<<xscon<<" nb"<<std::endl;
03109   oa<<"=== mode =========== ratio ==========="<<std::endl;
03110   for(int i=0;i<vmode.size();i++){
03111     //std::cout<<"i: "<<xscon<<" "<<VXS[Vmode[i]][599]<<std::endl;
03112       int themode=getModeIndex(vmode[i]);
03113       if(vmode[i]==74110) continue;
03114       xscon -= VXS[themode ][599];
03115      }
03116      if(xscon<0) xscon=0;
03117     //debugging
03118     for(int i=0;i<vmode.size();i++){
03119      int themode=getModeIndex(vmode[i]);
03120      if(vmode[i]==74110) continue;
03121      oa<<vmode[i]<<"-th mode: "<<100*VXS[themode][599]/xscon0<<" % "<<std::endl;
03122     }
03123     oa<<"74110-th mode: "<<100*xscon/xscon0<<" % "<<std::endl;
03124 
03125 
03126 }
03127 
03128 int EvtConExc::getModeIndex(int m){
03129   for (int i=0;i<vmode.size();i++){
03130      if(m==vmode[i]) return i;
03131   }
03132  std::cout<<"EvtConExc::getModeIndex: no index in vmode found "<<std::endl;
03133  abort();
03134 }

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