42 Double_t charge,
const char* ParticleClass, Int_t PDGcode, Int_t Anti, Int_t TrackingCode,
43 Double_t Lifetime, Double_t Spin, Double_t maxWidth, Int_t pythiaID)
54 TParticlePDG* old = GetParticle(PDGcode);
57 B2ERROR(
"EvtGenDatabasePDG::AddParticle: particle with PDGcode=" << PDGcode <<
" already defined");
61 if (std::strpbrk(name,
" \t\n\v\f\r")) {
62 B2ERROR(
"EvtGenDatabasePDG::AddParticle: invalid particle name '" << name <<
"'. Names may not contain Whitespace");
66 auto* p =
new EvtGenParticlePDG(name, title, mass, stable, width, charge, ParticleClass,
67 PDGcode, Anti, TrackingCode, Lifetime, Spin, maxWidth, pythiaID);
69 fParticleList->Add(p);
71 fPdgMap->Add((Long_t)PDGcode, (Long_t)p);
73 TParticleClassPDG* pclass = GetParticleClass(ParticleClass);
76 pclass =
new TParticleClassPDG(ParticleClass);
77 fListOfClasses->Add(pclass);
80 pclass->AddParticle(p);
89 if (defaultFilename.empty())
90 B2FATAL(
"Cannot find the default particle database file (evt.pdl).");
92 filename = defaultFilename.c_str();
94 if (filename != defaultFilename) {
95 B2RESULT(
"Loading non-standard evt.pdl file '" << filename <<
"'");
100 if (fParticleList ==
nullptr) {
102 fParticleList =
new THashList;
103 fListOfClasses =
new TObjArray;
106 fParticleList->Delete();
107 fListOfClasses->Delete();
112 std::ifstream indec(filename);
114 char cmnd[100], xxxx[100], pname[100];
116 double mass, pwidth, pmaxwidth;
122 B2ERROR(
"EvtGenDatabasePDG::ReadEvtGenTable: Could not particle data file '" << filename <<
"'");
126 std::map<int, TParticlePDG*> pdgToPartMap;
134 if (ch ==
'\n') indec.get(ch);
138 while (indec.get(ch1), ch1 !=
'\n');
144 if (strcmp(cmnd,
"end")) {
146 if (!strcmp(cmnd,
"add")) {
148 indec >> xxxx >> xxxx >> pname >> stdhepid;
149 indec >> mass >> pwidth >> pmaxwidth >> chg3 >> spin2 >> ctau >> lundkc;
152 TParticlePDG* part =
AddParticle(pname, pname, mass,
false, pwidth, chg3,
"Unknown", stdhepid, 0, 0,
153 ctau / c_mm_per_s, spin2 / 2.0, pmaxwidth, lundkc);
154 pdgToPartMap[stdhepid] = part;
156 B2FATAL(
"EvtGenDatabasePDG::ReadPDGTable: Problem creating particle '" << pname <<
"'");
160 }
while (strcmp(cmnd,
"end"));
163 for (
auto entry : pdgToPartMap) {
164 int pdg = entry.first;
165 TParticlePDG* part = entry.second;
167 const auto& antiPartIter = pdgToPartMap.find(-pdg);
168 if (antiPartIter != pdgToPartMap.end()) {
170 part->SetAntiParticle(antiPartIter->second);
173 part->SetAntiParticle(part);
182 for (TObject*
object : *fParticleList) {
185 B2FATAL(
"EvtGenDatabasePDG::WriteEvtgenTable: Particle "
186 << object->GetName() <<
187 " does not inherit from EventGenParticlePDG");
189 out <<
"add p Particle " << part->GetName() <<
" " << part->PdgCode()
190 <<
" " << std::scientific << std::setprecision(7) << part->Mass()
191 <<
" " << std::scientific << std::setprecision(7) << part->Width()
192 <<
" " << std::scientific << std::setprecision(7) << part->MaxWidth()
193 <<
" " << (int)(part->Charge())
194 <<
" " << (int)(part->Spin() * 2)
195 <<
" " << std::scientific << std::setprecision(7) << part->Lifetime() * c_mm_per_s
196 <<
" " << part->PythiaID()
200 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...