Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:09:43

0001 // -*- C++ -*-
0002 ///////////////////////////////////////////////////////////////////////////////
0003 // File: reference.h                                                         //
0004 // Description: header file for checkxor management (Creference class)       //
0005 // This file is part of the SISCone project.                                 //
0006 // For more details, see http://projects.hepforge.org/siscone                //
0007 //                                                                           //
0008 // Copyright (c) 2006 Gavin Salam and Gregory Soyez                          //
0009 //                                                                           //
0010 // This program is free software; you can redistribute it and/or modify      //
0011 // it under the terms of the GNU General Public License as published by      //
0012 // the Free Software Foundation; either version 2 of the License, or         //
0013 // (at your option) any later version.                                       //
0014 //                                                                           //
0015 // This program is distributed in the hope that it will be useful,           //
0016 // but WITHOUT ANY WARRANTY; without even the implied warranty of            //
0017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             //
0018 // GNU General Public License for more details.                              //
0019 //                                                                           //
0020 // You should have received a copy of the GNU General Public License         //
0021 // along with this program; if not, write to the Free Software               //
0022 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
0023 //                                                                           //
0024 // $Revision::                                                              $//
0025 // $Date::                                                                  $//
0026 ///////////////////////////////////////////////////////////////////////////////
0027 
0028 #ifndef __REFERENCE_H__
0029 #define __REFERENCE_H__
0030 
0031 namespace siscone{
0032 
0033 /**
0034  * \class Creference
0035  * \brief references used for checksums.
0036  *
0037  * This class implements some reference variable
0038  * that can be used for checksums. Those checksums
0039  * are useful to disentengle between contents of two
0040  * cones without looking into their explicit particle
0041  * contents.
0042  */
0043 class Creference{
0044  public:
0045   /// default constructor
0046   Creference();
0047 
0048   /// create a random reference
0049   void randomize();
0050 
0051   /// test emptyness
0052   bool is_empty();
0053 
0054   /// test non-emptyness
0055   bool not_empty();
0056 
0057   /// assignment of reference
0058   Creference& operator = (const Creference &r);
0059 
0060   /// addition of reference
0061   Creference operator + (const Creference &r);
0062 
0063   /// incrementation of reference
0064   Creference& operator += (const Creference &r);
0065 
0066   /// decrementation of reference
0067   Creference& operator -= (const Creference &r);
0068 
0069   /// accessing the reference
0070   inline unsigned int operator[] (int i) {return ref[i];}
0071 
0072   unsigned int ref[3];   ///< actual data for the reference
0073 };
0074 
0075 /// addition of two references
0076 Creference operator + (Creference &r1, Creference &r2);
0077 
0078 /// equality test of two references
0079 bool operator == (const Creference &r1, const Creference &r2);
0080 
0081 /// difference test of two references
0082 bool operator != (const Creference &r1, const Creference &r2);
0083 
0084 /// ordering of two references
0085 bool operator < (const Creference &r1, const Creference &r2);
0086 
0087 
0088 //=============== inline material ================
0089 
0090 // equality test for two references
0091 //----------------------------------
0092 inline bool operator == (const Creference &r1, const Creference &r2){
0093   return (r1.ref[0]==r2.ref[0]) && (r1.ref[1]==r2.ref[1]) && (r1.ref[2]==r2.ref[2]);
0094 }
0095 
0096 // difference test for two references
0097 //----------------------------------
0098 inline bool operator != (const Creference &r1, const Creference &r2){
0099   return (r1.ref[0]!=r2.ref[0]) || (r1.ref[1]!=r2.ref[1]) || (r1.ref[2]!=r2.ref[2]);
0100 }
0101 
0102 // difference test for two references
0103 //----------------------------------
0104 inline bool operator < (const Creference &r1, const Creference &r2){
0105   return (r1.ref[0]<r2.ref[0]) || ((r1.ref[0]==r2.ref[0]) && 
0106                    ((r1.ref[1]<r2.ref[1]) || ((r1.ref[1]==r2.ref[1]) && (r1.ref[2]<r2.ref[2]))
0107                     ));
0108 }
0109 
0110 }
0111 #endif