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