00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "Phokhara/Phokhara.h"
00013 #include "Phokhara/PhokharaDef.h"
00014
00015
00016 #include "HepMC/GenEvent.h"
00017 #include "HepMC/GenVertex.h"
00018 #include "HepMC/GenParticle.h"
00019 #include "CLHEP/Vector/LorentzVector.h"
00020
00021 #include "GaudiKernel/MsgStream.h"
00022 #include "GaudiKernel/ISvcLocator.h"
00023 #include "GaudiKernel/AlgFactory.h"
00024 #include "GaudiKernel/DataSvc.h"
00025 #include "GaudiKernel/SmartDataPtr.h"
00026
00027 #include "GeneratorObject/McGenEvent.h"
00028 #include "BesKernel/IBesRndmGenSvc.h"
00029 #include "CLHEP/Random/RandomEngine.h"
00030
00031 #include "cfortran/cfortran.h"
00032
00033 #include <stdlib.h>
00034 #include <iostream>
00035 #include <fstream>
00036
00037 using namespace std;
00038 using namespace CLHEP;
00039
00040 Phokhara::Phokhara(const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
00041 {
00042 m_initSeed = (0);
00043
00044 m_tagged = 0;
00045
00046 declareProperty( "InitialSeed", m_initSeed = 0);
00047
00048 declareProperty( "InitialEvents", m_nm = 50000 );
00049 declareProperty( "NLO", m_nlo = 1 );
00050 declareProperty( "SoftPhotonCutoff", m_w = 0.0001 );
00051 declareProperty( "Channel", m_pion = 0 );
00052
00053
00054
00055 declareProperty( "FSR", m_fsr = 1 );
00056 declareProperty( "FSRNLO", m_fsrnlo = 1 );
00057 declareProperty( "NarrowRes", m_NarrowRes = 1 );
00058 declareProperty( "KaonFormfactor", m_FF_Kaon = 1 );
00059 declareProperty( "VacuumPolarization", m_ivac = 0 );
00060
00061 declareProperty( "PionFormfactor", m_FF_Pion = 0 );
00062 declareProperty( "F0model", m_f0_model = 0 );
00063
00064 declareProperty( "Ecm", m_E = 3.097 );
00065 declareProperty( "CutTotalInvMass", m_q2min = 0.0 );
00066 declareProperty( "CutHadInvMass", m_q2_min_c = 0.0447 );
00067 declareProperty( "MaxHadInvMass", m_q2_max_c = 1.06 );
00068 declareProperty( "MinPhotonEnergy", m_gmin = 0.05 );
00069 declareProperty( "MinPhotonAngle", m_phot1cut = 0.0 );
00070 declareProperty( "MaxPhotonAngle", m_phot2cut = 180.0 );
00071 declareProperty( "MinHadronsAngle", m_pi1cut = 0.0 );
00072 declareProperty( "MaxHadronsAngle", m_pi2cut = 180.0 );
00073
00074 ievent = 0;
00075 }
00076
00077 StatusCode Phokhara::initialize(){
00078
00079 MsgStream log(messageService(), name());
00080
00081 log << MSG::INFO << "Phokhara initialize" << endreq;
00082
00083 int i,s_seed[105];
00084 long int k,j;
00085
00086 if( m_initSeed == 0)
00087 {
00088 IBesRndmGenSvc* p_BesRndmGenSvc;
00089 static const bool CREATEIFNOTTHERE(true);
00090 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
00091 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
00092 {
00093 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
00094 return RndmStatus;
00095 }
00096
00097
00098 HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("PHOKHARA");
00099 const long* s = engine->getSeeds();
00100 m_initSeed = s[0];
00101 }
00102
00103 log << MSG::INFO << "Set initial seed " << m_initSeed << endreq;
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 RLXDINIT(1, m_initSeed);
00118
00119
00120
00121
00122
00123 MAXIMA.iprint = 0;
00124
00125 FLAGS.nlo = m_nlo;
00126 FLAGS.pion = m_pion;
00127 FLAGS.fsr = m_fsr;
00128 FLAGS.fsrnlo = m_fsrnlo;
00129 FLAGS.ivac = m_ivac;
00130
00131 FLAGS.FF_pion = m_FF_Pion;
00132 FLAGS.f0_model = m_f0_model;
00133 FLAGS.FF_kaon = m_FF_Kaon;
00134 FLAGS.narr_res = m_NarrowRes;
00135
00136 CTES.Sp = m_E*m_E; ;
00137
00138 CUTS.w = m_w;
00139 CUTS.q2min = m_q2min;
00140 CUTS.q2_min_c = m_q2_min_c;
00141 CUTS.q2_max_c = m_q2_max_c;
00142 CUTS.gmin = m_gmin;
00143 CUTS.phot1cut = m_phot1cut;
00144 CUTS.phot2cut = m_phot2cut;
00145 CUTS.pi1cut = m_pi1cut;
00146 CUTS.pi2cut = m_pi2cut;
00147
00148 INPUT();
00149
00150 cout << "-------------------------------------------------------------" << endl;
00151 if (FLAGS.pion == 0)
00152 cout << " PHOKHARA 7.0 : e^+ e^- -> mu^+ mu^- gamma" << endl;
00153 else if (FLAGS.pion == 1)
00154 cout << " PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- gamma" << endl;
00155 else if (FLAGS.pion == 2)
00156 cout << " PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- 2pi^0 gamma" << endl;
00157 else if (FLAGS.pion == 3)
00158 cout << " PHOKHARA 7.0: e^+ e^- -> 2pi^+ 2pi^- gamma" << endl;
00159 else if (FLAGS.pion == 4)
00160 cout << " PHOKHARA 7.0: e^+ e^- -> p pbar gamma" << endl;
00161 else if (FLAGS.pion == 5)
00162 cout << " PHOKHARA 7.0: e^+ e^- -> n nbar gamma" << endl;
00163 else if (FLAGS.pion == 6)
00164 cout << " PHOKHARA 7.0: e^+ e^- -> K^+ K^- gamma" << endl;
00165 else if (FLAGS.pion == 7)
00166 cout << " PHOKHARA 7.0: e^+ e^- -> K_0 K_0bar gamma" << endl;
00167 else if (FLAGS.pion == 8)
00168 cout << " PHOKHARA 7.0: e^+ e^- -> pi^+ pi^- pi^0 gamma" << endl;
00169 else if (FLAGS.pion == 9) {
00170 cout << "PHOKHARA 7.0 : e^+ e^- ->" << endl;
00171 cout << " Lambda (-> pi^- p) Lambda bar (-> pi^+ pbar) gamma" << endl;
00172 } else
00173 cout << " PHOKHARA 7.0: not yet implemented" << endl;
00174
00175
00176 cout << "--------------------------------------------------------------" << endl;
00177 printf(" %s %f %s\n","cms total energy = ",sqrt(CTES.Sp)," GeV ");
00178
00179 if((CUTS.gmin/2.0/CTES.ebeam) < 0.0098){
00180 cerr << " minimal missing energy set to small" << endl;
00181 return 0;
00182 }
00183 printf(" %s %f %s\n","minimal tagged photon energy = ",CUTS.gmin," GeV ");
00184 printf(" %s %f,%f\n","angular cuts on tagged photon = ",CUTS.phot1cut,CUTS.phot2cut);
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 if (FLAGS.pion == 0)
00198 printf(" %s %f,%f\n","angular cuts on muons = ",CUTS.pi1cut,CUTS.pi2cut);
00199 else if (FLAGS.pion == 4)
00200 printf(" %s %f,%f\n","angular cuts on protons = ",CUTS.pi1cut,CUTS.pi2cut);
00201 else if (FLAGS.pion == 5)
00202 printf(" %s %f,%f\n","angular cuts on neutrons = ", CUTS.pi1cut,CUTS.pi2cut);
00203 else if ((FLAGS.pion == 6)||(FLAGS.pion == 7))
00204 printf(" %s %f,%f\n","angular cuts on kaons = ", CUTS.pi1cut,CUTS.pi2cut);
00205 else if (FLAGS.pion == 9)
00206 printf(" %s %f,%f\n","angular cuts on pions and protons = ", CUTS.pi1cut,CUTS.pi2cut);
00207 else
00208 printf(" %s %f,%f\n","angular cuts on pions = ", CUTS.pi1cut,CUTS.pi2cut);
00209
00210
00211 if (FLAGS.pion == 0)
00212 printf(" %s %f %s\n","min. muons-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2");
00213 else if (FLAGS.pion == 4)
00214 printf(" %s %f %s\n","min. protons-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00215 else if (FLAGS.pion == 5)
00216 printf(" %s %f %s\n","min. neutrons-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00217 else if ((FLAGS.pion == 6)||(FLAGS.pion == 7))
00218 printf(" %s %f %s\n","min. kaons-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00219 else if (FLAGS.pion == 9)
00220 printf(" %s %f %s\n"," min. lambdas-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00221 else
00222 printf(" %s %f %s\n","min. pions-tagged photon inv.mass^2 = ", CUTS.q2min," GeV^2" );
00223
00224
00225
00226 cos1min = cos(CUTS.phot2cut*CTES.pi/180.0);
00227 cos1max = cos(CUTS.phot1cut*CTES.pi/180.0);
00228
00229
00230
00231
00232
00233 cos2min = -1.0;
00234 cos2max = 1.0;
00235 cos3min = -1.0;
00236 cos3max = 1.0;
00237 if (FLAGS.pion == 0)
00238 qqmin = 4.0*CTES.mmu*CTES.mmu;
00239 else if (FLAGS.pion == 1)
00240 qqmin = 4.0*CTES.mpi*CTES.mpi;
00241 else if (FLAGS.pion == 2)
00242 qqmin = 4.0*(CTES.mpi+CTES.mpi0)*(CTES.mpi+CTES.mpi0);
00243 else if (FLAGS.pion == 3)
00244 qqmin = 16.0*CTES.mpi*CTES.mpi;
00245 else if (FLAGS.pion == 4)
00246 qqmin = 4.0*CTES.mp*CTES.mp;
00247 else if (FLAGS.pion == 5)
00248 qqmin = 4.0*CTES.mnt*CTES.mnt;
00249 else if (FLAGS.pion == 6)
00250 qqmin = 4.0*CTES.mKp*CTES.mKp;
00251 else if (FLAGS.pion == 7)
00252 qqmin = 4.0*CTES.mKn*CTES.mKn;
00253 else if (FLAGS.pion == 8)
00254 qqmin = (2.0*CTES.mpi+CTES.mpi0)*(2.0*CTES.mpi+CTES.mpi0);
00255 else if (FLAGS.pion == 9)
00256 qqmin = 4.0*CTES.mlamb*CTES.mlamb;
00257
00258
00259
00260 qqmax = CTES.Sp-2.0*sqrt(CTES.Sp)*CUTS.gmin;
00261 if (CUTS.q2_max_c < qqmax)
00262 qqmax=CUTS.q2_max_c;
00263
00264
00265 if ( (CUTS.q2_min_c > qqmin) && (CUTS.q2_min_c < (CTES.Sp*(1.0-2.0*(CUTS.gmin/sqrt(CTES.Sp)+CUTS.w))) ) )
00266 qqmin = CUTS.q2_min_c;
00267 else {
00268 cerr << "------------------------------" << endl;
00269 cerr << " Q^2_min TOO SMALL" << endl;
00270 cerr << " Q^2_min CHANGED BY PHOKHARA = " << qqmin << " GeV^2" << endl;
00271 cerr << "------------------------------" << endl;
00272 }
00273
00274 if(qqmax <= qqmin){
00275 cerr << " Q^2_max to small " << endl;
00276 cerr << " Q^2_max = " << qqmax << endl;
00277 cerr << " Q^2_min = " << qqmin << endl;
00278 return 0;
00279 }
00280
00281
00282 if (FLAGS.pion == 0) {
00283 printf(" %s %f %s\n", "minimal muon-pair invariant mass^2 = ", qqmin," GeV^2");
00284 printf(" %s %f %s\n", "maximal muon-pair invariant mass^2 = ", qqmax," GeV^2");
00285 } else if (FLAGS.pion == 1) {
00286 printf(" %s %f %s\n", "minimal pion-pair invariant mass^2 = ", qqmin," GeV^2");
00287 printf(" %s %f %s\n", "maximal pion-pair invariant mass^2 = ", qqmax," GeV^2");
00288 } else if (FLAGS.pion == 4) {
00289 printf(" %s %f %s\n", "minimal proton-pair invariant mass^2 = ", qqmin," GeV^2");
00290 printf(" %s %f %s\n", "maximal proton-pair invariant mass^2 = ", qqmax," GeV^2");
00291 } else if (FLAGS.pion == 5) {
00292 printf(" %s %f %s\n", "minimal neutron-pair invariant mass^2 = ", qqmin," GeV^2");
00293 printf(" %s %f %s\n", "maximal neutron-pair invariant mass^2 = ", qqmax," GeV^2");
00294 } else if ((FLAGS.pion == 6) || (FLAGS.pion == 7)) {
00295 printf(" %s %f %s\n", "minimal kaon-pair invariant mass^2 = ", qqmin," GeV^2");
00296 printf(" %s %f %s\n", "maximal kaon-pair invariant mass^2 = ", qqmax," GeV^2");
00297 } else if(FLAGS.pion == 8){
00298 printf(" %s %f %s\n", "minimal three-pion invariant mass^2 = ", qqmin," GeV^2");
00299 printf(" %s %f %s\n", "maximal three-pion invariant mass^2 = ", qqmax," GeV^2");
00300 } else if(FLAGS.pion == 9){
00301 printf(" %s %f %s\n", "minimal lambda-pair invariant mass^2 = ", qqmin," GeV^2");
00302 printf(" %s %f %s\n", "maximal lambda-pair invariant mass^2 = ", qqmax," GeV^2");
00303 } else {
00304 printf(" %s %f %s\n", "minimal four-pion invariant mass^2 = ", qqmin," GeV^2" );
00305 printf(" %s %f %s\n", "maximal four-pion invariant mass^2 = ", qqmax," GeV^2");
00306 }
00307
00308 if (FLAGS.nlo == 0) {
00309 cout << "Born" << endl;
00310 if(FLAGS.fsrnlo != 0){
00311 cerr << "WRONG FSRNLO flag - only fsrnlo=0 allowed for Born" << endl;
00312 return 0;
00313 }
00314 }
00315
00316 if((FLAGS.pion == 9) && (FLAGS.nlo != 0)) {
00317 cerr << "WRONG NLO flag - only Born allowed for Lambdas"<< endl;
00318 cerr << "If you feel that you need NLO"<< endl;
00319 cerr << "please contact the authors"<< endl;
00320 return 0;
00321 }
00322
00323 if (FLAGS.nlo == 1) printf(" %s %f\n", "NLO: soft photon cutoff w = ",CUTS.w);
00324 if ((FLAGS.pion <= 1) || (FLAGS.pion == 6))
00325 {
00326
00327 if( ! ((FLAGS.fsr == 1) || (FLAGS.fsr == 2) || (FLAGS.fsrnlo == 0)
00328 || (FLAGS.fsr == 1) || (FLAGS.fsrnlo == 1)
00329 || (FLAGS.fsr == 0) || (FLAGS.fsrnlo == 0))) {
00330 cerr << "WRONG combination of FSR, FSRNLO flags" <<endl;
00331 return 0;
00332 }
00333
00334
00335 if (FLAGS.fsr == 0)
00336 cout << "ISR only" << endl;
00337 else if (FLAGS.fsr == 1)
00338 cout << "ISR+FSR" << endl;
00339 else if (FLAGS.fsr == 2) {
00340 if (FLAGS.nlo == 0)
00341 cout << "ISR+INT+FSR" << endl;
00342 else {
00343 cerr << "WRONG FSR flag: interference is included only for nlo=0" << endl;
00344 return 0;
00345 }
00346 }
00347 else {
00348 cerr << "WRONG FSR flag" << FLAGS.fsr << endl;
00349 return 0;
00350 }
00351
00352 if(FLAGS.fsrnlo == 1)
00353 cout << "IFSNLO included" << endl;
00354 }
00355 else
00356 {
00357 if((FLAGS.fsr == 0) && (FLAGS.fsrnlo == 0))
00358 cout << "ISR only" << endl;
00359 else {
00360 cerr << "FSR is implemented only for pi+pi-, mu+mu- and K+K- modes" << endl;
00361 return 0;
00362 }
00363 }
00364
00365
00366 if(FLAGS.ivac == 0){
00367 cout << "Vacuum polarization is NOT included" << endl;}
00368 else if(FLAGS.ivac == 1){
00369 cout << "Vacuum polarization by Fred Jegerlehner (http://www-com.physik.hu-berlin.de/fjeger/alphaQEDn.uu)" << endl;}
00370 else if(FLAGS.ivac == 2){
00371 cout << "Vacuum polarization (VP_HLMNT_v1_3nonr) by Daisuke Nomura and Thomas Teubner" << endl;}
00372 else {
00373 cout << "WRONG vacuum polarization switch" << endl;
00374 return 0;
00375 }
00376
00377
00378 if(FLAGS.pion == 1){
00379 if(FLAGS.FF_pion == 0)
00380 cout << "Kuhn-Santamaria PionFormFactor" << endl;
00381 else if(FLAGS.FF_pion == 1)
00382 cout << "Gounaris-Sakurai PionFormFactor old" << endl;
00383 else if(FLAGS.FF_pion == 2)
00384 cout << "Gounaris-Sakurai PionFormFactor new" << endl;
00385 else {
00386 cout << "WRONG PionFormFactor switch" << endl;
00387 return 0;
00388 }
00389
00390 if(FLAGS.fsr != 0){
00391 if(FLAGS.f0_model == 0)
00392 cout << "f0+f0(600): K+K- model" << endl;
00393 else if(FLAGS.f0_model == 1)
00394 cout << "f0+f0(600): \"no structure\" model" << endl;
00395 else if(FLAGS.f0_model == 2)
00396 cout << "NO f0+f0(600)" << endl;
00397 else if(FLAGS.f0_model == 3)
00398 cout << "only f0, KLOE: Cesare Bini-private communication" << endl;
00399 else {
00400 cout << "WRONG f0+f0(600) switch" << endl;
00401 return 0;
00402 }
00403 }
00404 }
00405
00406
00407 if((FLAGS.pion == 6) || (FLAGS.pion==7)){
00408 if(FLAGS.FF_kaon == 0)
00409 cout << "constrained KaonFormFactor" << endl;
00410 else if(FLAGS.FF_kaon == 1) {
00411 cout << "unconstrained KaonFormFactor" << endl;}
00412 else if(FLAGS.FF_kaon == 2) {
00413 cout << "Kuhn-Khodjamirian-Bruch KaonFormFactor" << endl;}
00414 else{
00415 cout << "WRONG KaonFormFactor switch" << endl;
00416 return 0;
00417 }
00418 }
00419
00420 if((FLAGS.pion == 0) || (FLAGS.pion==1) || (FLAGS.pion == 6) || (FLAGS.pion == 7)){
00421 if(FLAGS.narr_res == 1){
00422 cout << "THE NARROW RESONANCE J/PSI INCLUDED" << endl;}
00423 else if(FLAGS.narr_res == 2){
00424 cout << "THE NARROW RESONANCE PSI(2S) INCLUDED" << endl;}
00425 else if(FLAGS.narr_res != 0){
00426 cout << "wrong flag narr_res: only 0, 1 or 2 allowed" << endl;
00427 return 0;
00428 }
00429 }
00430
00431
00432 cout << "--------------------------------------------------------------" << endl;
00433
00434
00435
00436 for( i = 0; i<2; i++)
00437 {
00438 MAXIMA.Mmax[i] = 1.0;
00439 MAXIMA.gross[i] = 0.0;
00440 MAXIMA.klein[i] = 0.0;
00441 }
00442
00443 if (FLAGS.nlo == 0)
00444 MAXIMA.Mmax[1]=0.0;
00445
00446 MAXIMA.tr[0] = 0.0;
00447 MAXIMA.tr[1] = 0.0;
00448 MAXIMA.count[0] = 0.0;
00449 MAXIMA.count[1] = 0.0;
00450
00451
00452
00453 for(j = 1; j <= m_nm; j++)
00454 {
00455 RANLXDF(Ar_r,1);
00456 Ar[1] = Ar_r[0];
00457 if (Ar[1] <= (MAXIMA.Mmax[0]/(MAXIMA.Mmax[0]+MAXIMA.Mmax[1]))) {
00458 MAXIMA.count[0] = MAXIMA.count[0]+1.0;
00459 GEN_1PH(1,qqmin,qqmax,cos1min,cos1max,cos3min,cos3max);
00460 }
00461 else {
00462 MAXIMA.count[1] = MAXIMA.count[1]+1.0;
00463 GEN_2PH(1,qqmin,cos1min,cos1max,cos2min,cos2max,cos3min,cos3max);
00464 }
00465 }
00466
00467
00468
00469 MAXIMA.Mmax[0] = MAXIMA.gross[0]+.05*sqrt(MAXIMA.gross[0]*MAXIMA.gross[0]);
00470 MAXIMA.Mmax[1] = MAXIMA.gross[1]+(.03+.02*CTES.Sp)*sqrt(MAXIMA.gross[1]*MAXIMA.gross[1]);
00471 if((FLAGS.pion == 1) && (FLAGS.fsrnlo == 1))
00472 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.5;
00473 if((FLAGS.pion == 0) && (FLAGS.fsrnlo == 1))
00474 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.5;
00475
00476 if((FLAGS.pion == 0) && (FLAGS.fsr == 1) && (FLAGS.fsrnlo == 0))
00477 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.2;
00478
00479 if((FLAGS.pion == 2) || (FLAGS.pion == 3)){
00480 MAXIMA.Mmax[0]=MAXIMA.Mmax[0]*1.1;
00481 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.1;
00482 }
00483
00484 if(FLAGS.pion == 8){
00485 MAXIMA.Mmax[0]=MAXIMA.Mmax[0]*1.08;
00486 MAXIMA.Mmax[1]=MAXIMA.Mmax[1]*1.1;
00487 }
00488
00489
00490 MAXIMA.tr[0] = 0.0;
00491 MAXIMA.tr[1] = 0.0;
00492 MAXIMA.count[0] = 0.0;
00493 MAXIMA.count[1] = 0.0;
00494
00495 return StatusCode::SUCCESS;
00496 }
00497
00498 StatusCode Phokhara::execute()
00499 {
00500 MsgStream log(messageService(), name());
00501
00502 int ntrials = 0;
00503 int tr_old[2];
00504 tr_old[0] = (int)MAXIMA.tr[0];
00505 tr_old[1] = (int)MAXIMA.tr[1];
00506
00507 while( ntrials < 10000)
00508 {
00509 ievent++;
00510 RANLXDF(Ar_r,1);
00511 Ar[1] = Ar_r[0];
00512
00513 if (Ar[1] <= (MAXIMA.Mmax[0]/(MAXIMA.Mmax[0]+MAXIMA.Mmax[1]))) {
00514 MAXIMA.count[0] = MAXIMA.count[0]+1.0;
00515 GEN_1PH(2,qqmin,qqmax,cos1min,cos1max,cos3min,cos3max);
00516 }
00517 else {
00518 MAXIMA.count[1] = MAXIMA.count[1]+1.0;
00519 GEN_2PH(2,qqmin,cos1min,cos1max,cos2min,cos2max,cos3min,cos3max);
00520 }
00521
00522 if( ((int)MAXIMA.tr[0]+(int)MAXIMA.tr[1]) > (tr_old[0]+tr_old[1]) )
00523 {
00524 storeParticles();
00525 return StatusCode::SUCCESS;
00526 }
00527 ntrials ++;
00528 }
00529
00530 log << MSG::FATAL << "Could not satisfy cuts after " << ntrials << "trials. Terminate." << endreq;
00531
00532 return StatusCode::FAILURE;
00533 }
00534
00535
00536 StatusCode Phokhara::storeParticles()
00537 {
00538 MsgStream log(messageService(), name());
00539 int npart = 0;
00540
00541
00542 GenEvent* evt = new GenEvent(1,1);
00543
00544 GenVertex* prod_vtx = new GenVertex();
00545
00546 evt->add_vertex( prod_vtx );
00547
00548
00549 GenParticle* p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][0], CTES.momenta[2][0], CTES.momenta[3][0], CTES.momenta[0][0] ), -11, 3);
00550 p->suggest_barcode( ++npart );
00551 prod_vtx->add_particle_in(p);
00552
00553
00554 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][1], CTES.momenta[2][1], CTES.momenta[3][1], CTES.momenta[0][1] ), 11, 3);
00555 p->suggest_barcode( ++npart );
00556 prod_vtx->add_particle_in(p);
00557
00558
00559
00560 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][2], CTES.momenta[2][2], CTES.momenta[3][2], CTES.momenta[0][2] ), 22, 1);
00561 p->suggest_barcode( ++npart );
00562 prod_vtx->add_particle_out(p);
00563
00564 if( CTES.momenta[0][3] != 0 )
00565 {
00566 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][3], CTES.momenta[2][3], CTES.momenta[3][3], CTES.momenta[0][3] ), 22, 1);
00567 p->suggest_barcode( ++npart );
00568 prod_vtx->add_particle_out(p);
00569 }
00570
00571
00572 if (FLAGS.pion == 0) {
00573
00574 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ), -13, 1);
00575 p->suggest_barcode( ++npart );
00576 prod_vtx->add_particle_out(p);
00577
00578 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), 13, 1);
00579 p->suggest_barcode( ++npart );
00580 prod_vtx->add_particle_out(p);
00581 }
00582
00583 if (FLAGS.pion == 1) {
00584
00585 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ),211, 1);
00586 p->suggest_barcode( ++npart );
00587 prod_vtx->add_particle_out(p);
00588
00589 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), -211, 1);
00590 p->suggest_barcode( ++npart );
00591 prod_vtx->add_particle_out(p);
00592 }
00593
00594 if (FLAGS.pion == 2) {
00595
00596 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ),111, 1);
00597 p->suggest_barcode( ++npart );
00598 prod_vtx->add_particle_out(p);
00599
00600 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), 111, 1);
00601 p->suggest_barcode( ++npart );
00602 prod_vtx->add_particle_out(p);
00603
00604 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][7], CTES.momenta[2][7], CTES.momenta[3][7], CTES.momenta[0][7] ),-211, 1);
00605 p->suggest_barcode( ++npart );
00606 prod_vtx->add_particle_out(p);
00607
00608 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][8], CTES.momenta[2][8], CTES.momenta[3][8], CTES.momenta[0][8] ), 211, 1);
00609 p->suggest_barcode( ++npart );
00610 prod_vtx->add_particle_out(p);
00611 }
00612
00613 if (FLAGS.pion == 3) {
00614
00615 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ),211, 1);
00616 p->suggest_barcode( ++npart );
00617 prod_vtx->add_particle_out(p);
00618
00619 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), -211, 1);
00620 p->suggest_barcode( ++npart );
00621 prod_vtx->add_particle_out(p);
00622
00623 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][7], CTES.momenta[2][7], CTES.momenta[3][7], CTES.momenta[0][7] ),-211, 1);
00624 p->suggest_barcode( ++npart );
00625 prod_vtx->add_particle_out(p);
00626
00627 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][8], CTES.momenta[2][8], CTES.momenta[3][8], CTES.momenta[0][8] ), 211, 1);
00628 p->suggest_barcode( ++npart );
00629 prod_vtx->add_particle_out(p);
00630 }
00631
00632 if (FLAGS.pion == 4) {
00633
00634 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ),-2212, 1);
00635 p->suggest_barcode( ++npart );
00636 prod_vtx->add_particle_out(p);
00637
00638 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), 2212, 1);
00639 p->suggest_barcode( ++npart );
00640 prod_vtx->add_particle_out(p);
00641 }
00642
00643 if (FLAGS.pion == 5) {
00644
00645 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ),-2112, 1);
00646 p->suggest_barcode( ++npart );
00647 prod_vtx->add_particle_out(p);
00648
00649 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), 2112, 1);
00650 p->suggest_barcode( ++npart );
00651 prod_vtx->add_particle_out(p);
00652 }
00653
00654 if (FLAGS.pion == 6) {
00655
00656 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ),321, 1);
00657 p->suggest_barcode( ++npart );
00658 prod_vtx->add_particle_out(p);
00659
00660 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), -321, 1);
00661 p->suggest_barcode( ++npart );
00662 prod_vtx->add_particle_out(p);
00663 }
00664
00665 if (FLAGS.pion == 7) {
00666
00667 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ), 311, 1);
00668 p->suggest_barcode( ++npart );
00669 prod_vtx->add_particle_out(p);
00670
00671 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), -311, 1);
00672 p->suggest_barcode( ++npart );
00673 prod_vtx->add_particle_out(p);
00674 }
00675
00676 if (FLAGS.pion == 8) {
00677
00678 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ), 211, 1);
00679 p->suggest_barcode( ++npart );
00680 prod_vtx->add_particle_out(p);
00681
00682 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), -211, 1);
00683 p->suggest_barcode( ++npart );
00684 prod_vtx->add_particle_out(p);
00685
00686 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][7], CTES.momenta[2][7], CTES.momenta[3][7], CTES.momenta[0][7] ), 111, 1);
00687 p->suggest_barcode( ++npart );
00688 prod_vtx->add_particle_out(p);
00689 }
00690
00691 if (FLAGS.pion == 9) {
00692
00693 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][5], CTES.momenta[2][5], CTES.momenta[3][5], CTES.momenta[0][5] ), -3122, 2);
00694 p->suggest_barcode( ++npart );
00695 prod_vtx->add_particle_out(p);
00696
00697 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][6], CTES.momenta[2][6], CTES.momenta[3][6], CTES.momenta[0][6] ), 3122, 2);
00698 p->suggest_barcode( ++npart );
00699 prod_vtx->add_particle_out(p);
00700
00701 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][7], CTES.momenta[2][7], CTES.momenta[3][7], CTES.momenta[0][7] ), 211, 1);
00702 p->suggest_barcode( ++npart );
00703 prod_vtx->add_particle_out(p);
00704
00705 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][8], CTES.momenta[2][8], CTES.momenta[3][8], CTES.momenta[0][8] ), -2212, 1);
00706 p->suggest_barcode( ++npart );
00707 prod_vtx->add_particle_out(p);
00708
00709 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][9], CTES.momenta[2][9], CTES.momenta[3][9], CTES.momenta[0][9] ), -211, 1);
00710 p->suggest_barcode( ++npart );
00711 prod_vtx->add_particle_out(p);
00712
00713 p = new GenParticle( CLHEP::HepLorentzVector( CTES.momenta[1][10], CTES.momenta[2][10], CTES.momenta[3][10], CTES.momenta[0][10] ), 2212, 1);
00714 p->suggest_barcode( ++npart );
00715 prod_vtx->add_particle_out(p);
00716 }
00717
00718 if( log.level() < MSG::INFO )
00719 {
00720 evt->print();
00721 }
00722
00723
00724 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(), "/Event/Gen");
00725 if (anMcCol!=0)
00726 {
00727
00728 MsgStream log(messageService(), name());
00729 log << MSG::INFO << "Add McGenEvent to existing collection" << endreq;
00730 McGenEvent* mcEvent = new McGenEvent(evt);
00731 anMcCol->push_back(mcEvent);
00732 }
00733 else
00734 {
00735
00736 McGenEventCol *mcColl = new McGenEventCol;
00737 McGenEvent* mcEvent = new McGenEvent(evt);
00738 mcColl->push_back(mcEvent);
00739 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
00740 if (sc != StatusCode::SUCCESS)
00741 {
00742 log << MSG::ERROR << "Could not register McGenEvent" << endreq;
00743 delete mcColl;
00744 delete evt;
00745 delete mcEvent;
00746 return StatusCode::FAILURE;
00747 }
00748 else
00749 {
00750 log << MSG::INFO << "McGenEventCol created and " << npart <<" particles stored in McGenEvent" << endreq;
00751 }
00752 }
00753
00754 return StatusCode::SUCCESS;
00755
00756 }
00757
00758 StatusCode Phokhara::finalize()
00759 {
00760 MsgStream log(messageService(), name());
00761
00762 if(FLAGS.pion == 9)
00763 MAXIMA.Mmax[1] = MAXIMA.Mmax[1] * (1.0 + LAMBDA_PAR.alpha_lamb)*(1.0 + LAMBDA_PAR.alpha_lamb)
00764 * LAMBDA_PAR.ratio_lamb*LAMBDA_PAR.ratio_lamb;
00765
00766
00767 if (FLAGS.nlo == 0) {
00768 sigma = MAXIMA.Mmax[0]/MAXIMA.count[0]*MAXIMA.tr[0];
00769 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]);
00770 } else {
00771 sigma1 = MAXIMA.Mmax[0]/MAXIMA.count[0]*MAXIMA.tr[0];
00772 sigma2 = MAXIMA.Mmax[1]/MAXIMA.count[1]*MAXIMA.tr[1];
00773 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]);
00774 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]);
00775
00776 sigma = sigma1+sigma2;
00777 dsigm = sqrt(dsigm1*dsigm1 + dsigm2*dsigm2);
00778 }
00779
00780
00781 cout << "-------------------------------------------------------------" << endl;
00782 cout << " PHOKHARA 7.0 Final Statistics " << endl;
00783 cout << "-------------------------------------------------------------" << endl;
00784 cout << int(MAXIMA.tr[0]+MAXIMA.tr[1]) << " total events accepted of " << endl;
00785 cout << int(ievent) << " total events generated" << endl;
00786 cout << int(MAXIMA.tr[0]) << " one photon events accepted of " << endl;
00787 cout << int(MAXIMA.count[0]) << " events generated" << endl;
00788 cout << int(MAXIMA.tr[1]) << " two photon events accepted of " << endl;
00789 cout << int(MAXIMA.count[1]) << " events generated" << endl;
00790 cout << endl;
00791 if (FLAGS.nlo != 0) cout << "sigma1(nbarn) = " << sigma1 << " +- " << dsigm1 << endl;
00792 if (FLAGS.nlo != 0) cout << "sigma2(nbarn) = " << sigma2 << " +- " << dsigm2 << endl;
00793 cout << "sigma (nbarn) = " << sigma << " +- " << dsigm << endl;
00794 cout << endl;
00795 cout << "maximum1 = " << MAXIMA.gross[0] << " minimum1 = " << MAXIMA.klein[0] << endl;
00796 cout << "Mmax1 = " << MAXIMA.Mmax[0] << endl;
00797 cout << "maximum2 = " << MAXIMA.gross[1] << " minimum2 = " << MAXIMA.klein[1] << endl;
00798 cout << "Mmax2 = " << MAXIMA.Mmax[1] << endl;
00799 cout << "-------------------------------------------------------------" << endl;
00800
00801 log << MSG::INFO << "Phokhara finalized" << endreq;
00802
00803 return StatusCode::SUCCESS;
00804 }