43#include "CLHEP/Random/RandomEngine.h"
44#include "cfortran/cfortran.h"
53using std::resetiosflags;
54using std::setiosflags;
57int EvtPhokhara::nphokharadecays=0;
59int EvtPhokhara::ntable=0;
61int EvtPhokhara::ncommand=0;
62int EvtPhokhara::lcommand=0;
63std::string* EvtPhokhara::commands=0;
64int EvtPhokhara::nevt=0;
85 sigma = sigma1+sigma2;
86 dsigm = sqrt(dsigm1*dsigm1 + dsigm2*dsigm2);
89 cout <<
"-------------------------------------------------------------" << endl;
90 cout <<
" PHOKHARA 7.0 Final Statistics " << endl;
91 cout <<
"-------------------------------------------------------------" << endl;
92 cout << int(
maxima_.tr[0]+
maxima_.tr[1]) <<
" total events accepted of " << endl;
93 cout << int(ievent) <<
" total events generated" << endl;
94 cout << int(
maxima_.tr[0]) <<
" one photon events accepted of " << endl;
95 cout << int(
maxima_.count[0]) <<
" events generated" << endl;
96 cout << int(
maxima_.tr[1]) <<
" two photon events accepted of " << endl;
97 cout << int(
maxima_.count[1]) <<
" events generated" << endl;
99 if (
flags_.nlo != 0) cout <<
"sigma1(nbarn) = " << sigma1 <<
" +- " << dsigm1 << endl;
100 if (
flags_.nlo != 0) cout <<
"sigma2(nbarn) = " << sigma2 <<
" +- " << dsigm2 << endl;
101 cout <<
"sigma (nbarn) = " << sigma <<
" +- " << dsigm << endl;
103 cout <<
"maximum1 = " <<
maxima_.gross[0] <<
" minimum1 = " <<
maxima_.klein[0] << endl;
104 cout <<
"Mmax1 = " <<
maxima_.Mmax[0] << endl;
105 cout <<
"maximum2 = " <<
maxima_.gross[1] <<
" minimum2 = " <<
maxima_.klein[1] << endl;
106 cout <<
"Mmax2 = " <<
maxima_.Mmax[1] << endl;
107 cout <<
"-------------------------------------------------------------" << endl;
113 if (nphokharadecays==0) {
119 for(i=0;i<nphokharadecays;i++){
120 if (phokharadecays[i]==
this){
121 phokharadecays[i]=phokharadecays[nphokharadecays-1];
123 if (nphokharadecays==0) {
131 report(
ERROR,
"EvtGen") <<
"Error in destroying Phokhara model!"<<endl;
138 model_name=
"PHOKHARA";
162 if(m_pion<0 || m_pion>9){std::cout<<
"mode index for phokhar 0~9, but you give "<<m_pion<<std::endl;abort();}
178 m_q2_min_c = 0.0447 ;
179 m_q2_max_c = m_E*m_E;
186 if(!(m_pion==0 || m_pion==1 || m_pion==6)){m_fsr = 0; m_fsrnlo = 0 ;}
187 if( m_pion==9 ){m_nlo = 0 ;}
189 m_initSeed = 123456789;
197 flags_.FF_pion = m_FF_Pion;
198 flags_.f0_model = m_f0_model;
199 flags_.FF_kaon = m_FF_Kaon;
200 flags_.narr_res = m_NarrowRes;
202 ctes_.Sp = m_E*m_E; ;
205 cuts_.q2min = m_q2min;
206 cuts_.q2_min_c = m_q2_min_c;
207 cuts_.q2_max_c = m_q2_max_c;
209 cuts_.phot1cut = m_phot1cut;
210 cuts_.phot2cut = m_phot2cut;
211 cuts_.pi1cut = m_pi1cut;
212 cuts_.pi2cut = m_pi2cut;
217 cout <<
"-------------------------------------------------------------" << endl;
219 cout <<
" PHOKHARA 7.0 : e^+ e^- -> mu^+ mu^- gamma" << endl;
220 else if (
flags_.pion == 1)
221 cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- gamma" << endl;
222 else if (
flags_.pion == 2)
223 cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- 2pi^0 gamma" << endl;
224 else if (
flags_.pion == 3)
225 cout <<
" PHOKHARA 7.0: e^+ e^- -> 2pi^+ 2pi^- gamma" << endl;
226 else if (
flags_.pion == 4)
227 cout <<
" PHOKHARA 7.0: e^+ e^- -> p pbar gamma" << endl;
228 else if (
flags_.pion == 5)
229 cout <<
" PHOKHARA 7.0: e^+ e^- -> n nbar gamma" << endl;
230 else if (
flags_.pion == 6)
231 cout <<
" PHOKHARA 7.0: e^+ e^- -> K^+ K^- gamma" << endl;
232 else if (
flags_.pion == 7)
233 cout <<
" PHOKHARA 7.0: e^+ e^- -> K_0 K_0bar gamma" << endl;
234 else if (
flags_.pion == 8)
235 cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- pi^0 gamma" << endl;
236 else if (
flags_.pion == 9) {
237 cout <<
"PHOKHARA 7.0 : e^+ e^- ->" << endl;
238 cout <<
" Lambda (-> pi^- p) Lambda bar (-> pi^+ pbar) gamma" << endl;
240 cout <<
" PHOKHARA 7.0: not yet implemented" << endl;
243 cout <<
"--------------------------------------------------------------" << endl;
244 printf(
" %s %f %s\n",
"cms total energy = ",sqrt(
ctes_.Sp),
" GeV ");
247 if(
cuts_.gmin<0.001){
248 cerr <<
" minimal missing energy set too small" << endl;
251 printf(
" %s %f %s\n",
"minimal tagged photon energy = ",
cuts_.gmin,
" GeV ");
252 printf(
" %s %f,%f\n",
"angular cuts on tagged photon = ",
cuts_.phot1cut,
cuts_.phot2cut);
256 printf(
" %s %f,%f\n",
"angular cuts on muons = ",
cuts_.pi1cut,
cuts_.pi2cut);
257 else if (
flags_.pion == 4)
258 printf(
" %s %f,%f\n",
"angular cuts on protons = ",
cuts_.pi1cut,
cuts_.pi2cut);
259 else if (
flags_.pion == 5)
260 printf(
" %s %f,%f\n",
"angular cuts on neutrons = ",
cuts_.pi1cut,
cuts_.pi2cut);
262 printf(
" %s %f,%f\n",
"angular cuts on kaons = ",
cuts_.pi1cut,
cuts_.pi2cut);
263 else if (
flags_.pion == 9)
264 printf(
" %s %f,%f\n",
"angular cuts on pions and protons = ",
cuts_.pi1cut,
cuts_.pi2cut);
266 printf(
" %s %f,%f\n",
"angular cuts on pions = ",
cuts_.pi1cut,
cuts_.pi2cut);
268 printf(
" %s %f %s\n",
"min. muons-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2");
269 else if (
flags_.pion == 4)
270 printf(
" %s %f %s\n",
"min. protons-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
271 else if (
flags_.pion == 5)
272 printf(
" %s %f %s\n",
"min. neutrons-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
274 printf(
" %s %f %s\n",
"min. kaons-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
275 else if (
flags_.pion == 9)
276 printf(
" %s %f %s\n",
" min. lambdas-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
278 printf(
" %s %f %s\n",
"min. pions-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
287 else if (
flags_.pion == 1)
289 else if (
flags_.pion == 2)
291 else if (
flags_.pion == 3)
293 else if (
flags_.pion == 4)
295 else if (
flags_.pion == 5)
297 else if (
flags_.pion == 6)
299 else if (
flags_.pion == 7)
301 else if (
flags_.pion == 8)
303 else if (
flags_.pion == 9)
306 if (
cuts_.q2_max_c < qqmax)
307 qqmax=
cuts_.q2_max_c;
311 qqmin =
cuts_.q2_min_c;
313 cerr <<
"------------------------------" << endl;
314 cerr <<
" Q^2_min TOO SMALL" << endl;
315 cerr <<
" Q^2_min CHANGED BY PHOKHARA = " << qqmin <<
" GeV^2" << endl;
316 cerr <<
"------------------------------" << endl;
320 cerr <<
" Q^2_max to small " << endl;
321 cerr <<
" Q^2_max = " << qqmax << endl;
322 cerr <<
" Q^2_min = " << qqmin << endl;
328 printf(
" %s %f %s\n",
"minimal muon-pair invariant mass^2 = ", qqmin,
" GeV^2");
329 printf(
" %s %f %s\n",
"maximal muon-pair invariant mass^2 = ", qqmax,
" GeV^2");
330 }
else if (
flags_.pion == 1) {
331 printf(
" %s %f %s\n",
"minimal pion-pair invariant mass^2 = ", qqmin,
" GeV^2");
332 printf(
" %s %f %s\n",
"maximal pion-pair invariant mass^2 = ", qqmax,
" GeV^2");
333 }
else if (
flags_.pion == 4) {
334 printf(
" %s %f %s\n",
"minimal proton-pair invariant mass^2 = ", qqmin,
" GeV^2");
335 printf(
" %s %f %s\n",
"maximal proton-pair invariant mass^2 = ", qqmax,
" GeV^2");
336 }
else if (
flags_.pion == 5) {
337 printf(
" %s %f %s\n",
"minimal neutron-pair invariant mass^2 = ", qqmin,
" GeV^2");
338 printf(
" %s %f %s\n",
"maximal neutron-pair invariant mass^2 = ", qqmax,
" GeV^2");
340 printf(
" %s %f %s\n",
"minimal kaon-pair invariant mass^2 = ", qqmin,
" GeV^2");
341 printf(
" %s %f %s\n",
"maximal kaon-pair invariant mass^2 = ", qqmax,
" GeV^2");
342 }
else if(
flags_.pion == 8){
343 printf(
" %s %f %s\n",
"minimal three-pion invariant mass^2 = ", qqmin,
" GeV^2");
344 printf(
" %s %f %s\n",
"maximal three-pion invariant mass^2 = ", qqmax,
" GeV^2");
345 }
else if(
flags_.pion == 9){
346 printf(
" %s %f %s\n",
"minimal lambda-pair invariant mass^2 = ", qqmin,
" GeV^2");
347 printf(
" %s %f %s\n",
"maximal lambda-pair invariant mass^2 = ", qqmax,
" GeV^2");
349 printf(
" %s %f %s\n",
"minimal four-pion invariant mass^2 = ", qqmin,
" GeV^2" );
350 printf(
" %s %f %s\n",
"maximal four-pion invariant mass^2 = ", qqmax,
" GeV^2");
354 cout <<
"Born" << endl;
356 cerr <<
"WRONG FSRNLO flag - only fsrnlo=0 allowed for Born" << endl;
362 cerr <<
"WRONG NLO flag - only Born allowed for Lambdas"<< endl;
363 cerr <<
"If you feel that you need NLO"<< endl;
364 cerr <<
"please contact the authors"<< endl;
368 if (
flags_.nlo == 1) printf(
" %s %f\n",
"NLO: soft photon cutoff w = ",
cuts_.w);
375 cerr <<
"WRONG combination of FSR, FSRNLO flags" <<endl;
380 cout <<
"ISR only" << endl;
382 cout <<
"ISR+FSR" << endl;
383 else if (
flags_.fsr == 2) {
385 cout <<
"ISR+INT+FSR" << endl;
387 cerr <<
"WRONG FSR flag: interference is included only for nlo=0" << endl;
392 cerr <<
"WRONG FSR flag" <<
flags_.fsr << endl;
396 cout <<
"IFSNLO included" << endl;
401 cout <<
"ISR only" << endl;
403 cerr <<
"FSR is implemented only for pi+pi-, mu+mu- and K+K- modes" << endl;
409 cout <<
"Vacuum polarization is NOT included" << endl;}
410 else if(
flags_.ivac == 1){
411 cout <<
"Vacuum polarization by Fred Jegerlehner (http://www-com.physik.hu-berlin.de/fjeger/alphaQEDn.uu)" << endl;}
412 else if(
flags_.ivac == 2){
413 cout <<
"Vacuum polarization (VP_HLMNT_v1_3nonr) by Daisuke Nomura and Thomas Teubner" << endl;}
415 cout <<
"WRONG vacuum polarization switch" << endl;
422 cout <<
"Kuhn-Santamaria PionFormFactor" << endl;
423 else if(
flags_.FF_pion == 1)
424 cout <<
"Gounaris-Sakurai PionFormFactor old" << endl;
425 else if(
flags_.FF_pion == 2)
426 cout <<
"Gounaris-Sakurai PionFormFactor new" << endl;
428 cout <<
"WRONG PionFormFactor switch" << endl;
433 cout <<
"f0+f0(600): K+K- model" << endl;
434 else if(
flags_.f0_model == 1)
435 cout <<
"f0+f0(600): \"no structure\" model" << endl;
436 else if(
flags_.f0_model == 2)
437 cout <<
"NO f0+f0(600)" << endl;
438 else if(
flags_.f0_model == 3)
439 cout <<
"only f0, KLOE: Cesare Bini-private communication" << endl;
441 cout <<
"WRONG f0+f0(600) switch" << endl;
449 cout <<
"constrained KaonFormFactor" << endl;
450 else if(
flags_.FF_kaon == 1) {
451 cout <<
"unconstrained KaonFormFactor" << endl;}
452 else if(
flags_.FF_kaon == 2) {
453 cout <<
"Kuhn-Khodjamirian-Bruch KaonFormFactor" << endl;}
455 cout <<
"WRONG KaonFormFactor switch" << endl;
462 cout <<
"THE NARROW RESONANCE J/PSI INCLUDED" << endl;}
463 else if(
flags_.narr_res == 2){
464 cout <<
"THE NARROW RESONANCE PSI(2S) INCLUDED" << endl;}
465 else if(
flags_.narr_res != 0){
466 cout <<
"wrong flag narr_res: only 0, 1 or 2 allowed" << endl;
471 cout <<
"--------------------------------------------------------------" << endl;
475 for(
int i = 0; i<2; i++)
492 for(
int j = 1; j <= m_nm; j++)
498 GEN_1PH(1,qqmin,qqmax,cos1min,cos1max,cos3min,cos3max);
502 GEN_2PH(1,qqmin,cos1min,cos1max,cos2min,cos2max,cos3min,cos3max);
510 theMmax[m_pion][0]=
maxima_.Mmax[0];
511 theMmax[m_pion][1]=
maxima_.Mmax[1];
545 for(
int i=0;i<=10;i++){ theMmax[i].resize(2); nevtgen[i]=0;}
547 Vfs.push_back(
" mu+mu-");
548 Vfs.push_back(
" pi+pi-");
549 Vfs.push_back(
" 2pi0pi+pi-");
550 Vfs.push_back(
" 2pi+2pi-");
551 Vfs.push_back(
" ppbar");
552 Vfs.push_back(
" nnbar");
553 Vfs.push_back(
" K+K-");
554 Vfs.push_back(
" K0K0bar");
555 Vfs.push_back(
" pi+pi-pi0");
556 Vfs.push_back(
" Lambda Lambdabar");
558 std::string locvp=getenv(
"BESEVTGENROOT");
559 system(
"cat $BESEVTGENROOT/share/phokhara.param>phokhara.param");
564 report(
ERROR,
"EvtGen") <<
"EvtPhokhara finds that you are decaying the"<<endl
565 <<
" aliased particle "
567 <<
" with the Phokhara model"<<endl
568 <<
" this does not work, please modify decay table."
570 report(
ERROR,
"EvtGen") <<
"Will terminate execution!"<<endl;
582 return std::string(
"PhokharaPar");
588 if (ncommand==lcommand){
590 lcommand=10+2*lcommand;
592 std::string* newcommands=
new std::string[lcommand];
596 for(i=0;i<ncommand;i++){
597 newcommands[i]=commands[i];
602 commands=newcommands;
606 commands[ncommand]=cmd;
616 if(p->
getId()!=myvpho) {std::cout<<
"Parent particle is required to be vpho for Phokhara model"<<std::endl;abort();}
620 std::cout<<
"PHOKHARA : "<<Vfs[m_pion]<<
" mode "<<std::endl;
625 tr_old[0] = (int)
maxima_.tr[0];
626 tr_old[1] = (
int)
maxima_.tr[1];
628 while( ntrials < 10000)
636 GEN_1PH(2,qqmin,qqmax,cos1min,cos1max,cos3min,cos3max);
640 GEN_2PH(2,qqmin,cos1min,cos1max,cos2min,cos2max,cos3min,cos3max);
643 if( ((
int)
maxima_.tr[0]+(
int)
maxima_.tr[1]) > (tr_old[0]+tr_old[1]) )
650 std::cout <<
"FATAL: Could not satisfy cuts after " << ntrials <<
"trials. Terminate." <<std::endl;
656 EvtId evtnumstable[100];
793 if(
ctes_.momenta[0][3] != 0 )
802 if(more) {std::cout<<
"Existence of mode "<<channel<<
" in exclusive decay list has the same final state as this one"<<std::endl;abort(); }
808 for(
int i=0;i<numstable;i++){
812 if ( ndaugFound == 0 ) {
813 report(
ERROR,
"EvtGen") <<
"Phokhara has failed to do a decay ";
827 if (nphokharadecays==ntable){
831 for(i=0;i<ntable;i++){
832 newphokharadecays[i]=phokharadecays[i];
835 delete [] phokharadecays;
836 phokharadecays=newphokharadecays;
839 phokharadecays[nphokharadecays++]=jsdecay;
865 if(m_pion<0 || m_pion>9){std::cout<<
"mode index for phokhar 0~9, but you give "<<m_pion<<std::endl;abort();}
881 m_q2_min_c = 0.0447 ;
882 m_q2_max_c = m_E*m_E;
889 if(!(m_pion==0 || m_pion==1 || m_pion==6)){m_fsr = 0; m_fsrnlo = 0 ;}
890 if( m_pion==9 ){m_nlo = 0 ;}
898 flags_.FF_pion = m_FF_Pion;
899 flags_.f0_model = m_f0_model;
900 flags_.FF_kaon = m_FF_Kaon;
901 flags_.narr_res = m_NarrowRes;
903 ctes_.Sp = m_E*m_E; ;
906 cuts_.q2min = m_q2min;
907 cuts_.q2_min_c = m_q2_min_c;
908 cuts_.q2_max_c = m_q2_max_c;
910 cuts_.phot1cut = m_phot1cut;
911 cuts_.phot2cut = m_phot2cut;
912 cuts_.pi1cut = m_pi1cut;
913 cuts_.pi2cut = m_pi2cut;
925 else if (
flags_.pion == 1)
927 else if (
flags_.pion == 2)
929 else if (
flags_.pion == 3)
931 else if (
flags_.pion == 4)
933 else if (
flags_.pion == 5)
935 else if (
flags_.pion == 6)
937 else if (
flags_.pion == 7)
939 else if (
flags_.pion == 8)
941 else if (
flags_.pion == 9)
944 if (
cuts_.q2_max_c < qqmax)
945 qqmax=
cuts_.q2_max_c;
949 qqmin =
cuts_.q2_min_c;
956 for(
int i = 0; i<2; i++)
973 maxima_.Mmax[0] = theMmax[m_pion][0];
974 maxima_.Mmax[1] = theMmax[m_pion][1];
double cos(const BesAngle a)
#define RLXDINIT(LUXURY, SEED)
#define GEN_1PH(I, QQMIN, QQMAX, COS1MIN, COS1MAX, COS3MIN, COS3MAX)
#define GEN_2PH(I, QQMIN, COS1MIN, COS1MAX, COS2MIN, COS2MAX, COS3MIN, COS3MAX)
ostream & report(Severity severity, const char *facility)
void checkNDaug(int d1, int d2=-1)
void checkNArg(int a1, int a2=-1, int a3=-1, int a4=-1)
static int inChannelList(EvtId parent, int ndaug, EvtId *daugs)
static int getStdHep(EvtId id)
static EvtId evtIdFromStdHep(int stdhep)
static std::string name(EvtId i)
static EvtId getId(const std::string &name)
void makeDaughters(int ndaug, EvtId *id)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
EvtParticle * getDaug(int i)
void command(std::string cmd)
void init_mode(EvtParticle *p)
void decay(EvtParticle *p)
std::string commandName()
void init_evt(EvtParticle *p)
void PhokharaInit(int dummy)
void getName(std::string &name)
void set(int i, double d)