40#include "BesRndmGenSvc/IBesRndmGenSvc.h"
41#include "CLHEP/Random/RandomEngine.h"
42#include "GeneratorObject/McGenEvent.h"
43#include "cfortran/cfortran.h"
52using std::resetiosflags;
53using std::setiosflags;
56int EvtPhokhara::nphokharadecays = 0;
58int EvtPhokhara::ntable = 0;
60int EvtPhokhara::ncommand = 0;
61int EvtPhokhara::lcommand = 0;
62std::string* EvtPhokhara::commands = 0;
63int EvtPhokhara::nevt = 0;
100 sigma = sigma1 + sigma2;
101 dsigm = sqrt( dsigm1 * dsigm1 + dsigm2 * dsigm2 );
104 cout <<
"-------------------------------------------------------------" << endl;
105 cout <<
" PHOKHARA 7.0 Final Statistics " << endl;
106 cout <<
"-------------------------------------------------------------" << endl;
107 cout << int(
maxima_.tr[0] +
maxima_.tr[1] ) <<
" total events accepted of " << endl;
108 cout << int( ievent ) <<
" total events generated" << endl;
109 cout << int(
maxima_.tr[0] ) <<
" one photon events accepted of " << endl;
110 cout << int(
maxima_.count[0] ) <<
" events generated" << endl;
111 cout << int(
maxima_.tr[1] ) <<
" two photon events accepted of " << endl;
112 cout << int(
maxima_.count[1] ) <<
" events generated" << endl;
114 if (
flags_.nlo != 0 ) cout <<
"sigma1(nbarn) = " << sigma1 <<
" +- " << dsigm1 << endl;
115 if (
flags_.nlo != 0 ) cout <<
"sigma2(nbarn) = " << sigma2 <<
" +- " << dsigm2 << endl;
116 cout <<
"sigma (nbarn) = " << sigma <<
" +- " << dsigm << endl;
118 cout <<
"maximum1 = " <<
maxima_.gross[0] <<
" minimum1 = " <<
maxima_.klein[0] << endl;
119 cout <<
"Mmax1 = " <<
maxima_.Mmax[0] << endl;
120 cout <<
"maximum2 = " <<
maxima_.gross[1] <<
" minimum2 = " <<
maxima_.klein[1] << endl;
121 cout <<
"Mmax2 = " <<
maxima_.Mmax[1] << endl;
122 cout <<
"-------------------------------------------------------------" << endl;
127 if ( nphokharadecays == 0 )
134 for ( i = 0; i < nphokharadecays; i++ )
136 if ( phokharadecays[i] ==
this )
138 phokharadecays[i] = phokharadecays[nphokharadecays - 1];
140 if ( nphokharadecays == 0 )
149 report(
ERROR,
"EvtGen" ) <<
"Error in destroying Phokhara model!" << endl;
164 if ( m_pion < 0 || m_pion > 9 )
166 std::cout <<
"mode index for phokhar 0~9, but you give " << m_pion << std::endl;
185 m_q2_max_c = m_E * m_E;
192 if ( !( m_pion == 0 || m_pion == 1 || m_pion == 6 ) )
197 if ( m_pion == 9 ) { m_nlo = 0; }
199 m_initSeed = 123456789;
207 flags_.FF_pion = m_FF_Pion;
208 flags_.f0_model = m_f0_model;
209 flags_.FF_kaon = m_FF_Kaon;
210 flags_.narr_res = m_NarrowRes;
212 ctes_.Sp = m_E * m_E;
216 cuts_.q2min = m_q2min;
217 cuts_.q2_min_c = m_q2_min_c;
218 cuts_.q2_max_c = m_q2_max_c;
220 cuts_.phot1cut = m_phot1cut;
221 cuts_.phot2cut = m_phot2cut;
222 cuts_.pi1cut = m_pi1cut;
223 cuts_.pi2cut = m_pi2cut;
228 cout <<
"-------------------------------------------------------------" << endl;
229 if (
flags_.pion == 0 ) cout <<
" PHOKHARA 7.0 : e^+ e^- -> mu^+ mu^- gamma" << endl;
230 else if (
flags_.pion == 1 ) cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- gamma" << endl;
231 else if (
flags_.pion == 2 )
232 cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- 2pi^0 gamma" << endl;
233 else if (
flags_.pion == 3 ) cout <<
" PHOKHARA 7.0: e^+ e^- -> 2pi^+ 2pi^- gamma" << endl;
234 else if (
flags_.pion == 4 ) cout <<
" PHOKHARA 7.0: e^+ e^- -> p pbar gamma" << endl;
235 else if (
flags_.pion == 5 ) cout <<
" PHOKHARA 7.0: e^+ e^- -> n nbar gamma" << endl;
236 else if (
flags_.pion == 6 ) cout <<
" PHOKHARA 7.0: e^+ e^- -> K^+ K^- gamma" << endl;
237 else if (
flags_.pion == 7 ) cout <<
" PHOKHARA 7.0: e^+ e^- -> K_0 K_0bar gamma" << endl;
238 else if (
flags_.pion == 8 )
239 cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- pi^0 gamma" << endl;
240 else if (
flags_.pion == 9 )
242 cout <<
"PHOKHARA 7.0 : e^+ e^- ->" << endl;
243 cout <<
" Lambda (-> pi^- p) Lambda bar (-> pi^+ pbar) gamma" << endl;
245 else cout <<
" PHOKHARA 7.0: not yet implemented" << endl;
248 cout <<
"--------------------------------------------------------------" << endl;
249 printf(
" %s %f %s\n",
"cms total energy = ", sqrt(
ctes_.Sp ),
253 if (
cuts_.gmin < 0.001 )
255 cerr <<
" minimal missing energy set too small" << endl;
258 printf(
" %s %f %s\n",
"minimal tagged photon energy = ",
cuts_.gmin,
" GeV " );
259 printf(
" %s %f,%f\n",
"angular cuts on tagged photon = ",
cuts_.phot1cut,
264 printf(
" %s %f,%f\n",
"angular cuts on muons = ",
cuts_.pi1cut,
266 else if (
flags_.pion == 4 )
267 printf(
" %s %f,%f\n",
"angular cuts on protons = ",
cuts_.pi1cut,
269 else if (
flags_.pion == 5 )
270 printf(
" %s %f,%f\n",
"angular cuts on neutrons = ",
cuts_.pi1cut,
272 else if ( (
flags_.pion == 6 ) || (
flags_.pion == 7 ) )
273 printf(
" %s %f,%f\n",
"angular cuts on kaons = ",
cuts_.pi1cut,
275 else if (
flags_.pion == 9 )
276 printf(
" %s %f,%f\n",
"angular cuts on pions and protons = ",
cuts_.pi1cut,
279 printf(
" %s %f,%f\n",
"angular cuts on pions = ",
cuts_.pi1cut,
282 printf(
" %s %f %s\n",
"min. muons-tagged photon inv.mass^2 = ",
cuts_.q2min,
284 else if (
flags_.pion == 4 )
285 printf(
" %s %f %s\n",
"min. protons-tagged photon inv.mass^2 = ",
cuts_.q2min,
287 else if (
flags_.pion == 5 )
288 printf(
" %s %f %s\n",
"min. neutrons-tagged photon inv.mass^2 = ",
cuts_.q2min,
290 else if ( (
flags_.pion == 6 ) || (
flags_.pion == 7 ) )
291 printf(
" %s %f %s\n",
"min. kaons-tagged photon inv.mass^2 = ",
cuts_.q2min,
293 else if (
flags_.pion == 9 )
294 printf(
" %s %f %s\n",
" min. lambdas-tagged photon inv.mass^2 = ",
cuts_.q2min,
297 printf(
" %s %f %s\n",
"min. pions-tagged photon inv.mass^2 = ",
cuts_.q2min,
308 else if (
flags_.pion == 2 )
315 else if (
flags_.pion == 8 )
319 if (
cuts_.q2_max_c < qqmax ) qqmax =
cuts_.q2_max_c;
322 if ( (
cuts_.q2_min_c > qqmin ) &&
325 qqmin =
cuts_.q2_min_c;
328 cerr <<
"------------------------------" << endl;
329 cerr <<
" Q^2_min TOO SMALL" << endl;
330 cerr <<
" Q^2_min CHANGED BY PHOKHARA = " << qqmin <<
" GeV^2" << endl;
331 cerr <<
"------------------------------" << endl;
334 if ( qqmax <= qqmin )
336 cerr <<
" Q^2_max to small " << endl;
337 cerr <<
" Q^2_max = " << qqmax << endl;
338 cerr <<
" Q^2_min = " << qqmin << endl;
345 printf(
" %s %f %s\n",
"minimal muon-pair invariant mass^2 = ", qqmin,
" GeV^2" );
346 printf(
" %s %f %s\n",
"maximal muon-pair invariant mass^2 = ", qqmax,
" GeV^2" );
348 else if (
flags_.pion == 1 )
350 printf(
" %s %f %s\n",
"minimal pion-pair invariant mass^2 = ", qqmin,
" GeV^2" );
351 printf(
" %s %f %s\n",
"maximal pion-pair invariant mass^2 = ", qqmax,
" GeV^2" );
353 else if (
flags_.pion == 4 )
355 printf(
" %s %f %s\n",
"minimal proton-pair invariant mass^2 = ", qqmin,
" GeV^2" );
356 printf(
" %s %f %s\n",
"maximal proton-pair invariant mass^2 = ", qqmax,
" GeV^2" );
358 else if (
flags_.pion == 5 )
360 printf(
" %s %f %s\n",
"minimal neutron-pair invariant mass^2 = ", qqmin,
" GeV^2" );
361 printf(
" %s %f %s\n",
"maximal neutron-pair invariant mass^2 = ", qqmax,
" GeV^2" );
363 else if ( (
flags_.pion == 6 ) || (
flags_.pion == 7 ) )
365 printf(
" %s %f %s\n",
"minimal kaon-pair invariant mass^2 = ", qqmin,
" GeV^2" );
366 printf(
" %s %f %s\n",
"maximal kaon-pair invariant mass^2 = ", qqmax,
" GeV^2" );
368 else if (
flags_.pion == 8 )
370 printf(
" %s %f %s\n",
"minimal three-pion invariant mass^2 = ", qqmin,
" GeV^2" );
371 printf(
" %s %f %s\n",
"maximal three-pion invariant mass^2 = ", qqmax,
" GeV^2" );
373 else if (
flags_.pion == 9 )
375 printf(
" %s %f %s\n",
"minimal lambda-pair invariant mass^2 = ", qqmin,
" GeV^2" );
376 printf(
" %s %f %s\n",
"maximal lambda-pair invariant mass^2 = ", qqmax,
" GeV^2" );
380 printf(
" %s %f %s\n",
"minimal four-pion invariant mass^2 = ", qqmin,
" GeV^2" );
381 printf(
" %s %f %s\n",
"maximal four-pion invariant mass^2 = ", qqmax,
" GeV^2" );
386 cout <<
"Born" << endl;
389 cerr <<
"WRONG FSRNLO flag - only fsrnlo=0 allowed for Born" << endl;
396 cerr <<
"WRONG NLO flag - only Born allowed for Lambdas" << endl;
397 cerr <<
"If you feel that you need NLO" << endl;
398 cerr <<
"please contact the authors" << endl;
403 printf(
" %s %f\n",
"NLO: soft photon cutoff w = ",
cuts_.w );
409 (
flags_.fsrnlo == 0 ) ) )
411 cerr <<
"WRONG combination of FSR, FSRNLO flags" << endl;
415 if (
flags_.fsr == 0 ) cout <<
"ISR only" << endl;
416 else if (
flags_.fsr == 1 ) cout <<
"ISR+FSR" << endl;
417 else if (
flags_.fsr == 2 )
419 if (
flags_.nlo == 0 ) cout <<
"ISR+INT+FSR" << endl;
422 cerr <<
"WRONG FSR flag: interference is included only for nlo=0" << endl;
428 cerr <<
"WRONG FSR flag" <<
flags_.fsr << endl;
431 if (
flags_.fsrnlo == 1 ) cout <<
"IFSNLO included" << endl;
435 if ( (
flags_.fsr == 0 ) && (
flags_.fsrnlo == 0 ) ) cout <<
"ISR only" << endl;
438 cerr <<
"FSR is implemented only for pi+pi-, mu+mu- and K+K- modes" << endl;
443 if (
flags_.ivac == 0 ) { cout <<
"Vacuum polarization is NOT included" << endl; }
444 else if (
flags_.ivac == 1 )
446 cout <<
"Vacuum polarization by Fred Jegerlehner "
447 "(http://www-com.physik.hu-berlin.de/fjeger/alphaQEDn.uu)"
450 else if (
flags_.ivac == 2 )
452 cout <<
"Vacuum polarization (VP_HLMNT_v1_3nonr) by Daisuke Nomura and Thomas Teubner"
457 cout <<
"WRONG vacuum polarization switch" << endl;
464 if (
flags_.FF_pion == 0 ) cout <<
"Kuhn-Santamaria PionFormFactor" << endl;
465 else if (
flags_.FF_pion == 1 ) cout <<
"Gounaris-Sakurai PionFormFactor old" << endl;
466 else if (
flags_.FF_pion == 2 ) cout <<
"Gounaris-Sakurai PionFormFactor new" << endl;
469 cout <<
"WRONG PionFormFactor switch" << endl;
474 if (
flags_.f0_model == 0 ) cout <<
"f0+f0(600): K+K- model" << endl;
475 else if (
flags_.f0_model == 1 ) cout <<
"f0+f0(600): \"no structure\" model" << endl;
476 else if (
flags_.f0_model == 2 ) cout <<
"NO f0+f0(600)" << endl;
477 else if (
flags_.f0_model == 3 )
478 cout <<
"only f0, KLOE: Cesare Bini-private communication" << endl;
481 cout <<
"WRONG f0+f0(600) switch" << endl;
489 if (
flags_.FF_kaon == 0 ) cout <<
"constrained KaonFormFactor" << endl;
490 else if (
flags_.FF_kaon == 1 ) { cout <<
"unconstrained KaonFormFactor" << endl; }
491 else if (
flags_.FF_kaon == 2 )
492 { cout <<
"Kuhn-Khodjamirian-Bruch KaonFormFactor" << endl; }
495 cout <<
"WRONG KaonFormFactor switch" << endl;
503 if (
flags_.narr_res == 1 ) { cout <<
"THE NARROW RESONANCE J/PSI INCLUDED" << endl; }
504 else if (
flags_.narr_res == 2 )
505 { cout <<
"THE NARROW RESONANCE PSI(2S) INCLUDED" << endl; }
506 else if (
flags_.narr_res != 0 )
508 cout <<
"wrong flag narr_res: only 0, 1 or 2 allowed" << endl;
513 cout <<
"--------------------------------------------------------------" << endl;
517 for (
int i = 0; i < 2; i++ )
533 for (
int j = 1; j <= m_nm; j++ )
540 GEN_1PH( 1, qqmin, qqmax, cos1min, cos1max, cos3min, cos3max );
545 GEN_2PH( 1, qqmin, cos1min, cos1max, cos2min, cos2max, cos3min, cos3max );
554 theMmax[m_pion][0] =
maxima_.Mmax[0];
555 theMmax[m_pion][1] =
maxima_.Mmax[1];
587 nevtgen.resize( 10 );
588 theMmax.resize( 10 );
589 for (
int i = 0; i <= 10; i++ )
591 theMmax[i].resize( 2 );
595 Vfs.push_back(
" mu+mu-" );
596 Vfs.push_back(
" pi+pi-" );
597 Vfs.push_back(
" 2pi0pi+pi-" );
598 Vfs.push_back(
" 2pi+2pi-" );
599 Vfs.push_back(
" ppbar" );
600 Vfs.push_back(
" nnbar" );
601 Vfs.push_back(
" K+K-" );
602 Vfs.push_back(
" K0K0bar" );
603 Vfs.push_back(
" pi+pi-pi0" );
604 Vfs.push_back(
" Lambda Lambdabar" );
606 std::string locvp = getenv(
"BESEVTGENROOT" );
607 system(
"cat $BESEVTGENROOT/share/phokhara.param>phokhara.param" );
612 report(
ERROR,
"EvtGen" ) <<
"EvtPhokhara finds that you are decaying the" << endl
614 <<
" with the Phokhara model" << endl
615 <<
" this does not work, please modify decay table." << endl;
616 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
627 if ( ncommand == lcommand )
630 lcommand = 10 + 2 * lcommand;
632 std::string* newcommands =
new std::string[lcommand];
636 for ( i = 0; i < ncommand; i++ ) { newcommands[i] = commands[i]; }
640 commands = newcommands;
643 commands[ncommand] = cmd;
650 if ( p->
getId() != myvpho )
652 std::cout <<
"Parent particle is required to be vpho for Phokhara model" << std::endl;
656 if ( nevtgen[m_pion] == 0 ) {
init_mode( p ); }
658 std::cout <<
"PHOKHARA : " << Vfs[m_pion] <<
" mode " << std::endl;
663 tr_old[0] = (int)
maxima_.tr[0];
664 tr_old[1] = (int)
maxima_.tr[1];
666 while ( ntrials < 10000 )
675 GEN_1PH( 2, qqmin, qqmax, cos1min, cos1max, cos3min, cos3max );
680 GEN_2PH( 2, qqmin, cos1min, cos1max, cos2min, cos2max, cos3min, cos3max );
684 ( tr_old[0] + tr_old[1] ) )
685 {
goto storedEvents; }
689 std::cout <<
"FATAL: Could not satisfy cuts after " << ntrials <<
"trials. Terminate."
696 EvtId evtnumstable[100];
705 ctes_.momenta[3][5] );
710 ctes_.momenta[3][6] );
718 ctes_.momenta[3][5] );
723 ctes_.momenta[3][6] );
731 ctes_.momenta[3][5] );
736 ctes_.momenta[3][6] );
741 ctes_.momenta[3][7] );
746 ctes_.momenta[3][8] );
754 ctes_.momenta[3][5] );
759 ctes_.momenta[3][6] );
764 ctes_.momenta[3][7] );
769 ctes_.momenta[3][8] );
777 ctes_.momenta[3][5] );
782 ctes_.momenta[3][6] );
790 ctes_.momenta[3][5] );
795 ctes_.momenta[3][6] );
803 ctes_.momenta[3][5] );
808 ctes_.momenta[3][6] );
816 ctes_.momenta[3][5] );
821 ctes_.momenta[3][6] );
829 ctes_.momenta[3][5] );
834 ctes_.momenta[3][6] );
839 ctes_.momenta[3][7] );
847 ctes_.momenta[3][7] );
852 ctes_.momenta[3][8] );
857 ctes_.momenta[3][9] );
862 ctes_.momenta[3][10] );
869 ctes_.momenta[3][2] );
871 if (
ctes_.momenta[0][3] != 0 )
875 ctes_.momenta[3][3] );
880 more = ( channel != -1 );
883 std::cout <<
"Existence of mode " << channel
884 <<
" in exclusive decay list has the same final state as this one" << std::endl;
892 for (
int i = 0; i < numstable; i++ )
897 if ( ndaugFound == 0 )
899 report(
ERROR,
"EvtGen" ) <<
"Phokhara has failed to do a decay ";
911 if ( nphokharadecays == ntable )
916 for ( i = 0; i < ntable; i++ ) { newphokharadecays[i] = phokharadecays[i]; }
917 ntable = 2 * ntable + 10;
918 delete[] phokharadecays;
919 phokharadecays = newphokharadecays;
922 phokharadecays[nphokharadecays++] = jsdecay;
926 static int first = 1;
942 if ( m_pion < 0 || m_pion > 9 )
944 std::cout <<
"mode index for phokhar 0~9, but you give " << m_pion << std::endl;
963 m_q2_max_c = m_E * m_E;
970 if ( !( m_pion == 0 || m_pion == 1 || m_pion == 6 ) )
975 if ( m_pion == 9 ) { m_nlo = 0; }
983 flags_.FF_pion = m_FF_Pion;
984 flags_.f0_model = m_f0_model;
985 flags_.FF_kaon = m_FF_Kaon;
986 flags_.narr_res = m_NarrowRes;
988 ctes_.Sp = m_E * m_E;
992 cuts_.q2min = m_q2min;
993 cuts_.q2_min_c = m_q2_min_c;
994 cuts_.q2_max_c = m_q2_max_c;
996 cuts_.phot1cut = m_phot1cut;
997 cuts_.phot2cut = m_phot2cut;
998 cuts_.pi1cut = m_pi1cut;
999 cuts_.pi2cut = m_pi2cut;
1012 else if (
flags_.pion == 2 )
1019 else if (
flags_.pion == 8 )
1023 if (
cuts_.q2_max_c < qqmax ) qqmax =
cuts_.q2_max_c;
1026 if ( (
cuts_.q2_min_c > qqmin ) &&
1029 qqmin =
cuts_.q2_min_c;
1034 for (
int i = 0; i < 2; i++ )
1050 maxima_.Mmax[0] = theMmax[m_pion][0];
1051 maxima_.Mmax[1] = theMmax[m_pion][1];
EvtDecayBase * EvtDecayBasePtr
struct @053254170326070136226344307237142165176240334330 ctes_
#define RLXDINIT(LUXURY, SEED)
struct @027003056066344010031101102046265032310161340072 maxima_
#define GEN_1PH(I, QQMIN, QQMAX, COS1MIN, COS1MAX, COS3MIN, COS3MAX)
struct @152360376016154317326265314214112361240371075021 lambda_par_
#define GEN_2PH(I, QQMIN, COS1MIN, COS1MAX, COS2MIN, COS2MAX, COS3MIN, COS3MAX)
struct @366025114004024134344043225357106161032107165361 flags_
struct @276363222274272223263152166363125067340201005217 cuts_
ostream & report(Severity severity, const char *facility)
double cos(const BesAngle a)
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)