LCOV - code coverage report
Current view: top level - TEvtGen/EvtGen/EvtGenBase - EvtPDL.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 192 0.5 %
Date: 2016-06-14 17:26:59 Functions: 1 41 2.4 %

          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: EvtPDL.cc
      12             : //
      13             : // Description: routines to store particle properties in EvtPDL structure.
      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 <fstream>
      24             : #include <stdlib.h>
      25             : #include <ctype.h>
      26             : #include <string.h>
      27             : #include "EvtGenBase/EvtPDL.hh"
      28             : #include "EvtGenBase/EvtPartProp.hh"
      29             : #include "EvtGenBase/EvtId.hh"
      30             : #include "EvtGenBase/EvtParticle.hh"
      31             : #include "EvtGenBase/EvtReport.hh"
      32             : using std::endl;
      33             : using std::fstream;
      34             : using std::ifstream;
      35             : 
      36             : static int first=1;
      37             : 
      38             : unsigned int EvtPDL::_firstAlias;
      39             : int EvtPDL::_nentries;
      40             : 
      41           6 : std::map<std::string,int> EvtPDL::_particleNameLookup;
      42             : 
      43           0 : EvtPDL::EvtPDL() {
      44             : 
      45           0 :   if (first!=0) { 
      46           0 :     first=0;
      47           0 :     _nentries=0;
      48           0 :     _firstAlias=999999;
      49           0 :   }
      50             : 
      51           0 : }
      52             : 
      53             : 
      54           0 : EvtPDL::~EvtPDL(){
      55             :   
      56           0 : }
      57             : 
      58             : void EvtPDL::read(const char* fname)
      59             : {
      60           0 :   readPDT(fname);
      61           0 : }
      62             : 
      63             : void EvtPDL::readPDT(const std::string fname){
      64             : 
      65             : 
      66           0 :   ifstream indec;
      67             :   
      68           0 :   indec.open(fname.c_str());
      69             : 
      70           0 :   char cmnd[100];
      71           0 :   char xxxx[100];
      72             : 
      73           0 :   char pname[100];
      74           0 :   int  stdhepid;
      75           0 :   double mass;
      76           0 :   double pwidth;
      77           0 :   double pmaxwidth;
      78           0 :   int    chg3;  
      79           0 :   int    spin2;
      80           0 :   double ctau;
      81           0 :   int    lundkc;
      82           0 :   EvtId i;
      83             : 
      84           0 :   if (!indec) {
      85           0 :     report(Severity::Error,"EvtGen") << "Could not open:"<<fname.c_str()<<"EvtPDL"<<endl;
      86           0 :     return;
      87             :   }
      88             : 
      89             :   do{
      90             : 
      91           0 :     char ch,ch1;
      92             : 
      93           0 :     do{
      94             : 
      95           0 :       indec.get(ch);  
      96           0 :       if (ch=='\n') indec.get(ch);
      97           0 :       if (ch!='*') {
      98           0 :         indec.putback(ch);
      99             :       }
     100             :       else{
     101           0 :         while (indec.get(ch1),ch1!='\n');
     102             :       }
     103           0 :     } while(ch=='*');
     104             : 
     105           0 :     indec >> cmnd;
     106             : 
     107           0 :     if (strcmp(cmnd,"end")){
     108             : 
     109           0 :       if (!strcmp(cmnd,"add")){
     110             : 
     111           0 :         indec >> xxxx;
     112           0 :         indec >> xxxx;
     113           0 :         indec >> pname;
     114           0 :         indec >> stdhepid;
     115           0 :         indec >> mass;
     116           0 :         indec >> pwidth;
     117           0 :         indec >> pmaxwidth;
     118           0 :         indec >> chg3;  
     119           0 :         indec >> spin2;
     120           0 :         indec >> ctau;
     121           0 :         indec >> lundkc;
     122             : 
     123             : 
     124           0 :         i=EvtId(_nentries,_nentries);
     125             : 
     126           0 :         EvtPartProp tmp;
     127             : 
     128           0 :         tmp.setSpinType(EvtSpinType::SCALAR);
     129             :         
     130             :         
     131           0 :         if (spin2==0) tmp.setSpinType(EvtSpinType::SCALAR);
     132           0 :         if (spin2==1) tmp.setSpinType(EvtSpinType::DIRAC);
     133           0 :         if (spin2==2) tmp.setSpinType(EvtSpinType::VECTOR);
     134           0 :         if (spin2==3) tmp.setSpinType(EvtSpinType::RARITASCHWINGER);
     135           0 :         if (spin2==4) tmp.setSpinType(EvtSpinType::TENSOR);
     136           0 :         if (spin2==5) tmp.setSpinType(EvtSpinType::SPIN5HALF);
     137           0 :         if (spin2==6) tmp.setSpinType(EvtSpinType::SPIN3);
     138           0 :         if (spin2==7) tmp.setSpinType(EvtSpinType::SPIN7HALF);
     139           0 :         if (spin2==8) tmp.setSpinType(EvtSpinType::SPIN4);
     140           0 :         if (spin2==2 && mass < 0.0001 ) tmp.setSpinType(EvtSpinType::PHOTON);
     141           0 :         if (spin2==1 && mass < 0.0001 ) tmp.setSpinType(EvtSpinType::NEUTRINO);
     142             :         
     143             :         
     144           0 :         if (!strcmp(pname,"string")){
     145           0 :           tmp.setSpinType(EvtSpinType::STRING);
     146           0 :         }
     147             :         
     148           0 :         if (!strcmp(pname,"vpho")){
     149           0 :           tmp.setSpinType(EvtSpinType::VECTOR);
     150           0 :         }
     151             :         
     152             :         
     153           0 :         tmp.setId(i);
     154           0 :         tmp.setIdChgConj(EvtId(-1,-1));
     155           0 :         tmp.setStdHep(stdhepid);
     156           0 :         tmp.setLundKC(lundkc);
     157           0 :         tmp.setName(pname);
     158           0 :         if (_particleNameLookup.find(std::string(pname))!=
     159           0 :             _particleNameLookup.end()) {
     160           0 :             report(Severity::Error,"EvtGen")<<"The particle name:"<<pname<<" is already defined."<<endl;
     161           0 :             report(Severity::Error,"EvtGen") << "Will terminate execution.";
     162           0 :             ::abort();
     163             :         }
     164           0 :         _particleNameLookup[std::string(pname)]=_nentries;
     165           0 :         tmp.setctau(ctau);
     166           0 :         tmp.setChg3(chg3);
     167             :         
     168           0 :         tmp.initLineShape(mass,pwidth,pmaxwidth);
     169             : 
     170             : 
     171           0 :         partlist().push_back(tmp);
     172           0 :         _nentries++;
     173             : 
     174           0 :       }
     175             : 
     176             :       // if find a set read information and discard it
     177             : 
     178           0 :       if (!strcmp(cmnd,"set")){
     179             : 
     180           0 :         indec >> xxxx;
     181           0 :         indec >> xxxx;
     182           0 :         indec >> xxxx;
     183           0 :         indec >> xxxx;
     184             :       }
     185             : 
     186             :     }
     187             : 
     188           0 :   }while(strcmp(cmnd,"end"));
     189             :   
     190           0 :   setUpConstsPdt();
     191             : 
     192           0 : }
     193             : 
     194             : 
     195             : void EvtPDL::aliasChgConj(EvtId a,EvtId abar){
     196             : 
     197           0 :   if (EvtPDL::chargeConj(EvtId(a.getId(),a.getId()))!=
     198           0 :                  EvtId(abar.getId(),abar.getId())) {
     199             : 
     200           0 :     report(Severity::Error,"EvtGen")<<"Can't charge conjugate the two aliases:"
     201           0 :                           <<EvtPDL::name(a).c_str()<<" and "<<EvtPDL::name(abar).c_str()<<endl;
     202             :       
     203           0 :     ::abort();
     204             : 
     205             :   }
     206             : 
     207           0 :   partlist()[a.getAlias()].setIdChgConj(abar);
     208           0 :   partlist()[abar.getAlias()].setIdChgConj(a);
     209             : 
     210           0 : }
     211             : 
     212             : EvtId EvtPDL::chargeConj(EvtId id){
     213           0 :   EvtId idchg=partlist()[id.getAlias()].getIdChgConj();
     214             : 
     215           0 :   if (idchg!=EvtId(-1,-1)) return idchg;
     216             : 
     217           0 :   if (id.getId()!=id.getAlias()){
     218           0 :     if (chargeConj(EvtId(id.getId(),id.getId()))==EvtId(id.getId(),id.getId())){
     219             :     
     220           0 :       partlist()[id.getAlias()].setIdChgConj(id);
     221           0 :       return id;
     222             :     }
     223             :   }
     224             : 
     225           0 :   if (id.getAlias()!=id.getId()) {
     226             : 
     227           0 :     report(Severity::Error,"EvtGen")<<"Trying to charge conjugate alias particle:"
     228           0 :                           <<name(id).c_str()<<" without defining the alias!"<<endl;
     229             :       
     230           0 :     ::abort();
     231             : 
     232             :   }
     233             : 
     234           0 :   for (size_t i=0;i<partlist().size();i++){
     235           0 :     if (partlist()[i].getStdHep()==-partlist()[id.getId()].getStdHep()){
     236           0 :       partlist()[id.getId()].setIdChgConj(partlist()[i].getId());
     237           0 :       return partlist()[i].getId();
     238             :     }
     239             :   }
     240             :   
     241           0 :   partlist()[id.getId()].setIdChgConj(id);
     242           0 :   return id;
     243             :   
     244           0 : }
     245             : 
     246             : EvtId EvtPDL::evtIdFromStdHep(int stdhep){
     247             : 
     248           0 :   for (size_t i=0;i<partlist().size();i++){
     249           0 :     if (partlist()[i].getStdHep()==stdhep)
     250           0 :       return partlist()[i].getId();
     251             :   }
     252             :   
     253           0 :   return EvtId(-1,-1);
     254             :   
     255           0 : }
     256             : 
     257             : 
     258             : 
     259             : void EvtPDL::alias(EvtId num,const std::string& newname){
     260             :   
     261           0 :   if ( _firstAlias < partlist().size() ) {
     262           0 :     for(size_t i=_firstAlias;i<partlist().size();i--){
     263           0 :       if (newname==partlist()[i].getName()){
     264           0 :         report(Severity::Warning,"EvtGen")<<"Redefining alias:"<<newname.c_str()<<" will be ignored!"<<endl;
     265           0 :         return;
     266             :       }
     267             :     }
     268             :   }
     269             :   else{
     270           0 :     _firstAlias=partlist().size();
     271             :   }
     272             : 
     273           0 :   partlist().push_back(partlist()[num.getId()]);
     274           0 :   int entry=partlist().size()-1;
     275           0 :   partlist()[entry].setName(newname);
     276           0 :   if (_particleNameLookup.find(std::string(newname))!=
     277           0 :       _particleNameLookup.end()){
     278           0 :             report(Severity::Error,"EvtGen")<<"The particle name:"<<newname<<" is already defined."<<endl;
     279           0 :             report(Severity::Error,"EvtGen") << "Will terminate execution.";
     280           0 :             ::abort();
     281             :   }
     282           0 :   _particleNameLookup[std::string(newname)]=entry;
     283           0 :   partlist()[entry].setId(EvtId(num.getId(),entry));
     284             :   //Lange - Dec7, 2003. Unset the charge conjugate.
     285           0 :   partlist()[entry].setIdChgConj(EvtId(-1,-1));
     286             : 
     287           0 : }
     288             : 
     289             : EvtId EvtPDL::getId(const std::string& name ){
     290             : 
     291           0 :   std::map<std::string,int>::iterator it=_particleNameLookup.find(std::string(name));
     292           0 :   if (it==_particleNameLookup.end()) return EvtId(-1,-1);
     293             : 
     294           0 :   return partlist()[it->second].getId();
     295             :   
     296           0 : }
     297             : 
     298             : void EvtPDL::setUpConstsPdt(){
     299             : 
     300           0 : }
     301             : 
     302             : 
     303             : // Function to get EvtId from LundKC ( == Pythia Hep Code , KF ) 
     304             : EvtId EvtPDL::evtIdFromLundKC(int pythiaId){
     305             : 
     306             :   unsigned int i;
     307             : 
     308           0 :   for (i=0;i<partlist().size();i++){
     309           0 :     if (partlist()[i].getLundKC()==pythiaId)
     310           0 :       return partlist()[i].getId();
     311             :   }
     312             :   
     313           0 :   return EvtId(-1,-1);
     314             :   
     315           0 : }
     316             :  
     317             : double EvtPDL::getMeanMass(EvtId i ) { 
     318           0 :   return partlist()[i.getId()].getMass(); 
     319             : }
     320             : 
     321             : double EvtPDL::getMass(EvtId i ) {
     322           0 :   return partlist()[i.getId()].rollMass();
     323             : }
     324             : 
     325             : double EvtPDL::getRandMass(EvtId i, EvtId *parId, int nDaug, EvtId *dauId, 
     326             :                            EvtId *othDaugId,double maxMass, 
     327             :                            double *dauMasses ) {
     328           0 :   return partlist()[i.getId()].getRandMass(parId,nDaug,dauId,
     329             :                                           othDaugId,maxMass,dauMasses);
     330             : }
     331             : 
     332             : double EvtPDL::getMassProb(EvtId i, double mass, double massPar, int nDaug, 
     333             :                            double *massDau) { 
     334           0 :   return partlist()[i.getId()].getMassProb(mass,massPar,nDaug,massDau);
     335             : }
     336             : 
     337             : double EvtPDL::getMaxMass(EvtId i ) {
     338           0 :   return partlist()[i.getId()].getMassMax();
     339             : }
     340             : 
     341             : double EvtPDL::getMinMass(EvtId i ) { 
     342           0 :   return partlist()[i.getId()].getMassMin();
     343             : }
     344             : 
     345             : double EvtPDL::getMaxRange(EvtId i ) {
     346           0 :   return partlist()[i.getId()].getMaxRange();
     347             : }
     348             : 
     349             : double EvtPDL::getWidth(EvtId i ) { 
     350           0 :   return partlist()[i.getId()].getWidth();
     351             : }
     352             : 
     353             : double EvtPDL::getctau(EvtId i ) {
     354           0 :   return partlist()[i.getId()].getctau();
     355             : }
     356             : 
     357             : int EvtPDL::getStdHep(EvtId id ) {
     358           0 :   return partlist()[id.getId()].getStdHep();
     359             : }
     360             : 
     361             : int EvtPDL::getLundKC(EvtId id ) {
     362           0 :   return partlist()[id.getId()].getLundKC();
     363             : }
     364             : 
     365             : int EvtPDL::chg3(EvtId i ) {
     366           0 :   return partlist()[i.getId()].getChg3();
     367             : }
     368             : 
     369             : EvtSpinType::spintype EvtPDL::getSpinType(EvtId i ) {
     370           0 :   return partlist()[i.getId()].getSpinType();
     371             : }
     372             : 
     373             : std::string EvtPDL::name(EvtId i) { 
     374           0 :   return partlist()[i.getAlias()].getName();
     375             : }
     376             : 
     377             : size_t EvtPDL::entries() { 
     378           0 :   return partlist().size();
     379             : }
     380             : 
     381             : EvtId EvtPDL::getEntry(int i) {
     382           0 :   return partlist()[i].getId();
     383             : }
     384             : 
     385             : void EvtPDL::reSetMass(EvtId i, double mass) {
     386           0 :   partlist()[i.getId()].reSetMass(mass);
     387           0 : }
     388             : 
     389             : void EvtPDL::reSetWidth(EvtId i, double width) { 
     390           0 :   partlist()[i.getId()].reSetWidth(width);
     391           0 : }
     392             : 
     393             : void EvtPDL::reSetMassMin(EvtId i, double mass) { 
     394           0 :   partlist()[i.getId()].reSetMassMin(mass);
     395           0 : }
     396             : 
     397             : void EvtPDL::reSetMassMax(EvtId i,double mass) { 
     398           0 :   partlist()[i.getId()].reSetMassMax(mass);
     399           0 : }
     400             : 
     401             : void EvtPDL::reSetBlatt(EvtId i,double blatt) {
     402           0 :   partlist()[i.getId()].reSetBlatt(blatt);
     403           0 : }
     404             : 
     405             : void EvtPDL::reSetBlattBirth(EvtId i,double blatt) {
     406           0 :   partlist()[i.getId()].reSetBlattBirth(blatt);
     407           0 : }
     408             : 
     409             : void EvtPDL::includeBirthFactor(EvtId i,bool yesno) {
     410           0 :   partlist()[i.getId()].includeBirthFactor(yesno);
     411           0 : }
     412             : 
     413             : void EvtPDL::includeDecayFactor(EvtId i,bool yesno) {
     414           0 :   partlist()[i.getId()].includeDecayFactor(yesno);
     415           0 : }
     416             : 
     417             : void EvtPDL::changeLS(EvtId i, std::string &newLS ) { 
     418           0 :   partlist()[i.getId()].newLineShape(newLS);
     419           0 : }
     420             : 
     421             : void EvtPDL::setPWForDecay(EvtId i, int spin, EvtId d1, EvtId d2) {  
     422           0 :   partlist()[i.getId()].setPWForDecay(spin,d1,d2);
     423           0 : }
     424             : 
     425             : void EvtPDL::setPWForBirthL(EvtId i, int spin, EvtId par, EvtId othD) {  
     426           0 :   partlist()[i.getId()].setPWForBirthL(spin,par,othD);
     427           0 : }

Generated by: LCOV version 1.11