SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
HepPDTManager.cc
Go to the documentation of this file.
1 #include "HepPDTManager.hh"
2 
3 namespace slic {
4 
6  Module("HepPDTManager"), m_datacol(0), m_fileSet(false) {
8 }
9 
11  delete m_datacol;
12 }
13 
14 HepPDT::ParticleDataTable* HepPDTManager::getParticleDataTable() {
15  if (m_datacol == 0) {
17  }
18  return m_datacol;
19 }
20 
21 void HepPDTManager::setParticleDataFile(std::string pdfile) {
22  m_pdfile = pdfile;
23  m_fileSet = true;
24 }
25 
27  // See if we can get the data file from the environment if it wasn't setup via CL or G4 macro.
28  if (!m_fileSet) {
29  char *heppdt = getenv("HEPPDT_BASE");
30  if (heppdt) {
31  m_pdfile = std::string(heppdt) + std::string("/data/particle.tbl");
32  } else {
33  log() << LOG::error << "Could not find particle.tbl!" << LOG::done;
34  return;
35  }
36  }
37 
38  std::ifstream pdfile(m_pdfile.c_str());
39  if (!pdfile) {
40 #ifdef SLIC_LOG
41  log() << LOG::error << "error reading file " << m_pdfile << LOG::done;
42 #endif
43  return;
44  }
45 
46  m_datacol = new HepPDT::ParticleDataTable("Particle Data Table");
47  HepPDT::TableBuilder *tb = new HepPDT::TableBuilder((*m_datacol));
48  if (!addParticleTable(pdfile, (*tb))) {
49 #ifdef SLIC_LOG
50  log() << LOG::error << "error reading lines from " << m_pdfile << LOG::done;
51 #endif
52  }
53 
54  delete tb;
55  tb = 0;
56  pdfile.close();
57 
58  // DEBUG
59  //printParticleData();
60 }
61 
63  log() << LOG::always << "-- HepPDT Particle Data Table --" << LOG::endl;
64  log() << "ParticleDataTable has " << m_datacol->size() << " particles" << LOG::endl;
65 
66  for (HepPDT::ParticleDataTable::const_iterator it = m_datacol->begin(); it != m_datacol->end(); it++) {
67  HepPDT::ParticleID id = it->first;
68  HepPDT::ParticleData pdata = it->second;
69 
70  log() << LOG::always << id.pid() << " " << id.PDTname();
71 
72  if (id.isSUSY()) {
73  log() << " <-- SUSY particle";
74  }
75 
76  log() << LOG::endl;
77  }
78 
79  log() << LOG::done;
80 }
81 
82 } // namespace slic
HepPDT::ParticleDataTable * getParticleDataTable()
std::string m_pdfile
void setParticleDataFile(std::string pdfile)
virtual ~HepPDTManager()
HepPDT::ParticleDataTable * m_datacol
void setOutputLevel(const LOG::ELevel &outputLevel)
Definition: LogStream.hh:135
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
@ debug
Definition: LogStream.hh:33
@ always
Definition: LogStream.hh:33
@ error
Definition: LogStream.hh:33
@ endl
Definition: LogStream.hh:26
@ done
Definition: LogStream.hh:26