44 Double_t charge,
const char* ParticleClass, Int_t PDGcode, Int_t Anti, Int_t TrackingCode,
45 Double_t Lifetime, Double_t Spin, Double_t maxWidth, Int_t pythiaID)
56 TParticlePDG* old = GetParticle(PDGcode);
59 B2ERROR(
"EvtGenDatabasePDG::AddParticle: particle with PDGcode=" << PDGcode <<
" already defined");
63 if (std::strpbrk(name,
" \t\n\v\f\r")) {
64 B2ERROR(
"EvtGenDatabasePDG::AddParticle: invalid particle name '" << name <<
"'. Names may not contain Whitespace");
68 auto* p =
new EvtGenParticlePDG(name, title, mass, stable, width, charge, ParticleClass,
69 PDGcode, Anti, TrackingCode, Lifetime, Spin, maxWidth, pythiaID);
71 fParticleList->Add(p);
73 fPdgMap->Add((Long_t)PDGcode, (Long_t)p);
75 TParticleClassPDG* pclass = GetParticleClass(ParticleClass);
78 pclass =
new TParticleClassPDG(ParticleClass);
79 fListOfClasses->Add(pclass);
82 pclass->AddParticle(p);
91 if (defaultFilename.empty())
92 B2FATAL(
"Cannot find the default particle database file (evt.pdl).");
94 filename = defaultFilename.c_str();
96 if (filename != defaultFilename) {
97 B2RESULT(
"Loading non-standard evt.pdl file '" << filename <<
"'");
102 if (fParticleList ==
nullptr) {
104 fParticleList =
new THashList;
105 fListOfClasses =
new TObjArray;
108 fParticleList->Delete();
109 fListOfClasses->Delete();
114 std::ifstream indec(filename);
116 char cmnd[100], xxxx[100], pname[100];
118 double mass, pwidth, pmaxwidth;
124 B2ERROR(
"EvtGenDatabasePDG::ReadEvtGenTable: Could not particle data file '" << filename <<
"'");
128 std::map<int, TParticlePDG*> pdgToPartMap;
136 if (ch ==
'\n') indec.get(ch);
140 while (indec.get(ch1), ch1 !=
'\n');
146 if (strcmp(cmnd,
"end")) {
148 if (!strcmp(cmnd,
"add")) {
150 indec >> xxxx >> xxxx >> pname >> stdhepid;
151 indec >> mass >> pwidth >> pmaxwidth >> chg3 >> spin2 >> ctau >> lundkc;
154 TParticlePDG* part =
AddParticle(pname, pname, mass,
false, pwidth, chg3,
"Unknown", stdhepid, 0, 0,
155 ctau / c_mm_per_s, spin2 / 2.0, pmaxwidth, lundkc);
156 pdgToPartMap[stdhepid] = part;
158 B2FATAL(
"EvtGenDatabasePDG::ReadPDGTable: Problem creating particle '" << pname <<
"'");
162 }
while (strcmp(cmnd,
"end"));
165 for (
auto entry : pdgToPartMap) {
166 int pdg = entry.first;
167 TParticlePDG* part = entry.second;
169 const auto& antiPartIter = pdgToPartMap.find(-pdg);
170 if (antiPartIter != pdgToPartMap.end()) {
172 part->SetAntiParticle(antiPartIter->second);
175 part->SetAntiParticle(part);
184 for (TObject*
object : *fParticleList) {
187 B2FATAL(
"EvtGenDatabasePDG::WriteEvtgenTable: Particle "
188 << object->GetName() <<
189 " does not inherit from EventGenParticlePDG");
191 out <<
"add p Particle " << part->GetName() <<
" " << part->PdgCode()
192 <<
" " << std::scientific << std::setprecision(7) << part->Mass()
193 <<
" " << std::scientific << std::setprecision(7) << part->Width()
194 <<
" " << std::scientific << std::setprecision(7) << part->MaxWidth()
195 <<
" " << (int)(part->Charge())
196 <<
" " << (int)(part->Spin() * 2)
197 <<
" " << std::scientific << std::setprecision(7) << part->Lifetime() * c_mm_per_s
198 <<
" " << part->PythiaID()
202 out <<
"end" << std::endl << std::flush;
TParticlePDG * AddParticle(const char *name, const char *title, Double_t mass, Bool_t stable, Double_t width, Double_t charge, const char *ParticleClass, Int_t PDGcode, Int_t Anti, Int_t TrackingCode) override
override old AddParticle
Helper class for setting additional TParticlePDG members and storing the ones it doesn't have yet.
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...