00001 #include "Phokhara/PhokharaDef.h"
00002
00003 #include <fstream>
00004 #include <iostream>
00005 #include <iomanip>
00006
00007 #include "Phokhara/ranlxd.h"
00008
00009 using namespace std;
00010
00011 PROTOCCALLSFSUB1(RLXDRESETF,rlxdresetf,INTV);
00012 #define RLXDRESETF(SEED) CCALLSFSUB1(RLXDRESETF,rlxdresetf,INTV, SEED)
00013
00014 PROTOCCALLSFSUB3(INPUT,input,PLONG,PINT,PSTRING);
00015 #define INPUT(NGES,NM,OUTFILE) CCALLSFSUB3(INPUT,input,PLONG,PINT,PSTRING,NGES,NM,OUTFILE)
00016
00017 PROTOCCALLSFSUB0(INITHISTO,inithisto);
00018 #define INITHISTO() CCALLSFSUB0(INITHISTO,inithisto)
00019
00020 PROTOCCALLSFSUB0(ENDHISTO,endhisto);
00021 #define ENDHISTO() CCALLSFSUB0(ENDHISTO,endhisto)
00022
00023 PROTOCCALLSFSUB0(WRITEEVENT,writeevent);
00024 #define WRITEEVENT() CCALLSFSUB0(WRITEEVENT,writeevent)
00025
00026 PROTOCCALLSFSUB2(RANLXDF,ranlxdf,DOUBLEV,INT);
00027 #define RANLXDF(AR, VAL) CCALLSFSUB2(RANLXDF,ranlxdf,DOUBLEV, INT, AR, VAL)
00028
00029 PROTOCCALLSFSUB7(GEN_1PH,gen_1ph_,INT, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE);
00030 #define GEN_1PH(I,QQMIN,QQMAX,COS1MIN,COS1MAX,COS3MIN,COS3MAX) CCALLSFSUB7(GEN_1PH,gen_1ph_,INT, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE,I,QQMIN,QQMAX,COS1MIN,COS1MAX,COS3MIN,COS3MAX)
00031
00032 PROTOCCALLSFSUB8(GEN_2PH,gen_2ph_,INT, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE);
00033 #define GEN_2PH(I,QQMIN,COS1MIN,COS1MAX,COS2MIN,COS2MAX,COS3MIN,COS3MAX) CCALLSFSUB8(GEN_2PH,gen_2ph_,INT, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE,I,QQMIN,COS1MIN,COS1MAX,COS2MIN,COS2MAX,COS3MIN,COS3MAX)
00034
00035 int main(){
00036 double qqmin,qqmax;
00037 double cos1min,cos1max,cos2min,cos2max,cos3min,cos3max;
00038 double dsigm1,dsigm2,sigma1,sigma2,sigma,dsigm,Ar[14],Ar_r[14];
00039 int nm,i,s_seed[105];
00040 long int nges,k,j;
00041 char outfile[20];
00042
00043
00044 ifstream seeds("seed.dat");
00045 if( seeds.is_open() )
00046 {
00047 int ii=0;
00048 while( ! seeds.eof() )
00049 seeds >> s_seed[ii++];
00050 }
00051 else
00052 cerr << "Cannot open file seed.dat for reading" << endl;
00053
00054 RLXDRESETF(s_seed);
00055
00056
00057
00058
00059 INPUT(nges, nm, outfile);
00060
00061
00062
00063
00064
00065 cout << "----------------------------------------------------" << FLAGS.pion<< endl;
00066 if (FLAGS.pion == 0)
00067 cout << " PHOKHARA 6.0 : e^+ e^- -> mu^+ mu^- gamma" << endl;
00068 else if (FLAGS.pion == 1)
00069 cout << " PHOKHARA 6.0: e^+ e^- -> pi^+ pi^- gamma" << endl;
00070 else if (FLAGS.pion == 2)
00071 cout << " PHOKHARA 6.0: e^+ e^- -> pi^+ pi^- 2pi^0 gamma" << endl;
00072 else if (FLAGS.pion == 3)
00073 cout << " PHOKHARA 6.0: e^+ e^- -> 2pi^+ 2pi^- gamma" << endl;
00074 else if (FLAGS.pion == 4)
00075 cout << " PHOKHARA 6.0: e^+ e^- -> p pbar gamma" << endl;
00076 else if (FLAGS.pion == 5)
00077 cout << " PHOKHARA 6.0: e^+ e^- -> n nbar gamma" << endl;
00078 else if (FLAGS.pion == 6)
00079 cout << " PHOKHARA 6.0: e^+ e^- -> K^+ K^- gamma" << endl;
00080 else if (FLAGS.pion == 7)
00081 cout << " PHOKHARA 6.0: e^+ e^- -> K_0 K_0bar gamma" << endl;
00082 else if (FLAGS.pion == 8)
00083 cout << " PHOKHARA 6.0: e^+ e^- -> pi^+ pi^- pi^0 gamma" << endl;
00084 else if (FLAGS.pion == 9) {
00085 cout << "PHOKHARA 6.0 : e^+ e^- ->" << endl;
00086 cout << " Lambda (-> pi^- p) Lambda bar (-> pi^+ pbar) gamma" << endl;
00087 } else
00088 cout << " PHOKHARA 6.0: not yet implemented" << endl;
00089
00090
00091 cout << "----------------------------------------------------" << endl;
00092 printf(" %s %f %s\n","cms total energy = ",sqrt(CTES.Sp)," GeV ");
00093 if (FLAGS.tagged == 0) {
00094 if((CUTS.gmin/2.0/CTES.ebeam) < 0.0098){
00095 cerr << " minimal missing energy set to small" << endl;
00096 return 0;
00097 }
00098 printf(" %s %f %s\n","minimal tagged photon energy = ",CUTS.gmin," GeV ");
00099 printf(" %s %f,%f\n","angular cuts on tagged photon = ",CUTS.phot1cut,CUTS.phot2cut);
00100 }
00101 else {
00102 if((CUTS.gmin/2.0/CTES.ebeam) < 0.0098){
00103 cerr << " minimal missing energy set to small" << endl;
00104 return 0;
00105 }
00106 printf(" %s %f %s\n","minimal missing energy = ",CUTS.gmin," GeV ");
00107 printf(" %s %f,%f\n","angular cuts on missing momentum = ",CUTS.phot1cut, CUTS.phot2cut);
00108 }
00109
00110
00111
00112 if (FLAGS.pion == 0)
00113 printf(" %s %f,%f\n","angular cuts on muons = ",CUTS.pi1cut,CUTS.pi2cut);
00114 else if (FLAGS.pion == 4)
00115 printf(" %s %f,%f\n","angular cuts on protons = ",CUTS.pi1cut,CUTS.pi2cut);
00116 else if (FLAGS.pion == 5)
00117 printf(" %s %f,%f\n","angular cuts on neutrons = ", CUTS.pi1cut,CUTS.pi2cut);
00118 else if ((FLAGS.pion == 6)||(FLAGS.pion == 7))
00119 printf(" %s %f,%f\n","angular cuts on kaons = ", CUTS.pi1cut,CUTS.pi2cut);
00120 else if (FLAGS.pion == 9)
00121 printf(" %s %f,%f\n","angular cuts on pions and protons = ", CUTS.pi1cut,CUTS.pi2cut);
00122 else
00123 printf(" %s %f,%f\n","angular cuts on pions = ", CUTS.pi1cut,CUTS.pi2cut);
00124
00125 if (FLAGS.tagged == 0) {
00126 if (FLAGS.pion == 0)
00127 printf(" %s %f %s\n","min. muons-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2");
00128 else if (FLAGS.pion == 4)
00129 printf(" %s %f %s\n","min. protons-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00130 else if (FLAGS.pion == 5)
00131 printf(" %s %f %s\n","min. neutrons-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00132 else if ((FLAGS.pion == 6)||(FLAGS.pion == 7))
00133 printf(" %s %f %s\n","min. kaons-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00134 else if (FLAGS.pion == 9)
00135 printf(" %s %f %s\n"," min. lambdas-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00136 else
00137 printf(" %s %f %s\n","min. pions-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00138 }
00139
00140
00141
00142 INITHISTO();
00143
00144
00145 if (FLAGS.tagged == 0) {
00146 cos1min = cos(CUTS.phot2cut*CTES.pi/180.0);
00147 cos1max = cos(CUTS.phot1cut*CTES.pi/180.0);
00148 } else {
00149 cos1min = -1.0;
00150 cos1max = 1.0;
00151 CUTS.gmin = CUTS.gmin/2.0;
00152 }
00153 cos2min = -1.0;
00154 cos2max = 1.0;
00155 cos3min = -1.0;
00156 cos3max = 1.0;
00157 if (FLAGS.pion == 0)
00158 qqmin = 4.0*CTES.mmu*CTES.mmu;
00159 else if (FLAGS.pion == 1)
00160 qqmin = 4.0*CTES.mpi*CTES.mpi;
00161 else if (FLAGS.pion == 2)
00162 qqmin = 4.0*(CTES.mpi+CTES.mpi0)*(CTES.mpi+CTES.mpi0);
00163 else if (FLAGS.pion == 3)
00164 qqmin = 16.0*CTES.mpi*CTES.mpi;
00165 else if (FLAGS.pion == 4)
00166 qqmin = 4.0*CTES.mp*CTES.mp;
00167 else if (FLAGS.pion == 5)
00168 qqmin = 4.0*CTES.mnt*CTES.mnt;
00169 else if (FLAGS.pion == 6)
00170 qqmin = 4.0*CTES.mKp*CTES.mKp;
00171 else if (FLAGS.pion == 7)
00172 qqmin = 4.0*CTES.mKn*CTES.mKn;
00173 else if (FLAGS.pion == 8)
00174 qqmin = (2.0*CTES.mpi+CTES.mpi0)*(2.0*CTES.mpi+CTES.mpi0);
00175 else if (FLAGS.pion == 9)
00176 qqmin = 4.0*CTES.mlamb*CTES.mlamb;
00177
00178
00179
00180 qqmax = CTES.Sp-2.0*sqrt(CTES.Sp)*CUTS.gmin;
00181 if (CUTS.q2_max_c < qqmax)
00182 qqmax=CUTS.q2_max_c;
00183
00184
00185 if ( (CUTS.q2_min_c > qqmin) && (CUTS.q2_min_c < (CTES.Sp*(1.0-2.0*(CUTS.gmin/sqrt(CTES.Sp)+CUTS.w))) ) )
00186 qqmin = CUTS.q2_min_c;
00187 else {
00188 cerr << "------------------------------" << endl;
00189 cerr << " Q^2_min TOO SMALL" << endl;
00190 cerr << " Q^2_min CHANGE BY PHOKHARA = " << qqmin << " GeV^2" << endl;
00191 cerr << "------------------------------" << endl;
00192 }
00193
00194 if(qqmax <= qqmin){
00195 cerr << " Q^2_max to small " << endl;
00196 cerr << " Q^2_max = " << qqmax << endl;
00197 cerr << " Q^2_min = " << qqmin << endl;
00198 return 0;
00199 }
00200
00201
00202 if (FLAGS.pion == 0) {
00203 printf(" %s %f %s\n", "minimal muon-pair invariant mass^2 = ", qqmin," GeV^2");
00204 printf(" %s %f %s\n", "maximal muon-pair invariant mass^2 = ", qqmax," GeV^2");
00205 } else if (FLAGS.pion == 1) {
00206 printf(" %s %f %s\n", "minimal pion-pair invariant mass^2 = ", qqmin," GeV^2");
00207 printf(" %s %f %s\n", "maximal pion-pair invariant mass^2 = ", qqmax," GeV^2");
00208 } else if (FLAGS.pion == 4) {
00209 printf(" %s %f %s\n", "minimal proton-pair invariant mass^2 = ", qqmin," GeV^2");
00210 printf(" %s %f %s\n", "maximal proton-pair invariant mass^2 = ", qqmax," GeV^2");
00211 } else if (FLAGS.pion == 5) {
00212 printf(" %s %f %s\n", "minimal neutron-pair invariant mass^2 = ", qqmin," GeV^2");
00213 printf(" %s %f %s\n", "maximal neutron-pair invariant mass^2 = ", qqmax," GeV^2");
00214 } else if ((FLAGS.pion == 6) || (FLAGS.pion == 7)) {
00215 printf(" %s %f %s\n", "minimal kaon-pair invariant mass^2 = ", qqmin," GeV^2");
00216 printf(" %s %f %s\n", "maximal kaon-pair invariant mass^2 = ", qqmax," GeV^2");
00217 } else if(FLAGS.pion == 8){
00218 printf(" %s %f %s\n", "minimal three-pion invariant mass^2 = ", qqmin," GeV^2");
00219 printf(" %s %f %s\n", "maximal three-pion invariant mass^2 = ", qqmax," GeV^2");
00220 } else if(FLAGS.pion == 9){
00221 printf(" %s %f %s\n", "minimal lambda-pair invariant mass^2 = ", qqmin," GeV^2");
00222 printf(" %s %f %s\n", "maximal lambda-pair invariant mass^2 = ", qqmax," GeV^2");
00223 } else {
00224 printf(" %s %f %s\n", "minimal four-pion invariant mass^2 = ", qqmin," GeV^2" );
00225 printf(" %s %f %s\n", "maximal four-pion invariant mass^2 = ", qqmax," GeV^2");
00226 }
00227
00228 if (FLAGS.nlo == 0) {
00229 cout << "Born" << endl;
00230 if(FLAGS.fsrnlo != 0){
00231 cerr << "WRONG FSRNLO flag - only fsrnlo=0 allowed for Born" << endl;
00232 return 0;
00233 }
00234 }
00235
00236 if((FLAGS.pion == 9) && (FLAGS.nlo != 0)) {
00237 cerr << "WRONG NLO flag - only Born allowed for Lambdas"<< endl;
00238 cerr << "If you feel that you need NLO"<< endl;
00239 cerr << "please contact the authors"<< endl;
00240 return 0;
00241 }
00242
00243 if (FLAGS.nlo == 1) printf(" %s %f\n", "NLO: soft photon cutoff w = ",CUTS.w);
00244 if ((FLAGS.pion <= 1) || (FLAGS.pion == 6))
00245 {
00246
00247 if( ! ((FLAGS.fsr == 1) || (FLAGS.fsr == 2) || (FLAGS.fsrnlo == 0)
00248 || (FLAGS.fsr == 1) || (FLAGS.fsrnlo == 1)
00249 || (FLAGS.fsr == 0) || (FLAGS.fsrnlo == 0))) {
00250 cerr << "WRONG combination of FSR, FSRNLO flags" <<endl;
00251 return 0;
00252 }
00253
00254
00255 if (FLAGS.fsr == 0)
00256 cout << "ISR only" << endl;
00257 else if (FLAGS.fsr == 1)
00258 cout << "ISR+FSR" << endl;
00259 else if (FLAGS.fsr == 2) {
00260 if (FLAGS.nlo == 0)
00261 cout << "ISR+INT+FSR" << endl;
00262 else {
00263 cerr << "WRONG FSR flag: interference is included only for nlo=0" << endl;
00264 return 0;
00265 }
00266 }
00267 else {
00268 cerr << "WRONG FSR flag" << FLAGS.fsr << endl;
00269 return 0;
00270 }
00271
00272 if(FLAGS.fsrnlo == 1)
00273 cout << "IFSNLO included" << endl;
00274 }
00275 else
00276 {
00277 if((FLAGS.fsr == 0) && (FLAGS.fsrnlo == 0))
00278 cout << "ISR only" << endl;
00279 else {
00280 cerr << "FSR is implemented only for pi+pi-, mu+mu- and K+K- modes" << endl;
00281 return 0;
00282 }
00283 }
00284
00285
00286 if(FLAGS.ivac == 0){
00287 cout << "Vacuum polarization is NOT included" << endl;
00288 } else if(FLAGS.ivac == 1){
00289 cout << "Vacuum polarization is included" << endl;
00290 } else {
00291 cout << "WRONG vacuum polarization switch" << endl;
00292 return 0;
00293 }
00294
00295 if(FLAGS.pion == 1){
00296 if(FLAGS.FF_pion == 0)
00297 cout << "Kuhn-Santamaria PionFormFactor" << endl;
00298 else if(FLAGS.FF_pion == 1)
00299 cout << "Gounaris-Sakurai PionFormFactor" << endl;
00300 else {
00301 cout << "WRONG PionFormFactor switch" << endl;
00302 return 0;
00303 }
00304
00305 if(FLAGS.fsr != 0){
00306 if(FLAGS.f0_model == 0)
00307 cout << "f0+f0(600): K+K- model" << endl;
00308 else if(FLAGS.f0_model == 1)
00309 cout << "f0+f0(600): \"no structure\" model" << endl;
00310 else if(FLAGS.f0_model == 2)
00311 cout << "NO f0+f0(600)" << endl;
00312 else if(FLAGS.f0_model == 3)
00313 cout << "only f0, KLOE: Cesare Bini-private communication" << endl;
00314 else {
00315 cout << "WRONG f0+f0(600) switch" << endl;
00316 return 0;
00317 }
00318 }
00319 }
00320
00321
00322
00323 k = nm;
00324 for( i = 0; i<2; i++)
00325 {
00326 MAXIMA.Mmax[i] = 1.0;
00327 MAXIMA.gross[i] = 0.0;
00328 MAXIMA.klein[i] = 0.0;
00329 }
00330 if (FLAGS.nlo == 0)
00331 MAXIMA.Mmax[1]=0.0;
00332
00333 for( i = 1; i<=2; i++) {
00334 MAXIMA.tr[0] = 0.0;
00335 MAXIMA.tr[1] = 0.0;
00336 MAXIMA.count[0] = 0.0;
00337 MAXIMA.count[1] = 0.0;
00338
00339
00340
00341 for(j = 1; j <= k; j++)
00342 {
00343 RANLXDF(Ar_r,1);
00344 Ar[1] = Ar_r[0];
00345
00346 if (Ar[1] <= (MAXIMA.Mmax[0]/(MAXIMA.Mmax[0]+MAXIMA.Mmax[1]))) {
00347 MAXIMA.count[0] = MAXIMA.count[0]+1.0;
00348 GEN_1PH(i,qqmin,qqmax,cos1min,cos1max,cos3min,cos3max);
00349 }
00350 else {
00351 MAXIMA.count[1] = MAXIMA.count[1]+1.0;
00352 GEN_2PH(i,qqmin,cos1min,cos1max,cos2min,cos2max,cos3min,cos3max);
00353 }
00354 }
00355
00356
00357
00358 k = nges;
00359 if (i == 1) {
00360 MAXIMA.Mmax[0] = MAXIMA.gross[0]+.05*sqrt(MAXIMA.gross[0]*MAXIMA.gross[0]);
00361 MAXIMA.Mmax[1] = MAXIMA.gross[1]+(.03+.02*CTES.Sp)*sqrt(MAXIMA.gross[1]*MAXIMA.gross[1]);
00362
00363 if((FLAGS.pion == 1) && (FLAGS.fsrnlo == 1))
00364 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.5;
00365 if((FLAGS.pion == 0) && (FLAGS.fsrnlo == 1))
00366 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.5;
00367
00368 if((FLAGS.pion == 0) && (FLAGS.fsr == 1) && (FLAGS.fsrnlo == 0))
00369 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.2;
00370
00371 if((FLAGS.pion == 2) || (FLAGS.pion == 3)){
00372 MAXIMA.Mmax[0]=MAXIMA.Mmax[0]*1.1;
00373 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.1;
00374 }
00375
00376 if(FLAGS.pion == 8){
00377 MAXIMA.Mmax[0]=MAXIMA.Mmax[0]*1.08;
00378 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.1;
00379 }
00380 }
00381 }
00382
00383
00384
00385 if(FLAGS.pion == 9)
00386 MAXIMA.Mmax[1] = MAXIMA.Mmax[1] * (1.0 + LAMBDA_PAR.alpha_lamb)*(1.0 + LAMBDA_PAR.alpha_lamb)
00387 * LAMBDA_PAR.ratio_lamb*LAMBDA_PAR.ratio_lamb;
00388
00389
00390
00391 ENDHISTO();
00392
00393
00394 if (FLAGS.nlo == 0) {
00395 sigma = MAXIMA.Mmax[0]/MAXIMA.count[0]*MAXIMA.tr[0];
00396 dsigm = MAXIMA.Mmax[0]*sqrt((MAXIMA.tr[0]/MAXIMA.count[0]-(MAXIMA.tr[0]/MAXIMA.count[0])*(MAXIMA.tr[0]/MAXIMA.count[0]))/MAXIMA.count[0]);
00397 } else {
00398 sigma1 = MAXIMA.Mmax[0]/MAXIMA.count[0]*MAXIMA.tr[0];
00399 sigma2 = MAXIMA.Mmax[1]/MAXIMA.count[1]*MAXIMA.tr[1];
00400 dsigm1 = MAXIMA.Mmax[0]*sqrt((MAXIMA.tr[0]/MAXIMA.count[0]-(MAXIMA.tr[0]/MAXIMA.count[0])*(MAXIMA.tr[0]/MAXIMA.count[0]))/MAXIMA.count[0]);
00401 dsigm2 = MAXIMA.Mmax[1]*sqrt((MAXIMA.tr[1]/MAXIMA.count[1]-(MAXIMA.tr[1]/MAXIMA.count[1])*(MAXIMA.tr[1]/MAXIMA.count[1]))/MAXIMA.count[1]);
00402
00403 sigma = sigma1+sigma2;
00404 dsigm = sqrt(dsigm1*dsigm1 + dsigm2*dsigm2);
00405 }
00406
00407
00408 cout << "----------------------------------------------------" << endl;
00409 cout << int(MAXIMA.tr[0]+MAXIMA.tr[1]) << " total events accepted of " << endl;
00410 cout << int(nges) << " total events generated" << endl;
00411 cout << int(MAXIMA.tr[0]) << " one photon events accepted of " << endl;
00412 cout << int(MAXIMA.count[0]) << " events generated" << endl;
00413 cout << int(MAXIMA.tr[1]) << " two photon events accepted of " << endl;
00414 cout << int(MAXIMA.count[1]) << " events generated" << endl;
00415 cout << endl;
00416 if (FLAGS.nlo != 0) cout << "sigma1(nbarn) = " << sigma1 << " +- " << dsigm1 << endl;
00417 if (FLAGS.nlo != 0) cout << "sigma2(nbarn) = " << sigma2 << " +- " << dsigm2 << endl;
00418 cout << "sigma (nbarn) = " << sigma << " +- " <<dsigm << endl;
00419 cout << endl;
00420 cout << "maximum1 = " << MAXIMA.gross[0] << " minimum1 = " << MAXIMA.klein[0] << endl;
00421 cout << "Mmax1 = " << MAXIMA.Mmax[0] << endl;
00422 cout << "maximum2 = " << MAXIMA.gross[1] << " minimum2 = " << MAXIMA.klein[1] << endl;
00423 cout << "Mmax2 = " << MAXIMA.Mmax[1] << endl;
00424 cout << "----------------------------------------------------" << endl;
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437 return 0;
00438 }