![]() |
![]() |
00001 #include "SimGeneral/HepPDTESSource/interface/HepPDTESSource.h" 00002 00003 HepPDTESSource::HepPDTESSource( const edm::ParameterSet& cfg ) : 00004 pdtFileName( cfg.getParameter<edm::FileInPath>( "pdtFileName" ) ) { 00005 setWhatProduced( this ); 00006 findingRecord<PDTRecord>(); 00007 } 00008 00009 HepPDTESSource::~HepPDTESSource() { 00010 } 00011 00012 HepPDTESSource::ReturnType 00013 HepPDTESSource::produce( const PDTRecord & iRecord ) { 00014 using namespace edm::es; 00015 std::auto_ptr<PDT> pdt( new PDT( "PDG table" ) ); 00016 std::ifstream pdtFile( pdtFileName.fullPath().c_str() ); 00017 if( ! pdtFile ) 00018 throw cms::Exception( "FileNotFound", "can't open pdt file" ) 00019 << "cannot open " << pdtFileName.fullPath(); 00020 { // notice: the builder has to be destroyed 00021 // in order to fill the table! 00022 HepPDT::TableBuilder builder( * pdt ); 00023 if( ! addParticleTable( pdtFile, builder ) ) { 00024 throw cms::Exception( "ConfigError", "can't read pdt file" ) 00025 << "wrong format of " << pdtFileName.fullPath(); 00026 } 00027 } 00028 return pdt; 00029 } 00030 00031 void HepPDTESSource::setIntervalFor( const edm::eventsetup::EventSetupRecordKey&, 00032 const edm::IOVSyncValue&, 00033 edm::ValidityInterval& oInterval ) { 00034 // the same PDT is valid for any time 00035 oInterval = edm::ValidityInterval( edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime() ); 00036 } 00037 00038 //define this as a plug-in 00039 //DEFINE_FWK_EVENTSETUP_SOURCE( HepPDTESSource );