BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtParticle.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
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.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtParticle.cc
12//
13// Description: Class to describe all particles
14//
15// Modification history:
16//
17// DJL/RYD September 25, 1996 Module created
18//
19//------------------------------------------------------------------------
20//
21#include "EvtParticle.hh"
22#include "EvtCPUtil.hh"
23#include "EvtDecayTable.hh"
24#include "EvtDiracParticle.hh"
25#include "EvtGenKine.hh"
26#include "EvtId.hh"
28#include "EvtPDL.hh"
29#include "EvtParticleFactory.hh"
30#include "EvtPatches.hh"
31#include "EvtPhotonParticle.hh"
32#include "EvtRadCorr.hh"
33#include "EvtRandom.hh"
34#include "EvtRaritaSchwingerParticle.hh" //Pingrg 2007.3.15
35#include "EvtReport.hh"
36#include "EvtScalarParticle.hh"
37#include "EvtSecondary.hh"
38#include "EvtSpinDensity.hh"
39#include "EvtStdHep.hh"
40#include "EvtStringParticle.hh"
41#include "EvtTensorParticle.hh"
42#include "EvtVectorParticle.hh"
43#include <fstream>
44#include <iostream>
45#include <math.h>
46#include <stdio.h>
47#include <stdlib.h>
48#include <strstream>
49#include <sys/stat.h>
50
51using std::endl;
52using std::fstream;
53using std::strstream;
54
58
59EvtParticle::~EvtParticle() { delete _decayProb; }
60
62 _ndaug = 0;
63 _parent = 0;
64 _channel = -10;
65 _t = 0.0;
66 _genlifetime = 1;
67 _first = 1;
68 _isInit = false;
69 _validP4 = false;
70 _isDecayed = false;
71 _decayProb = 0;
72 // _mix=false;
73}
74
75void EvtParticle::setFirstOrNot() { _first = 0; }
76void EvtParticle::resetFirstOrNot() { _first = 1; }
77
78void EvtParticle::setChannel( int i ) { _channel = i; }
79
80EvtParticle* EvtParticle::getDaug( int i ) { return _daug[i]; }
81
82EvtParticle* EvtParticle::getParent() { return _parent; }
83
84void EvtParticle::setLifetime( double tau ) { _t = tau; }
85
87 if ( _genlifetime ) { _t = -log( EvtRandom::Flat() ) * EvtPDL::getctau( getId() ); }
88}
89
90double EvtParticle::getLifetime() { return _t; }
91
93 node->_daug[node->_ndaug++] = this;
94 _ndaug = 0;
95 _parent = node;
96}
97
98int EvtParticle::firstornot() const { return _first; }
99
100EvtId EvtParticle::getId() const { return _id; }
101
103
107
108const EvtVector4R& EvtParticle::getP4() const { return _p; }
109
110int EvtParticle::getChannel() const { return _channel; }
111
112int EvtParticle::getNDaug() const { return _ndaug; }
113
114double EvtParticle::mass() const { return _p.mass(); }
115
116void EvtParticle::setDiagonalSpinDensity() { _rhoForward.SetDiag( getSpinStates() ); }
117
119
120 if ( getSpinStates() != 3 )
121 {
122 report( ERROR, "EvtGen" ) << "Error in EvtParticle::setVectorSpinDensity" << endl;
123 report( ERROR, "EvtGen" ) << "spin_states:" << getSpinStates() << endl;
124 report( ERROR, "EvtGen" ) << "particle:" << EvtPDL::name( _id ).c_str() << endl;
125 ::abort();
126 }
127
128 EvtSpinDensity rho;
129
130 // Set helicity +1 and -1 to 1.
131 rho.SetDiag( getSpinStates() );
132 rho.Set( 1, 1, EvtComplex( 0.0, 0.0 ) );
134}
135
136void EvtParticle::setPolarizedSpinDensity( double r00, double r11, double r22 ) {
137
138 if ( getSpinStates() != 3 )
139 {
140 report( ERROR, "EvtGen" ) << "Error in EvtParticle::setVectorSpinDensity" << endl;
141 report( ERROR, "EvtGen" ) << "spin_states:" << getSpinStates() << endl;
142 report( ERROR, "EvtGen" ) << "particle:" << EvtPDL::name( _id ).c_str() << endl;
143 ::abort();
144 }
145
146 EvtSpinDensity rho;
147
148 // Set helicity +1 and -1 to 1.
149 rho.SetDiag( getSpinStates() );
150 rho.Set( 0, 0, EvtComplex( r00, 0. ) );
151 rho.Set( 1, 1, EvtComplex( r11, 0. ) );
152 rho.Set( 2, 2, EvtComplex( r22, 0. ) );
154}
155
157
159
160 assert( R.GetDim() == rho.GetDim() );
161
162 int n = rho.GetDim();
163
164 _rhoForward.SetDim( n );
165
166 int i, j, k, l;
167
168 for ( i = 0; i < n; i++ )
169 {
170 for ( j = 0; j < n; j++ )
171 {
172 EvtComplex tmp = 0.0;
173 for ( k = 0; k < n; k++ )
174 {
175 for ( l = 0; l < n; l++ )
176 { tmp += R.Get( l, i ) * rho.Get( l, k ) * conj( R.Get( k, j ) ); }
177 }
178 _rhoForward.Set( i, j, tmp );
179 }
180 }
181
182 // report(INFO,"EvtGen") << "_rhoForward:"<<_rhoForward<<endl;
183}
184
186 double beta, double gamma ) {
187
188 EvtSpinDensity R = rotateToHelicityBasis( alpha, beta, gamma );
189
190 assert( R.GetDim() == rho.GetDim() );
191
192 int n = rho.GetDim();
193
194 _rhoForward.SetDim( n );
195
196 int i, j, k, l;
197
198 for ( i = 0; i < n; i++ )
199 {
200 for ( j = 0; j < n; j++ )
201 {
202 EvtComplex tmp = 0.0;
203 for ( k = 0; k < n; k++ )
204 {
205 for ( l = 0; l < n; l++ )
206 { tmp += R.Get( l, i ) * rho.Get( l, k ) * conj( R.Get( k, j ) ); }
207 }
208 _rhoForward.Set( i, j, tmp );
209 }
210 }
211
212 // report(INFO,"EvtGen") << "_rhoForward:"<<_rhoForward<<endl;
213}
214
215void EvtParticle::initDecay( bool useMinMass ) {
216
217 EvtParticle* p = this;
218 // carefull - the parent mass might be fixed in stone..
219 EvtParticle* par = p->getParent();
220 double parMass = -1.;
221 if ( par != 0 )
222 {
223 if ( par->hasValidP4() ) parMass = par->mass();
224 int i;
225 for ( i = 0; i < par->getNDaug(); i++ )
226 {
227 EvtParticle* tDaug = par->getDaug( i );
228 if ( p != tDaug ) parMass -= EvtPDL::getMinMass( tDaug->getId() );
229 }
230 }
231
232 if ( _isInit )
233 {
234 // we have already been here - just reroll the masses!
235 if ( _ndaug > 0 )
236 {
237 int ii;
238 for ( ii = 0; ii < _ndaug; ii++ )
239 {
240 if ( _ndaug == 1 || EvtPDL::getWidth( p->getDaug( ii )->getId() ) > 0.0000001 )
241 p->getDaug( ii )->initDecay( useMinMass );
242 else p->getDaug( ii )->setMass( EvtPDL::getMeanMass( p->getDaug( ii )->getId() ) );
243 }
244 }
245
246 int j;
247 EvtId* dauId = 0;
248 double* dauMasses = 0;
249 if ( _ndaug > 0 )
250 {
251 dauId = new EvtId[_ndaug];
252 dauMasses = new double[_ndaug];
253 for ( j = 0; j < _ndaug; j++ )
254 {
255 dauId[j] = p->getDaug( j )->getId();
256 dauMasses[j] = p->getDaug( j )->mass();
257 }
258 }
259 EvtId* parId = 0;
260 EvtId* othDauId = 0;
261 EvtParticle* tempPar = p->getParent();
262 if ( tempPar )
263 {
264 parId = new EvtId( tempPar->getId() );
265 if ( tempPar->getNDaug() == 2 )
266 {
267 if ( tempPar->getDaug( 0 ) == this )
268 othDauId = new EvtId( tempPar->getDaug( 1 )->getId() );
269 else othDauId = new EvtId( tempPar->getDaug( 0 )->getId() );
270 }
271 }
272 if ( p->getParent() && _validP4 == false )
273 {
274 if ( !useMinMass )
275 p->setMass( EvtPDL::getRandMass( p->getId(), parId, _ndaug, dauId, othDauId, parMass,
276 dauMasses ) );
277 else p->setMass( EvtPDL::getMinMass( p->getId() ) );
278 }
279 if ( parId ) delete parId;
280 if ( othDauId ) delete othDauId;
281 if ( dauId ) delete[] dauId;
282 if ( dauMasses ) delete[] dauMasses;
283 return;
284 }
285
286 // Will include effects of mixing here
287 // added by Lange Jan4,2000
288 static EvtId BS0 = EvtPDL::getId( "B_s0" );
289 static EvtId BSB = EvtPDL::getId( "anti-B_s0" );
290 static EvtId BD0 = EvtPDL::getId( "B0" );
291 static EvtId BDB = EvtPDL::getId( "anti-B0" );
292
293 // only makes sense if there is no parent particle
294 if ( ( getNDaug() == 0 && getParent() == 0 ) &&
295 ( getId() == BS0 || getId() == BSB || getId() == BD0 || getId() == BDB ) )
296 {
297 double t;
298 int mix;
300 setLifetime( t );
301
302 if ( mix )
303 {
304
305 EvtScalarParticle* scalar_part;
306
307 scalar_part = new EvtScalarParticle;
308 if ( getId() == BS0 )
309 {
310 EvtVector4R p_init( EvtPDL::getMass( BSB ), 0.0, 0.0, 0.0 );
311 scalar_part->init( BSB, p_init );
312 }
313 else if ( getId() == BSB )
314 {
315 EvtVector4R p_init( EvtPDL::getMass( BS0 ), 0.0, 0.0, 0.0 );
316 scalar_part->init( BS0, p_init );
317 }
318 else if ( getId() == BD0 )
319 {
320 EvtVector4R p_init( EvtPDL::getMass( BDB ), 0.0, 0.0, 0.0 );
321 scalar_part->init( BDB, p_init );
322 }
323 else if ( getId() == BDB )
324 {
325 EvtVector4R p_init( EvtPDL::getMass( BD0 ), 0.0, 0.0, 0.0 );
326 scalar_part->init( BD0, p_init );
327 }
328
329 scalar_part->setLifetime( 0 );
330
331 scalar_part->setDiagonalSpinDensity();
332
333 insertDaugPtr( 0, scalar_part );
334
335 _ndaug = 1;
336 _isInit = true;
337 p = scalar_part;
338 p->initDecay( useMinMass );
339 return;
340 }
341 }
342 if ( _ndaug == 1 ) std::cout << "hi " << EvtPDL::name( this->getId() ) << std::endl;
343
344 EvtDecayBase* decayer;
345 decayer = EvtDecayTable::getDecayFunc( p );
346
347 if ( decayer )
348 {
349 p->makeDaughters( decayer->nRealDaughters(), decayer->getDaugs() );
350 // report(INFO,"EvtGen") << "has found decay " << decayer->nRealDaughters() << endl;
351 // then loop over the daughters and init their decay
352 int i;
353 for ( i = 0; i < p->getNDaug(); i++ )
354 {
355 if ( EvtPDL::getWidth( p->getDaug( i )->getId() ) > 0.0000001 )
356 p->getDaug( i )->initDecay( useMinMass );
357 else p->getDaug( i )->setMass( EvtPDL::getMeanMass( p->getDaug( i )->getId() ) );
358 // report(INFO,"EvtGen") << "has inited " << EvtPDL::name(p->getDaug(i)->getId()) <<
359 // " " << EvtPDL::name(p->getId()) << endl;
360 }
361 }
362 // figure masses in separate step...
363 // if ( p->getParent() && _validP4==false ) EvtDecayBase::findMass(p);
364
365 int j;
366 EvtId* dauId = 0;
367 double* dauMasses = 0;
368 int nDaugT = p->getNDaug();
369 if ( nDaugT > 0 )
370 {
371 dauId = new EvtId[nDaugT];
372 dauMasses = new double[nDaugT];
373 for ( j = 0; j < nDaugT; j++ )
374 {
375 dauId[j] = p->getDaug( j )->getId();
376 dauMasses[j] = p->getDaug( j )->mass();
377 }
378 }
379
380 EvtId* parId = 0;
381 EvtId* othDauId = 0;
382 EvtParticle* tempPar = p->getParent();
383 if ( tempPar )
384 {
385 parId = new EvtId( tempPar->getId() );
386 if ( tempPar->getNDaug() == 2 )
387 {
388 if ( tempPar->getDaug( 0 ) == this )
389 othDauId = new EvtId( tempPar->getDaug( 1 )->getId() );
390 else othDauId = new EvtId( tempPar->getDaug( 0 )->getId() );
391 }
392 }
393 if ( p->getParent() && p->hasValidP4() == false )
394 {
395 if ( !useMinMass )
396 p->setMass( EvtPDL::getRandMass( p->getId(), parId, p->getNDaug(), dauId, othDauId,
397 parMass, dauMasses ) );
398 else p->setMass( EvtPDL::getMinMass( p->getId() ) );
399 }
400 if ( parId ) delete parId;
401 if ( othDauId ) delete othDauId;
402 if ( dauId ) delete[] dauId;
403 if ( dauMasses ) delete[] dauMasses;
404 _isInit = true;
405}
406
408
409 // P is particle to decay, typically 'this' but sometime
410 // modified by mixing
411 EvtParticle* p = this;
412 // Did it mix?
413 // if ( p->getMixed() ) {
414 // should take C(p) - this should only
415 // happen the first time we call decay for this
416 // particle
417 // p->takeCConj();
418 // p->setUnMixed();
419 // }
420 EvtSpinDensity myRho; // pingrg test code
421 EvtDecayBase* decayer;
422 decayer = EvtDecayTable::getDecayFunc( p );
423 // if ( decayer ) {
424 // report(INFO,"EvtGen") << "calling decay for " << EvtPDL::name(p->getId()) << " " <<
425 // p->mass() << " " << p->getP4() << " " << p->getNDaug() << " " << p << endl;
426 // report(INFO,"EvtGen") << "NDaug= " << decayer->getNDaug() << endl; int ti; for ( ti=0;
427 // ti<decayer->getNDaug(); ti++)
428 // report(INFO,"EvtGen") << "Daug " << ti << " " << EvtPDL::name(decayer->getDaug(ti))
429 // << endl;
430 // }
431 // if (p->_ndaug>0) {
432 // report(INFO,"EvtGen") <<"Is decaying particle with daughters!!!!!"<<endl;
433 // ::abort();
434 // return;
435 // call initdecay first - April 29,2002 - Lange
436 //}
437
438 // if there are already daughters, then this step is already done!
439 // figure out the masses
440 if ( _ndaug == 0 ) generateMassTree();
441 static EvtId BS0 = EvtPDL::getId( "B_s0" );
442 static EvtId BSB = EvtPDL::getId( "anti-B_s0" );
443 static EvtId BD0 = EvtPDL::getId( "B0" );
444 static EvtId BDB = EvtPDL::getId( "anti-B0" );
445 if ( _ndaug == 1 &&
446 ( getId() == BS0 || getId() == BSB || getId() == BD0 || getId() == BDB ) )
447 {
448 getDaug( 0 )->decay();
449 std::cout
450 << "if ( _ndaug==1 && (getId()==BS0||getId()==BSB||getId()==BD0||getId()==BDB) )"
451 << endl;
452 }
453
454 else
455 {
456 // now we have accepted a set of masses - time
457 if ( decayer )
458 {
459 decayer->makeDecay( p );
460 // p->printTree(); //for debugging
461 }
462 else { p->_rhoBackward.SetDiag( p->getSpinStates() ); }
463 }
464 _isDecayed = true;
465 return;
466}
467
469 double massProb = 1.;
470 double ranNum = 2.;
471 int counter = 0;
472 EvtParticle* p = this;
473 while ( massProb < ranNum )
474 {
475 // check it out the first time.
476 p->initDecay();
477 // report(INFO,"EvtGen") << "calling massProb \n";
478 massProb = p->compMassProb();
479 ranNum = EvtRandom::Flat();
480 // report(INFO,"EvtGen") << "end of iter " << massProb <<endl;
481 counter++;
482
483 if ( counter > 10000 )
484 {
485 if ( counter == 10001 )
486 {
487 report( INFO, "EvtGen" )
488 << "Too many iterations to determine the mass tree. Parent mass= " << p->mass()
489 << _p << " " << massProb << endl;
490 p->printTree();
491 report( INFO, "EvtGen" ) << "will take next combo with non-zero likelihood\n";
492 }
493 if ( massProb > 0. ) massProb = 2.0;
494 if ( counter > 20000 )
495 {
496 // one last try - take the minimum masses
497 p->initDecay( true );
498 p->printTree();
499 massProb = p->compMassProb();
500 if ( massProb > 0. )
501 {
502 massProb = 2.0;
503 report( INFO, "EvtGen" )
504 << "Taking the minimum mass of all particles in the chain\n";
505 }
506 else
507 {
508 report( INFO, "EvtGen" ) << "Sorry, no luck finding a valid set of masses. This "
509 "may be a pathological combo\n";
510 std::cout << EvtPDL::name( p->getId() ) << ": Parent mass " << p->getP4().mass()
511 << " with momentum " << p->getP4() << std::endl;
513 {
515 return;
516 }
517 else { abort(); }
518 // assert(0);
519 }
520 }
521 }
522 }
523 // report(INFO,"EvtGen") << counter << endl;
524 // p->printTree();
525}
526
528
529 EvtParticle* p = this;
530 // report(INFO,"EvtGen") << "compMassProb " << endl;
531 // p->printTree();
532 double mass = p->mass();
533 double parMass = 0.;
534 if ( p->getParent() ) { parMass = p->getParent()->mass(); }
535
536 int nDaug = p->getNDaug();
537 double* dMasses = 0;
538
539 int i;
540 if ( nDaug > 0 )
541 {
542 dMasses = new double[nDaug];
543 for ( i = 0; i < nDaug; i++ ) dMasses[i] = p->getDaug( i )->mass();
544 }
545
546 double temp = 1.0;
547 temp = EvtPDL::getMassProb( p->getId(), mass, parMass, nDaug, dMasses );
548
549 // report(INFO,"EvtGen") << temp << " " << EvtPDL::name(p->getId()) << endl;
550 // If the particle already has a mass, we dont need to include
551 // it in the probability calculation
552 if ( ( !p->getParent() || _validP4 ) && temp > 0.0 ) temp = 1.;
553
554 delete[] dMasses;
555 // if ( temp < 0.9999999 )
556 for ( i = 0; i < nDaug; i++ ) { temp *= p->getDaug( i )->compMassProb(); }
557 return temp;
558}
559
560void EvtParticle::deleteDaughters( bool keepChannel ) {
561 int i;
562
563 for ( i = 0; i < _ndaug; i++ ) { _daug[i]->deleteTree(); }
564
565 _ndaug = 0;
566 // if ( keepChannel ) report(INFO,"EvtGen") << "keeping \n";
567 if ( !keepChannel ) _channel = -10;
568 //_t=0.0;
569 //_genlifetime=1;
570 _first = 1;
571 _isInit = false;
572 // report(INFO,"EvtGen") << "calling deletedaughters " << EvtPDL::name(this->getId()) <<endl;
573}
574
576
577 this->deleteDaughters();
578
579 delete this;
580}
581
583 EvtVector4C temp;
585 report( ERROR, "EvtGen" ) << "and you have asked for the:" << i << "th polarization vector."
586 << " I.e. you thought it was a"
587 << " vector particle!" << endl;
588 ::abort();
589 return temp;
590}
591
593 EvtVector4C temp;
595 report( ERROR, "EvtGen" ) << "and you have asked for the:" << i << "th polarization vector."
596 << " I.e. you thought it was a"
597 << " vector particle!" << endl;
598 ::abort();
599 return temp;
600}
601
603 EvtVector4C temp;
605 report( ERROR, "EvtGen" ) << "and you have asked for the:" << i
606 << "th polarization vector of photon."
607 << " I.e. you thought it was a"
608 << " photon particle!" << endl;
609 ::abort();
610 return temp;
611}
612
614 EvtVector4C temp;
616 report( ERROR, "EvtGen" ) << "and you have asked for the:" << i
617 << "th polarization vector of a photon."
618 << " I.e. you thought it was a"
619 << " photon particle!" << endl;
620 ::abort();
621 return temp;
622}
623
625 EvtDiracSpinor tempD;
626 int temp;
627 temp = i;
629 report( ERROR, "EvtGen" ) << "and you have asked for the:" << i << "th dirac spinor."
630 << " I.e. you thought it was a"
631 << " Dirac particle!" << endl;
632 ::abort();
633 return tempD;
634}
635
637 EvtDiracSpinor tempD;
638 int temp;
639 temp = i;
641 report( ERROR, "EvtGen" ) << "and you have asked for the:" << i << "th dirac spinor."
642 << " I.e. you thought it was a"
643 << " Dirac particle!" << endl;
644 ::abort();
645 return tempD;
646}
647
649 EvtDiracSpinor tempD;
651 report( ERROR, "EvtGen" ) << "and you have asked for the "
652 << "dirac spinor."
653 << " I.e. you thought it was a"
654 << " neutrino particle!" << endl;
655 ::abort();
656 return tempD;
657}
658
660 EvtDiracSpinor tempD;
662 report( ERROR, "EvtGen" ) << "and you have asked for the "
663 << "dirac spinor."
664 << " I.e. you thought it was a"
665 << " neutrino particle!" << endl;
666 ::abort();
667 return tempD;
668}
669
671 int temp;
672 temp = i;
673 EvtTensor4C tempC;
675 report( ERROR, "EvtGen" ) << "and you have asked for the:" << i << "th tensor."
676 << " I.e. you thought it was a"
677 << " Tensor particle!" << endl;
678 ::abort();
679 return tempC;
680}
681
683 int temp;
684 temp = i;
685 EvtTensor4C tempC;
687 report( ERROR, "EvtGen" ) << "and you have asked for the:" << i << "th tensor."
688 << " I.e. you thought it was a"
689 << " Tensor particle!" << endl;
690 ::abort();
691 return tempC;
692}
693
695 EvtVector4R temp, mom;
696 EvtParticle* ptemp;
697
698 temp = this->getP4();
699 ptemp = this;
700
701 while ( ptemp->getParent() != 0 )
702 {
703 ptemp = ptemp->getParent();
704 mom = ptemp->getP4();
705 temp = boostTo( temp, mom );
706 }
707 return temp;
708}
709
711
713
714 EvtVector4R temp, mom;
715 EvtParticle* ptemp;
716
717 temp.set( 0.0, 0.0, 0.0, 0.0 );
718 ptemp = getParent();
719
720 if ( ptemp == 0 ) return temp;
721
722 temp = ( ptemp->_t / ptemp->mass() ) * ( ptemp->getP4() );
723
724 while ( ptemp->getParent() != 0 )
725 {
726 ptemp = ptemp->getParent();
727 mom = ptemp->getP4();
728 temp = boostTo( temp, mom );
729 temp = temp + ( ptemp->_t / ptemp->mass() ) * ( ptemp->getP4() );
730 }
731
732 return temp;
733}
734
736
737 EvtParticle* bpart;
738 EvtParticle* current;
739
740 current = this;
741 int i;
742
743 if ( _ndaug != 0 ) return _daug[0];
744
745 do {
746 bpart = current->_parent;
747 if ( bpart == 0 ) return 0;
748 i = 0;
749 while ( bpart->_daug[i] != current ) { i++; }
750
751 if ( bpart == rootOfTree )
752 {
753 if ( i == bpart->_ndaug - 1 ) return 0;
754 }
755
756 i++;
757 current = bpart;
758
759 } while ( i >= bpart->_ndaug );
760
761 return bpart->_daug[i];
762}
763
765 EvtId* list_of_stable ) {
766
767 // first add particle to the stdhep list;
768 stdhep.createParticle( getP4Lab(), get4Pos(), -1, -1, EvtPDL::getStdHep( getId() ) );
769
770 int ii = 0;
771
772 // lets see if this is a longlived particle and terminate the
773 // list building!
774
775 while ( list_of_stable[ii] != EvtId( -1, -1 ) )
776 {
777 if ( getId() == list_of_stable[ii] )
778 {
779 secondary.createSecondary( 0, this );
780 return;
781 }
782 ii++;
783 }
784
785 int i;
786 for ( i = 0; i < _ndaug; i++ )
787 {
788 stdhep.createParticle( _daug[i]->getP4Lab(), _daug[i]->get4Pos(), 0, 0,
789 EvtPDL::getStdHep( _daug[i]->getId() ) );
790 }
791
792 for ( i = 0; i < _ndaug; i++ )
793 { _daug[i]->makeStdHepRec( 1 + i, 1 + i, stdhep, secondary, list_of_stable ); }
794 return;
795}
796
798
799 // first add particle to the stdhep list;
800 stdhep.createParticle( getP4Lab(), get4Pos(), -1, -1, EvtPDL::getStdHep( getId() ) );
801
802 int i;
803 for ( i = 0; i < _ndaug; i++ )
804 {
805 stdhep.createParticle( _daug[i]->getP4Lab(), _daug[i]->get4Pos(), 0, 0,
806 EvtPDL::getStdHep( _daug[i]->getId() ) );
807 }
808
809 for ( i = 0; i < _ndaug; i++ ) { _daug[i]->makeStdHepRec( 1 + i, 1 + i, stdhep ); }
810 return;
811}
812
813void EvtParticle::makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep,
814 EvtSecondary& secondary, EvtId* list_of_stable ) {
815
816 int ii = 0;
817
818 // lets see if this is a longlived particle and terminate the
819 // list building!
820
821 while ( list_of_stable[ii] != EvtId( -1, -1 ) )
822 {
823 if ( getId() == list_of_stable[ii] )
824 {
825 secondary.createSecondary( firstparent, this );
826 return;
827 }
828 ii++;
829 }
830
831 int i;
832 int parent_num = stdhep.getNPart();
833 for ( i = 0; i < _ndaug; i++ )
834 {
835 stdhep.createParticle( _daug[i]->getP4Lab(), _daug[i]->get4Pos(), firstparent, lastparent,
836 EvtPDL::getStdHep( _daug[i]->getId() ) );
837 }
838
839 for ( i = 0; i < _ndaug; i++ )
840 {
841 _daug[i]->makeStdHepRec( parent_num + i, parent_num + i, stdhep, secondary,
842 list_of_stable );
843 }
844 return;
845}
846
847void EvtParticle::makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep ) {
848
849 int i;
850 int parent_num = stdhep.getNPart();
851 for ( i = 0; i < _ndaug; i++ )
852 {
853 stdhep.createParticle( _daug[i]->getP4Lab(), _daug[i]->get4Pos(), firstparent, lastparent,
854 EvtPDL::getStdHep( _daug[i]->getId() ) );
855 }
856
857 for ( i = 0; i < _ndaug; i++ )
858 { _daug[i]->makeStdHepRec( parent_num + i, parent_num + i, stdhep ); }
859 return;
860}
861
862void EvtParticle::printTreeRec( int level ) const {
863
864 int newlevel, i;
865 newlevel = level + 1;
866
867 if ( _ndaug != 0 )
868 {
869 if ( level > 0 )
870 {
871 for ( i = 0; i < ( 5 * level ); i++ ) { report( INFO, "" ) << " "; }
872 }
873 report( INFO, "" ) << EvtPDL::name( _id ).c_str();
874 report( INFO, "" ) << " -> ";
875 for ( i = 0; i < _ndaug; i++ )
876 { report( INFO, "" ) << EvtPDL::name( _daug[i]->getId() ).c_str() << " "; }
877 for ( i = 0; i < _ndaug; i++ ) { report( INFO, "" ) << _daug[i]->mass() << " "; }
878 report( INFO, "" ) << endl;
879 for ( i = 0; i < _ndaug; i++ ) { _daug[i]->printTreeRec( newlevel ); }
880 }
881}
882
884
885 report( INFO, "EvtGen" ) << "This is the current decay chain" << endl;
886 report( INFO, "" ) << "This top particle is " << EvtPDL::name( _id ).c_str() << endl;
887
888 this->printTreeRec( 0 );
889 report( INFO, "EvtGen" ) << "End of decay chain." << endl;
890}
891
892std::string EvtParticle::treeStrRec( int level ) const {
893
894 int newlevel, i;
895 newlevel = level + 1;
896
897 std::string retval = "";
898
899 for ( i = 0; i < _ndaug; i++ )
900 {
901 retval += EvtPDL::name( _daug[i]->getId() );
902 if ( _daug[i]->getNDaug() > 0 )
903 {
904 retval += " (";
905 retval += _daug[i]->treeStrRec( newlevel );
906 retval += ") ";
907 }
908 else
909 {
910 if ( i != _ndaug - 1 ) retval += " ";
911 }
912 }
913
914 return retval;
915}
916
917std::string EvtParticle::writeTreeRec( std::string resonance ) const { // pingrg, Jun. 6, 2008
918 std::string retval = "";
919
920 if ( resonance == EvtPDL::name( _id ).c_str() && _ndaug != 0 )
921 {
922 retval = resonance + ": " + IntToStr( _ndaug ) + " ";
923 for ( int i = 0; i < _ndaug; i++ )
924 {
925 retval += EvtPDL::name( _daug[i]->getId() ).c_str();
926 retval += " ";
927 }
928 }
929
930 for ( int i = 0; i < _ndaug; i++ ) { _daug[i]->writeTreeRec( resonance ); }
931 std::cout << retval;
932 return retval;
933}
934
935void EvtParticle::dumpTreeRec( int level, int dj ) const { // pingrg, Mar. 25,2008
936
937 int newlevel, i;
938 newlevel = level + 1;
939
940 if ( _ndaug != 0 )
941 {
942
943 int Ids = EvtPDL::getStdHep( _id );
944 std::string c1, cid;
945 if ( Ids > 0 ) c1 = "p";
946 if ( Ids < 0 )
947 {
948 c1 = "m";
949 Ids = -1 * Ids;
950 }
951
952 cid = c1 + IntToStr( Ids );
953
954 report( INFO, "" ) << newlevel << " " << cid << " " << dj;
955 report( INFO, "" ) << " = ";
956
957 int Nchannel = this->getChannel() + 1;
958 report( INFO, "" ) << Nchannel << endl;
959
960 for ( i = 0; i < _ndaug; i++ ) { _daug[i]->dumpTreeRec( newlevel, i ); }
961 }
962}
963
964void EvtParticle::dumpTree() const { // pingrg, Mar. 25,2008
965
966 report( INFO, "EvtGen" ) << "This is the current decay chain to dump" << endl;
967 report( INFO, "" ) << "This top particle is " << EvtPDL::name( _id ).c_str() << endl;
968
969 this->dumpTreeRec( 0, 0 );
970 report( INFO, "EvtGen" ) << "End of decay chain." << endl;
971}
972
973std::string EvtParticle::treeStr() const {
974
975 std::string retval = EvtPDL::name( _id );
976 retval += " -> ";
977
978 retval += treeStrRec( 0 );
979
980 return retval;
981}
982
984
985 switch ( EvtPDL::getSpinType( _id ) )
986 {
988 report( INFO, "EvtGen" ) << "This is a scalar particle:" << EvtPDL::name( _id ).c_str()
989 << "\n";
990 break;
992 report( INFO, "EvtGen" ) << "This is a vector particle:" << EvtPDL::name( _id ).c_str()
993 << "\n";
994 break;
996 report( INFO, "EvtGen" ) << "This is a tensor particle:" << EvtPDL::name( _id ).c_str()
997 << "\n";
998 break;
1000 report( INFO, "EvtGen" ) << "This is a dirac particle:" << EvtPDL::name( _id ).c_str()
1001 << "\n";
1002 break;
1004 report( INFO, "EvtGen" ) << "This is a photon:" << EvtPDL::name( _id ).c_str() << "\n";
1005 break;
1007 report( INFO, "EvtGen" ) << "This is a neutrino:" << EvtPDL::name( _id ).c_str() << "\n";
1008 break;
1010 report( INFO, "EvtGen" ) << "This is a raritaschwinger:" << EvtPDL::name( _id ).c_str()
1011 << "\n";
1012 break;
1014 report( INFO, "EvtGen" ) << "This is a string:" << EvtPDL::name( _id ).c_str() << "\n";
1015 break;
1016 default:
1017 report( INFO, "EvtGen" ) << "Unknown particle type in EvtParticle::printParticle()"
1018 << endl;
1019 break;
1020 }
1021 report( INFO, "EvtGen" ) << "Number of daughters:" << _ndaug << "\n";
1022}
1023
1024void init_vector( EvtParticle** part ) { *part = (EvtParticle*)new EvtVectorParticle; }
1025
1026void init_scalar( EvtParticle** part ) { *part = (EvtParticle*)new EvtScalarParticle; }
1027
1028void init_tensor( EvtParticle** part ) { *part = (EvtParticle*)new EvtTensorParticle; }
1029
1030void init_dirac( EvtParticle** part ) { *part = (EvtParticle*)new EvtDiracParticle; }
1031
1032void init_photon( EvtParticle** part ) { *part = (EvtParticle*)new EvtPhotonParticle; }
1033
1037
1039
1040void init_string( EvtParticle** part ) { *part = (EvtParticle*)new EvtStringParticle; }
1041
1042double EvtParticle::initializePhaseSpace( int numdaughter, EvtId* daughters, double poleSize,
1043 int whichTwo1, int whichTwo2 ) {
1044
1045 double m_b;
1046 int i;
1047 // lange
1048 // this->makeDaughters(numdaughter,daughters);
1049
1050 static EvtVector4R p4[100];
1051 static double mass[100];
1052
1053 m_b = this->mass();
1054
1055 // lange - Jan2,2002 - Need to check to see if the daughters of the parent
1056 // have changed. If so, delete them and start over.
1057 // report(INFO,"EvtGen") << "the parent is\n";
1058 // if ( this->getParent() ) {
1059 // if ( this->getParent()->getParent() ) this->getParent()->getParent()->printTree();
1060 // this->getParent()->printTree();
1061 //}
1062 // report(INFO,"EvtGen") << "and this is\n";
1063 // if ( this) this->printTree();
1064 bool resetDaughters = false;
1065 if ( numdaughter != this->getNDaug() && this->getNDaug() > 0 ) resetDaughters = true;
1066 if ( numdaughter == this->getNDaug() )
1067 for ( i = 0; i < numdaughter; i++ )
1068 {
1069 if ( this->getDaug( i )->getId() != daughters[i] ) resetDaughters = true;
1070 // report(INFO,"EvtGen") << this->getDaug(i)->getId() << " " << daughters[i] << endl;
1071 }
1072
1073 if ( resetDaughters )
1074 {
1075 // report(INFO,"EvtGen") << "reseting daughters\n";
1076 // for (i=0; i<numdaughter;i++) {
1077 // report(INFO,"EvtGen") << "reset " <<i<< " "<< EvtPDL::name(this->getDaug(i)->getId())
1078 // << " " << EvtPDL::name(daughters[i]) << endl;
1079 //}
1080 bool t1 = true;
1081 // but keep the decay channel of the parent.
1082 this->deleteDaughters( t1 );
1083 this->makeDaughters( numdaughter, daughters );
1084 this->generateMassTree();
1085 }
1086
1087 double weight = 0.;
1088 // EvtDecayBase::findMasses( this, numdaughter, daughters, mass );
1089 // get the list of masses
1090 // report(INFO,"EvtGen") << "mpar= " << m_b << " " << this <<endl;
1091 for ( i = 0; i < numdaughter; i++ )
1092 {
1093 mass[i] = this->getDaug( i )->mass();
1094 // report(INFO,"EvtGen") << "mass " << i << " " << mass[i] << " " << this->getDaug(i) <<
1095 // endl;
1096 }
1097
1098 if ( poleSize < -0.1 )
1099 {
1100 EvtGenKine::PhaseSpace( numdaughter, mass, p4, m_b );
1101 for ( i = 0; i < numdaughter; i++ ) { this->getDaug( i )->init( daughters[i], p4[i] ); }
1102 }
1103 else
1104 {
1105 if ( numdaughter != 3 )
1106 {
1107 report( ERROR, "EvtGen" ) << "Only can generate pole phase space "
1108 << "distributions for 3 body final states" << endl
1109 << "Will terminate." << endl;
1110 ::abort();
1111 }
1112 bool ok = false;
1113 if ( ( whichTwo1 == 1 && whichTwo2 == 0 ) || ( whichTwo1 == 0 && whichTwo2 == 1 ) )
1114 {
1115 weight = EvtGenKine::PhaseSpacePole( m_b, mass[0], mass[1], mass[2], poleSize, p4 );
1116 // report(INFO,"EvtGen") << "here " << weight << " " << poleSize << endl;
1117 this->getDaug( 0 )->init( daughters[0], p4[0] );
1118 this->getDaug( 1 )->init( daughters[1], p4[1] );
1119 this->getDaug( 2 )->init( daughters[2], p4[2] );
1120 ok = true;
1121 }
1122 if ( ( whichTwo1 == 1 && whichTwo2 == 2 ) || ( whichTwo1 == 2 && whichTwo2 == 1 ) )
1123 {
1124 weight = EvtGenKine::PhaseSpacePole( m_b, mass[2], mass[1], mass[0], poleSize, p4 );
1125 this->getDaug( 0 )->init( daughters[0], p4[2] );
1126 this->getDaug( 1 )->init( daughters[1], p4[1] );
1127 this->getDaug( 2 )->init( daughters[2], p4[0] );
1128 ok = true;
1129 }
1130 if ( ( whichTwo1 == 0 && whichTwo2 == 2 ) || ( whichTwo1 == 2 && whichTwo2 == 0 ) )
1131 {
1132 weight = EvtGenKine::PhaseSpacePole( m_b, mass[1], mass[0], mass[2], poleSize, p4 );
1133 this->getDaug( 0 )->init( daughters[0], p4[1] );
1134 this->getDaug( 1 )->init( daughters[1], p4[0] );
1135 this->getDaug( 2 )->init( daughters[2], p4[2] );
1136 ok = true;
1137 }
1138 if ( !ok )
1139 {
1140 report( ERROR, "EvtGen" ) << "Invalid pair of particle to generate a pole dist"
1141 << whichTwo1 << " " << whichTwo2 << endl
1142 << "Will terminate." << endl;
1143 ::abort();
1144 }
1145 }
1146
1147 return weight;
1148}
1149
1150void EvtParticle::makeDaughters( int ndaugstore, EvtId* id ) {
1151
1152 int i;
1153 if ( _channel < 0 )
1154 {
1155 // report(INFO,"EvtGen") << "setting channel " << EvtPDL::name(this->getId()) << endl;
1156 setChannel( 0 );
1157 }
1158 EvtParticle* pdaug;
1159 if ( _ndaug != 0 )
1160 {
1161 if ( _ndaug != ndaugstore )
1162 {
1163 report( ERROR, "EvtGen" ) << "Asking to make a different number of "
1164 << "daughters than what was previously created." << endl
1165 << "Will terminate." << endl;
1166 ::abort();
1167 }
1168 }
1169 else
1170 {
1171 for ( i = 0; i < ndaugstore; i++ )
1172 {
1174 pdaug->setId( id[i] );
1175 pdaug->addDaug( this );
1176 }
1177
1178 } // else
1179} // makeDaughters
1180
1181void EvtParticle::setDecayProb( double prob ) {
1182
1183 if ( _decayProb == 0 ) _decayProb = new double;
1184 *_decayProb = prob;
1185}
1186
1187// ---------- pingrg;2008-03-24
1188std::string IntToStr( int a ) {
1189 std::string ans;
1190 std::string ans1;
1191 int k = 10;
1192 while ( a > 0 )
1193 {
1194 ans += char( a % 10 + 48 );
1195 a /= 10;
1196 }
1197 for ( int i = ans.size() - 1; i >= 0; i-- ) { ans1 += ans[i]; }
1198 return ans1;
1199}
const Int_t n
Evt3Rank3C conj(const Evt3Rank3C &t2)
EvtDiracSpinor boostTo(const EvtDiracSpinor &sp, const EvtVector4R p4)
void init_photon(EvtParticle **part)
void init_dirac(EvtParticle **part)
void init_neutrino(EvtParticle **part)
std::string IntToStr(int a)
void init_vector(EvtParticle **part)
void init_raritaschinger(EvtParticle **part)
void init_tensor(EvtParticle **part)
void init_scalar(EvtParticle **part)
void init_string(EvtParticle **part)
std::string IntToStr(int a)
double alpha
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ ERROR
Definition EvtReport.hh:49
@ INFO
Definition EvtReport.hh:52
*********DOUBLE PRECISION m_pi INTEGER m_lenwt !max no of aux weights INTEGER m_phmax !maximum photon multiplicity ISR FSR *DOUBLE COMPLEX m_Pauli4 DOUBLE COMPLEX m_AmpBorn DOUBLE COMPLEX m_AmpBoxy DOUBLE COMPLEX m_AmpBorn1 DOUBLE COMPLEX m_AmpBorn2 DOUBLE COMPLEX m_AmpExpo2p DOUBLE COMPLEX m_Rmat DOUBLE COMPLEX m_BoxGZut !DOUBLE COMPLEX m_F1finPair2 !DOUBLE PRECISION m_Vcut DOUBLE PRECISION m_Alfinv DOUBLE PRECISION m_Lorin1 DOUBLE PRECISION m_Lorin2 DOUBLE PRECISION m_b
Definition GPS.h:30
*********Class see also m_nmax DOUBLE PRECISION m_MasPhot DOUBLE PRECISION m_phsu DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_r2 DOUBLE PRECISION m_WtMass INTEGER m_nmax INTEGER m_Nevgen INTEGER m_IsFSR INTEGER m_MarTot *COMMON c_KarFin $ !Output file $ !Event serial number $ !alpha QED at Thomson limit $ !minimum energy at CMS for remooval $ !infrared dimensionless $ !dummy photon IR regulator $ !crude photon multiplicity enhancement factor *EVENT $ !MC crude volume of PhhSpace *Sfactors $ !YFS formfactor IR part only $ !YFS formfactor non IR finite part $ !mass weight
Definition KarFin.h:34
static void incoherentMix(const EvtId id, double &t, int &mix)
Definition EvtCPUtil.cc:289
virtual int nRealDaughters()
virtual void makeDecay(EvtParticle *p)=0
EvtId * getDaugs()
static EvtDecayBase * getDecayFunc(EvtParticle *)
static double PhaseSpacePole(double M, double m1, double m2, double m3, double a, EvtVector4R p4[10])
static double PhaseSpace(int ndaug, double mass[30], EvtVector4R p4[30], double mp)
Definition EvtGenKine.cc:47
static bool ConExcPythia
Definition EvtId.hh:27
static double getWidth(EvtId i)
Definition EvtPDL.hh:59
static int getStdHep(EvtId id)
Definition EvtPDL.hh:61
static double getRandMass(EvtId i, EvtId *parId, int nDaug, EvtId *dauId, EvtId *othDaugId, double maxMass, double *dauMasses)
Definition EvtPDL.hh:45
static double getMeanMass(EvtId i)
Definition EvtPDL.hh:43
static std::string name(EvtId i)
Definition EvtPDL.hh:70
static double getMassProb(EvtId i, double mass, double massPar, int nDaug, double *massDau)
Definition EvtPDL.hh:50
static double getMinMass(EvtId i)
Definition EvtPDL.hh:56
static EvtSpinType::spintype getSpinType(EvtId i)
Definition EvtPDL.hh:66
static double getMass(EvtId i)
Definition EvtPDL.hh:44
static EvtId getId(const std::string &name)
Definition EvtPDL.cc:272
static double getctau(EvtId i)
Definition EvtPDL.hh:60
static EvtParticle * particleFactory(EvtSpinType::spintype spinType)
virtual EvtVector4C epsPhoton(int i)
void setMass(double m)
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
void setDecayProb(double p)
void makeDaughters(int ndaug, EvtId *id)
virtual ~EvtParticle()
virtual EvtVector4C epsParent(int i) const
void initDecay(bool useMinMass=false)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void insertDaugPtr(int idaug, EvtParticle *partptr)
EvtVector4R getP4Lab()
virtual EvtTensor4C epsTensorParent(int i) const
virtual EvtVector4C epsParentPhoton(int i)
void printTreeRec(int level) const
EvtId getId() const
EvtParticle * getParent()
virtual EvtDiracSpinor spParentNeutrino() const
static EvtId _NextLevelId[20]
virtual EvtDiracSpinor spParent(int) const
void setVectorSpinDensity()
bool hasValidP4()
void printParticle() const
virtual EvtDiracSpinor spNeutrino() const
static int _NextLevelDauNum
int getSpinStates() const
EvtVector4R getP4Restframe()
void setLifetime()
void setPolarizedSpinDensity(double r00, double r11, double r22)
double getLifetime()
void setDiagonalSpinDensity()
double compMassProb()
EvtSpinType::spintype getSpinType() const
void setChannel(int i)
const EvtVector4R & getP4() const
void printTree() const
void setLifetime(double tau)
virtual EvtSpinDensity rotateToHelicityBasis() const =0
void resetFirstOrNot()
int getNDaug() const
EvtParticle * getDaug(int i)
void dumpTreeRec(int level, int dj) const
void deleteDaughters(bool keepChannel=false)
static EvtVector4R _NextLevelP4[20]
double mass() const
virtual EvtDiracSpinor sp(int) const
void makeStdHep(EvtStdHep &stdhep, EvtSecondary &secondary, EvtId *stable_parent_ihep)
int firstornot() const
EvtVector4R get4Pos()
virtual EvtVector4C eps(int i) const
void addDaug(EvtParticle *node)
void dumpTree() const
std::string treeStr() const
std::string treeStrRec(int level) const
int getChannel() const
virtual EvtTensor4C epsTensor(int i) const
void setId(EvtId id)
std::string writeTreeRec(std::string) const
void setFirstOrNot()
double initializePhaseSpace(int numdaughter, EvtId *daughters, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
EvtParticle * nextIter(EvtParticle *rootOfTree=0)
void generateMassTree()
void deleteTree()
static double Flat()
Definition EvtRandom.cc:69
static double Flat(double min, double max)
Definition EvtRandom.cc:55
void init(EvtId part_n, double e, double px, double py, double pz)
void createSecondary(int stdhepindex, EvtParticle *prnt)
int GetDim() const
void SetDiag(int n)
const EvtComplex & Get(int i, int j) const
void Set(int i, int j, const EvtComplex &rhoij)
static int getSpinStates(spintype stype)
void createParticle(EvtVector4R p4, EvtVector4R x, int prntfirst, int prntlast, int id)
Definition EvtStdHep.cc:37
int getNPart()
Definition EvtStdHep.cc:35
double mass() const
void set(int i, double d)
int t()
Definition t.c:1