1 | // -*- C++ -*-
|
---|
2 | ///////////////////////////////////////////////////////////////////////////////
|
---|
3 | // File: protocones.h //
|
---|
4 | // Description: header file for stable cones determination (Cstable_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: 1.1 $//
|
---|
25 | // $Date: 2008-10-02 15:20:27 $//
|
---|
26 | ///////////////////////////////////////////////////////////////////////////////
|
---|
27 |
|
---|
28 | #ifndef __PROTOCONES_H__
|
---|
29 | #define __PROTOCONES_H__
|
---|
30 |
|
---|
31 | #include "momentum.h"
|
---|
32 | #include "vicinity.h"
|
---|
33 | #include <stdio.h>
|
---|
34 | #include <vector>
|
---|
35 | #include <list>
|
---|
36 | #include "hash.h"
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 | namespace siscone{
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * \class Cborder_store
|
---|
44 | *
|
---|
45 | * class for storing a border momentum (in context of co-circularity
|
---|
46 | * checks).
|
---|
47 |
|
---|
48 | * This class essentially calculates angle of border point w.r.t.
|
---|
49 | * circle center (eta & phi), and provides a store of information
|
---|
50 | * about whether we are currently including this point in the
|
---|
51 | * candidate
|
---|
52 | */
|
---|
53 | class Cborder_store{
|
---|
54 | public:
|
---|
55 | /// default ctor
|
---|
56 | Cborder_store(Cmomentum * momentum, double centre_eta, double centre_phi) :
|
---|
57 | mom(momentum), is_in(false) {
|
---|
58 | angle = atan2(mom->phi - centre_phi, mom->eta - centre_eta);
|
---|
59 | }
|
---|
60 |
|
---|
61 | Cmomentum * mom; ///< particle momentum
|
---|
62 | double angle; ///< angle w.r.t. circle centre
|
---|
63 | bool is_in; ///< inclusion status of the particle
|
---|
64 | };
|
---|
65 |
|
---|
66 |
|
---|
67 | /// allows easy sorting of Cborder_store objects (which need to be
|
---|
68 | /// ordered in angle).
|
---|
69 | inline bool operator<(const Cborder_store & a, const Cborder_store & b) {
|
---|
70 | return a.angle < b.angle;
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * \class Cstable_cones
|
---|
76 | * \brief Computes the list of stable comes from a particle list.
|
---|
77 | *
|
---|
78 | * This class does the first fundamental task of te cone algorithm:
|
---|
79 | * it is used to compute the list of stable cones given a list
|
---|
80 | * of particles.
|
---|
81 | */
|
---|
82 | class Cstable_cones : public Cvicinity{
|
---|
83 | public:
|
---|
84 | /// default ctor
|
---|
85 | Cstable_cones();
|
---|
86 |
|
---|
87 | /// ctor with initialisation (sse init for details)
|
---|
88 | Cstable_cones(std::vector<Cmomentum> &_particle_list);
|
---|
89 |
|
---|
90 | /// default dtor
|
---|
91 | ~Cstable_cones();
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * initialisation
|
---|
95 | * \param _particle_list list of particles
|
---|
96 | */
|
---|
97 | void init(std::vector<Cmomentum> &_particle_list);
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * compute stable cones.
|
---|
101 | * This function really does the job i.e. computes
|
---|
102 | * the list of stable cones (in a seedless way)
|
---|
103 | * \param _radius radius of the cones
|
---|
104 | * \return The number of stable cones found is returned
|
---|
105 | */
|
---|
106 | int get_stable_cones(double _radius);
|
---|
107 |
|
---|
108 | /// list of stable cones
|
---|
109 | std::vector<Cmomentum> protocones;
|
---|
110 |
|
---|
111 | /// list of candidates
|
---|
112 | hash_cones *hc;
|
---|
113 |
|
---|
114 | /// total number of tested cones
|
---|
115 | int nb_tot;
|
---|
116 |
|
---|
117 | protected:
|
---|
118 | /// cone radius
|
---|
119 | double R;
|
---|
120 |
|
---|
121 | /// cone radius SQUARED
|
---|
122 | double R2;
|
---|
123 |
|
---|
124 | private:
|
---|
125 | /// cone with a given particle as parent
|
---|
126 | /// this reduction to a single vector assumes we trust the checksums
|
---|
127 | Cmomentum cone;
|
---|
128 |
|
---|
129 | /// child particle, taken in the 'vicinity' list
|
---|
130 | Cmomentum *child;
|
---|
131 |
|
---|
132 | /// centre of the tested cone
|
---|
133 | Cvicinity_elm *centre;
|
---|
134 |
|
---|
135 | /// index in the particle list;
|
---|
136 | unsigned int centre_idx;
|
---|
137 |
|
---|
138 | /// first cone used in the vicinity list
|
---|
139 | unsigned int first_cone;
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * initialise the cone.
|
---|
143 | * We take the first particle in the angular ordering to compute this one
|
---|
144 | * \return 0 on success, 1 on error
|
---|
145 | */
|
---|
146 | int init_cone();
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * test cones.
|
---|
150 | * We check if the cone(s) build with the present parent and child
|
---|
151 | * are stable
|
---|
152 | * \return 0 on success 1 on error
|
---|
153 | */
|
---|
154 | int test_cone();
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * update the cone
|
---|
158 | * go to the next child for that parent and update 'cone' appropriately
|
---|
159 | * \return 0 if update candidate found, 1 otherwise
|
---|
160 | */
|
---|
161 | int update_cone();
|
---|
162 |
|
---|
163 | /*
|
---|
164 | * run through the vicinity of the current parent and for each child
|
---|
165 | * indicate which members are cocircular...
|
---|
166 | */
|
---|
167 | void prepare_cocircular_lists();
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * check if we are in a situation of cocircularity.
|
---|
171 | * if it is the case, update and test in the corresponding way
|
---|
172 | * \return 'false' if no cocircularity detected, 'true' otherwise
|
---|
173 | * Note that if cocircularity is detected, we need to
|
---|
174 | * recall 'update' from 'update' !!!
|
---|
175 | */
|
---|
176 | bool cocircular_check();
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Routine for testing cocircular configurations in p^3 time,
|
---|
180 | * rather than 2^p time;
|
---|
181 | */
|
---|
182 | void test_cone_cocircular(Cmomentum & borderless_cone,
|
---|
183 | std::list<Cmomentum *> & border_list);
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * carry out the computations needed for the stability check of the
|
---|
187 | * candidate, using the border_vect to indicate which particles
|
---|
188 | * should / should not be in the stable cone; if the cone is stable
|
---|
189 | * insert it into the hash.
|
---|
190 | */
|
---|
191 | void test_stability(Cmomentum & candidate,
|
---|
192 | const std::vector<Cborder_store> & border_vect);
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * compute the cone contents by going once around the full set of
|
---|
196 | * circles and tracking the entry/exit status each time -- this sets
|
---|
197 | * up the inclusion information, which can then be directly used to
|
---|
198 | * calculate the cone momentum.
|
---|
199 | */
|
---|
200 | void compute_cone_contents();
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * compute the cone momentum from particle list.
|
---|
204 | * in this version, we use the 'pincluded' information
|
---|
205 | * from the Cviinity class
|
---|
206 | */
|
---|
207 | void recompute_cone_contents();
|
---|
208 |
|
---|
209 | /*
|
---|
210 | * if we have gone beyond the acceptable threshold of change, compute
|
---|
211 | * the cone momentum from particle list. in this version, we use the
|
---|
212 | * 'pincluded' information from the Cvicinity class, but we don't
|
---|
213 | * change the member cone, only the locally supplied one
|
---|
214 | */
|
---|
215 | void recompute_cone_contents_if_needed(Cmomentum & this_cone, double & this_dpt);
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * compute stability of all enumerated candidates.
|
---|
219 | * For all candidate cones which are stable w.r.t. their border particles,
|
---|
220 | * pass the last test: stability with quadtree intersection
|
---|
221 | */
|
---|
222 | int proceed_with_stability();
|
---|
223 |
|
---|
224 | /*
|
---|
225 | * circle intersection.
|
---|
226 | * computes the intersection with a circle of given centre and radius.
|
---|
227 | * The output takes the form of a checkxor of the intersection's particles
|
---|
228 | * - cx circle centre x coordinate
|
---|
229 | * - cy circle centre y coordinate
|
---|
230 | * return the checkxor for the intersection
|
---|
231 | ******************************************************************/
|
---|
232 | Creference circle_intersect(double cx, double cy);
|
---|
233 |
|
---|
234 | /// present candidate cone
|
---|
235 | Cmomentum cone_candidate;
|
---|
236 |
|
---|
237 | /// in case of co-circular points, vector for them
|
---|
238 | std::vector<Cmomentum*> child_list;
|
---|
239 |
|
---|
240 | /// list of cocircular enclusures already studied
|
---|
241 | /// first element if cone contents, second is cone border
|
---|
242 | std::vector< std::pair<Creference,Creference> > multiple_centre_done;
|
---|
243 |
|
---|
244 | // information for updating cone contents to avoid rounding errors
|
---|
245 | double dpt; ///< sums of Delta P_t
|
---|
246 |
|
---|
247 | /**
|
---|
248 | * test if a particle is inside a cone of given centre.
|
---|
249 | * check if the particle of coordinates 'v' is inside the circle of radius R
|
---|
250 | * centered at 'centre'.
|
---|
251 | * \param centre centre of the circle
|
---|
252 | * \param v particle to test
|
---|
253 | * \return true if inside, false if outside
|
---|
254 | */
|
---|
255 | inline bool is_inside(Cmomentum *centre, Cmomentum *v);
|
---|
256 | };
|
---|
257 |
|
---|
258 | /*
|
---|
259 | * compute the absolute value of the difference between 2 angles.
|
---|
260 | * We take care of the 2pi periodicity
|
---|
261 | * \param angle1 first angle
|
---|
262 | * \param angle2 second angle
|
---|
263 | * \return the absolute value of the difference between the angles
|
---|
264 | *****************************************************************/
|
---|
265 | inline double abs_dangle(double &angle1, double &angle2);
|
---|
266 |
|
---|
267 | }
|
---|
268 | #endif
|
---|