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