41#include "GeneratorObject/McGenEvent.h"
42#include "BesKernel/IBesRndmGenSvc.h"
43#include "CLHEP/Random/RandomEngine.h"
44#include "cfortran/cfortran.h"
53using std::resetiosflags;
54using std::setiosflags;
57int EvtPhokhara_4pi::nevtgen=0;
58int EvtPhokhara_4pi::nphokharadecays=0;
60int EvtPhokhara_4pi::ntable=0;
62int EvtPhokhara_4pi::ncommand=0;
63int EvtPhokhara_4pi::lcommand=0;
64std::string* EvtPhokhara_4pi::commands=0;
65int EvtPhokhara_4pi::nevt=0;
72 if (nphokharadecays==0) {
78 for(i=0;i<nphokharadecays;i++){
79 if (phokharadecays[i]==
this){
80 phokharadecays[i]=phokharadecays[nphokharadecays-1];
82 if (nphokharadecays==0) {
90 report(
ERROR,
"EvtGen") <<
"Error in destroying Phokhara model!"<<endl;
97 model_name=
"PHOKHARA_4pi";
121 if(m_pion<0 || m_pion>9){std::cout<<
"mode index for phokhar 0~9, but you give "<<m_pion<<std::endl;abort();}
127 m_initSeed = 123456789;
135 flags_.FF_pion = m_FF_Pion;
136 flags_.f0_model = m_f0_model;
137 flags_.FF_kaon = m_FF_Kaon;
138 flags_.narr_res = m_NarrowRes;
140 ctes_.Sp = m_E*m_E; ;
143 cuts_.q2min = m_q2min;
144 cuts_.q2_min_c = m_q2_min_c;
145 cuts_.q2_max_c = m_q2_max_c;
147 cuts_.phot1cut = m_phot1cut;
148 cuts_.phot2cut = m_phot2cut;
149 cuts_.pi1cut = m_pi1cut;
150 cuts_.pi2cut = m_pi2cut;
155 cout <<
"-------------------------------------------------------------" << endl;
157 cout <<
" PHOKHARA 7.0 : e^+ e^- -> mu^+ mu^- gamma" << endl;
158 else if (
flags_.pion == 1)
159 cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- gamma" << endl;
160 else if (
flags_.pion == 2)
161 cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- 2pi^0 gamma" << endl;
162 else if (
flags_.pion == 3)
163 cout <<
" PHOKHARA 7.0: e^+ e^- -> 2pi^+ 2pi^- gamma" << endl;
164 else if (
flags_.pion == 4)
165 cout <<
" PHOKHARA 7.0: e^+ e^- -> p pbar gamma" << endl;
166 else if (
flags_.pion == 5)
167 cout <<
" PHOKHARA 7.0: e^+ e^- -> n nbar gamma" << endl;
168 else if (
flags_.pion == 6)
169 cout <<
" PHOKHARA 7.0: e^+ e^- -> K^+ K^- gamma" << endl;
170 else if (
flags_.pion == 7)
171 cout <<
" PHOKHARA 7.0: e^+ e^- -> K_0 K_0bar gamma" << endl;
172 else if (
flags_.pion == 8)
173 cout <<
" PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- pi^0 gamma" << endl;
174 else if (
flags_.pion == 9) {
175 cout <<
"PHOKHARA 7.0 : e^+ e^- ->" << endl;
176 cout <<
" Lambda (-> pi^- p) Lambda bar (-> pi^+ pbar) gamma" << endl;
178 cout <<
" PHOKHARA 7.0: not yet implemented" << endl;
181 cout <<
"--------------------------------------------------------------" << endl;
182 printf(
" %s %f %s\n",
"cms total energy = ",sqrt(
ctes_.Sp),
" GeV ");
185 if(
cuts_.gmin<0.001){
186 cerr <<
" minimal missing energy set too small, abort" << endl;
189 printf(
" %s %f %s\n",
"minimal tagged photon energy = ",
cuts_.gmin,
" GeV ");
190 printf(
" %s %f,%f\n",
"angular cuts on tagged photon = ",
cuts_.phot1cut,
cuts_.phot2cut);
194 printf(
" %s %f,%f\n",
"angular cuts on muons = ",
cuts_.pi1cut,
cuts_.pi2cut);
195 else if (
flags_.pion == 4)
196 printf(
" %s %f,%f\n",
"angular cuts on protons = ",
cuts_.pi1cut,
cuts_.pi2cut);
197 else if (
flags_.pion == 5)
198 printf(
" %s %f,%f\n",
"angular cuts on neutrons = ",
cuts_.pi1cut,
cuts_.pi2cut);
200 printf(
" %s %f,%f\n",
"angular cuts on kaons = ",
cuts_.pi1cut,
cuts_.pi2cut);
201 else if (
flags_.pion == 9)
202 printf(
" %s %f,%f\n",
"angular cuts on pions and protons = ",
cuts_.pi1cut,
cuts_.pi2cut);
204 printf(
" %s %f,%f\n",
"angular cuts on pions = ",
cuts_.pi1cut,
cuts_.pi2cut);
206 printf(
" %s %f %s\n",
"min. muons-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2");
207 else if (
flags_.pion == 4)
208 printf(
" %s %f %s\n",
"min. protons-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
209 else if (
flags_.pion == 5)
210 printf(
" %s %f %s\n",
"min. neutrons-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
212 printf(
" %s %f %s\n",
"min. kaons-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
213 else if (
flags_.pion == 9)
214 printf(
" %s %f %s\n",
" min. lambdas-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
216 printf(
" %s %f %s\n",
"min. pions-tagged photon inv.mass^2 = ",
cuts_.q2min,
" GeV^2" );
225 else if (
flags_.pion == 1)
227 else if (
flags_.pion == 2)
229 else if (
flags_.pion == 3)
231 else if (
flags_.pion == 4)
233 else if (
flags_.pion == 5)
235 else if (
flags_.pion == 6)
237 else if (
flags_.pion == 7)
239 else if (
flags_.pion == 8)
241 else if (
flags_.pion == 9)
244 if (
cuts_.q2_max_c < qqmax)
245 qqmax=
cuts_.q2_max_c;
249 qqmin =
cuts_.q2_min_c;
251 cerr <<
"------------------------------" << endl;
252 cerr <<
" Q^2_min TOO SMALL" << endl;
253 cerr <<
" Q^2_min CHANGED BY PHOKHARA = " << qqmin <<
" GeV^2" << endl;
254 cerr <<
"------------------------------" << endl;
258 cerr <<
" Q^2_max to small " << endl;
259 cerr <<
" Q^2_max = " << qqmax << endl;
260 cerr <<
" Q^2_min = " << qqmin << endl;
266 printf(
" %s %f %s\n",
"minimal muon-pair invariant mass^2 = ", qqmin,
" GeV^2");
267 printf(
" %s %f %s\n",
"maximal muon-pair invariant mass^2 = ", qqmax,
" GeV^2");
268 }
else if (
flags_.pion == 1) {
269 printf(
" %s %f %s\n",
"minimal pion-pair invariant mass^2 = ", qqmin,
" GeV^2");
270 printf(
" %s %f %s\n",
"maximal pion-pair invariant mass^2 = ", qqmax,
" GeV^2");
271 }
else if (
flags_.pion == 4) {
272 printf(
" %s %f %s\n",
"minimal proton-pair invariant mass^2 = ", qqmin,
" GeV^2");
273 printf(
" %s %f %s\n",
"maximal proton-pair invariant mass^2 = ", qqmax,
" GeV^2");
274 }
else if (
flags_.pion == 5) {
275 printf(
" %s %f %s\n",
"minimal neutron-pair invariant mass^2 = ", qqmin,
" GeV^2");
276 printf(
" %s %f %s\n",
"maximal neutron-pair invariant mass^2 = ", qqmax,
" GeV^2");
278 printf(
" %s %f %s\n",
"minimal kaon-pair invariant mass^2 = ", qqmin,
" GeV^2");
279 printf(
" %s %f %s\n",
"maximal kaon-pair invariant mass^2 = ", qqmax,
" GeV^2");
280 }
else if(
flags_.pion == 8){
281 printf(
" %s %f %s\n",
"minimal three-pion invariant mass^2 = ", qqmin,
" GeV^2");
282 printf(
" %s %f %s\n",
"maximal three-pion invariant mass^2 = ", qqmax,
" GeV^2");
283 }
else if(
flags_.pion == 9){
284 printf(
" %s %f %s\n",
"minimal lambda-pair invariant mass^2 = ", qqmin,
" GeV^2");
285 printf(
" %s %f %s\n",
"maximal lambda-pair invariant mass^2 = ", qqmax,
" GeV^2");
287 printf(
" %s %f %s\n",
"minimal four-pion invariant mass^2 = ", qqmin,
" GeV^2" );
288 printf(
" %s %f %s\n",
"maximal four-pion invariant mass^2 = ", qqmax,
" GeV^2");
292 cout <<
"Born" << endl;
294 cerr <<
"WRONG FSRNLO flag - only fsrnlo=0 allowed for Born" << endl;
300 cerr <<
"WRONG NLO flag - only Born allowed for Lambdas"<< endl;
301 cerr <<
"If you feel that you need NLO"<< endl;
302 cerr <<
"please contact the authors"<< endl;
306 if (
flags_.nlo == 1) printf(
" %s %f\n",
"NLO: soft photon cutoff w = ",
cuts_.w);
313 cerr <<
"WRONG combination of FSR, FSRNLO flags" <<endl;
318 cout <<
"ISR only" << endl;
320 cout <<
"ISR+FSR" << endl;
321 else if (
flags_.fsr == 2) {
323 cout <<
"ISR+INT+FSR" << endl;
325 cerr <<
"WRONG FSR flag: interference is included only for nlo=0" << endl;
330 cerr <<
"WRONG FSR flag" <<
flags_.fsr << endl;
334 cout <<
"IFSNLO included" << endl;
339 cout <<
"ISR only" << endl;
341 cerr <<
"FSR is implemented only for pi+pi-, mu+mu- and K+K- modes" << endl;
347 cout <<
"Vacuum polarization is NOT included" << endl;}
348 else if(
flags_.ivac == 1){
349 cout <<
"Vacuum polarization by Fred Jegerlehner (http://www-com.physik.hu-berlin.de/fjeger/alphaQEDn.uu)" << endl;}
350 else if(
flags_.ivac == 2){
351 cout <<
"Vacuum polarization (VP_HLMNT_v1_3nonr) by Daisuke Nomura and Thomas Teubner" << endl;}
353 cout <<
"WRONG vacuum polarization switch" << endl;
360 cout <<
"Kuhn-Santamaria PionFormFactor" << endl;
361 else if(
flags_.FF_pion == 1)
362 cout <<
"Gounaris-Sakurai PionFormFactor old" << endl;
363 else if(
flags_.FF_pion == 2)
364 cout <<
"Gounaris-Sakurai PionFormFactor new" << endl;
366 cout <<
"WRONG PionFormFactor switch" << endl;
371 cout <<
"f0+f0(600): K+K- model" << endl;
372 else if(
flags_.f0_model == 1)
373 cout <<
"f0+f0(600): \"no structure\" model" << endl;
374 else if(
flags_.f0_model == 2)
375 cout <<
"NO f0+f0(600)" << endl;
376 else if(
flags_.f0_model == 3)
377 cout <<
"only f0, KLOE: Cesare Bini-private communication" << endl;
379 cout <<
"WRONG f0+f0(600) switch" << endl;
387 cout <<
"constrained KaonFormFactor" << endl;
388 else if(
flags_.FF_kaon == 1) {
389 cout <<
"unconstrained KaonFormFactor" << endl;}
390 else if(
flags_.FF_kaon == 2) {
391 cout <<
"Kuhn-Khodjamirian-Bruch KaonFormFactor" << endl;}
393 cout <<
"WRONG KaonFormFactor switch" << endl;
400 cout <<
"THE NARROW RESONANCE J/PSI INCLUDED" << endl;}
401 else if(
flags_.narr_res == 2){
402 cout <<
"THE NARROW RESONANCE PSI(2S) INCLUDED" << endl;}
403 else if(
flags_.narr_res != 0){
404 cout <<
"wrong flag narr_res: only 0, 1 or 2 allowed" << endl;
409 cout <<
"--------------------------------------------------------------" << endl;
413 for(
int i = 0; i<2; i++)
430 for(
int j = 1; j <= m_nm; j++)
436 GEN_1PH(1,qqmin,qqmax,cos1min,cos1max,cos3min,cos3max);
440 GEN_2PH(1,qqmin,cos1min,cos1max,cos2min,cos2max,cos3min,cos3max);
480 std::string locvp=getenv(
"BESEVTGENROOT");
481 system(
"cat $BESEVTGENROOT/share/phokhara.param>phokhara.param");
486 report(
ERROR,
"EvtGen") <<
"EvtPhokhara finds that you are decaying the"<<endl
487 <<
" aliased particle "
489 <<
" with the Phokhara model"<<endl
490 <<
" this does not work, please modify decay table."
492 report(
ERROR,
"EvtGen") <<
"Will terminate execution!"<<endl;
504 return std::string(
"PhokharaPar");
510 if (ncommand==lcommand){
512 lcommand=10+2*lcommand;
514 std::string* newcommands=
new std::string[lcommand];
518 for(i=0;i<ncommand;i++){
519 newcommands[i]=commands[i];
524 commands=newcommands;
528 commands[ncommand]=cmd;
538 if(p->
getId()!=myvpho) {std::cout<<
"Parent particle is required to be vpho for Phokhara model"<<std::endl;abort();}
541 std::cout<<
"PHOKHARA : 2(pi+pi-) mode "<<std::endl;
547 tr_old[0] = (int)
maxima_.tr[0];
548 tr_old[1] = (
int)
maxima_.tr[1];
550 while( ntrials < 10000)
558 GEN_1PH(2,qqmin,qqmax,cos1min,cos1max,cos3min,cos3max);
562 GEN_2PH(2,qqmin,cos1min,cos1max,cos2min,cos2max,cos3min,cos3max);
565 if( ((
int)
maxima_.tr[0]+(
int)
maxima_.tr[1]) > (tr_old[0]+tr_old[1]) )
572 std::cout <<
"FATAL: Could not satisfy cuts after " << ntrials <<
"trials. Terminate." <<std::endl;
578 EvtId evtnumstable[100];
715 if(
ctes_.momenta[0][3] != 0 )
724 if(more) {std::cout<<
"Existence of mode "<<channel<<
" in exclusive decay list has the same final state as this one"<<std::endl;abort(); }
731 for(
int i=0;i<numstable;i++){
735 if ( ndaugFound == 0 ) {
736 report(
ERROR,
"EvtGen") <<
"Phokhara has failed to do a decay ";
750 if (nphokharadecays==ntable){
754 for(i=0;i<ntable;i++){
755 newphokharadecays[i]=phokharadecays[i];
758 delete [] phokharadecays;
759 phokharadecays=newphokharadecays;
762 phokharadecays[nphokharadecays++]=jsdecay;
788 if(m_pion<0 || m_pion>9){std::cout<<
"mode index for phokhar 0~9, but you give "<<m_pion<<std::endl;abort();}
800 flags_.FF_pion = m_FF_Pion;
801 flags_.f0_model = m_f0_model;
802 flags_.FF_kaon = m_FF_Kaon;
803 flags_.narr_res = m_NarrowRes;
805 ctes_.Sp = m_E*m_E; ;
808 cuts_.q2min = m_q2min;
809 cuts_.q2_min_c = m_q2_min_c;
810 cuts_.q2_max_c = m_q2_max_c;
812 cuts_.phot1cut = m_phot1cut;
813 cuts_.phot2cut = m_phot2cut;
814 cuts_.pi1cut = m_pi1cut;
815 cuts_.pi2cut = m_pi2cut;
827 else if (
flags_.pion == 1)
829 else if (
flags_.pion == 2)
831 else if (
flags_.pion == 3)
833 else if (
flags_.pion == 4)
835 else if (
flags_.pion == 5)
837 else if (
flags_.pion == 6)
839 else if (
flags_.pion == 7)
841 else if (
flags_.pion == 8)
843 else if (
flags_.pion == 9)
846 if (
cuts_.q2_max_c < qqmax)
847 qqmax=
cuts_.q2_max_c;
851 qqmin =
cuts_.q2_min_c;
858 for(
int i = 0; i<2; i++)
914 m_q2min = (4*0.135)*(4*0.135);
915 m_q2_min_c = m_q2min ;
916 m_q2_max_c = m_E*m_E;
922 if(!(m_pion==0 || m_pion==1 || m_pion==6)){m_fsr = 0; m_fsrnlo = 0 ;}
923 if( m_pion==9 ){m_nlo = 0 ;}
#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)
double cos(const BesAngle a)
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)
virtual ~EvtPhokhara_4pi()
void PhokharaInit(int dummy)
void getName(std::string &name)
std::string commandName()
void init_evt(EvtParticle *p)
void command(std::string cmd)
void init_mode(EvtParticle *p)
void decay(EvtParticle *p)
void set(int i, double d)