Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:15:33

0001 // -*- C++ -*-
0002 ///////////////////////////////////////////////////////////////////////////////
0003 // File: hash.h                                                              //
0004 // Description: header file for classes hash_element and hash_cones          //
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 __HASH_H__
0029 #define __HASH_H__
0030 
0031 #include "momentum.h"
0032 #include "reference.h"
0033 
0034 namespace siscone{
0035 
0036 /**
0037  * \class hash_element
0038  * information on store cones candidates.
0039  *
0040  * We store in this class the information used to count all 
0041  * protocones in a first pass. This first pass only count
0042  * cones with different references and test their stbility
0043  * with the parent-child particles (border particles).
0044  */
0045 class hash_element{
0046  public:
0047   Creference ref;      ///< reference
0048   double eta;          ///< centre: eta coordinate
0049   double phi;          ///< centre: phi coordinate
0050   bool is_stable;      ///< true if stable w.r.t. "border particles"
0051 
0052   hash_element *next;  ///< pointer to the next element
0053 };
0054 
0055 /**
0056  * \class hash_cones
0057  * list of cones candidates.
0058  *
0059  * We store in this class all the hash_elements and give
0060  * functions to manipulate them.
0061  */
0062 class hash_cones{
0063  public:
0064   /// constructor with initialisation
0065   /// \param _Np  number of particles
0066   /// \param _R2  cone radius (squared)
0067   hash_cones(int _Np, double _R2);
0068 
0069   /// destructor
0070   ~hash_cones();
0071 
0072   /**
0073    * insert a new candidate into the hash.
0074    * \param v       4-momentum of te cone to add
0075    * \param parent  parent particle defining the cone
0076    * \param child   child particle defining the cone
0077    * \param p_io    whether the parent has to belong to the cone or not
0078    * \param c_io    whether the child has to belong to the cone or not
0079    * \return 0 on success, 1 on error
0080    */
0081   int insert(Cmomentum *v, Cmomentum *parent, Cmomentum *child, bool p_io, bool c_io);
0082 
0083   /**
0084    * insert a new candidate into the hash.
0085    * \param v       4-momentum of te cone to add
0086    * Note, in this case, we assume stability. We also assume
0087    * that eta and phi are computed for v
0088    * \return 0 on success, 1 on error
0089    */
0090   int insert(Cmomentum *v);
0091 
0092   /// the cone data itself
0093   hash_element **hash_array;
0094 
0095   /// number of elements
0096   int n_cones;
0097 
0098   /// number of occupied cells
0099 #ifdef DEBUG_STABLE_CONES
0100   int n_occupied_cells;
0101 #endif
0102 
0103   /// number of cells-1
0104   int mask;
0105 
0106   /// circle radius (squared)
0107   /// NOTE: need to be set before any call to 'insert'
0108   double R2;
0109 
0110   /**
0111    * test if a particle is inside a cone of given centre.
0112    * check if the particle of coordinates 'v' is inside the circle of radius R 
0113    * centered at 'centre'.
0114    * \param centre   centre of the circle
0115    * \param v        particle to test
0116    * \return true if inside, false if outside
0117    */
0118   inline bool is_inside(Cmomentum *centre, Cmomentum *v);
0119 };
0120 
0121 }
0122 #endif