CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/SimGeneral/HepPDTESSource/src/HepPDTESSource.cc

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