1 //--------------------------------------------------------------------------
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.
8 // Copyright Information: See EvtGen/COPYRIGHT
9 // Copyright (C) 1998 Caltech, UCSB
11 // Module: EvtParticle.cc
13 // Description: Class to describe all particles
15 // Modification history:
17 // DJL/RYD September 25, 1996 Module created
19 //------------------------------------------------------------------------
21 #include "EvtGenBase/EvtPatches.hh"
27 #include "EvtGenBase/EvtParticle.hh"
28 #include "EvtGenBase/EvtId.hh"
29 #include "EvtGenBase/EvtRandom.hh"
30 #include "EvtGenBase/EvtRadCorr.hh"
31 #include "EvtGenBase/EvtPDL.hh"
32 #include "EvtGenBase/EvtDecayTable.hh"
33 #include "EvtGenBase/EvtDiracParticle.hh"
34 #include "EvtGenBase/EvtScalarParticle.hh"
35 #include "EvtGenBase/EvtVectorParticle.hh"
36 #include "EvtGenBase/EvtTensorParticle.hh"
37 #include "EvtGenBase/EvtPhotonParticle.hh"
38 #include "EvtGenBase/EvtNeutrinoParticle.hh"
39 #include "EvtGenBase/EvtRaritaSchwingerParticle.hh"
40 #include "EvtGenBase/EvtStringParticle.hh"
41 #include "EvtGenBase/EvtStdHep.hh"
42 #include "EvtGenBase/EvtSecondary.hh"
43 #include "EvtGenBase/EvtReport.hh"
44 #include "EvtGenBase/EvtGenKine.hh"
45 #include "EvtGenBase/EvtCPUtil.hh"
46 #include "EvtGenBase/EvtParticleFactory.hh"
47 #include "EvtGenBase/EvtIdSet.hh"
53 EvtParticle::~EvtParticle() {
57 EvtParticle::EvtParticle() {
71 void EvtParticle::setFirstOrNot() {
74 void EvtParticle::resetFirstOrNot() {
78 void EvtParticle::setChannel( int i ) {
82 EvtParticle *EvtParticle::getDaug(int i) { return _daug[i]; }
84 EvtParticle *EvtParticle::getParent() const { return _parent;}
86 void EvtParticle::setLifetime(double tau){
90 void EvtParticle::setLifetime(){
92 _t=-log(EvtRandom::Flat())*EvtPDL::getctau(getId());
96 double EvtParticle::getLifetime(){
101 void EvtParticle::addDaug(EvtParticle *node) {
102 node->_daug[node->_ndaug++]=this;
108 int EvtParticle::firstornot() const { return _first;}
110 EvtId EvtParticle::getId() const { return _id;}
112 EvtSpinType::spintype EvtParticle::getSpinType() const
113 { return EvtPDL::getSpinType(_id);}
115 int EvtParticle::getSpinStates() const
116 { return EvtSpinType::getSpinStates(EvtPDL::getSpinType(_id));}
118 const EvtVector4R& EvtParticle::getP4() const { return _p;}
120 int EvtParticle::getChannel() const { return _channel;}
122 size_t EvtParticle::getNDaug() const { return _ndaug;}
124 double EvtParticle::mass() const {
130 void EvtParticle::setDiagonalSpinDensity(){
132 _rhoForward.setDiag(getSpinStates());
135 void EvtParticle::setVectorSpinDensity(){
137 if (getSpinStates()!=3) {
138 report(ERROR,"EvtGen")<<"Error in EvtParticle::setVectorSpinDensity"<<endl;
139 report(ERROR,"EvtGen")<<"spin_states:"<<getSpinStates()<<endl;
140 report(ERROR,"EvtGen")<<"particle:"<<EvtPDL::name(_id).c_str()<<endl;
146 //Set helicity +1 and -1 to 1.
147 rho.setDiag(getSpinStates());
148 rho.set(1,1,EvtComplex(0.0,0.0));
150 setSpinDensityForwardHelicityBasis(rho);
155 void EvtParticle::setSpinDensityForwardHelicityBasis(const EvtSpinDensity& rho){
157 EvtSpinDensity R=rotateToHelicityBasis();
159 assert(R.getDim()==rho.getDim());
163 _rhoForward.setDim(n);
172 tmp+=R.get(l,i)*rho.get(l,k)*conj(R.get(k,j));
175 _rhoForward.set(i,j,tmp);
181 void EvtParticle::setSpinDensityForwardHelicityBasis(const EvtSpinDensity& rho,
186 EvtSpinDensity R=rotateToHelicityBasis(alpha,beta,gamma);
188 assert(R.getDim()==rho.getDim());
192 _rhoForward.setDim(n);
201 tmp+=R.get(l,i)*rho.get(l,k)*conj(R.get(k,j));
204 _rhoForward.set(i,j,tmp);
210 void EvtParticle::initDecay(bool useMinMass) {
213 // carefull - the parent mass might be fixed in stone..
214 EvtParticle* par=p->getParent();
217 if ( par->hasValidP4() ) parMass=par->mass();
218 for (size_t i=0;i<par->getNDaug();i++) {
219 EvtParticle *tDaug=par->getDaug(i);
221 parMass-=EvtPDL::getMinMass(tDaug->getId());
226 //we have already been here - just reroll the masses!
228 for(size_t ii=0;ii<_ndaug;ii++){
229 if ( _ndaug==1 || EvtPDL::getWidth(p->getDaug(ii)->getId()) > 0.0000001)
230 p->getDaug(ii)->initDecay(useMinMass);
231 else p->getDaug(ii)->setMass(EvtPDL::getMeanMass(p->getDaug(ii)->getId()));
238 dauId=new EvtId[_ndaug];
239 dauMasses=new double[_ndaug];
240 for (size_t j=0;j<_ndaug;j++) {
241 dauId[j]=p->getDaug(j)->getId();
242 dauMasses[j]=p->getDaug(j)->mass();
247 EvtParticle *tempPar=p->getParent();
249 parId=new EvtId(tempPar->getId());
250 if ( tempPar->getNDaug()==2 ) {
251 if ( tempPar->getDaug(0) == this ) othDauId=new EvtId(tempPar->getDaug(1)->getId());
252 else othDauId=new EvtId(tempPar->getDaug(0)->getId());
255 if ( p->getParent() && _validP4==false ) {
257 p->setMass(EvtPDL::getRandMass(p->getId(),parId,_ndaug,dauId,othDauId,parMass,dauMasses));
259 else p->setMass(EvtPDL::getMinMass(p->getId()));
261 if ( parId) delete parId;
262 if ( othDauId) delete othDauId;
263 if ( dauId) delete [] dauId;
264 if ( dauMasses) delete [] dauMasses;
269 //Will include effects of mixing here
270 //added by Lange Jan4,2000
271 static EvtId BS0=EvtPDL::getId("B_s0");
272 static EvtId BSB=EvtPDL::getId("anti-B_s0");
273 static EvtId BD0=EvtPDL::getId("B0");
274 static EvtId BDB=EvtPDL::getId("anti-B0");
275 static EvtId D0=EvtPDL::getId("D0");
276 static EvtId D0B=EvtPDL::getId("anti-D0");
277 static EvtId U4S=EvtPDL::getId("Upsilon(4S)");
278 static EvtIdSet borUps(BS0,BSB,BD0,BDB,U4S);
280 //only makes sense if there is no parent particle which is a B or an Upsilon
281 bool hasBorUps=false;
282 if ( getParent() && borUps.contains(getParent()->getId()) ) hasBorUps=true;
283 // if ( (getNDaug()==0)&&(getParent()==0) && (getId()==BS0||getId()==BSB||getId()==BD0||getId()==BDB)){
284 EvtId thisId=getId();
285 // remove D0 mixing for now.
286 // if ( (getNDaug()==0 && !hasBorUps) && (thisId==BS0||thisId==BSB||thisId==BD0||thisId==BDB||thisId==D0||thisId==D0B)){
287 if ( (getNDaug()==0 && !hasBorUps) && (thisId==BS0||thisId==BSB||thisId==BD0||thisId==BDB)){
290 EvtCPUtil::incoherentMix(getId(), t, mix);
295 EvtScalarParticle* scalar_part;
297 scalar_part=new EvtScalarParticle;
299 EvtVector4R p_init(EvtPDL::getMass(BSB),0.0,0.0,0.0);
300 scalar_part->init(BSB,p_init);
302 else if (getId()==BSB) {
303 EvtVector4R p_init(EvtPDL::getMass(BS0),0.0,0.0,0.0);
304 scalar_part->init(BS0,p_init);
306 else if (getId()==BD0) {
307 EvtVector4R p_init(EvtPDL::getMass(BDB),0.0,0.0,0.0);
308 scalar_part->init(BDB,p_init);
310 else if (getId()==BDB) {
311 EvtVector4R p_init(EvtPDL::getMass(BD0),0.0,0.0,0.0);
312 scalar_part->init(BD0,p_init);
314 else if (getId()==D0) {
315 EvtVector4R p_init(EvtPDL::getMass(D0B),0.0,0.0,0.0);
316 scalar_part->init(D0B,p_init);
318 else if (getId()==D0B) {
319 EvtVector4R p_init(EvtPDL::getMass(D0),0.0,0.0,0.0);
320 scalar_part->init(D0,p_init);
323 scalar_part->setLifetime(0);
324 scalar_part->setDiagonalSpinDensity();
326 insertDaugPtr(0,scalar_part);
331 p->initDecay(useMinMass);
337 if ( _ndaug==1 ) std::cout << "hi " << EvtPDL::name(this->getId()) << std::endl;
339 EvtDecayBase *decayer;
340 decayer = EvtDecayTable::getDecayFunc(p);
343 p->makeDaughters(decayer->nRealDaughters(),decayer->getDaugs());
344 //then loop over the daughters and init their decay
345 for(size_t i=0;i<p->getNDaug();i++){
346 // std::cout << EvtPDL::name(p->getDaug(i)->getId()) << " " << i << " " << p->getDaug(i)->getSpinType() << " " << EvtPDL::name(p->getId()) << std::endl;
347 if ( EvtPDL::getWidth(p->getDaug(i)->getId()) > 0.0000001)
348 p->getDaug(i)->initDecay(useMinMass);
349 else p->getDaug(i)->setMass(EvtPDL::getMeanMass(p->getDaug(i)->getId()));
356 int nDaugT=p->getNDaug();
358 dauId=new EvtId[nDaugT];
359 dauMasses=new double[nDaugT];
360 for (j=0;j<nDaugT;j++) {
361 dauId[j]=p->getDaug(j)->getId();
362 dauMasses[j]=p->getDaug(j)->mass();
368 EvtParticle *tempPar=p->getParent();
370 parId=new EvtId(tempPar->getId());
371 if ( tempPar->getNDaug()==2 ) {
372 if ( tempPar->getDaug(0) == this ) othDauId=new EvtId(tempPar->getDaug(1)->getId());
373 else othDauId=new EvtId(tempPar->getDaug(0)->getId());
376 if ( p->getParent() && p->hasValidP4()==false ) {
378 p->setMass(EvtPDL::getRandMass(p->getId(),parId,p->getNDaug(),dauId,othDauId,parMass,dauMasses));
381 p->setMass(EvtPDL::getMinMass(p->getId()));
384 if ( parId) delete parId;
385 if ( othDauId) delete othDauId;
386 if ( dauId) delete [] dauId;
387 if ( dauMasses) delete [] dauMasses;
392 void EvtParticle::decay(){
393 //P is particle to decay, typically 'this' but sometime
397 //if ( p->getMixed() ) {
398 //should take C(p) - this should only
399 //happen the first time we call decay for this
405 EvtDecayBase *decayer;
406 decayer = EvtDecayTable::getDecayFunc(p);
408 // report(INFO,"EvtGen") << "calling decay for " << EvtPDL::name(p->getId()) << " " << p->mass() << " " << p->getP4() << " " << p->getNDaug() << " " << p << endl;
409 // report(INFO,"EvtGen") << "NDaug= " << decayer->getNDaug() << endl;
411 // for ( ti=0; ti<decayer->getNDaug(); ti++)
412 // report(INFO,"EvtGen") << "Daug " << ti << " " << EvtPDL::name(decayer->getDaug(ti)) << endl;
415 // report(INFO,"EvtGen") <<"Is decaying particle with daughters!!!!!"<<endl;
418 //call initdecay first - April 29,2002 - Lange
421 //if there are already daughters, then this step is already done!
422 // figure out the masses
423 if ( _ndaug == 0 ) generateMassTree();
425 static EvtId BS0=EvtPDL::getId("B_s0");
426 static EvtId BSB=EvtPDL::getId("anti-B_s0");
427 static EvtId BD0=EvtPDL::getId("B0");
428 static EvtId BDB=EvtPDL::getId("anti-B0");
429 static EvtId D0=EvtPDL::getId("D0");
430 static EvtId D0B=EvtPDL::getId("anti-D0");
432 EvtId thisId=getId();
433 // remove D0 mixing for now..
434 // if ( _ndaug==1 && (thisId==BS0||thisId==BSB||thisId==BD0||thisId==BDB||thisId==D0||thisId==D0B) ) {
435 if ( _ndaug==1 && (thisId==BS0||thisId==BSB||thisId==BD0||thisId==BDB) ) {
437 decayer = EvtDecayTable::getDecayFunc(p);
439 //now we have accepted a set of masses - time
441 decayer->makeDecay(p);
444 p->_rhoBackward.setDiag(p->getSpinStates());
451 void EvtParticle::generateMassTree() {
456 while (massProb<ranNum) {
457 //check it out the first time.
459 massProb=p->compMassProb();
460 ranNum=EvtRandom::Flat();
463 if ( counter > 10000 ) {
464 if ( counter == 10001 ) {
465 report(INFO,"EvtGen") << "Too many iterations to determine the mass tree. Parent mass= "<< p->mass() << " " << massProb <<endl;
467 report(INFO,"EvtGen") << "will take next combo with non-zero likelihood\n";
469 if ( massProb>0. ) massProb=2.0;
470 if ( counter > 20000 ) {
471 // one last try - take the minimum masses
474 massProb=p->compMassProb();
477 report(INFO,"EvtGen") << "Taking the minimum mass of all particles in the chain\n";
480 report(INFO,"EvtGen") << "Sorry, no luck finding a valid set of masses. This may be a pathological combo\n";
488 double EvtParticle::compMassProb() {
491 double mass=p->mass();
493 if ( p->getParent()) {
494 parMass=p->getParent()->mass();
497 int nDaug=p->getNDaug();
502 dMasses=new double[nDaug];
503 for (i=0; i<nDaug; i++) dMasses[i]=p->getDaug(i)->mass();
507 temp=EvtPDL::getMassProb(p->getId(), mass, parMass, nDaug, dMasses);
509 //If the particle already has a mass, we dont need to include
510 //it in the probability calculation
511 if ( (!p->getParent() || _validP4 ) && temp>0.0 ) temp=1.;
514 for (i=0; i<nDaug; i++) {
515 temp*=p->getDaug(i)->compMassProb();
520 void EvtParticle::deleteDaughters(bool keepChannel){
522 for(size_t i=0;i<_ndaug;i++){
523 _daug[i]->deleteTree();
527 if ( !keepChannel) _channel=-10;
532 void EvtParticle::deleteTree(){
534 this->deleteDaughters();
540 EvtVector4C EvtParticle::epsParent(int i) const {
543 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
544 <<"th polarization vector."
545 <<" I.e. you thought it was a"
546 <<" vector particle!" << endl;
551 EvtVector4C EvtParticle::eps(int i) const {
554 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
555 <<"th polarization vector."
556 <<" I.e. you thought it was a"
557 <<" vector particle!" << endl;
562 EvtVector4C EvtParticle::epsParentPhoton(int i){
565 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
566 <<"th polarization vector of photon."
567 <<" I.e. you thought it was a"
568 <<" photon particle!" << endl;
573 EvtVector4C EvtParticle::epsPhoton(int i){
576 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
577 <<"th polarization vector of a photon."
578 <<" I.e. you thought it was a"
579 <<" photon particle!" << endl;
584 EvtDiracSpinor EvtParticle::spParent(int i) const {
585 EvtDiracSpinor tempD;
589 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
591 <<" I.e. you thought it was a"
592 <<" Dirac particle!" << endl;
597 EvtDiracSpinor EvtParticle::sp(int i) const {
598 EvtDiracSpinor tempD;
602 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
604 <<" I.e. you thought it was a"
605 <<" Dirac particle!" << endl;
610 EvtDiracSpinor EvtParticle::spParentNeutrino() const {
611 EvtDiracSpinor tempD;
613 report(ERROR,"EvtGen") << "and you have asked for the "
615 <<" I.e. you thought it was a"
616 <<" neutrino particle!" << endl;
621 EvtDiracSpinor EvtParticle::spNeutrino() const {
622 EvtDiracSpinor tempD;
624 report(ERROR,"EvtGen") << "and you have asked for the "
626 <<" I.e. you thought it was a"
627 <<" neutrino particle!" << endl;
632 EvtTensor4C EvtParticle::epsTensorParent(int i) const {
637 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
639 <<" I.e. you thought it was a"
640 <<" Tensor particle!" << endl;
645 EvtTensor4C EvtParticle::epsTensor(int i) const {
650 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
652 <<" I.e. you thought it was a"
653 <<" Tensor particle!" << endl;
659 EvtRaritaSchwinger EvtParticle::spRSParent(int i) const {
660 EvtRaritaSchwinger tempD;
664 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
665 <<"th Rarita-Schwinger spinor."
666 <<" I.e. you thought it was a"
667 <<" RaritaSchwinger particle!" << std::endl;
672 EvtRaritaSchwinger EvtParticle::spRS(int i) const {
673 EvtRaritaSchwinger tempD;
677 report(ERROR,"EvtGen") << "and you have asked for the:"<<i
678 <<"th Rarita-Schwinger spinor."
679 <<" I.e. you thought it was a"
680 <<" RaritaSchwinger particle!" << std::endl;
687 EvtVector4R EvtParticle::getP4Lab() const {
688 EvtVector4R temp,mom;
689 const EvtParticle *ptemp;
694 while (ptemp->getParent()!=0) {
695 ptemp=ptemp->getParent();
697 temp=boostTo(temp,mom);
702 EvtVector4R EvtParticle::getP4LabBeforeFSR() {
703 EvtVector4R temp,mom;
706 temp=this->_pBeforeFSR;
709 while (ptemp->getParent()!=0) {
710 ptemp=ptemp->getParent();
712 temp=boostTo(temp,mom);
719 EvtVector4R EvtParticle::getP4Restframe() const {
721 return EvtVector4R(mass(),0.0,0.0,0.0);
725 EvtVector4R EvtParticle::get4Pos() const {
727 EvtVector4R temp,mom;
730 temp.set(0.0,0.0,0.0,0.0);
733 if (ptemp==0) return temp;
735 temp=(ptemp->_t/ptemp->mass())*(ptemp->getP4());
737 while (ptemp->getParent()!=0) {
738 ptemp=ptemp->getParent();
740 temp=boostTo(temp,mom);
741 temp=temp+(ptemp->_t/ptemp->mass())*(ptemp->getP4());
748 EvtParticle * EvtParticle::nextIter(EvtParticle *rootOfTree) {
751 EvtParticle *current;
756 if (_ndaug!=0) return _daug[0];
759 bpart=current->_parent;
760 if (bpart==0) return 0;
762 while (bpart->_daug[i]!=current) {i++;}
764 if ( bpart==rootOfTree ) {
765 if ( i+1 == bpart->_ndaug ) return 0;
771 }while(i>=bpart->_ndaug);
773 return bpart->_daug[i];
778 void EvtParticle::makeStdHep(EvtStdHep& stdhep,EvtSecondary& secondary,
779 EvtId *list_of_stable){
781 //first add particle to the stdhep list;
782 stdhep.createParticle(getP4Lab(),get4Pos(),-1,-1,
783 EvtPDL::getStdHep(getId()));
787 //lets see if this is a longlived particle and terminate the
790 while (list_of_stable[ii]!=EvtId(-1,-1)) {
791 if (getId()==list_of_stable[ii]){
792 secondary.createSecondary(0,this);
800 for(size_t i=0;i<_ndaug;i++){
801 stdhep.createParticle(_daug[i]->getP4Lab(),_daug[i]->get4Pos(),0,0,
802 EvtPDL::getStdHep(_daug[i]->getId()));
805 for(size_t i=0;i<_ndaug;i++){
806 _daug[i]->makeStdHepRec(1+i,1+i,stdhep,secondary,list_of_stable);
812 void EvtParticle::makeStdHep(EvtStdHep& stdhep){
814 //first add particle to the stdhep list;
815 stdhep.createParticle(getP4Lab(),get4Pos(),-1,-1,
816 EvtPDL::getStdHep(getId()));
818 for(size_t i=0;i<_ndaug;i++){
819 stdhep.createParticle(_daug[i]->getP4Lab(),_daug[i]->get4Pos(),0,0,
820 EvtPDL::getStdHep(_daug[i]->getId()));
823 for(size_t i=0;i<_ndaug;i++){
824 _daug[i]->makeStdHepRec(1+i,1+i,stdhep);
831 void EvtParticle::makeStdHepRec(int firstparent,int lastparent,
833 EvtSecondary& secondary,
834 EvtId *list_of_stable){
839 //lets see if this is a longlived particle and terminate the
842 while (list_of_stable[ii]!=EvtId(-1,-1)) {
843 if (getId()==list_of_stable[ii]){
844 secondary.createSecondary(firstparent,this);
852 int parent_num=stdhep.getNPart();
853 for(size_t i=0;i<_ndaug;i++){
854 stdhep.createParticle(_daug[i]->getP4Lab(),_daug[i]->get4Pos(),
855 firstparent,lastparent,
856 EvtPDL::getStdHep(_daug[i]->getId()));
859 for(size_t i=0;i<_ndaug;i++){
860 _daug[i]->makeStdHepRec(parent_num+i,parent_num+i,stdhep,
861 secondary,list_of_stable);
867 void EvtParticle::makeStdHepRec(int firstparent,int lastparent,
870 int parent_num=stdhep.getNPart();
871 for(size_t i=0;i<_ndaug;i++){
872 stdhep.createParticle(_daug[i]->getP4Lab(),_daug[i]->get4Pos(),
873 firstparent,lastparent,
874 EvtPDL::getStdHep(_daug[i]->getId()));
877 for(size_t i=0;i<_ndaug;i++){
878 _daug[i]->makeStdHepRec(parent_num+i,parent_num+i,stdhep);
884 void EvtParticle::printTreeRec(unsigned int level) const {
892 for (i=0;i<(5*level);i++) {
893 report(INFO,"") <<" ";
896 report(INFO,"") << EvtPDL::name(_id).c_str();
897 report(INFO,"") << " -> ";
898 for(i=0;i<_ndaug;i++){
899 report(INFO,"") << EvtPDL::name(_daug[i]->getId()).c_str()<<" ";
901 for(i=0;i<_ndaug;i++){
902 report(INFO,"") << _daug[i]->mass()<<" " << _daug[i]->getSpinStates() << " ";
904 report(INFO,"")<<endl;
905 for(i=0;i<_ndaug;i++){
906 _daug[i]->printTreeRec(newlevel);
911 void EvtParticle::printTree() const {
913 report(INFO,"EvtGen") << "This is the current decay chain"<<endl;
914 report(INFO,"") << "This top particle is "<<
915 EvtPDL::name(_id).c_str()<<" " << this->mass() << " " << this->getP4() << endl;
917 this->printTreeRec(0);
918 report(INFO,"EvtGen") << "End of decay chain."<<endl;
922 std::string EvtParticle::treeStrRec(unsigned int level) const {
927 std::string retval="";
929 for(i=0;i<_ndaug;i++){
930 retval+=EvtPDL::name(_daug[i]->getId());
931 if ( _daug[i]->getNDaug() > 0 ) {
933 retval+= _daug[i]->treeStrRec(newlevel);
937 if ( i+1 !=_ndaug) retval+=" ";
945 std::string EvtParticle::treeStr() const {
947 std::string retval=EvtPDL::name(_id);
950 retval+=treeStrRec(0);
955 void EvtParticle::printParticle() const {
957 switch (EvtPDL::getSpinType(_id)){
958 case EvtSpinType::SCALAR:
959 report(INFO,"EvtGen") << "This is a scalar particle:"<<EvtPDL::name(_id).c_str()<<"\n";
961 case EvtSpinType::VECTOR:
962 report(INFO,"EvtGen") << "This is a vector particle:"<<EvtPDL::name(_id).c_str()<<"\n";
964 case EvtSpinType::TENSOR:
965 report(INFO,"EvtGen") << "This is a tensor particle:"<<EvtPDL::name(_id).c_str()<<"\n";
967 case EvtSpinType::DIRAC:
968 report(INFO,"EvtGen") << "This is a dirac particle:"<<EvtPDL::name(_id).c_str()<<"\n";
970 case EvtSpinType::PHOTON:
971 report(INFO,"EvtGen") << "This is a photon:"<<EvtPDL::name(_id).c_str()<<"\n";
973 case EvtSpinType::NEUTRINO:
974 report(INFO,"EvtGen") << "This is a neutrino:"<<EvtPDL::name(_id).c_str()<<"\n";
976 case EvtSpinType::STRING:
977 report(INFO,"EvtGen") << "This is a string:"<<EvtPDL::name(_id).c_str()<<"\n";
980 report(INFO,"EvtGen") <<"Unknown particle type in EvtParticle::printParticle()"<<endl;
983 report(INFO,"EvtGen") << "Number of daughters:"<<_ndaug<<"\n";
990 void init_vector( EvtParticle **part ){
991 *part = (EvtParticle *) new EvtVectorParticle;
995 void init_scalar( EvtParticle **part ){
996 *part = (EvtParticle *) new EvtScalarParticle;
999 void init_tensor( EvtParticle **part ){
1000 *part = (EvtParticle *) new EvtTensorParticle;
1003 void init_dirac( EvtParticle **part ){
1004 *part = (EvtParticle *) new EvtDiracParticle;
1007 void init_photon( EvtParticle **part ){
1008 *part = (EvtParticle *) new EvtPhotonParticle;
1011 void init_neutrino( EvtParticle **part ){
1012 *part = (EvtParticle *) new EvtNeutrinoParticle;
1015 void init_string( EvtParticle **part ){
1016 *part = (EvtParticle *) new EvtStringParticle;
1019 double EvtParticle::initializePhaseSpace(
1020 unsigned int numdaughter,EvtId *daughters,
1021 bool forceDaugMassReset, double poleSize,
1022 int whichTwo1, int whichTwo2) {
1027 // this->makeDaughters(numdaughter,daughters);
1029 static EvtVector4R p4[100];
1030 static double mass[100];
1034 //lange - Jan2,2002 - Need to check to see if the daughters of the parent
1035 // have changed. If so, delete them and start over.
1036 //report(INFO,"EvtGen") << "the parent is\n";
1037 //if ( this->getParent() ) {
1038 // if ( this->getParent()->getParent() ) this->getParent()->getParent()->printTree();
1039 // this->getParent()->printTree();
1041 //report(INFO,"EvtGen") << "and this is\n";
1042 //if ( this) this->printTree();
1043 bool resetDaughters=false;
1045 if ( numdaughter != this->getNDaug() && this->getNDaug() > 0 ) resetDaughters=true;
1046 if ( numdaughter == this->getNDaug() )
1047 for (i=0; i<numdaughter;i++) {
1048 if ( this->getDaug(i)->getId() != daughters[i] ) resetDaughters=true;
1049 //report(INFO,"EvtGen") << EvtPDL::name(this->getDaug(i)->getId())
1050 // << " " << EvtPDL::name(daughters[i]) << endl;
1053 if ( resetDaughters || forceDaugMassReset) {
1055 //but keep the decay channel of the parent.
1056 this->deleteDaughters(t1);
1057 this->makeDaughters(numdaughter,daughters);
1058 this->generateMassTree();
1062 for (i=0; i<numdaughter;i++) {
1063 mass[i]=this->getDaug(i)->mass();
1066 if ( poleSize<-0.1) {
1067 //special case to enforce 4-momentum conservation in 1->1 decays
1068 if (numdaughter==1) {
1069 this->getDaug(0)->init(daughters[0],EvtVector4R(m_b,0.0,0.0,0.0));
1072 EvtGenKine::PhaseSpace( numdaughter, mass, p4, m_b );
1073 for(i=0;i<numdaughter;i++){
1074 this->getDaug(i)->init(daughters[i],p4[i]);
1079 if ( numdaughter != 3 ) {
1080 report(ERROR,"EvtGen") << "Only can generate pole phase space "
1081 << "distributions for 3 body final states"
1082 << endl<<"Will terminate."<<endl;
1086 if ( (whichTwo1 == 1 && whichTwo2 == 0 ) ||
1087 (whichTwo1 == 0 && whichTwo2 == 1 ) ) {
1088 weight=EvtGenKine::PhaseSpacePole( m_b, mass[0], mass[1], mass[2],
1090 this->getDaug(0)->init(daughters[0],p4[0]);
1091 this->getDaug(1)->init(daughters[1],p4[1]);
1092 this->getDaug(2)->init(daughters[2],p4[2]);
1095 if ( (whichTwo1 == 1 && whichTwo2 == 2 ) ||
1096 (whichTwo1 == 2 && whichTwo2 == 1 ) ) {
1097 weight=EvtGenKine::PhaseSpacePole( m_b, mass[2], mass[1], mass[0],
1099 this->getDaug(0)->init(daughters[0],p4[2]);
1100 this->getDaug(1)->init(daughters[1],p4[1]);
1101 this->getDaug(2)->init(daughters[2],p4[0]);
1104 if ( (whichTwo1 == 0 && whichTwo2 == 2 ) ||
1105 (whichTwo1 == 2 && whichTwo2 == 0 ) ) {
1106 weight=EvtGenKine::PhaseSpacePole( m_b, mass[1], mass[0], mass[2],
1108 this->getDaug(0)->init(daughters[0],p4[1]);
1109 this->getDaug(1)->init(daughters[1],p4[0]);
1110 this->getDaug(2)->init(daughters[2],p4[2]);
1114 report(ERROR,"EvtGen") << "Invalid pair of particle to generate a pole dist "
1115 << whichTwo1 << " " << whichTwo2
1116 << endl<<"Will terminate."<<endl;
1124 void EvtParticle::makeDaughters( unsigned int ndaugstore, EvtId *id){
1127 if ( _channel < 0 ) {
1132 if (_ndaug!=ndaugstore){
1133 report(ERROR,"EvtGen") << "Asking to make a different number of "
1134 << "daughters than what was previously created."<<endl;
1135 report(ERROR,"EvtGen") << "Original parent:"<<EvtPDL::name(_id)<<endl;
1136 for (size_t i=0;i<_ndaug;i++){
1137 report(ERROR,"EvtGen") << "Original daugther:"<<EvtPDL::name(getDaug(i)->getId())<<endl;
1139 for (size_t i=0;i<ndaugstore;i++){
1140 report(ERROR,"EvtGen") << "New Daug:"<<EvtPDL::name(id[i])<<endl;
1142 report(ERROR,"EvtGen") << "Will terminate."<<endl;
1147 for(i=0;i<ndaugstore;i++){
1148 pdaug=EvtParticleFactory::particleFactory(EvtPDL::getSpinType(id[i]));
1149 pdaug->setId(id[i]);
1150 pdaug->addDaug(this);
1157 void EvtParticle::setDecayProb(double prob) {
1159 if ( _decayProb == 0 ) _decayProb=new double;