]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/fastjet/siscone/spherical/protocones.h
added pdet-ppart over ppart histogram for detector response
[u/mrichter/AliRoot.git] / JETAN / fastjet / siscone / spherical / protocones.h
CommitLineData
370be031 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// 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) $//
28///////////////////////////////////////////////////////////////////////////////
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
42namespace siscone_spherical{
43
44/**
45 * \class CSphborder_store
46 *
47 * class for storing a border momentum (in context of co-circularity
48 * checks).
49
50 * This class essentially calculates angle of border point w.r.t.
51 * circle center (eta & phi), and provides a store of information
52 * about whether we are currently including this point in the
53 * candidate
54 */
55class CSphborder_store{
56public:
57 /// default ctor
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
68 CSphmomentum * mom; ///< particle momentum
69 double angle; ///< angle w.r.t. circle centre
70 bool is_in; ///< inclusion status of the particle
71};
72
73
74/// allows easy sorting of CSphborder_store objects (which need to be
75/// ordered in angle).
76inline bool operator<(const CSphborder_store & a, const CSphborder_store & b) {
77 return a.angle < b.angle;
78}
79
80
81/**
82 * \class CSphstable_cones
83 * \brief Computes the list of stable comes from a particle list.
84 *
85 * This class does the first fundamental task of te cone algorithm:
86 * it is used to compute the list of stable cones given a list
87 * of particles.
88 */
89class CSphstable_cones : public CSphvicinity{
90 public:
91 /// default ctor
92 CSphstable_cones();
93
94 /// ctor with initialisation (sse init for details)
95 CSphstable_cones(std::vector<CSphmomentum> &_particle_list);
96
97 /// default dtor
98 ~CSphstable_cones();
99
100 /**
101 * initialisation
102 * \param _particle_list list of particles
103 */
104 void init(std::vector<CSphmomentum> &_particle_list);
105
106 /**
107 * compute stable cones.
108 * This function really does the job i.e. computes
109 * the list of stable cones (in a seedless way)
110 * \param _radius radius of the cones
111 * \return The number of stable cones found is returned
112 */
113 int get_stable_cones(double _radius);
114
115 /// list of stable cones
116 std::vector<CSphmomentum> protocones;
117
118 /// list of candidates
119 sph_hash_cones *hc;
120
121 /// total number of tested cones
122 int nb_tot;
123#ifdef DEBUG_STABLE_CONES
124 int nb_hash_cones, nb_hash_occupied;
125#endif
126
127 protected:
128 /// cone radius
129 double R;
130
131 /// cone radius SQUARED
132 double R2;
133
134 /// squared tangent of the cone radius
135 double tan2R;
136
137 private:
138 /// cone with a given particle as parent
139 /// this reduction to a single vector assumes we trust the checksums
140 CSphmomentum cone;
141
142 /// child particle, taken in the 'vicinity' list
143 CSphmomentum *child;
144
145 /// centre of the tested cone
146 CSphvicinity_elm *centre;
147
148 /// index in the particle list;
149 unsigned int centre_idx;
150
151 /// first cone used in the vicinity list
152 unsigned int first_cone;
153
154 /**
155 * initialise the cone.
156 * We take the first particle in the angular ordering to compute this one
157 * \return 0 on success, 1 on error
158 */
159 int init_cone();
160
161 /**
162 * test cones.
163 * We check if the cone(s) build with the present parent and child
164 * are stable
165 * \return 0 on success 1 on error
166 */
167 int test_cone();
168
169 /**
170 * update the cone
171 * go to the next child for that parent and update 'cone' appropriately
172 * \return 0 if update candidate found, 1 otherwise
173 */
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
182 /**
183 * check if we are in a situation of cocircularity.
184 * if it is the case, update and test in the corresponding way
185 * \return 'false' if no cocircularity detected, 'true' otherwise
186 * Note that if cocircularity is detected, we need to
187 * recall 'update' from 'update' !!!
188 */
189 bool cocircular_check();
190
191 /**
192 * Routine for testing cocircular configurations in p^3 time,
193 * rather than 2^p time;
194 */
195 void test_cone_cocircular(CSphmomentum & borderless_cone,
196 std::list<CSphmomentum *> & border_list);
197
198 /**
199 * carry out the computations needed for the stability check of the
200 * candidate, using the border_vect to indicate which particles
201 * should / should not be in the stable cone; if the cone is stable
202 * insert it into the hash.
203 */
204 void test_stability(CSphmomentum & candidate,
205 const std::vector<CSphborder_store> & border_vect);
206
207 /**
208 * compute the cone contents by going once around the full set of
209 * circles and tracking the entry/exit status each time -- this sets
210 * up the inclusion information, which can then be directly used to
211 * calculate the cone momentum.
212 */
213 void compute_cone_contents();
214
215 /**
216 * compute the cone momentum from particle list.
217 * in this version, we use the 'pincluded' information
218 * from the CSphvicinity class
219 */
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
230 /**
231 * compute stability of all enumerated candidates.
232 * For all candidate cones which are stable w.r.t. their border particles,
233 * pass the last test: stability with quadtree intersection
234 */
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
247 /// present candidate cone
248 CSphmomentum cone_candidate;
249
250 /// in case of co-circular points, vector for them
251 std::vector<CSphmomentum*> child_list;
252
253 /// list of cocircular enclusures already studied
254 /// first element if cone contents, second is cone border
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; ///< sums of Delta P_t
259};
260
261}
262#endif