00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "EvtGenBase/EvtPatches.hh"
00022 #include <iostream>
00023 #include <fstream>
00024 #include <stdlib.h>
00025 #include <ctype.h>
00026 #include <string.h>
00027 #include "EvtGenBase/EvtPDL.hh"
00028 #include "EvtGenBase/EvtPartProp.hh"
00029 #include "EvtGenBase/EvtId.hh"
00030 #include "EvtGenBase/EvtParticle.hh"
00031 #include "EvtGenBase/EvtReport.hh"
00032 using std::endl;
00033 using std::fstream;
00034 using std::ifstream;
00035
00036 static int first=1;
00037
00038 int EvtPDL::_firstAlias;
00039 int EvtPDL::_nentries;
00040
00041 std::map<std::string,int> EvtPDL::_particleNameLookup;
00042
00043 EvtPDL::EvtPDL() {
00044
00045 if (first!=0) {
00046 first=0;
00047 _nentries=0;
00048 _firstAlias=999999;
00049 }
00050
00051 }
00052
00053
00054 EvtPDL::~EvtPDL(){
00055
00056 }
00057
00058 void EvtPDL::read(const char* fname)
00059 {
00060 readPDT(fname);
00061 }
00062
00063 void EvtPDL::readPDT(const std::string fname){
00064
00065
00066 ifstream indec;
00067
00068 indec.open(fname.c_str());
00069
00070 char cmnd[100];
00071 char xxxx[100];
00072
00073 char pname[100];
00074 int stdhepid;
00075 double mass;
00076 double pwidth;
00077 double pmaxwidth;
00078 int chg3;
00079 int spin2;
00080 double ctau;
00081 int lundkc;
00082 EvtId i;
00083
00084 if (!indec) {
00085 report(ERROR,"EvtGen") << "Could not open:"<<fname.c_str()<<"EvtPDL"<<endl;
00086 return;
00087 }
00088
00089 do{
00090
00091 char ch,ch1;
00092
00093 do{
00094
00095 indec.get(ch);
00096 if (ch=='\n') indec.get(ch);
00097 if (ch!='*') {
00098 indec.putback(ch);
00099 }
00100 else{
00101 while (indec.get(ch1),ch1!='\n');
00102 }
00103 } while(ch=='*');
00104
00105 indec >> cmnd;
00106
00107 if (strcmp(cmnd,"end")){
00108
00109 if (!strcmp(cmnd,"add")){
00110
00111 indec >> xxxx;
00112 indec >> xxxx;
00113 indec >> pname;
00114 indec >> stdhepid;
00115 indec >> mass;
00116 indec >> pwidth;
00117 indec >> pmaxwidth;
00118 indec >> chg3;
00119 indec >> spin2;
00120 indec >> ctau;
00121 indec >> lundkc;
00122
00123
00124 i=EvtId(_nentries,_nentries);
00125
00126 EvtPartProp tmp;
00127
00128 tmp.setSpinType(EvtSpinType::SCALAR);
00129
00130 if (spin2==0) tmp.setSpinType(EvtSpinType::SCALAR);
00131 if (spin2==1) tmp.setSpinType(EvtSpinType::DIRAC);
00132 if (spin2==2) tmp.setSpinType(EvtSpinType::VECTOR);
00133 if (spin2==3) tmp.setSpinType(EvtSpinType::RARITASCHWINGER);
00134 if (spin2==4) tmp.setSpinType(EvtSpinType::TENSOR);
00135 if (spin2==5) tmp.setSpinType(EvtSpinType::SPIN5HALF);
00136 if (spin2==6) tmp.setSpinType(EvtSpinType::SPIN3);
00137 if (spin2==7) tmp.setSpinType(EvtSpinType::SPIN7HALF);
00138 if (spin2==8) tmp.setSpinType(EvtSpinType::SPIN4);
00139 if (spin2==2 && mass < 0.0001 ) tmp.setSpinType(EvtSpinType::PHOTON);
00140 if (spin2==1 && mass < 0.0001 ) tmp.setSpinType(EvtSpinType::NEUTRINO);
00141
00142
00143 if (!strcmp(pname,"string")){
00144 tmp.setSpinType(EvtSpinType::STRING);
00145 }
00146
00147 if (!strcmp(pname,"vpho")){
00148 tmp.setSpinType(EvtSpinType::VECTOR);
00149 }
00150
00151
00152 tmp.setId(i);
00153 tmp.setIdChgConj(EvtId(-1,-1));
00154 tmp.setStdHep(stdhepid);
00155 tmp.setLundKC(lundkc);
00156 tmp.setName(pname);
00157 assert(_particleNameLookup.find(std::string(pname))==
00158 _particleNameLookup.end());
00159 _particleNameLookup[std::string(pname)]=_nentries;
00160 tmp.setctau(ctau);
00161 tmp.setChg3(chg3);
00162
00163
00164 tmp.initLineShape(mass,pwidth,pmaxwidth);
00165
00166
00167 partlist().push_back(tmp);
00168 _nentries++;
00169
00170 }
00171
00172
00173
00174 if (!strcmp(cmnd,"set")){
00175
00176 indec >> xxxx;
00177 indec >> xxxx;
00178 indec >> xxxx;
00179 indec >> xxxx;
00180 }
00181
00182 }
00183
00184 }while(strcmp(cmnd,"end"));
00185
00186 setUpConstsPdt();
00187
00188 }
00189
00190
00191 void EvtPDL::aliasChgConj(EvtId a,EvtId abar){
00192
00193 if (EvtPDL::chargeConj(EvtId(a.getId(),a.getId()))!=
00194 EvtId(abar.getId(),abar.getId())) {
00195
00196 report(ERROR,"EvtGen")<<"Can't charge conjugate the two aliases:"
00197 <<EvtPDL::name(a).c_str()<<" and "<<EvtPDL::name(abar).c_str()<<endl;
00198
00199 ::abort();
00200
00201 }
00202
00203 partlist()[a.getAlias()].setIdChgConj(abar);
00204 partlist()[abar.getAlias()].setIdChgConj(a);
00205
00206 }
00207
00208 EvtId EvtPDL::chargeConj(EvtId id){
00209 EvtId idchg=partlist()[id.getAlias()].getIdChgConj();
00210
00211 if (idchg!=EvtId(-1,-1)) return idchg;
00212
00213 if (id.getId()!=id.getAlias()){
00214 if (chargeConj(EvtId(id.getId(),id.getId()))==EvtId(id.getId(),id.getId())){
00215
00216 partlist()[id.getAlias()].setIdChgConj(id);
00217 return id;
00218 }
00219 }
00220
00221 if (id.getAlias()!=id.getId()) {
00222
00223 report(ERROR,"EvtGen")<<"Trying to charge conjugate alias particle:"
00224 <<name(id).c_str()<<" without defining the alias!"<<endl;
00225
00226 ::abort();
00227
00228 }
00229
00230 int i;
00231
00232 for (i=0;i<partlist().size();i++){
00233 if (partlist()[i].getStdHep()==-partlist()[id.getId()].getStdHep()){
00234 partlist()[id.getId()].setIdChgConj(partlist()[i].getId());
00235 return partlist()[i].getId();
00236 }
00237 }
00238
00239 partlist()[id.getId()].setIdChgConj(id);
00240 return id;
00241
00242 }
00243
00244 EvtId EvtPDL::evtIdFromStdHep(int stdhep){
00245
00246 int i;
00247
00248 for (i=0;i<partlist().size();i++){
00249 if (partlist()[i].getStdHep()==stdhep)
00250 return partlist()[i].getId();
00251 }
00252
00253 return EvtId(-1,-1);
00254
00255 }
00256
00257
00258
00259 void EvtPDL::alias(EvtId num,const std::string& newname){
00260
00261 int i;
00262
00263 if ( _firstAlias < partlist().size() ) {
00264 for(i=_firstAlias;i<partlist().size();i--){
00265 if (newname==partlist()[i].getName()){
00266 report(WARNING,"EvtGen")<<"Redefining alias:"<<newname.c_str()<<" will be ignored!"<<endl;
00267 return;
00268 }
00269 }
00270 }
00271 else{
00272 _firstAlias=partlist().size();
00273 }
00274
00275 partlist().push_back(partlist()[num.getId()]);
00276 int entry=partlist().size()-1;
00277 partlist()[entry].setName(newname);
00278 assert(_particleNameLookup.find(std::string(newname))==
00279 _particleNameLookup.end());
00280 _particleNameLookup[std::string(newname)]=entry;
00281 partlist()[entry].setId(EvtId(num.getId(),entry));
00282
00283 partlist()[entry].setIdChgConj(EvtId(-1,-1));
00284
00285 }
00286
00287 EvtId EvtPDL::getId(const std::string& name ){
00288
00289 std::map<std::string,int>::iterator it=_particleNameLookup.find(std::string(name));
00290 if (it==_particleNameLookup.end()) return EvtId(-1,-1);
00291
00292 return partlist()[it->second].getId();
00293
00294 }
00295
00296 void EvtPDL::setUpConstsPdt(){
00297
00298 }
00299
00300