|
Gaudi Framework, version v21r11 |
| Home | Generated: 30 Sep 2010 |
Functions | |
| PartPropSvc (const std::string &name, ISvcLocator *svc) | |
| ~PartPropSvc () | |
| StatusCode | initialize () |
| StatusCode | reinitialize () |
| StatusCode | finalize () |
| bool(*)(std::istream &, HepPDT::TableBuilder &) | parseTableType (std::string &typ) |
| StatusCode | createTable () |
| HepPDT::ParticleDataTable * | PDT () |
| void | setUnknownParticleHandler (HepPDT::ProcessUnknownID *puid, const std::string &n) |
| StatusCode PartPropSvc::createTable | ( | ) |
Definition at line 202 of file PartPropSvc.cpp.
00202 { 00203 00204 // use a handler for unknown heavy ions 00205 if ( m_upid == 0 ) { 00206 setUnknownParticleHandler(new HepPDT::HeavyIonUnknownID, 00207 "Default Heavy Ion Handler"); 00208 m_upid_local = true; 00209 } 00210 00211 m_pdt = new HepPDT::ParticleDataTable(m_upid_name, m_upid); 00212 00213 HepPDT::TableBuilder tb( *m_pdt ); 00214 00215 std::vector< std::pair<std::string, 00216 bool(*) (std::istream&,HepPDT::TableBuilder&)> >::const_iterator itr; 00217 for (itr = m_inputs.begin(); itr != m_inputs.end(); ++itr) { 00218 string f = itr->first; 00219 bool (*pF) (std::istream&,HepPDT::TableBuilder&) = itr->second; 00220 00221 m_log << MSG::DEBUG << "Reading PDT file \"" << f << "\"" 00222 << endmsg; 00223 00224 std::ifstream pdfile( f.c_str() ); 00225 // build a table from the file 00226 if ( ! pF(pdfile,tb) ) { 00227 m_log << MSG::ERROR << "Error reading PDT file: \"" << f 00228 << "\"" << endmsg; 00229 return StatusCode::FAILURE; 00230 } 00231 00232 } 00233 00234 return StatusCode::SUCCESS; 00235 00236 }
| StatusCode PartPropSvc::finalize | ( | ) |
Definition at line 144 of file PartPropSvc.cpp.
00144 { 00145 00146 if (m_pdt != 0) { 00147 delete m_pdt; 00148 m_pdt = 0; 00149 } 00150 00151 if (m_upid_local && m_upid != 0) { 00152 m_upid_local = false; 00153 // This will cause a memory leak, but we can't delete it as the 00154 // destructor of HepPDT::processUnknownID is protected. 00155 // We need this though to call reinitialize successfully. 00156 m_upid = 0; 00157 } 00158 00159 MsgStream m_log( msgSvc(), name() ); 00160 StatusCode status = Service::finalize(); 00161 00162 if ( status.isSuccess() ) 00163 m_log << MSG::DEBUG << "Service finalised successfully" << endmsg; 00164 00165 return status; 00166 }
| StatusCode PartPropSvc::initialize | ( | ) |
Definition at line 59 of file PartPropSvc.cpp.
00059 { 00060 00061 std::vector<std::string>::const_iterator itr; 00062 00063 StatusCode status = Service::initialize(); 00064 m_log.setLevel( m_outputLevel.value() ); 00065 00066 if ( status.isFailure() ) { 00067 m_log << MSG::ERROR << "Could not initialize main svc" << endmsg; 00068 return StatusCode::FAILURE; 00069 } 00070 00071 00072 std::string key = m_pdtFiles.value(); 00073 00074 Tokenizer tok(true); 00075 00076 tok.analyse( key, " ", "", "", "=", "", ""); 00077 00078 for ( Tokenizer::Items::iterator i = tok.items().begin(); 00079 i != tok.items().end(); i++) { 00080 const std::string& fname = (*i).tag(); 00081 00082 // see if input file exists in $DATAPATH 00083 std::string rfile = System::PathResolver::find_file(fname,"DATAPATH"); 00084 if (rfile == "") { 00085 m_log << MSG::ERROR << "Could not find PDT file: \"" << *itr 00086 << "\" in $DATAPATH" << endmsg; 00087 return StatusCode::FAILURE; 00088 } 00089 00090 00091 // is the file readable? 00092 std::ifstream pdfile( rfile.c_str() ); 00093 if (!pdfile) { 00094 m_log << MSG::ERROR << "Could not open PDT file: \"" << rfile 00095 << "\"" << endmsg; 00096 return StatusCode::FAILURE; 00097 } 00098 00099 std::string val,VAL; 00100 val = (*i).value(); 00101 VAL = val; 00102 toupper(VAL); 00103 00104 // default: no type specified, assume PDG 00105 if (val == fname) { 00106 m_log << MSG::INFO << "No table format type specified for \"" << fname 00107 << "\". Assuming PDG" << endmsg; 00108 VAL = "PDG"; 00109 } 00110 00111 bool (*pF) (std::istream &, 00112 HepPDT::TableBuilder &); 00113 try { 00114 pF = parseTableType(VAL); 00115 } catch (...) { 00116 m_log << MSG::ERROR 00117 << "Could not determine Particle Property table type: \"" 00118 << val << "\" for file \"" << fname << "\"" << endmsg; 00119 return StatusCode::FAILURE; 00120 } 00121 00122 m_log << MSG::DEBUG << "Adding PDT file \"" << rfile << "\" type " 00123 << VAL << endmsg; 00124 00125 m_inputs.push_back( make_pair<std::string, bool(*) (std::istream&,HepPDT::TableBuilder&)>( rfile, pF ) ); 00126 00127 } 00128 00129 00130 return status; 00131 }
| bool(*)(std::istream&, HepPDT::TableBuilder&) PartPropSvc::parseTableType | ( | std::string & | typ | ) |
Definition at line 171 of file PartPropSvc.cpp.
00172 { 00173 00174 bool (*pF) (std::istream &, 00175 HepPDT::TableBuilder &); 00176 00177 if (typ == "PDG") { 00178 pF = &HepPDT::addPDGParticles; 00179 } else if (typ == "PYTHIA") { 00180 pF = &HepPDT::addPythiaParticles; 00181 } else if (typ == "EVTGEN") { 00182 pF = &HepPDT::addEvtGenParticles; 00183 } else if (typ == "HERWIG") { 00184 pF = &HepPDT::addHerwigParticles; 00185 } else if (typ == "ISAJET") { 00186 pF = &HepPDT::addIsajetParticles; 00187 } else if (typ == "QQ") { 00188 pF = &HepPDT::addQQParticles; 00189 } else { 00190 m_log << MSG::ERROR << "Unknown Particle Data file type: \"" 00191 << typ << "\"" << endmsg; 00192 throw( std::runtime_error("error parsing particle table type") ); 00193 } 00194 00195 return pF; 00196 00197 }
| PartPropSvc::PartPropSvc | ( | const std::string & | name, | |
| ISvcLocator * | svc | |||
| ) |
Definition at line 43 of file PartPropSvc.cpp.
00044 : base_class( name, svc ), m_upid(0), m_pdt(0), m_log(msgSvc(), name), 00045 m_upid_local(false) { 00046 00047 declareProperty( "InputFile", m_pdtFiles="PDGTABLE.MeV"); 00048 00049 }
| HepPDT::ParticleDataTable* PartPropSvc::PDT | ( | ) |
Definition at line 241 of file PartPropSvc.cpp.
00241 { 00242 00243 if (m_pdt == 0) { 00244 m_log << MSG::DEBUG << "creating ParticleDataTable" << endmsg; 00245 if (createTable().isFailure()) { 00246 m_log << MSG::FATAL << "Could not create ParticleDataTable" << endmsg; 00247 m_pdt = 0; 00248 } 00249 } 00250 00251 return m_pdt; 00252 }
| StatusCode PartPropSvc::reinitialize | ( | ) |
Definition at line 135 of file PartPropSvc.cpp.
00135 { 00136 00137 return StatusCode::SUCCESS; 00138 00139 }
| void PartPropSvc::setUnknownParticleHandler | ( | HepPDT::ProcessUnknownID * | puid, | |
| const std::string & | n | |||
| ) |
Definition at line 257 of file PartPropSvc.cpp.
00258 { 00259 if (m_pdt != 0) { 00260 m_log << MSG::ERROR << "not setting Unknown Particle Handler \"" << n 00261 << "\" as ParticleDataTable already instantiated" << endmsg; 00262 return; 00263 } 00264 00265 m_log << MSG::DEBUG << "setting Unknown Particle Handler \"" << n 00266 << "\" at " << puid << endmsg; 00267 00268 if (m_upid != 0) { 00269 m_log << MSG::WARNING 00270 << "overriding previously selected Unknown Particle Handler \"" 00271 << m_upid_name << "\" with \"" << n << "\"" << endmsg; 00272 } 00273 00274 m_upid = puid; 00275 m_upid_name = n; 00276 00277 }
| PartPropSvc::~PartPropSvc | ( | ) |