57{
58
60
61 if ( ndaug == 1 ) {
63 return 1.0;
64 }
65
66
67 if ( ndaug == 2 ) {
68
69
70
73
75
77
79 p3 = -1.0*p3;
81
82
83
86
89
90 return 1.0;
91 }
92
93 if ( ndaug != 2 ) {
94
95 double wtmax=0.0;
96 double pm[5][30],to[4],pmin,pmax,psum,rnd[30];
97 double ran,wt,pa,costh,sinth,phi,p[4][30],be[4],bep,temp;
98 int i,il,ilr,i1,il1u,il1,il2r,ilu;
99 int il2=0;
100
101 for(i=0;i<ndaug;i++){
102 pm[4][i]=0.0;
103 rnd[i]=0.0;
104 }
105
107 pm[1][0]=0.0;
108 pm[2][0]=0.0;
109 pm[3][0]=0.0;
111
113 to[1]=0.0;
114 to[2]=0.0;
115 to[3]=0.0;
116
117 psum=0.0;
118 for(i=1;i<ndaug+1;i++){
120 }
121
122 pm[4][ndaug-1]=
mass[ndaug-1];
123
124 switch (ndaug) {
125
126 case 1:
127 wtmax=1.0/16.0;
128 break;
129 case 2:
130 wtmax=1.0/150.0;
131 break;
132 case 3:
133 wtmax=1.0/2.0;
134 break;
135 case 4:
136 wtmax=1.0/5.0;
137 break;
138 case 5:
139 wtmax=1.0/15.0;
140 break;
141 case 6:
142 wtmax=1.0/15.0;
143 break;
144 case 7:
145 wtmax=1.0/15.0;
146 break;
147 case 8:
148 wtmax=1.0/15.0;
149 break;
150 case 9:
151 wtmax=1.0/15.0;
152 break;
153 case 10:
154 wtmax=1.0/15.0;
155 break;
156 case 11:
157 wtmax=1.0/15.0;
158 break;
159 case 12:
160 wtmax=1.0/15.0;
161 break;
162 case 13:
163 wtmax=1.0/15.0;
164 break;
165 case 14:
166 wtmax=1.0/15.0;
167 break;
168 case 15:
169 wtmax=1.0/15.0;
170 break;
171 default:
172 report(
ERROR,
"EvtGen") <<
"too many daughters for phase space..." << ndaug <<
" "<<
mp <<endl;;
173 break;
174 }
175
176 pmax=
mp-psum+
mass[ndaug-1];
177
178 pmin=0.0;
179
180 for(ilr=2;ilr<ndaug+1;ilr++){
181 il=ndaug+1-ilr;
182 pmax=pmax+
mass[il-1];
183 pmin=pmin+
mass[il+1-1];
185 }
186
187
188
189 do{
190
191 rnd[0]=1.0;
192 il1u=ndaug-1;
193
194 for (il1=2;il1<il1u+1;il1++){
196 for (il2r=2;il2r<il1+1;il2r++){
197 il2=il1+1-il2r;
198 if (ran<=rnd[il2-1]) goto two39;
199 rnd[il2+1-1]=rnd[il2-1];
200 }
201 two39:
202 rnd[il2+1-1]=ran;
203 }
204
205 rnd[ndaug-1]=0.0;
206 wt=1.0;
207 for(ilr=2;ilr<ndaug+1;ilr++){
208 il=ndaug+1-ilr;
209 pm[4][il-1]=pm[4][il+1-1]+
mass[il-1]+
210 (rnd[il-1]-rnd[il+1-1])*(
mp-psum);
211 wt=wt*
EvtPawt(pm[4][il-1],pm[4][il+1-1],
mass[il-1]);
212 }
213 if (wt>wtmax) {
214 report(
ERROR,
"EvtGen") <<
"wtmax to small in EvtPhaseSpace with "
215 << ndaug <<" daughters"<<endl;;
216 }
218
219 ilu=ndaug-1;
220
221 for (il=1;il<ilu+1;il++){
224 sinth=sqrt(1.0-costh*costh);
226 p[1][il-1]=pa*sinth*
cos(phi);
227 p[2][il-1]=pa*sinth*
sin(phi);
228 p[3][il-1]=pa*costh;
229 pm[1][il+1-1]=-p[1][il-1];
230 pm[2][il+1-1]=-p[2][il-1];
231 pm[3][il+1-1]=-p[3][il-1];
232 p[0][il-1]=sqrt(pa*pa+
mass[il-1]*
mass[il-1]);
233 pm[0][il+1-1]=sqrt(pa*pa+pm[4][il+1-1]*pm[4][il+1-1]);
234 }
235
236 p[0][ndaug-1]=pm[0][ndaug-1];
237 p[1][ndaug-1]=pm[1][ndaug-1];
238 p[2][ndaug-1]=pm[2][ndaug-1];
239 p[3][ndaug-1]=pm[3][ndaug-1];
240
241 for (ilr=2;ilr<ndaug+1;ilr++){
242 il=ndaug+1-ilr;
243 be[0]=pm[0][il-1]/pm[4][il-1];
244 be[1]=pm[1][il-1]/pm[4][il-1];
245 be[2]=pm[2][il-1]/pm[4][il-1];
246 be[3]=pm[3][il-1]/pm[4][il-1];
247
248 for (i1=il;i1<ndaug+1;i1++){
249 bep=be[1]*p[1][i1-1]+be[2]*p[2][i1-1]+
250 be[3]*p[3][i1-1]+be[0]*p[0][i1-1];
251 temp=(p[0][i1-1]+bep)/(be[0]+1.0);
252 p[1][i1-1]=p[1][i1-1]+temp*be[1];
253 p[2][i1-1]=p[2][i1-1]+temp*be[2];
254 p[3][i1-1]=p[3][i1-1]+temp*be[3];
255 p[0][i1-1]=bep;
256
257 }
258 }
259
260 for (ilr=0;ilr<ndaug;ilr++){
261 p4[ilr].
set(p[0][ilr],p[1][ilr],p[2][ilr],p[3][ilr]);
262 }
263
264 return 1.0;
265 }
266
267 return 1.0;
268
269}
double sin(const BesAngle a)
double cos(const BesAngle a)
double EvtPawt(double a, double b, double c)
ostream & report(Severity severity, const char *facility)
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
static const double twoPi
void applyRotateEuler(double alpha, double beta, double gamma)
void set(int i, double d)