Functions | |
PartPropSvc (const std::string &name, ISvcLocator *svc) | |
~PartPropSvc () | |
const InterfaceID & | type () const |
StatusCode | initialize () |
StatusCode | finalize () |
StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface) |
PartPropSvc::PartPropSvc | ( | const std::string & | name, | |
ISvcLocator * | svc | |||
) |
Definition at line 21 of file PartPropSvc.cpp.
00022 : Service( name, svc ), m_pdt(0) { 00023 00024 declareProperty( "InputType", m_inputType="PDG"); 00025 declareProperty( "InputFile", m_pdtFiles); 00026 00027 if (m_pdtFiles.empty() ) { 00028 m_pdtFiles.push_back("PDGTABLE.MeV"); 00029 } 00030 00031 }
PartPropSvc::~PartPropSvc | ( | ) |
const InterfaceID& PartPropSvc::type | ( | ) | const |
StatusCode PartPropSvc::initialize | ( | ) |
Definition at line 50 of file PartPropSvc.cpp.
00050 { 00051 00052 MsgStream log( msgSvc(), name() ); 00053 std::vector<std::string>::const_iterator itr; 00054 00055 StatusCode status = Service::initialize(); 00056 00057 log << MSG::INFO << "PDT file(s): " << endreq; 00058 for (itr=m_pdtFiles.begin(); itr!=m_pdtFiles.end(); ++itr) { 00059 log << MSG::INFO << " " << *itr << endreq; 00060 } 00061 log << MSG::INFO << "Type: " << m_inputType << endreq; 00062 00063 if ( status.isFailure() ) { 00064 log << MSG::ERROR << "Could not initialize main svc" << endreq; 00065 return StatusCode::FAILURE; 00066 } 00067 00068 bool (*pF) (std::istream &, 00069 HepPDT::TableBuilder &); 00070 00071 00072 // Determine type of input 00073 if (m_inputType == "PDG") { 00074 pF = &HepPDT::addPDGParticles; 00075 } else if (m_inputType == "Pythia") { 00076 pF = &HepPDT::addPythiaParticles; 00077 } else if (m_inputType == "EvtGen") { 00078 pF = &HepPDT::addEvtGenParticles; 00079 } else if (m_inputType == "Herwig") { 00080 pF = &HepPDT::addHerwigParticles; 00081 } else if (m_inputType == "IsaJet") { 00082 pF = &HepPDT::addIsajetParticles; 00083 } else if (m_inputType == "QQ") { 00084 pF = &HepPDT::addQQParticles; 00085 } else { 00086 log << MSG::ERROR << "Unknown Particle Data file type: \"" 00087 << m_inputType << "\"" << endreq; 00088 return StatusCode::FAILURE; 00089 } 00090 00091 // Make sure we have at least one file 00092 if (m_pdtFiles.size() == 0) { 00093 log << MSG::ERROR << "Need at least 1 PDT file" << endreq; 00094 log << MSG::ERROR << "Check value of property \"InputFile\"" << endreq; 00095 return StatusCode::FAILURE; 00096 } 00097 00098 m_pdt = new HepPDT::ParticleDataTable; 00099 00100 { 00101 // Construct table builder 00102 HepPDT::TableBuilder tb( *m_pdt ); 00103 00104 // read the input 00105 int good(0); 00106 for (itr=m_pdtFiles.begin(); itr!=m_pdtFiles.end(); ++itr) { 00107 00108 std::string rfile = System::PathResolver::find_file(*itr,"DATAPATH"); 00109 if (rfile == "") { 00110 log << MSG::ERROR << "Could not find PDT file: \"" << *itr 00111 << "\" in $DATAPATH" << endreq; 00112 continue; 00113 } 00114 00115 std::ifstream pdfile( rfile.c_str() ); 00116 if (!pdfile) { 00117 log << MSG::ERROR << "Could not open PDT file: \"" << rfile 00118 << "\"" << endreq; 00119 continue; 00120 } 00121 00122 if ( ! pF(pdfile,tb) ) { 00123 log << MSG::ERROR << "Error reading PDT file: \"" << rfile 00124 << "\"" << endreq; 00125 return StatusCode::FAILURE; 00126 } 00127 ++good; 00128 } 00129 if (0 == good) { 00130 log << MSG::ERROR << "Unable to access any PDT file" <<endreq; 00131 return StatusCode::FAILURE; 00132 } 00133 00134 } // the tb destructor fills datacol 00135 00136 00137 00138 return status; 00139 }
StatusCode PartPropSvc::finalize | ( | ) |
Definition at line 143 of file PartPropSvc.cpp.
00143 { 00144 00145 MsgStream log( msgSvc(), name() ); 00146 StatusCode status = Service::finalize(); 00147 00148 if ( status.isSuccess() ) 00149 log << MSG::INFO << "Service finalised successfully" << endreq; 00150 00151 return status; 00152 }
StatusCode PartPropSvc::queryInterface | ( | const InterfaceID & | riid, | |
void ** | ppvInterface | |||
) |
Definition at line 156 of file PartPropSvc.cpp.
00157 { 00158 StatusCode sc = StatusCode::FAILURE; 00159 if ( ppvInterface ) { 00160 *ppvInterface = 0; 00161 00162 if ( riid == IID_IPartPropSvc ) { 00163 *ppvInterface = static_cast<IPartPropSvc*>(this); 00164 sc = StatusCode::SUCCESS; 00165 addRef(); 00166 } 00167 else 00168 sc = Service::queryInterface( riid, ppvInterface ); 00169 } 00170 return sc; 00171 }