CMS 3D CMS Logo

PdtEntry.cc
Go to the documentation of this file.
4 
5 int PdtEntry::pdgId() const {
6  if (pdgId_ == 0)
7  throw cms::Exception("ConfigError") << "PdtEntry::pdgId was not set.\n"
8  << "please, call PdtEntry::setup(const EventSetup & es)";
9  return pdgId_;
10 }
11 
12 std::string const &PdtEntry::name() const {
13  if (name_.empty())
14  throw cms::Exception("ConfigError") << "PdtEntry::name was not set."
15  << "please, call PdtEntry::setup(const EventSetup & es)";
16  return name_;
17 }
18 
20  if (data_ == nullptr)
21  throw cms::Exception("ConfigError") << "PdtEntry::name was not set."
22  << "please, call PdtEntry::setup(const EventSetup & es)";
23  return *data_;
24 }
25 
27  HepPDT::ParticleData const *p = nullptr;
28  if (pdgId_ == 0) {
29  p = pdt.particle(name_);
30  if (p == nullptr)
31  throw cms::Exception("ConfigError") << "PDT has no entry for " << name_ << "."
32  << "PdtEntry can't be set.";
33  pdgId_ = p->pid();
34  } else {
35  p = pdt.particle(pdgId_);
36  if (p == nullptr)
37  throw cms::Exception("ConfigError") << "PDT has no entry for " << pdgId_ << "."
38  << "PdtEntry can't be set.";
39  name_ = p->name();
40  }
41  data_ = p;
42 }
43 namespace edm {
44  namespace pdtentry {
45  PdtEntry getPdtEntry(Entry const &e, char const *name) {
46  if (e.typeCode() == 'I')
47  return PdtEntry(e.getInt32());
48  else if (e.typeCode() == 'S')
49  return PdtEntry(e.getString());
50  else
51  throw Exception(errors::Configuration, "EntryError")
52  << "can not convert representation of " << name << " to value of type PdtEntry. "
53  << "Please, provide a parameter either of type int32 or string.";
54  }
55 
56  std::vector<PdtEntry> getPdtEntryVector(Entry const &e, char const *name) {
57  std::vector<PdtEntry> ret;
58  if (e.typeCode() == 'i') {
59  std::vector<int> v(e.getVInt32());
60  for (std::vector<int>::const_iterator i = v.begin(); i != v.end(); ++i)
61  ret.push_back(PdtEntry(*i));
62  return ret;
63  } else if (e.typeCode() == 's') {
64  std::vector<std::string> v(e.getVString());
65  for (std::vector<std::string>::const_iterator i = v.begin(); i != v.end(); ++i)
66  ret.push_back(PdtEntry(*i));
67  return ret;
68  } else
69  throw Exception(errors::Configuration, "EntryError")
70  << "can not convert representation of " << name << " to value of type PdtEntry. "
71  << "Please, provide a parameter either of type int32 or string.";
72  }
73  } // namespace pdtentry
74 } // namespace edm
int pdgId_
PDG id.
Definition: PdtEntry.h:39
PdtEntry getPdtEntry(Entry const &e, char const *name)
Definition: PdtEntry.cc:45
const HepPDT::ParticleData & data() const
particle data
Definition: PdtEntry.cc:19
void setup(const HepPDT::ParticleDataTable &)
fill data from Event Setup
Definition: PdtEntry.cc:26
HepPDT::ParticleDataTable ParticleDataTable
ret
prodAgent to be discontinued
std::string name_
particle name
Definition: PdtEntry.h:41
std::vector< PdtEntry > getPdtEntryVector(Entry const &e, char const *name)
Definition: PdtEntry.cc:56
HepPDT::ParticleData ParticleData
const std::string & name() const
particle name
Definition: PdtEntry.cc:12
const HepPDT::ParticleData * data_
particle data
Definition: PdtEntry.h:43
int pdgId() const
PDG id.
Definition: PdtEntry.cc:5
HLT enums.