1 | // -*- C++ -*-
|
---|
2 | ///////////////////////////////////////////////////////////////////////////////
|
---|
3 | // File: hash.h //
|
---|
4 | // Description: header file for classes hash_element and hash_cones //
|
---|
5 | // This file is part of the SISCone project. //
|
---|
6 | // For more details, see http://projects.hepforge.org/siscone //
|
---|
7 | // //
|
---|
8 | // Copyright (c) 2006 Gavin Salam and Gregory Soyez //
|
---|
9 | // //
|
---|
10 | // This program is free software; you can redistribute it and/or modify //
|
---|
11 | // it under the terms of the GNU General Public License as published by //
|
---|
12 | // the Free Software Foundation; either version 2 of the License, or //
|
---|
13 | // (at your option) any later version. //
|
---|
14 | // //
|
---|
15 | // This program is distributed in the hope that it will be useful, //
|
---|
16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
---|
17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
---|
18 | // GNU General Public License for more details. //
|
---|
19 | // //
|
---|
20 | // You should have received a copy of the GNU General Public License //
|
---|
21 | // along with this program; if not, write to the Free Software //
|
---|
22 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
|
---|
23 | // //
|
---|
24 | // $Revision:: 224 $//
|
---|
25 | // $Date:: 2008-05-16 19:58:30 +0200 (Fri, 16 May 2008) $//
|
---|
26 | ///////////////////////////////////////////////////////////////////////////////
|
---|
27 |
|
---|
28 | #ifndef __HASH_H__
|
---|
29 | #define __HASH_H__
|
---|
30 |
|
---|
31 | #include "momentum.h"
|
---|
32 | #include "reference.h"
|
---|
33 |
|
---|
34 | namespace siscone{
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * \class hash_element
|
---|
38 | * information on store cones candidates.
|
---|
39 | *
|
---|
40 | * We store in this class the information used to count all
|
---|
41 | * protocones in a first pass. This first pass only count
|
---|
42 | * cones with different references and test their stbility
|
---|
43 | * with the parent-child particles (border particles).
|
---|
44 | */
|
---|
45 | class hash_element{
|
---|
46 | public:
|
---|
47 | Creference ref; ///< reference
|
---|
48 | double eta; ///< centre: eta coordinate
|
---|
49 | double phi; ///< centre: phi coordinate
|
---|
50 | bool is_stable; ///< true if stable w.r.t. "border particles"
|
---|
51 |
|
---|
52 | hash_element *next; ///< pointer to the next element
|
---|
53 | };
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * \class hash_cones
|
---|
57 | * list of cones candidates.
|
---|
58 | *
|
---|
59 | * We store in this class all the hash_elements and give
|
---|
60 | * functions to manipulate them.
|
---|
61 | */
|
---|
62 | class hash_cones{
|
---|
63 | public:
|
---|
64 | /// constructor with initialisation
|
---|
65 | /// \param _Np number of particles
|
---|
66 | /// \param _R2 cone radius (squared)
|
---|
67 | hash_cones(int _Np, double _R2);
|
---|
68 |
|
---|
69 | /// destructor
|
---|
70 | ~hash_cones();
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * insert a new candidate into the hash.
|
---|
74 | * \param v 4-momentum of te cone to add
|
---|
75 | * \param parent parent particle defining the cone
|
---|
76 | * \param child child particle defining the cone
|
---|
77 | * \param p_io whether the parent has to belong to the cone or not
|
---|
78 | * \param c_io whether the child has to belong to the cone or not
|
---|
79 | * \return 0 on success, 1 on error
|
---|
80 | */
|
---|
81 | int insert(Cmomentum *v, Cmomentum *parent, Cmomentum *child, bool p_io, bool c_io);
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * insert a new candidate into the hash.
|
---|
85 | * \param v 4-momentum of te cone to add
|
---|
86 | * Note, in this case, we assume stability. We also assume
|
---|
87 | * that eta and phi are computed for v
|
---|
88 | * \return 0 on success, 1 on error
|
---|
89 | */
|
---|
90 | int insert(Cmomentum *v);
|
---|
91 |
|
---|
92 | /// the cone data itself
|
---|
93 | hash_element **hash_array;
|
---|
94 |
|
---|
95 | /// number of elements
|
---|
96 | int n_cones;
|
---|
97 |
|
---|
98 | /// number of occupied cells
|
---|
99 | #ifdef DEBUG_STABLE_CONES
|
---|
100 | int n_occupied_cells;
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | /// number of cells-1
|
---|
104 | int mask;
|
---|
105 |
|
---|
106 | /// circle radius (squared)
|
---|
107 | /// NOTE: need to be set before any call to 'insert'
|
---|
108 | double R2;
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * test if a particle is inside a cone of given centre.
|
---|
112 | * check if the particle of coordinates 'v' is inside the circle of radius R
|
---|
113 | * centered at 'centre'.
|
---|
114 | * \param centre centre of the circle
|
---|
115 | * \param v particle to test
|
---|
116 | * \return true if inside, false if outside
|
---|
117 | */
|
---|
118 | inline bool is_inside(Cmomentum *centre, Cmomentum *v);
|
---|
119 | };
|
---|
120 |
|
---|
121 | }
|
---|
122 | #endif
|
---|