1 //--------------------------------------------------------------------------
4 // This software is part of the EvtGen package developed jointly
5 // for the BaBar and CLEO collaborations. If you use all or part
6 // of it, please give an appropriate acknowledgement.
8 // Copyright Information: See EvtGen/COPYRIGHT
9 // Copyright (C) 1998 Caltech, UCSB
11 // Module: EvtPHOTOS.cc
13 // Description: This routine takes the particle *p and applies
14 // the PHOTOS package to generate final state radiation
15 // on the produced mesons.
17 // Modification history:
19 // RYD October 1, 1997 Module created
21 //------------------------------------------------------------------------
23 #include "EvtGenBase/EvtPatches.hh"
24 #include "EvtGenBase/EvtPatches.hh"
25 #include "EvtGenBase/EvtIdSet.hh"
26 #include "EvtGenBase/EvtParticle.hh"
27 #include "EvtGenBase/EvtPhotonParticle.hh"
28 #include "EvtGenBase/EvtPDL.hh"
29 #include "EvtGenModels/EvtPHOTOS.hh"
30 #include "EvtGenBase/EvtReport.hh"
34 extern "C" void begevtgenstorex_(int *,int *,int *,int *,
35 int *,int *,int *,int *,
36 double *,double *,double *,
37 double *,double *,double *,
38 double *,double *,double *);
40 extern "C" void begevtgengetx_(int *,int *,int *,int *,
41 int *,int *,int *,int *,
42 double *,double *,double *,
43 double *,double *,double *,
44 double *,double *,double *);
46 extern "C" void heplst_(int *);
48 extern "C" void photos_(int *);
50 extern "C" void phoini_(int *, int *);
53 EvtPHOTOS::EvtPHOTOS(std::string photontype){
55 _photontype=photontype;
59 void EvtPHOTOS::doRadCorr( EvtParticle *p){
63 //added by Lange Jan4,2000
64 //allow to set photon tupe
65 static EvtId GAMM=EvtPDL::getId(_photontype);
67 if (GAMM==EvtId(-1,-1)) {
68 report(ERROR,"EvtGen") << "In EvtPHOTOS::doRadCorr():Particle:"<<
69 _photontype<<" is not in EvtPDL"<<std::endl;
75 int iseed1=(int)gRandom->Integer(31327);
76 int iseed2=(int)gRandom->Integer(30080);
77 phoini_(&iseed1,&iseed2);
80 double mpho=EvtPDL::getMeanMass(GAMM);
82 int entry,eventnum,numparticle,istat,partnum,mother;
83 int daugfirst,dauglast;
85 int numparticlephotos;
87 double px,py,pz,e,m,x,y,z,t;
89 static EvtId dq=EvtPDL::getId("d");
90 static EvtId adq=EvtPDL::getId("anti-d");
91 static EvtId uq=EvtPDL::getId("u");
92 static EvtId auq=EvtPDL::getId("anti-u");
93 static EvtId sq=EvtPDL::getId("s");
94 static EvtId asq=EvtPDL::getId("anti-s");
95 static EvtId cq=EvtPDL::getId("c");
96 static EvtId acq=EvtPDL::getId("anti-c");
97 static EvtId bq=EvtPDL::getId("b");
98 static EvtId abq=EvtPDL::getId("anti-b");
99 static EvtId tq=EvtPDL::getId("t");
100 static EvtId atq=EvtPDL::getId("anti-t");
101 static EvtId vpho=EvtPDL::getId("vpho");
103 static EvtIdSet quarks(dq,adq,uq,auq,sq,asq,cq,acq,bq,abq,tq,atq);
105 if ( p->getId() == vpho ) return;
106 if ( p->getNDaug() > 10 ) return;
122 partnum=EvtPDL::getStdHep(p->getId());
125 dauglast=1+p->getNDaug();
127 begevtgenstorex_(&entry,&eventnum,&numparticle,&istat,&partnum,
128 &mother,&daugfirst,&dauglast,
129 &px,&py,&pz,&e,&m,&x,&y,&z,&t);
131 // std::cout << EvtPDL::name(p->getId()) <<" " ;
132 for(size_t i=0;i<p->getNDaug();i++){
134 //No quarks to photos
135 if (quarks.contains(p->getDaug(i)->getId())==1) continue;
137 px=p->getDaug(i)->getP4().get(1);
138 py=p->getDaug(i)->getP4().get(2);
139 pz=p->getDaug(i)->getP4().get(3);
140 e=p->getDaug(i)->getP4().get(0);
141 m=p->getDaug(i)->mass();
147 // std::cout << EvtPDL::name(p->getDaug(i)->getId()) << " " ;
152 partnum=EvtPDL::getStdHep(p->getDaug(i)->getId());
157 begevtgenstorex_(&entry,&eventnum,&numparticle,&istat,&partnum,
158 &mother,&daugfirst,&dauglast,
159 &px,&py,&pz,&e,&m,&x,&y,&z,&t);
163 // std::cout << std::endl;
164 //can't use heplst since the common block used by the BaBar
165 //implementation of PHOTOS is renamed due to real*4 vs real*8
174 // report(INFO,"EvtGen") << "Doing photos " << EvtPDL::name(p->getId()) << endl;
176 // report(INFO,"EvtGen") << "done\n";
177 begevtgengetx_(&entry,&eventnum,&numparticlephotos,&istat,&partnum,
178 &mother,&daugfirst,&dauglast,
179 &px,&py,&pz,&e,&m,&x,&y,&z,&t);
182 //report(INFO,"EvtGen") << "numparticlephotos:"<<numparticlephotos<<endl;
184 if (numparticle==numparticlephotos) return;
190 for(size_t i=0;i<p->getNDaug();i++){
194 begevtgengetx_(&entry,&eventnum,&np,&istat,&partnum,
195 &mother,&daugfirst,&dauglast,
196 &px,&py,&pz,&e,&m,&x,&y,&z,&t);
198 //this is needed to ensure that photos does not
199 //change the masses. But it will violate energy conservation!
200 double mp=p->getDaug(i)->mass();
201 e=sqrt(mp*mp+px*px+py*py+pz*pz);
203 new4mom.set(e,px,py,pz);
205 p->getDaug(i)->setP4WithFSR(new4mom);
211 for(entry=numparticle+1;entry<=numparticlephotos;entry++){
213 begevtgengetx_(&entry,&eventnum,&np,&istat,&partnum,
214 &mother,&daugfirst,&dauglast,
215 &px,&py,&pz,&e,&m,&x,&y,&z,&t);
217 //Hack here to give the photon the mass of the generated particle
218 e=sqrt(mpho*mpho+px*px+py*py+pz*pz);
219 new4mom.set(e,px,py,pz);
223 EvtPhotonParticle* gamma;
224 gamma=new EvtPhotonParticle;
225 gamma->init(GAMM,new4mom);
226 gamma->setFSRP4toZero();
227 // report(INFO,"EvtGen") << gamma << " " << p << " "<< px << " " << py << " " << pz << " " << p->getNDaug() << " " << EvtPDL::name(p->getId())<<" " << entry << " " <<numparticlephotos<<endl;
230 // p->getDaug(i)->set_type(EvtSpinType::PHOTON);