test
CMS 3D CMS Logo

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