Fork me on GitHub

source: git/external/fastjet/plugins/SISCone/protocones.h@ b750b0a

Last change on this file since b750b0a was 35cdc46, checked in by Pavel Demin <demin@…>, 10 years ago

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

  • Property mode set to 100644
File size: 8.8 KB
Line 
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:: 224 $//
25// $Date:: 2008-05-16 19:58:30 +0200 (Fri, 16 May 2008) $//
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#include "defines.h"
39
40namespace 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 */
53class Cborder_store{
54public:
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).
69inline 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 */
82class 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#ifdef DEBUG_STABLE_CONES
117 int nb_hash_cones, nb_hash_occupied;
118#endif
119
120 protected:
121 /// cone radius
122 double R;
123
124 /// cone radius SQUARED
125 double R2;
126
127 private:
128 /// cone with a given particle as parent
129 /// this reduction to a single vector assumes we trust the checksums
130 Cmomentum cone;
131
132 /// child particle, taken in the 'vicinity' list
133 Cmomentum *child;
134
135 /// centre of the tested cone
136 Cvicinity_elm *centre;
137
138 /// index in the particle list;
139 unsigned int centre_idx;
140
141 /// first cone used in the vicinity list
142 unsigned int first_cone;
143
144 /**
145 * initialise the cone.
146 * We take the first particle in the angular ordering to compute this one
147 * \return 0 on success, 1 on error
148 */
149 int init_cone();
150
151 /**
152 * test cones.
153 * We check if the cone(s) build with the present parent and child
154 * are stable
155 * \return 0 on success 1 on error
156 */
157 int test_cone();
158
159 /**
160 * update the cone
161 * go to the next child for that parent and update 'cone' appropriately
162 * \return 0 if update candidate found, 1 otherwise
163 */
164 int update_cone();
165
166 /*
167 * run through the vicinity of the current parent and for each child
168 * indicate which members are cocircular...
169 */
170 void prepare_cocircular_lists();
171
172 /**
173 * check if we are in a situation of cocircularity.
174 * if it is the case, update and test in the corresponding way
175 * \return 'false' if no cocircularity detected, 'true' otherwise
176 * Note that if cocircularity is detected, we need to
177 * recall 'update' from 'update' !!!
178 */
179 bool cocircular_check();
180
181 /**
182 * Routine for testing cocircular configurations in p^3 time,
183 * rather than 2^p time;
184 */
185 void test_cone_cocircular(Cmomentum & borderless_cone,
186 std::list<Cmomentum *> & border_list);
187
188 /**
189 * carry out the computations needed for the stability check of the
190 * candidate, using the border_vect to indicate which particles
191 * should / should not be in the stable cone; if the cone is stable
192 * insert it into the hash.
193 */
194 void test_stability(Cmomentum & candidate,
195 const std::vector<Cborder_store> & border_vect);
196
197 /**
198 * compute the cone contents by going once around the full set of
199 * circles and tracking the entry/exit status each time -- this sets
200 * up the inclusion information, which can then be directly used to
201 * calculate the cone momentum.
202 */
203 void compute_cone_contents();
204
205 /**
206 * compute the cone momentum from particle list.
207 * in this version, we use the 'pincluded' information
208 * from the Cviinity class
209 */
210 void recompute_cone_contents();
211
212 /*
213 * if we have gone beyond the acceptable threshold of change, compute
214 * the cone momentum from particle list. in this version, we use the
215 * 'pincluded' information from the Cvicinity class, but we don't
216 * change the member cone, only the locally supplied one
217 */
218 void recompute_cone_contents_if_needed(Cmomentum & this_cone, double & this_dpt);
219
220 /**
221 * compute stability of all enumerated candidates.
222 * For all candidate cones which are stable w.r.t. their border particles,
223 * pass the last test: stability with quadtree intersection
224 */
225 int proceed_with_stability();
226
227 /*
228 * circle intersection.
229 * computes the intersection with a circle of given centre and radius.
230 * The output takes the form of a checkxor of the intersection's particles
231 * - cx circle centre x coordinate
232 * - cy circle centre y coordinate
233 * return the checkxor for the intersection
234 ******************************************************************/
235 Creference circle_intersect(double cx, double cy);
236
237 /// present candidate cone
238 Cmomentum cone_candidate;
239
240 /// in case of co-circular points, vector for them
241 std::vector<Cmomentum*> child_list;
242
243 /// list of cocircular enclusures already studied
244 /// first element if cone contents, second is cone border
245 std::vector< std::pair<Creference,Creference> > multiple_centre_done;
246
247 // information for updating cone contents to avoid rounding errors
248 double dpt; ///< sums of Delta P_t
249
250 /**
251 * test if a particle is inside a cone of given centre.
252 * check if the particle of coordinates 'v' is inside the circle of radius R
253 * centered at 'centre'.
254 * \param centre centre of the circle
255 * \param v particle to test
256 * \return true if inside, false if outside
257 */
258 inline bool is_inside(Cmomentum *centre, Cmomentum *v);
259};
260
261/*
262 * compute the absolute value of the difference between 2 angles.
263 * We take care of the 2pi periodicity
264 * \param angle1 first angle
265 * \param angle2 second angle
266 * \return the absolute value of the difference between the angles
267 *****************************************************************/
268inline double abs_dangle(double &angle1, double &angle2);
269
270}
271#endif
Note: See TracBrowser for help on using the repository browser.