Skip to content
Snippets Groups Projects
PdtTestApp.cc 1.39 KiB
Newer Older
#include "Particle/ParticleTable.hh"
#include "Particle/Particle.hh"
#include "Particle/PdtParser.hh"

#include <iostream>
#include <string>

int main()
{
  ParticleTable pTable;
  PdtParser parser;
  std::string theSourcePath=getenv("CMAKE_SOURCE_DIR"); 
  std::string pdtFile(theSourcePath+"/Particle/pdt.table");

  if (parser.parse(pdtFile, pTable)) {
    pTable.print(std::cout);

    std::string name("omega");
    Particle* omega = pTable.particle(name);
    if (0 != omega)
      omega->print(std::cout);
    else
      std::cout << name << " not found" << std::endl;

    name = std::string("oohps");
    Particle* dummy = pTable.particle(name);
    if (0 != dummy)
      dummy->print(std::cout);
    else
      std::cout << name << " not found" << std::endl;

    // try clone error handling
    pTable.clone(std::string("omegaNew"), std::string("omeGa")); // syntax here is clone(new, old);
    pTable.clone(std::string("omegaNew"), std::string("omega"));
    pTable.particle(std::string("omegaNew"))->print(std::cout);

    pTable.clone(std::string("omegaNew"), std::string("omega"));

    // try to modify mass and width
    pTable.modifyMass(std::string("omegaNew"), 1.42);
    pTable.modifyWidth(std::string("omegaNew"), 0.13);
    pTable.particle(std::string("omegaNew"))->print(std::cout);

  } else {
    std::cout << "Error: could not parse " << pdtFile << std::endl;
    exit(1);
  }

  return 0;
}