BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtPDL.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: 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//
22#include <iostream>
23#include <fstream>
24#include <stdlib.h>
25#include <ctype.h>
26#include <string.h>
27#include "EvtGenBase/EvtPDL.hh"
29#include "EvtGenBase/EvtId.hh"
32using std::endl;
33using std::fstream;
34using std::ifstream;
35
36static int first=1;
37
38int EvtPDL::_firstAlias;
39int EvtPDL::_nentries;
40
41std::map<std::string,int> EvtPDL::_particleNameLookup;
42
44
45 if (first!=0) {
46 first=0;
47 _nentries=0;
48 _firstAlias=999999;
49 }
50
51}
52
53
55
56}
57
58void EvtPDL::read(const char* fname)
59{
60 readPDT(fname);
61}
62
63void EvtPDL::readPDT(const std::string fname){
64
65
66 ifstream indec;
67
68 indec.open(fname.c_str());
69
70 char cmnd[100];
71 char xxxx[100];
72
73 char pname[100];
74 int stdhepid;
75 double mass;
76 double pwidth;
77 double pmaxwidth;
78 int chg3;
79 int spin2;
80 double ctau;
81 int lundkc;
82 EvtId i;
83
84 if (!indec) {
85 report(ERROR,"EvtGen") << "Could not open:"<<fname.c_str()<<"EvtPDL"<<endl;
86 return;
87 }
88
89 do{
90
91 char ch,ch1;
92
93 do{
94
95 indec.get(ch);
96 if (ch=='\n') indec.get(ch);
97 if (ch!='*') {
98 indec.putback(ch);
99 }
100 else{
101 while (indec.get(ch1),ch1!='\n');
102 }
103 } while(ch=='*');
104
105 indec >> cmnd;
106
107 if (strcmp(cmnd,"end")){
108
109 if (!strcmp(cmnd,"add")){
110
111 indec >> xxxx;
112 indec >> xxxx;
113 indec >> pname;
114 indec >> stdhepid;
115 indec >> mass;
116 indec >> pwidth;
117 indec >> pmaxwidth;
118 indec >> chg3;
119 indec >> spin2;
120 indec >> ctau;
121 indec >> lundkc;
122
123
124 i=EvtId(_nentries,_nentries);
125
126 EvtPartProp tmp;
127
129
130 if (spin2==0) tmp.setSpinType(EvtSpinType::SCALAR);
131 if (spin2==1) tmp.setSpinType(EvtSpinType::DIRAC);
132 if (spin2==2) tmp.setSpinType(EvtSpinType::VECTOR);
133 if (spin2==3) tmp.setSpinType(EvtSpinType::RARITASCHWINGER);
134 if (spin2==4) tmp.setSpinType(EvtSpinType::TENSOR);
135 if (spin2==5) tmp.setSpinType(EvtSpinType::SPIN5HALF);
136 if (spin2==6) tmp.setSpinType(EvtSpinType::SPIN3);
137 if (spin2==7) tmp.setSpinType(EvtSpinType::SPIN7HALF);
138 if (spin2==8) tmp.setSpinType(EvtSpinType::SPIN4);
139 if (spin2==2 && mass < 0.0001 ) tmp.setSpinType(EvtSpinType::PHOTON);
140 if (spin2==1 && mass < 0.0001 ) tmp.setSpinType(EvtSpinType::NEUTRINO);
141
142
143 if (!strcmp(pname,"string")){
145 }
146
147 if (!strcmp(pname,"vpho")){
149 }
150
151
152 tmp.setId(i);
153 tmp.setIdChgConj(EvtId(-1,-1));
154 tmp.setStdHep(stdhepid);
155 tmp.setLundKC(lundkc);
156 tmp.setName(pname);
157 assert(_particleNameLookup.find(std::string(pname))==
158 _particleNameLookup.end());
159 _particleNameLookup[std::string(pname)]=_nentries;
160 tmp.setctau(ctau);
161 tmp.setChg3(chg3);
162 //report(INFO,"EvtGen") << "particle,chg3:"<<i<<","<<chg3<<endl;
163
164 tmp.initLineShape(mass,pwidth,pmaxwidth);
165
166
167 partlist().push_back(tmp);
168 _nentries++;
169
170 }
171
172 // if find a set read information and discard it
173
174 if (!strcmp(cmnd,"set")){
175
176 indec >> xxxx;
177 indec >> xxxx;
178 indec >> xxxx;
179 indec >> xxxx;
180 }
181
182 }
183
184 }while(strcmp(cmnd,"end"));
185
186 setUpConstsPdt();
187
188}
189
190
192
193 if (EvtPDL::chargeConj(EvtId(a.getId(),a.getId()))!=
194 EvtId(abar.getId(),abar.getId())) {
195
196 report(ERROR,"EvtGen")<<"Can't charge conjugate the two aliases:"
197 <<EvtPDL::name(a).c_str()<<" and "<<EvtPDL::name(abar).c_str()<<endl;
198
199 ::abort();
200
201 }
202
203 partlist()[a.getAlias()].setIdChgConj(abar);
204 partlist()[abar.getAlias()].setIdChgConj(a);
205
206}
207
209 EvtId idchg=partlist()[id.getAlias()].getIdChgConj();
210
211 if (idchg!=EvtId(-1,-1)) return idchg;
212
213 if (id.getId()!=id.getAlias()){
214 if (chargeConj(EvtId(id.getId(),id.getId()))==EvtId(id.getId(),id.getId())){
215
216 partlist()[id.getAlias()].setIdChgConj(id);
217 return id;
218 }
219 }
220
221 if (id.getAlias()!=id.getId()) {
222
223 report(ERROR,"EvtGen")<<"Trying to charge conjugate alias particle:"
224 <<name(id).c_str()<<" without defining the alias!"<<endl;
225
226 ::abort();
227
228 }
229
230 int i;
231
232 for (i=0;i<partlist().size();i++){
233 if (partlist()[i].getStdHep()==-partlist()[id.getId()].getStdHep()){
234 partlist()[id.getId()].setIdChgConj(partlist()[i].getId());
235 return partlist()[i].getId();
236 }
237 }
238
239 partlist()[id.getId()].setIdChgConj(id);
240 return id;
241
242}
243
245
246 int i;
247
248 for (i=0;i<partlist().size();i++){
249 if (partlist()[i].getStdHep()==stdhep)
250 return partlist()[i].getId();
251 }
252
253 return EvtId(-1,-1);
254
255}
256
257
258
259void EvtPDL::alias(EvtId num,const std::string& newname){
260
261 int i;
262
263 if ( _firstAlias < partlist().size() ) {
264 for(i=_firstAlias;i<partlist().size();i--){
265 if (newname==partlist()[i].getName()){
266 report(WARNING,"EvtGen")<<"Redefining alias:"<<newname.c_str()<<" will be ignored!"<<endl;
267 return;
268 }
269 }
270 }
271 else{
272 _firstAlias=partlist().size();
273 }
274
275 partlist().push_back(partlist()[num.getId()]);
276 int entry=partlist().size()-1;
277 partlist()[entry].setName(newname);
278 assert(_particleNameLookup.find(std::string(newname))==
279 _particleNameLookup.end());
280 _particleNameLookup[std::string(newname)]=entry;
281 partlist()[entry].setId(EvtId(num.getId(),entry));
282 //Lange - Dec7, 2003. Unset the charge conjugate.
283 partlist()[entry].setIdChgConj(EvtId(-1,-1));
284
285}
286
287EvtId EvtPDL::getId(const std::string& name ){
288
289 std::map<std::string,int>::iterator it=_particleNameLookup.find(std::string(name));
290 if (it==_particleNameLookup.end()) return EvtId(-1,-1);
291
292 return partlist()[it->second].getId();
293
294}
295
296void EvtPDL::setUpConstsPdt(){
297
298}
299
300
double mass
ostream & report(Severity severity, const char *facility)
Definition: EvtReport.cc:36
@ ERROR
Definition: EvtReport.hh:49
@ WARNING
Definition: EvtReport.hh:50
Definition: EvtId.hh:27
int getAlias() const
Definition: EvtId.hh:43
int getId() const
Definition: EvtId.hh:41
void read(const char *fname)
Definition: EvtPDL.cc:58
void readPDT(const std::string fname)
Definition: EvtPDL.cc:63
static EvtId evtIdFromStdHep(int stdhep)
Definition: EvtPDL.cc:244
static void alias(EvtId num, const std::string &newname)
Definition: EvtPDL.cc:259
static std::string name(EvtId i)
Definition: EvtPDL.hh:64
static EvtId chargeConj(EvtId id)
Definition: EvtPDL.cc:208
static int chg3(EvtId i)
Definition: EvtPDL.hh:60
EvtPDL()
Definition: EvtPDL.cc:43
static void aliasChgConj(EvtId a, EvtId abar)
Definition: EvtPDL.cc:191
static EvtId getId(const std::string &name)
Definition: EvtPDL.cc:287
~EvtPDL()
Definition: EvtPDL.cc:54
void initLineShape(double mass, double width, double maxRange)
Definition: EvtPartProp.cc:90
void setName(std::string pname)
Definition: EvtPartProp.cc:72
void setStdHep(int stdhep)
Definition: EvtPartProp.hh:68
void setChg3(int c3)
Definition: EvtPartProp.hh:53
void setSpinType(EvtSpinType::spintype stype)
Definition: EvtPartProp.hh:56
void setIdChgConj(EvtId idchgconj)
Definition: EvtPartProp.hh:65
void setLundKC(int lundkc)
Definition: EvtPartProp.hh:71
void setId(EvtId id)
Definition: EvtPartProp.hh:62
void setctau(double tau)
Definition: EvtPartProp.hh:50