Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:29

0001 // -*- C++ -*-
0002 //
0003 // PID.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef ThePEG_PID_H
0010 #define ThePEG_PID_H
0011 
0012 #include "EnumParticles.h"
0013 
0014 namespace ThePEG {
0015 
0016 /**
0017  * PID is a helper class implementing the type of PDG particle ids. At
0018  * the moment it just converts to a long, and other conversions are
0019  * intercepted.
0020  *
0021  * @see ParticleData
0022  */
0023 class PID {
0024 public:
0025   /**
0026    * Generic construction is disallowed.
0027    */
0028   template <typename T>
0029   PID(T t) { 
0030     t.ERROR_only_use_long_as_Particle_ID_type(); 
0031   }
0032 
0033   /**
0034    * Casting to generic types is disallowed.
0035    */
0036   template <typename T>
0037   operator T() const {
0038     T t; 
0039     t.ERROR_only_use_long_as_Particle_ID_type(); 
0040     return t;
0041   }
0042 
0043   /**
0044    * The negation operator
0045    */
0046   PID operator-() const;
0047 
0048 private:
0049   /**
0050    * The particle id.
0051    */
0052   long id;
0053 };
0054 
0055 /// Specialized constructor for 'long'
0056 template <> inline PID::PID(long t) : id(t) {} 
0057 
0058 /// Specialized constructor for 'int'
0059 template <> inline PID::PID(int t) : id(t) {} 
0060 
0061 /// Specialized constructor for Particle Code enum
0062 template <> inline PID::PID(ParticleID::ParticleCodes t) : id(t) {} 
0063 
0064 /// Specialized cast for 'long'
0065 template <> inline PID::operator long() const { return id; }
0066 
0067 /**
0068  * The negation operator
0069  */
0070 inline PID PID::operator-() const {
0071   return -id;
0072 }
0073 
0074 }
0075 
0076 #endif /* ThePEG_PID_H */