CMS 3D CMS Logo

Functions
pdgEntryReplace.cc File Reference
#include "PhysicsTools/HepMCCandAlgos/interface/pdgEntryReplace.h"
#include "SimGeneral/HepPDTRecord/interface/PdtEntry.h"
#include <sstream>

Go to the source code of this file.

Functions

string pdgEntryReplace (const string &in, HepPDT::ParticleDataTable const &pdt)
 

Function Documentation

◆ pdgEntryReplace()

string pdgEntryReplace ( const string &  in,
HepPDT::ParticleDataTable const &  pdt 
)

Definition at line 6 of file pdgEntryReplace.cc.

References recoMuon::in, dqmiodumpmetadata::n, Skims_PA_cff::name, EcalTangentSkim_cfg::o, MillePedeFileConverter_cfg::out, LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, PdtEntry::pdgId(), alignCSCRings::s, and PdtEntry::setup().

6  {
7  string out = in;
8  for (;;) {
9  size_t p1 = out.find_first_of('{');
10  if (p1 == string::npos)
11  break;
12  size_t p2 = out.find_first_of('}', p1 + 1);
13  if (p2 == string::npos)
14  break;
15  size_t n = p2 - p1 - 1;
16  string name(out, p1 + 1, n);
17  PdtEntry particle(name);
18  particle.setup(pdt);
19  ostringstream o;
20  o << particle.pdgId();
21  string s = o.str();
22  out.replace(p1, n + 2, s);
23  }
24  return out;
25 }