Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:30:21

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Whitney Armstrong, Sylvester Joosten
0003 
0004 #ifndef PARTICLESVC_H
0005 #define PARTICLESVC_H
0006 
0007 #include <map>
0008 
0009 #include "GaudiKernel/Service.h"
0010 
0011 #include "JugBase/IParticleSvc.h"
0012 
0013 /** Simple particle service.
0014  *
0015  *  This meant to provide basic particle information for reconstruction purposes.
0016  *  If particle data is needed, be sure to grab everything you can in an initialization
0017  *  step. Currently the  returned Particle/ParticleMap are by value.
0018  */
0019 class ParticleSvc : public extends<Service, IParticleSvc> {
0020 public:
0021   using Particle    = Jug::Base::ParticleData;
0022   using ParticleMap = std::map<int, Particle>;
0023 
0024   const ParticleMap m_particleMap;
0025 
0026 public:
0027   ParticleSvc(const std::string& name, ISvcLocator* svc);
0028 
0029   virtual ~ParticleSvc();
0030 
0031   virtual StatusCode initialize() final;
0032   virtual StatusCode finalize() final { return StatusCode::SUCCESS; }
0033 
0034   virtual ParticleMap particleMap() const { return m_particleMap; }
0035   virtual Particle particle(int pdg) const {
0036     if (m_particleMap.count(pdg) == 0) {
0037       // error
0038       return m_particleMap.at(0);
0039     }
0040     return m_particleMap.at(pdg);
0041   }
0042 };
0043 
0044 #endif