CMS 3D CMS Logo

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