Commit 6cf55ea0 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Added particle service.

	new file:   JugBase/IParticleSvc.h
	new file:   src/components/ParticleSvc.h
parent 80d26877
#ifndef IParticleSvc_H
#define IParticleSvc_H
#include "GaudiKernel/IService.h"
#include <unordered_map>
namespace Jug::Base {
/** Simple particle data.
*
*/
struct Particle {
int pdgCode;
int charge;
int mass;
};
} // namespace Jug::Base
/** Particle interface.
*
* \ingroup base
*/
class GAUDI_API IParticleSvc : virtual public IService {
public:
using ParticleMap = std::map<int, Particle>;
public:
/// InterfaceID
DeclareInterfaceID(IParticleSvc, 1, 0);
virtual ~IParticleSvc() {}
virtual ParticleMap particleMap() const;
virtual Particle particle(int pdg) const;
};
#endif // IParticleSvc_H
#ifndef PARTICLESVC_H
#define PARTICLESVC_H
#include "JugBase/IParticleSvc.h"
#include "GaudiKernel/Service.h"
/** Simple particle service.
*
* This meant to provide basic particle information for reconstruction purposes.
*/
class ParticleSvc : public extends<Service, IParticleSvc> {
public:
using ParticleMap = std::map<int, Particle>;
ParticleMap m_particleMap;
public:
ParticleSvc(const std::string& name, ISvcLocator* svc) : base_class(name, svc) {}
virtual ~ParticleSvc() {}
virtual StatusCode initialize() final {
{
StatusCode sc = Service::initialize();
if (!sc.isSuccess())
return sc;
m_particleMap = {
{11, {11, -1, 0.000510998928}},
{-11, {-11, 1, 0.000510998928}},
{13, {13, -1, 0.105658357}},
{-13, {-13, 1, 0.105658357}},
{22, {22, 0, 0.0}},
{111, {111, 0, 0.1349766}},
{211, {211, 1, 0.1395701}},
{-211, {-211, -1, 0.1395701}},
};
}
StatusCode GeoSvc::finalize() final { return StatusCode::SUCCESS; }
virtual ParticleMap particleMap() const { return m_particleMap; }
virtual Particle particle(int pdg) const
{
if (m_particleMap.count(pdg) == 0) {
// error
}
return m_particleMap.at(pdg);
}
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment