CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/SimGeneral/HepPDTRecord/interface/PdtEntry.h

Go to the documentation of this file.
00001 #ifndef Utilities_PdtEntry_h
00002 #define Utilities_PdtEntry_h
00003 /* \class PdtEntry
00004  *
00005  * \author Luca Lista, INFN
00006  *
00007  */
00008 #include <string>
00009 #include <iterator>
00010 #include <vector>
00011 
00012 namespace edm { class EventSetup; }
00013 namespace HepPDT { class ParticleData; }
00014 
00015 class PdtEntry {
00016 public:
00018   explicit PdtEntry() : pdgId_( 0 ), data_( 0 ) { }
00020   explicit PdtEntry( int pdgId ) : pdgId_( pdgId ), data_( 0 ) { }
00022   explicit PdtEntry( const std::string & name ) : pdgId_( 0 ), name_( name ), data_( 0 ) { }
00024   int pdgId() const;
00026   const std::string & name() const;
00028   const HepPDT::ParticleData & data() const; 
00030   void setup( const edm::EventSetup & ); 
00031 
00032 private:
00034   int pdgId_;
00036   std::string name_;
00038   const HepPDT::ParticleData * data_;
00039 };
00040 
00041 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00042 
00043 namespace edm {
00044   namespace pdtentry {
00045     PdtEntry getPdtEntry(Entry const& e, char const* name);
00046     std::vector<PdtEntry> getPdtEntryVector(Entry const& e, char const* name);
00047   }
00048 
00049   template<>
00050   inline PdtEntry ParameterSet::getParameter<PdtEntry>(std::string const& name) const {
00051     Entry const& e = retrieve(name);
00052     return pdtentry::getPdtEntry(e, name.c_str());
00053   }
00054 
00055   template<>
00056   inline PdtEntry ParameterSet::getUntrackedParameter<PdtEntry>(std::string const& name) const {
00057     Entry const* e = getEntryPointerOrThrow_(name);
00058     return pdtentry::getPdtEntry(*e, name.c_str());
00059   }
00060 
00061   template<>
00062   inline PdtEntry ParameterSet::getUntrackedParameter<PdtEntry>(std::string const& name, 
00063                                                                 PdtEntry const& defaultValue) const {
00064     Entry const* e = retrieveUntracked(name);
00065     if (e == 0) return defaultValue;
00066     return pdtentry::getPdtEntry(*e, name.c_str());
00067   }
00068 
00069   template<>
00070   inline PdtEntry ParameterSet::getParameter<PdtEntry>(char const* name) const {
00071     Entry const& e = retrieve(name);
00072     return pdtentry::getPdtEntry(e, name);
00073   }
00074 
00075   template<>
00076   inline PdtEntry ParameterSet::getUntrackedParameter<PdtEntry>(char const* name) const {
00077     Entry const* e = getEntryPointerOrThrow_(name);
00078     return pdtentry::getPdtEntry(*e, name);
00079   }
00080 
00081   template<>
00082   inline PdtEntry ParameterSet::getUntrackedParameter<PdtEntry>(char const* name, 
00083                                                                 PdtEntry const& defaultValue) const {
00084     Entry const* e = retrieveUntracked(name);
00085     if (e == 0) return defaultValue;
00086     return pdtentry::getPdtEntry(*e, name);
00087   }
00088 
00089   template<>
00090   inline std::vector<PdtEntry> ParameterSet::getParameter<std::vector<PdtEntry> >(std::string const& name) const {
00091     Entry const& e = retrieve(name);
00092     return pdtentry::getPdtEntryVector(e, name.c_str());
00093   }
00094 
00095   template<>
00096   inline std::vector<PdtEntry> ParameterSet::getUntrackedParameter<std::vector<PdtEntry> >(std::string const& name) const {
00097     Entry const* e = getEntryPointerOrThrow_(name);
00098     return pdtentry::getPdtEntryVector(*e, name.c_str());
00099   }
00100 
00101   template<>
00102   inline std::vector<PdtEntry> ParameterSet::getUntrackedParameter<std::vector<PdtEntry> >(std::string const& name,
00103                                                                    std::vector<PdtEntry> const& defaultValue) const {
00104     Entry const* e = retrieveUntracked(name);
00105     if (e == 0) return defaultValue;
00106     return pdtentry::getPdtEntryVector(*e, name.c_str());
00107   }
00108 
00109   template<>
00110   inline std::vector<PdtEntry> ParameterSet::getParameter<std::vector<PdtEntry> >(char const* name) const {
00111     Entry const& e = retrieve(name);
00112     return pdtentry::getPdtEntryVector(e, name);
00113   }
00114 
00115   template<>
00116   inline std::vector<PdtEntry> ParameterSet::getUntrackedParameter<std::vector<PdtEntry> >(char const* name) const {
00117     Entry const* e = getEntryPointerOrThrow_(name);
00118     return pdtentry::getPdtEntryVector(*e, name);
00119   }
00120 
00121   template<>
00122   inline std::vector<PdtEntry> ParameterSet::getUntrackedParameter<std::vector<PdtEntry> >(char const* name,
00123                                                                    std::vector<PdtEntry> const& defaultValue) const {
00124     Entry const* e = retrieveUntracked(name);
00125     if (e == 0) return defaultValue;
00126     return pdtentry::getPdtEntryVector(*e, name);
00127   }
00128 
00129   template<>
00130   inline std::vector<std::string> ParameterSet::getParameterNamesForType<PdtEntry>(bool trackiness) const {
00131     std::vector<std::string> ints = getParameterNamesForType<int>(trackiness);
00132     std::vector<std::string> strings = getParameterNamesForType<std::string>(trackiness);
00133     std::copy( strings.begin(), strings.end(), std::back_insert_iterator<std::vector<std::string> >( ints ) ); 
00134     return ints;
00135   }
00136   
00137   template<>
00138   inline std::vector<std::string> ParameterSet::getParameterNamesForType<std::vector<PdtEntry> >(bool trackiness) const {
00139     std::vector<std::string> ints = getParameterNamesForType<std::vector<int> >(trackiness);
00140     std::vector<std::string> strings = getParameterNamesForType<std::vector<std::string> >(trackiness);
00141     std::copy( strings.begin(), strings.end(), std::back_insert_iterator<std::vector<std::string> >( ints ) ); 
00142     return ints;
00143   }
00144 
00145 }
00146 #endif