169 {
170
171 static int iniflag = 1;
172
174
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
196
197
198 EvtVector4R p4[50];
199
200 int i, more;
202 int ndaugjs;
203 static int kf[4000];
204 EvtId evtnumstable[100], evtnumparton[100];
205 int stableindex[100], partonindex[100];
206 int numstable;
207 int numparton;
208 static int km[4000];
210
211 int isr = 1;
213
214 static double px[4000], py[4000], pz[4000], e[4000];
215 if ( iniflag == 1 )
lundar_( &isr, &iniflag, &xmp, &ndaugjs, kf, km, px, py, pz, e );
216
218
220 bool mtg = 0;
221
222 do {
223
224 iniflag = iniflag + 1;
225
226 modeSelection:
227 lundar_( &isr, &iniflag, &xmp, &ndaugjs, kf, km, px, py, pz, e );
228
230 if ( mtg ) std::cout <<
"checktag_.decaytag=" <<
checktag_.decaytag << std::endl;
231
232
233
235 numstable = 0;
236 numparton = 0;
237
238 double esum = 0;
239
240
241
242
243
244
245
246 for ( i = 0; i < ndaugjs; i++ )
247 {
248 if ( fabs( kf[i] ) == 11 || kf[i] == 92 || kf[i] == 22 )
249 continue;
250
251
252
254 {
255 report(
ERROR,
"EvtGen" ) <<
"Lunda returned particle:" << kf[i] << endl;
256 report(
ERROR,
"EvtGen" ) <<
"This can not be translated to evt number" << endl;
257 report(
ERROR,
"EvtGen" ) <<
"and the decay will be rejected!" << endl;
258 report(
ERROR,
"EvtGen" ) <<
"The decay was of particle:" << ip << endl;
259
260 std::cout << "xmp= " << xmp << std::endl;
261 goto modeSelection;
262 }
263
264
265 if ( fabs( kf[i] ) <= 6 || kf[i] == 21 )
266 {
267 partonindex[numparton] = i;
269 numparton++;
270 }
271 else
272 {
273 stableindex[numstable] = i;
275 numstable++;
276 }
277
278 esum += e[i];
279
280
281
282
283 if ( px[i] * px[i] + py[i] * py[i] + pz[i] * pz[i] >= e[i] * e[i] )
284 { e[i] = sqrt( px[i] * px[i] + py[i] * py[i] + pz[i] * pz[i] ) + 0.0000000001; }
285
286 p4[i].
set( e[i], px[i], py[i], pz[i] );
287 }
288
290
291
292
293 more = ( channel != -1 );
294
295 if ( fabs( esum - xmp ) > 0.001 )
296 {
297 std::cout << "Unexpected final states from Lunda with total energy " << esum
298 << " unequal to " << xmp << std::endl;
299
300 std::cout << "xmp= " << xmp << std::endl;
301 goto modeSelection;
302 }
303
305 }
while ( more && (
count < 10000 ) && mtg );
306
307
309 {
310 report(
INFO,
"EvtGen" ) <<
"Too many loops in EvtLunda!!!" << endl;
312 for ( i = 0; i < numstable; i++ )
313 {
314 report(
INFO,
"EvtGen" ) <<
"Daug(" << i <<
")"
316 }
317 }
318
319 if ( numparton == 0 )
320 {
321
323 int ndaugFound = 0;
324 for ( i = 0; i < numstable; i++ )
325 {
326 p->
getDaug( i )->
init( evtnumstable[i], p4[stableindex[i]] );
327 ndaugFound++;
328 }
329 if ( ndaugFound == 0 )
330 {
331 report(
ERROR,
"EvtGen" ) <<
"Lunda has failed to do a decay ";
333 << endl;
334 assert( 0 );
335 }
336
337 fixPolarizations( p );
338
339
340
341 return;
342 }
343 else
344 {
345
346
347
348 EvtVector4R p4string( 0.0, 0.0, 0.0, 0.0 );
349
350 for ( i = 0; i < numparton; i++ ) { p4string += p4[partonindex[i]]; }
351
352 int nprimary = 1;
353 type[0] = STRNG;
354 for ( i = 0; i < numstable; i++ )
355 {
356 if ( km[stableindex[i]] == 0 ) { type[nprimary++] = evtnumstable[i]; }
357 }
358
360
362
363 EvtVector4R p4partons[10];
364
365 for ( i = 0; i < numparton; i++ ) { p4partons[i] = p4[partonindex[i]]; }
366
367 ( (EvtStringParticle*)p->
getDaug( 0 ) )->initPartons( numparton, p4partons, evtnumparton );
368
369 nprimary = 1;
370
371 for ( i = 0; i < numstable; i++ )
372 {
373
374 if ( km[stableindex[i]] == 0 )
375 { p->
getDaug( nprimary++ )->
init( evtnumstable[i], p4[stableindex[i]] ); }
376 }
377
378 int nsecond = 0;
379 for ( i = 0; i < numstable; i++ )
380 {
381 if ( km[stableindex[i]] != 0 ) { type[nsecond++] = evtnumstable[i]; }
382 }
383
385
386 EvtVector4R p4stringboost( p4string.get( 0 ), -p4string.get( 1 ), -p4string.get( 2 ),
387 -p4string.get( 3 ) );
388
389 nsecond = 0;
390 for ( i = 0; i < numstable; i++ )
391 {
392 if ( km[stableindex[i]] != 0 )
393 {
394 p4[stableindex[i]] =
boostTo( p4[stableindex[i]], p4stringboost );
398 nsecond++;
399 }
400 }
401
402 if ( nsecond == 0 )
403 {
404 report(
ERROR,
"EvtGen" ) <<
"Jetset has failed to do a decay ";
406 << endl;
407 assert( 0 );
408 }
409
410 fixPolarizations( p );
411
412 return;
413 }
414}
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
void lundar_(int *, int *, float *, int *, int *, int *, double *, double *, double *, double *)
struct @266045204252233114312134205125322121371134010276 checktag_
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)