Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:36

0001 #include "HepPDT/HeavyIonUnknownID.hh"
0002 #include "SimGeneral/HepPDTESSource/interface/HepPDTESSource.h"
0003 
0004 HepPDTESSource::HepPDTESSource(const edm::ParameterSet &cfg)
0005     : pdtFileName(cfg.getParameter<edm::FileInPath>("pdtFileName")) {
0006   setWhatProduced(this);
0007   findingRecord<PDTRecord>();
0008 }
0009 
0010 HepPDTESSource::~HepPDTESSource() {}
0011 
0012 HepPDTESSource::ReturnType HepPDTESSource::produce(const PDTRecord &iRecord) {
0013   using namespace edm::es;
0014   auto pdt = std::make_unique<PDT>("PDG table", new HepPDT::HeavyIonUnknownID);
0015   std::ifstream pdtFile(pdtFileName.fullPath().c_str());
0016   if (!pdtFile)
0017     throw cms::Exception("FileNotFound", "can't open pdt file") << "cannot open " << pdtFileName.fullPath();
0018   {  // notice: the builder has to be destroyed
0019     // in order to fill the table!
0020     HepPDT::TableBuilder builder(*pdt);
0021     if (!addParticleTable(pdtFile, builder)) {
0022       throw cms::Exception("ConfigError", "can't read pdt file") << "wrong format of " << pdtFileName.fullPath();
0023     }
0024   }
0025   return pdt;
0026 }
0027 
0028 void HepPDTESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0029                                     const edm::IOVSyncValue &,
0030                                     edm::ValidityInterval &oInterval) {
0031   // the same PDT is valid for any time
0032   oInterval = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0033 }
0034 
0035 // define this as a plug-in
0036 // DEFINE_FWK_EVENTSETUP_SOURCE( HepPDTESSource );