File indexing completed on 2024-04-06 12:23:25
0001 #include "PhysicsTools/HepMCCandAlgos/interface/pdgEntryReplace.h"
0002 #include "SimGeneral/HepPDTRecord/interface/PdtEntry.h"
0003 #include <sstream>
0004 using namespace std;
0005
0006 string pdgEntryReplace(const string& in, HepPDT::ParticleDataTable const& pdt) {
0007 string out = in;
0008 for (;;) {
0009 size_t p1 = out.find_first_of('{');
0010 if (p1 == string::npos)
0011 break;
0012 size_t p2 = out.find_first_of('}', p1 + 1);
0013 if (p2 == string::npos)
0014 break;
0015 size_t n = p2 - p1 - 1;
0016 string name(out, p1 + 1, n);
0017 PdtEntry particle(name);
0018 particle.setup(pdt);
0019 ostringstream o;
0020 o << particle.pdgId();
0021 string s = o.str();
0022 out.replace(p1, n + 2, s);
0023 }
0024 return out;
0025 }