193 {
194
195 static int iniflag=1;
196
198
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
219
220
222
223 int i,more;
225 int ndaugjs;
226 static int kf[4000];
227 EvtId evtnumstable[100],evtnumparton[100];
228 int stableindex[100],partonindex[100];
229 int numstable;
230 int numparton;
231 static int km[4000];
233
234 int isr=1;
236
237 static double px[4000],py[4000],pz[4000],e[4000];
238 if (iniflag==1)
lundar_(&isr,&iniflag,&xmp,&ndaugjs,kf,km,px,py,pz,e);
239
241
243 bool mtg=0;
244
245 do{
246
247 iniflag=iniflag+1;
248
249modeSelection:
250 lundar_(&isr,&iniflag,&xmp,&ndaugjs,kf,km,px,py,pz,e);
251
253 if(mtg)std::cout<<
"checktag_.decaytag="<<
checktag_.decaytag<<std::endl;
254
255
256
258 numstable=0;
259 numparton=0;
260
261 double esum=0;
262
263
264
265
266
267 for(i=0;i<ndaugjs;i++){
268 if (
abs(kf[i])==11 || kf[i]==92 || kf[i]==22)
continue;
269
271 report(
ERROR,
"EvtGen") <<
"Lunda returned particle:"<<kf[i]<<endl;
272 report(
ERROR,
"EvtGen") <<
"This can not be translated to evt number"<<endl;
273 report(
ERROR,
"EvtGen") <<
"and the decay will be rejected!"<<endl;
274 report(
ERROR,
"EvtGen") <<
"The decay was of particle:"<<ip<<endl;
275
276 std::cout<<"xmp= "<<xmp<<std::endl;
277 goto modeSelection;
278 }
279
280
281 if (
abs(kf[i])<=6||kf[i]==21){
282 partonindex[numparton]=i;
284 numparton++;
285 }
286 else{
287 stableindex[numstable]=i;
289 numstable++;
290 }
291
292 esum+=e[i];
293
294
295
296
297 if (px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i]>=e[i]*e[i]){
298
299 e[i]=sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])+0.0000000001;
300
301 }
302
303 p4[i].
set(e[i],px[i],py[i],pz[i]);
304
305
306 }
307
309
310
311
312 more=(channel!=-1);
313
314 if(
abs(esum-xmp)>0.001 ){
315 std::cout<<"Unexpected final states from Lunda with total energy "<<esum<<" unequal to "<<xmp<<std::endl;
316
317 std::cout<<"xmp= "<<xmp<<std::endl;
318 goto modeSelection;
319 }
320
322 }
while( more && (
count<10000) && mtg );
323
324
326 report(
INFO,
"EvtGen") <<
"Too many loops in EvtLunda!!!"<<endl;
328 for(i=0;i<numstable;i++){
330 }
331
332 }
333
334
335
336 if (numparton==0){
337
339 int ndaugFound=0;
340 for(i=0;i<numstable;i++){
341 p->
getDaug(i)->
init(evtnumstable[i],p4[stableindex[i]]);
342 ndaugFound++;
343 }
344 if ( ndaugFound == 0 ) {
345 report(
ERROR,
"EvtGen") <<
"Lunda has failed to do a decay ";
347 assert(0);
348 }
349
350 fixPolarizations(p);
351
352
353
354 return ;
355
356 }
357 else{
358
359
360
362
363 for(i=0;i<numparton;i++){
364 p4string+=p4[partonindex[i]];
365 }
366
367 int nprimary=1;
368 type[0]=STRNG;
369 for(i=0;i<numstable;i++){
370 if (km[stableindex[i]]==0){
371 type[nprimary++]=evtnumstable[i];
372 }
373 }
374
376
378
380
381 for(i=0;i<numparton;i++){
382 p4partons[i]=p4[partonindex[i]];
383 }
384
386
387
388
389 nprimary=1;
390
391 for(i=0;i<numstable;i++){
392
393 if (km[stableindex[i]]==0){
394 p->
getDaug(nprimary++)->
init(evtnumstable[i],p4[stableindex[i]]);
395 }
396 }
397
398
399 int nsecond=0;
400 for(i=0;i<numstable;i++){
401 if (km[stableindex[i]]!=0){
402 type[nsecond++]=evtnumstable[i];
403 }
404 }
405
406
408
409 EvtVector4R p4stringboost(p4string.get(0),-p4string.get(1),
410 -p4string.get(2),-p4string.get(3));
411
412 nsecond=0;
413 for(i=0;i<numstable;i++){
414 if (km[stableindex[i]]!=0){
415 p4[stableindex[i]]=
boostTo(p4[stableindex[i]],p4stringboost);
419 nsecond++;
420 }
421 }
422
423 if ( nsecond == 0 ) {
424 report(
ERROR,
"EvtGen") <<
"Jetset has failed to do a decay ";
426 assert(0);
427 }
428
429 fixPolarizations(p);
430
431 return ;
432
433 }
434
435}
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
void lundar_(int *, int *, float *, int *, int *, int *, double *, double *, double *, double *)
DOUBLE_PRECISION count[3]
static int inChannelList(EvtId parent, int ndaug, EvtId *daugs)
void LundaInit(int dummy)
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
void setDiagonalSpinDensity()
EvtParticle * getDaug(int i)
void deleteDaughters(bool keepChannel=false)
void set(int i, double d)