CMS 3D CMS Logo

HepPDTESSource.cc
Go to the documentation of this file.
1 #include "HepPDT/HeavyIonUnknownID.hh"
3 
5  : pdtFileName(cfg.getParameter<edm::FileInPath>("pdtFileName")) {
6  setWhatProduced(this);
7  findingRecord<PDTRecord>();
8 }
9 
11 
13  using namespace edm::es;
14  auto pdt = std::make_unique<PDT>("PDG table", new HepPDT::HeavyIonUnknownID);
15  std::ifstream pdtFile(pdtFileName.fullPath().c_str());
16  if (!pdtFile)
17  throw cms::Exception("FileNotFound", "can't open pdt file") << "cannot open " << pdtFileName.fullPath();
18  { // notice: the builder has to be destroyed
19  // in order to fill the table!
20  HepPDT::TableBuilder builder(*pdt);
21  if (!addParticleTable(pdtFile, builder)) {
22  throw cms::Exception("ConfigError", "can't read pdt file") << "wrong format of " << pdtFileName.fullPath();
23  }
24  }
25  return pdt;
26 }
27 
29  const edm::IOVSyncValue &,
30  edm::ValidityInterval &oInterval) {
31  // the same PDT is valid for any time
33 }
34 
35 // define this as a plug-in
36 // DEFINE_FWK_EVENTSETUP_SOURCE( HepPDTESSource );
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
std::string fullPath() const
Definition: FileInPath.cc:161
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
edm::FileInPath pdtFileName
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
HepPDTESSource(const edm::ParameterSet &)
constructor from parameter set
~HepPDTESSource() override
destructor
std::unique_ptr< PDT > ReturnType
define the return type
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
set validity interval
HLT enums.
ReturnType produce(const PDTRecord &)
return the particle table