00001 #include <sys/stat.h> 00002 #include <stdlib.h> 00003 #include <iostream> 00004 #include <sstream> 00005 #include <fstream> 00006 #include <iomanip> 00007 #include <stdexcept> 00008 00009 #include "TFile.h" 00010 #include "TRandom3.h" 00011 00012 #include "TRadCor.h" 00013 #include "TEPCrossPart.h" 00014 #include "TMuCrossPart.h" 00015 #include "TPiCrossPart.h" 00016 #include "TKnCrossPart.h" 00017 #include "TRadGlobal.h" 00018 #include "TKinemCut.h" 00019 00020 TRadCor *gRad; 00021 TRadGlobal *gGlobal; 00022 TKinemCut *gCut; 00023 TConstants *gConst; 00024 int pid[2]; 00025 extern "C" { 00026 void init_prime_gen_(const int&, const double&, 00027 const double&, const double&); 00028 void makeevent_(double*, int*, int&); 00029 void genfinish_(void); 00030 } 00031 using namespace std; 00032 string RandomFileName; 00033 void init_prime_gen_(const int& proc, const double& EBeam, 00034 const double& te, const double& c){ 00035 cout<<proc<<" "<<EBeam<<" "<<te<<" "<<c<<endl<<flush; 00036 00037 gConst = new TConstants(); 00038 gGlobal = new TRadGlobal(); 00039 gCut = new TKinemCut(); 00040 00041 int NRad = 10000; 00042 int IsHardPhoton = 1; 00043 int IsNoVacPol = 0; 00044 int IsFSR = 1; 00045 RandomFileName = ".random_stat.root"; 00046 double pc = 0.; 00047 double de = -1.; 00048 double nt0 = -1.; 00049 double dt = 0.5; 00050 double dp = 0.3; 00051 double at = c; 00052 double td = c - dt/2; 00053 double am = 90.; 00054 double cm = 90.; 00055 double em = 50.; 00056 double ti = 0.473; 00057 double al = 1.; 00058 double thm = -1.; 00059 double thp = -1.; 00060 double re = 0.05; 00061 00062 if((proc%10)==3){ 00063 td = 0.025; 00064 dt = 10; 00065 dp = 10; 00066 cm = 0; 00067 am = 0; 00068 } 00069 00070 const int MaxList = 20; 00071 bool InList[MaxList]; 00072 for(int j = 0; j<MaxList; j++) InList[j] = true; 00073 00074 if( ( EBeam < 100 || EBeam > 2500 ) && !IsNoVacPol ){ 00075 cerr<<"Invalid value of beam energy:"<<EBeam<<endl; 00076 exit(1); 00077 } 00078 00079 gGlobal->Set_TotalError(te); 00080 00081 gGlobal->Set_RelativeError(re); 00082 00083 gGlobal->Set_Type((proc%10)); 00084 00085 gGlobal->Set_E(EBeam); 00086 00087 gGlobal->Set_ThetaInt(ti); 00088 00089 if(0>td) 00090 gGlobal->Set_ThetaMin(at-dt/2); 00091 else 00092 gGlobal->Set_ThetaMin(td); 00093 00094 if(0>de){ 00095 if((proc%10)==0) 00096 gGlobal->Set_dE_Abs(0.015*EBeam); 00097 else 00098 gGlobal->Set_dE_Abs(0.0003*EBeam); 00099 } 00100 else 00101 gGlobal->Set_dE_Abs(de); 00102 00103 if(0>nt0){ 00104 if(proc>10) 00105 gGlobal->Set_Theta0_Rel(0.0); 00106 else 00107 gGlobal->Set_Theta0_Rel(1.5); 00108 }else 00109 gGlobal->Set_Theta0_Rel(nt0); 00110 00111 if(0<thm){ 00112 gCut->ThetaMinM(thm); 00113 gGlobal->Set_ThetaMin(thm); 00114 } 00115 00116 if(0<thp) 00117 gCut->ThetaMinP(thp); 00118 00119 gCut->CosPsi(cos(pc)); 00120 00121 gCut->DeltaTheta(dt); 00122 00123 gCut->AverageTheta(at); 00124 00125 gCut->DeltaPhi(dp); 00126 00127 gCut->PAverage(am); 00128 00129 gCut->PCross(cm); 00130 00131 gCut->EMin(em); 00132 00133 gConst->SetAlphaScale(al); 00134 00135 gConst->Print(); 00136 00137 try{ 00138 gGlobal->Init(); 00139 }catch(std::logic_error lge){ 00140 cout<<lge.what()<<endl; 00141 exit(-1); 00142 } 00143 gGlobal->Print(); 00144 00145 gCut->Init(); 00146 gCut->Print(); 00147 00148 cout<<"Cross-section statistical precision will be better than " 00149 <<gGlobal->Get_TotalError()<<" nb and " 00150 <<gGlobal->Get_RelativeError()*100<<"%"<<endl; 00151 00152 if(!IsHardPhoton) 00153 cout<<"Hard photon on big angle is not included!"<<endl; 00154 00155 if(IsNoVacPol) 00156 cout<<"Vacuum polarization is not included!"<<endl; 00157 00158 if(!IsFSR) 00159 cout<<"Final state radiation is not included!"<<endl; 00160 00161 if(proc>10) 00162 cout<<"Alpha order generation only!"<<endl; 00163 00164 cout<<flush; 00165 00166 if(gRandom) delete gRandom; 00167 gRandom = new TRandom3(); 00168 struct stat stbuf; 00169 if( stat(RandomFileName.c_str(),&stbuf) == 0 ){ 00170 cout<<"Reading random seed from file \""<<RandomFileName<<"\"."<<endl; 00171 gRandom->ReadRandom(RandomFileName.c_str()); 00172 } 00173 00174 TVCrossPart *MatrixElements; 00175 if(proc==0){ 00176 MatrixElements = new TEPCrossPart(); 00177 InList[18] = false; 00178 } 00179 else if(proc==1) 00180 MatrixElements = new TMuCrossPart(); 00181 else if(proc==2) 00182 MatrixElements = new TPiCrossPart(); 00183 else if(proc==3) 00184 MatrixElements = new TKnCrossPart(); 00185 else if(proc==10){ 00186 MatrixElements = new TEPCrossPart(); 00187 for(int j = 0; j<MaxList; j++) InList[j] = false; 00188 InList[16] = true; 00189 InList[17] = true; 00190 InList[18] = true; 00191 } 00192 else 00193 return; 00194 00195 if(IsNoVacPol) 00196 MatrixElements->SetZeroVP(); 00197 00198 if(!IsFSR) 00199 MatrixElements->SetNoFSR(); 00200 00201 gRad = new TRadCor(MatrixElements); 00202 gRad->SetNEvents(NRad); 00203 gRad->SetPartList(InList); 00204 gRad->Init(); 00205 00206 MatrixElements->SetHardPhoton(IsHardPhoton); 00207 gRad->MakeCrossSection(); 00208 if((proc%10)==2)((TPiCrossPart*)MatrixElements)->GetFormFactor()->Print(); 00209 00210 if((proc%10)==0){ 00211 pid[0] = 3; pid[1] = 2; 00212 } 00213 if((proc%10)==1){ 00214 pid[0] = 6; pid[1] = 5; 00215 } 00216 if((proc%10)==2){ 00217 pid[0] = 9; pid[1] = 8; 00218 } 00219 if((proc%10)==3){ 00220 pid[0] = 10; pid[1] = 16; 00221 } 00222 if((proc%10)==4){ 00223 pid[0] = 12; pid[1] = 11; 00224 } 00225 } 00226 00227 void makeevent_(double *mom, int *part, int &n){ 00228 gRad->MakeEvent(mom, n); 00229 part[0] = pid[0]; 00230 part[1] = pid[1]; 00231 for(int i=2;i<n;i++){ 00232 part[i] = 1; 00233 } 00234 } 00235 00236 void genfinish_(void){ 00237 struct stat stbuf; 00238 if( stat(RandomFileName.c_str(),&stbuf) == 0 ){ 00239 remove(RandomFileName.c_str()); 00240 } 00241 cout<<"Writing random seed to file \""<<RandomFileName<<"\"."<<endl; 00242 gRandom->WriteRandom(RandomFileName.c_str()); 00243 delete gRandom; 00244 }