LCOV - code coverage report
Current view: top level - TEvtGen/EvtGen/EvtGenBase - EvtParticle.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 599 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 70 0.0 %

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

Generated by: LCOV version 1.11