SISCone  2.0.5
protocones.h
1 // -*- C++ -*-
3 // File: protocones.h //
4 // Description: header file for stable cones determination (Cstable_cones) //
5 // This file is part of the SISCone project. //
6 // WARNING: this is not the main SISCone trunk but //
7 // an adaptation to spherical coordinates //
8 // For more details, see http://projects.hepforge.org/siscone //
9 // //
10 // Copyright (c) 2006-2008 Gavin Salam and Gregory Soyez //
11 // //
12 // This program is free software; you can redistribute it and/or modify //
13 // it under the terms of the GNU General Public License as published by //
14 // the Free Software Foundation; either version 2 of the License, or //
15 // (at your option) any later version. //
16 // //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details. //
21 // //
22 // You should have received a copy of the GNU General Public License //
23 // along with this program; if not, write to the Free Software //
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
25 // //
26 // $Revision:: 255 $//
27 // $Date:: 2008-07-12 17:40:35 +0200 (Sat, 12 Jul 2008) $//
29 
30 #ifndef __SPH_PROTOCONES_H__
31 #define __SPH_PROTOCONES_H__
32 
33 #include "momentum.h"
34 #include "vicinity.h"
35 #include <stdio.h>
36 #include <vector>
37 #include <list>
38 #include "hash.h"
39 
40 #include <siscone/defines.h>
41 
42 namespace siscone_spherical{
43 
56 public:
58  CSphborder_store(CSphmomentum * momentum, CSph3vector &centre, CSph3vector &angl_dir1, CSph3vector &angl_dir2) :
59  mom(momentum), is_in(false) {
60  CSph3vector diff = (*momentum) - centre;
61  angle = atan2(dot_product3(diff, angl_dir2), dot_product3(diff, angl_dir1));
62 #ifdef DEBUG_STABLE_CONES
63  std::cout << " adding point " << momentum->_theta << ", " << momentum->_phi
64  << " at an angle of " << angle << std::endl;
65 #endif
66  }
67 
69  double angle;
70  bool is_in;
71 };
72 
73 
76 inline bool operator<(const CSphborder_store & a, const CSphborder_store & b) {
77  return a.angle < b.angle;
78 }
79 
80 
90  public:
93 
95  CSphstable_cones(std::vector<CSphmomentum> &_particle_list);
96 
99 
104  void init(std::vector<CSphmomentum> &_particle_list);
105 
113  int get_stable_cones(double _radius);
114 
116  std::vector<CSphmomentum> protocones;
117 
120 
122  int nb_tot;
123 #ifdef DEBUG_STABLE_CONES
124  int nb_hash_cones, nb_hash_occupied;
125 #endif
126 
127  protected:
129  double R;
130 
132  double R2;
133 
135  double tan2R;
136 
137  private:
140  CSphmomentum cone;
141 
143  CSphmomentum *child;
144 
146  CSphvicinity_elm *centre;
147 
149  unsigned int centre_idx;
150 
152  unsigned int first_cone;
153 
159  int init_cone();
160 
167  int test_cone();
168 
174  int update_cone();
175 
176  /*
177  * run through the vicinity of the current parent and for each child
178  * indicate which members are cocircular...
179  */
180  void prepare_cocircular_lists();
181 
189  bool cocircular_check();
190 
195  void test_cone_cocircular(CSphmomentum & borderless_cone,
196  std::list<CSphmomentum *> & border_list);
197 
204  void test_stability(CSphmomentum & candidate,
205  const std::vector<CSphborder_store> & border_vect);
206 
213  void compute_cone_contents();
214 
220  void recompute_cone_contents();
221 
222  /*
223  * if we have gone beyond the acceptable threshold of change, compute
224  * the cone momentum from particle list. in this version, we use the
225  * 'pincluded' information from the CSphvicinity class, but we don't
226  * change the member cone, only the locally supplied one
227  */
228  void recompute_cone_contents_if_needed(CSphmomentum & this_cone, double & this_dpt);
229 
235  int proceed_with_stability();
236 
237  /*
238  * circle intersection.
239  * computes the intersection with a circle of given centre and radius.
240  * The output takes the form of a checkxor of the intersection's particles
241  * - cx circle centre x coordinate
242  * - cy circle centre y coordinate
243  * return the checkxor for the intersection
244  ******************************************************************/
245  siscone::Creference circle_intersect(CSph3vector &cone_centre);
246 
248  CSphmomentum cone_candidate;
249 
251  std::vector<CSphmomentum*> child_list;
252 
255  std::vector< std::pair<siscone::Creference,siscone::Creference> > multiple_centre_done;
256 
257  // information for updating cone contents to avoid rounding errors
258  double dpt;
259 };
260 
261 }
262 #endif
The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated on Wed May 30 2012 06:46:25 for SISCone by  Doxygen 1.8.1