|
SISCone
2.0.5
|
00001 // -*- C++ -*- 00003 // File: protocones.h // 00004 // Description: header file for stable cones determination (Cstable_cones) // 00005 // This file is part of the SISCone project. // 00006 // For more details, see http://projects.hepforge.org/siscone // 00007 // // 00008 // Copyright (c) 2006 Gavin Salam and Gregory Soyez // 00009 // // 00010 // This program is free software; you can redistribute it and/or modify // 00011 // it under the terms of the GNU General Public License as published by // 00012 // the Free Software Foundation; either version 2 of the License, or // 00013 // (at your option) any later version. // 00014 // // 00015 // This program is distributed in the hope that it will be useful, // 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 00018 // GNU General Public License for more details. // 00019 // // 00020 // You should have received a copy of the GNU General Public License // 00021 // along with this program; if not, write to the Free Software // 00022 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA // 00023 // // 00024 // $Revision:: 224 $// 00025 // $Date:: 2008-05-16 19:58:30 +0200 (Fri, 16 May 2008) $// 00027 00028 #ifndef __PROTOCONES_H__ 00029 #define __PROTOCONES_H__ 00030 00031 #include "momentum.h" 00032 #include "vicinity.h" 00033 #include <stdio.h> 00034 #include <vector> 00035 #include <list> 00036 #include "hash.h" 00037 00038 #include "defines.h" 00039 00040 namespace siscone{ 00041 00053 class Cborder_store{ 00054 public: 00056 Cborder_store(Cmomentum * momentum, double centre_eta, double centre_phi) : 00057 mom(momentum), is_in(false) { 00058 angle = atan2(mom->phi - centre_phi, mom->eta - centre_eta); 00059 } 00060 00061 Cmomentum * mom; 00062 double angle; 00063 bool is_in; 00064 }; 00065 00066 00069 inline bool operator<(const Cborder_store & a, const Cborder_store & b) { 00070 return a.angle < b.angle; 00071 } 00072 00073 00082 class Cstable_cones : public Cvicinity{ 00083 public: 00085 Cstable_cones(); 00086 00088 Cstable_cones(std::vector<Cmomentum> &_particle_list); 00089 00091 ~Cstable_cones(); 00092 00097 void init(std::vector<Cmomentum> &_particle_list); 00098 00106 int get_stable_cones(double _radius); 00107 00109 std::vector<Cmomentum> protocones; 00110 00112 hash_cones *hc; 00113 00115 int nb_tot; 00116 #ifdef DEBUG_STABLE_CONES 00117 int nb_hash_cones, nb_hash_occupied; 00118 #endif 00119 00120 protected: 00122 double R; 00123 00125 double R2; 00126 00127 private: 00130 Cmomentum cone; 00131 00133 Cmomentum *child; 00134 00136 Cvicinity_elm *centre; 00137 00139 unsigned int centre_idx; 00140 00142 unsigned int first_cone; 00143 00149 int init_cone(); 00150 00157 int test_cone(); 00158 00164 int update_cone(); 00165 00166 /* 00167 * run through the vicinity of the current parent and for each child 00168 * indicate which members are cocircular... 00169 */ 00170 void prepare_cocircular_lists(); 00171 00179 bool cocircular_check(); 00180 00185 void test_cone_cocircular(Cmomentum & borderless_cone, 00186 std::list<Cmomentum *> & border_list); 00187 00194 void test_stability(Cmomentum & candidate, 00195 const std::vector<Cborder_store> & border_vect); 00196 00203 void compute_cone_contents(); 00204 00210 void recompute_cone_contents(); 00211 00212 /* 00213 * if we have gone beyond the acceptable threshold of change, compute 00214 * the cone momentum from particle list. in this version, we use the 00215 * 'pincluded' information from the Cvicinity class, but we don't 00216 * change the member cone, only the locally supplied one 00217 */ 00218 void recompute_cone_contents_if_needed(Cmomentum & this_cone, double & this_dpt); 00219 00225 int proceed_with_stability(); 00226 00227 /* 00228 * circle intersection. 00229 * computes the intersection with a circle of given centre and radius. 00230 * The output takes the form of a checkxor of the intersection's particles 00231 * - cx circle centre x coordinate 00232 * - cy circle centre y coordinate 00233 * return the checkxor for the intersection 00234 ******************************************************************/ 00235 Creference circle_intersect(double cx, double cy); 00236 00238 Cmomentum cone_candidate; 00239 00241 std::vector<Cmomentum*> child_list; 00242 00245 std::vector< std::pair<Creference,Creference> > multiple_centre_done; 00246 00247 // information for updating cone contents to avoid rounding errors 00248 double dpt; 00249 00258 inline bool is_inside(Cmomentum *centre, Cmomentum *v); 00259 }; 00260 00261 /* 00262 * compute the absolute value of the difference between 2 angles. 00263 * We take care of the 2pi periodicity 00264 * \param angle1 first angle 00265 * \param angle2 second angle 00266 * \return the absolute value of the difference between the angles 00267 *****************************************************************/ 00268 inline double abs_dangle(double &angle1, double &angle2); 00269 00270 } 00271 #endif