204 {
205
206 static int iniflag=1;
207
209
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
230
231
233
234 int i,more;
236 int ndaugjs;
237 static int kf[4000];
238 EvtId evtnumstable[100],evtnumparton[100];
239 int stableindex[100],partonindex[100];
240 int numstable;
241 int numparton;
242 static int km[4000];
244
245 int isr=1;
247
248 static double px[4000],py[4000],pz[4000],e[4000];
249 if (iniflag==1)
lundar_(&isr,&iniflag,&xmp,&ndaugjs,kf,km,px,py,pz,e);
250
252
254 bool mtg=0;
255
256 do{
257
258 iniflag=iniflag+1;
259
260modeSelection:
261 lundar_(&isr,&iniflag,&xmp,&ndaugjs,kf,km,px,py,pz,e);
262
264 if(mtg)std::cout<<
"checktag_.decaytag="<<
checktag_.decaytag<<std::endl;
265
266
267
269 numstable=0;
270 numparton=0;
271
272 double esum=0;
273
274
275
276
277
278 for(i=0;i<ndaugjs;i++){
279 if (
abs(kf[i])==11 || kf[i]==92 || kf[i]==22)
continue;
280
282 report(
ERROR,
"EvtGen") <<
"Lunda returned particle:"<<kf[i]<<endl;
283 report(
ERROR,
"EvtGen") <<
"This can not be translated to evt number"<<endl;
284 report(
ERROR,
"EvtGen") <<
"and the decay will be rejected!"<<endl;
285 report(
ERROR,
"EvtGen") <<
"The decay was of particle:"<<ip<<endl;
286
287 std::cout<<"xmp= "<<xmp<<std::endl;
288 goto modeSelection;
289 }
290
291
292 if (
abs(kf[i])<=6||kf[i]==21){
293 partonindex[numparton]=i;
295 numparton++;
296 }
297 else{
298 stableindex[numstable]=i;
300 numstable++;
301 }
302
303 esum+=e[i];
304
305
306
307
308 if (px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i]>=e[i]*e[i]){
309
310 e[i]=sqrt(px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i])+0.0000000001;
311
312 }
313
314 p4[i].
set(e[i],px[i],py[i],pz[i]);
315
316
317 }
318
320
321
322
323 more=(channel!=-1);
324
325 if(
abs(esum-xmp)>0.001 ){
326 std::cout<<"Unexpected final states from Lunda with total energy "<<esum<<" unequal to "<<xmp<<std::endl;
327
328 std::cout<<"xmp= "<<xmp<<std::endl;
329 goto modeSelection;
330 }
331
333 }
while( more && (
count<10000) && mtg );
334
335
337 report(
INFO,
"EvtGen") <<
"Too many loops in EvtLunda!!!"<<endl;
339 for(i=0;i<numstable;i++){
341 }
342
343 }
344
345
346
347 if (numparton==0){
348
350 int ndaugFound=0;
351 for(i=0;i<numstable;i++){
352 p->
getDaug(i)->
init(evtnumstable[i],p4[stableindex[i]]);
353 ndaugFound++;
354 }
355 if ( ndaugFound == 0 ) {
356 report(
ERROR,
"EvtGen") <<
"Lunda has failed to do a decay ";
358 assert(0);
359 }
360
361 fixPolarizations(p);
362
363
364
365 return ;
366
367 }
368 else{
369
370
371
373
374 for(i=0;i<numparton;i++){
375 p4string+=p4[partonindex[i]];
376 }
377
378 int nprimary=1;
379 type[0]=STRNG;
380 for(i=0;i<numstable;i++){
381 if (km[stableindex[i]]==0){
382 type[nprimary++]=evtnumstable[i];
383 }
384 }
385
387
389
391
392 for(i=0;i<numparton;i++){
393 p4partons[i]=p4[partonindex[i]];
394 }
395
397
398
399
400 nprimary=1;
401
402 for(i=0;i<numstable;i++){
403
404 if (km[stableindex[i]]==0){
405 p->
getDaug(nprimary++)->
init(evtnumstable[i],p4[stableindex[i]]);
406 }
407 }
408
409
410 int nsecond=0;
411 for(i=0;i<numstable;i++){
412 if (km[stableindex[i]]!=0){
413 type[nsecond++]=evtnumstable[i];
414 }
415 }
416
417
419
420 EvtVector4R p4stringboost(p4string.get(0),-p4string.get(1),
421 -p4string.get(2),-p4string.get(3));
422
423 nsecond=0;
424 for(i=0;i<numstable;i++){
425 if (km[stableindex[i]]!=0){
426 p4[stableindex[i]]=
boostTo(p4[stableindex[i]],p4stringboost);
430 nsecond++;
431 }
432 }
433
434 if ( nsecond == 0 ) {
435 report(
ERROR,
"EvtGen") <<
"Jetset has failed to do a decay ";
437 assert(0);
438 }
439
440 fixPolarizations(p);
441
442 return ;
443
444 }
445
446}
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
void lundar_(int *, int *, float *, int *, int *, int *, double *, double *, double *, double *)
DOUBLE_PRECISION count[2]
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)