Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-17 10:01:03

0001 // ----------------------------------------------------------------------
0002 //
0003 // ParticleDataTableComparison.hh
0004 // Author: Lynn Garren
0005 //
0006 // ----------------------------------------------------------------------
0007 #ifndef ParticleDataTableComparison_HH
0008 #define ParticleDataTableComparison_HH
0009 
0010 #include "HepPDT/ParticleID.hh"
0011 
0012 namespace HepPDT {
0013   
0014 //! The ParticleDataTableComparison class provides a utility for sorting the PDT.
0015 
0016 ///
0017 /// \class ParticleDataTableComparison
0018 /// \author Lynn Garren
0019 ///
0020 ///  Sort the PDT by absolute value of the particle ID.
0021 ///  If the absolute values are equal, the positive number comes first.
0022 ///
0023 class ParticleDataTableComparison  {
0024 
0025 public:
0026   /// stateless class
0027   ParticleDataTableComparison( ) {;}
0028   
0029   /// Comparison method sorts by absolute value.
0030   /// If the absolute values are the same, the positive entry comes first.
0031   inline bool operator() ( const ParticleID&, const ParticleID & ) const;
0032 
0033 };  // ParticleDataTableComparison
0034 
0035 
0036 bool ParticleDataTableComparison::operator() ( const ParticleID& p1, const ParticleID & p2 ) const
0037 {
0038     if( p1.abspid() == p2.abspid() ) {
0039       return  p2.pid() <  p1.pid();
0040     }
0041     return p1.abspid() < p2.abspid();
0042 }
0043 
0044 
0045 }   // HepPDT
0046 
0047 #endif // ParticleDataTableComparison_HH